Package org.xmlBlaster.client

Examples of org.xmlBlaster.client.I_XmlBlasterAccess


    * state.
    */
   public boolean isConnected() throws XmlBlasterException {
      if (isLocalNode())
         return true;
      I_XmlBlasterAccess con = getXmlBlasterAccess();
      if (con != null)
         return con.isConnected();
      return false;
   }
View Full Code Here


    *       determine the connection state.
    */
   public boolean isPolling() throws XmlBlasterException {
      if (isLocalNode())
         return false;
      I_XmlBlasterAccess con = getXmlBlasterAccess();
      if (con != null)
         return con.isPolling();
      return false;
   }
View Full Code Here

    * @return Always true for the local node
    */
   public boolean isAlive() throws XmlBlasterException {
      if (isLocalNode())
         return true;
      I_XmlBlasterAccess con = getXmlBlasterAccess();
      if (con != null)
         return con.isAlive();
      return false;
   }
View Full Code Here

   synchronized public boolean start(String name) {
      if (this.isRunning) return true;
      try {
         if (!prepareClient(this.view.drawing())) return this.isRunning;

         I_XmlBlasterAccess con = global.getXmlBlasterAccess();
         ConnectQos qos = new ConnectQos(this.global, /*drawing.getTitle()*/ name, "secret");
         con.connect(qos, this)// Login to xmlBlaster, register for updates

         this.isRunning = true;
     
         if (this.cmdInstances.size() > 0) {
            MonitorCommand[] oidCommands = (MonitorCommand[])this.cmdInstances.values().toArray(new MonitorCommand[this.cmdInstances.size()]);
            for (int i=0; i < oidCommands.length; i++)
               con.subscribe("<key oid='" + oidCommands[i].getOid() + "'/>", "<qos/>");
         }
         if (this.cmdTemplates.size() > 0) {
            MonitorCommand[] xpathCommands = (MonitorCommand[])this.cmdTemplates.values().toArray(new MonitorCommand[this.cmdTemplates.size()]);
            for (int i=0; i < xpathCommands.length; i++)
               con.subscribe("<key oid='' queryType='XPATH'>//" + xpathCommands[i].getType() + "</key>", "<qos/>");
         }
      }
      catch (Exception e) {
         System.err.println(e.getMessage());
      }
View Full Code Here

      return this.isRunning;
   }


   public void stop() {
      I_XmlBlasterAccess con = global.getXmlBlasterAccess();
      con.disconnect(null);
   }
View Full Code Here

     
      System.out.println("============== Connect/Disconnect for general/1 to cleanup first");

      try { // we just connect and disconnect to make sure all resources are really cleaned up
         Global tmpGlobal = this.origGlobal.getClone(null);
         I_XmlBlasterAccess con = tmpGlobal.getXmlBlasterAccess(); // Find orb

         String passwd = "secret";
         ConnectQos connectQos = new ConnectQos(tmpGlobal, senderName, passwd); // == "<qos>...</qos>";
         connectQos.setSessionName(new SessionName(tmpGlobal, "general/1"));
         // set the persistent connection
         connectQos.setPersistent(this.persistent);
         // Setup fail save handling for connection ...
         Address addressProp = new Address(tmpGlobal);
         addressProp.setDelay(reconnectDelay); // retry connecting every 2 sec
         addressProp.setRetries(-1);       // -1 == forever
         addressProp.setPingInterval(-1L); // switched off
         con.registerConnectionListener(this);
         connectQos.setAddress(addressProp);
        
         // setup failsafe handling for callback ...
         if (this.failsafeCallback) {
            CallbackAddress cbAddress = new CallbackAddress(tmpGlobal);
            cbAddress.setRetries(-1);
            cbAddress.setPingInterval(-1);
            cbAddress.setDelay(1000L);
            cbAddress.setSecretCbSessionId("someSecredSessionId");
            connectQos.addCallbackAddress(cbAddress);
         }
         con.connect(connectQos, this);
         DisconnectQos disconnectQos = new DisconnectQos(tmpGlobal);
         con.disconnect(disconnectQos);
      }
      catch (XmlBlasterException e) {
          log.warning("setUp() - login failed: " + e.getMessage());
          fail("setUp() - login fail: " + e.getMessage());
      }
      catch (Exception e) {
          log.severe("setUp() - login failed: " + e.toString());
          e.printStackTrace();
          fail("setUp() - login fail: " + e.toString());
      }

      System.out.println("============== Connect for general/1");

      try {
         I_XmlBlasterAccess con = this.glob.getXmlBlasterAccess(); // Find orb

         String passwd = "secret";
         ConnectQos connectQos = new ConnectQos(this.glob, senderName, passwd); // == "<qos>...</qos>";
         connectQos.setSessionName(new SessionName(this.glob, "general/1"));
         // set the persistent connection
         connectQos.setPersistent(this.persistent);
         // Setup fail save handling for connection ...
         Address addressProp = new Address(glob);
         addressProp.setDelay(reconnectDelay); // retry connecting every 2 sec
         addressProp.setRetries(-1);       // -1 == forever
         addressProp.setPingInterval(-1L); // switched off
         con.registerConnectionListener(this);
         connectQos.setAddress(addressProp);
        
         // setup failsafe handling for callback ...
         if (this.failsafeCallback) {
            CallbackAddress cbAddress = new CallbackAddress(this.glob);
            cbAddress.setRetries(-1);
            cbAddress.setPingInterval(-1);
            cbAddress.setDelay(1000L);
            cbAddress.setSecretCbSessionId("someSecredSessionId");
            connectQos.addCallbackAddress(cbAddress);
         }

         con.connect(connectQos, this)// Login to xmlBlaster, register for updates
      }
      catch (XmlBlasterException e) {
          log.warning("setUp() - login failed: " + e.getMessage());
          fail("setUp() - login fail: " + e.getMessage());
      }
View Full Code Here

      String xmlKey = "<key oid='' queryType='XPATH'>\n" +
                      "   //TestPersistentSession-AGENT" +
                      "</key>";

      String qos = "<qos><forceDestroy>true</forceDestroy></qos>";
      I_XmlBlasterAccess con = this.glob.getXmlBlasterAccess();
      try {
         System.out.println("============== tearDown(), erase: " + xmlKey);
         con.erase(xmlKey, qos);

         PropString defaultPlugin = new PropString("CACHE,1.0");
         String propName = defaultPlugin.setFromEnv(this.glob, glob.getStrippedId(), null, "persistence", Constants.RELATING_TOPICSTORE, "defaultPlugin");
         log.info("Lookup of propName=" + propName + " defaultValue=" + defaultPlugin.getValue());
      }
      catch(XmlBlasterException e) {
         log.severe("XmlBlasterException: " + e.getMessage());
      }
      finally {
         System.out.println("============== tearDown(), disconnect");
         con.disconnect(null);
         Util.delay(1000);
         System.out.println("============== tearDown(), stopXmlBlaster");
         EmbeddedXmlBlaster.stopXmlBlaster(this.serverThread);
         this.serverThread = null;
         // reset to default server bootstrapPort (necessary if other tests follow in the same JVM).
View Full Code Here

   // -----------------------------------------------------------------
   private Global createConnection(Global parentGlobal, String sessionName, boolean isPersistent, boolean expectEx) {
      try {
         Global ret = parentGlobal.getClone(null);
         I_XmlBlasterAccess con = ret.getXmlBlasterAccess(); // Find orb
         ConnectQos connectQos = new ConnectQos(glob); // == "<qos>...</qos>";
         connectQos.setSessionName(new SessionName(ret, sessionName));
         // set the persistent connection
         connectQos.setPersistent(isPersistent);
         // Setup fail save handling for connection ...
         Address addressProp = new Address(glob);
         addressProp.setDelay(reconnectDelay); // retry connecting every 2 sec
         addressProp.setRetries(-1);       // -1 == forever
         addressProp.setPingInterval(-1L); // switched off
         connectQos.setAddress(addressProp);
     
         // setup failsafe handling for callback ...
         if (this.failsafeCallback) {
            CallbackAddress cbAddress = new CallbackAddress(this.glob);
            cbAddress.setRetries(-1);
            cbAddress.setPingInterval(-1);
            cbAddress.setDelay(1000L);
            connectQos.addCallbackAddress(cbAddress);
         }
         con.connect(connectQos, this)// Login to xmlBlaster, register for updates
         if (expectEx) assertTrue("an exception was expected here because of overflow: Configuration of session queue probably not working", false);
         return ret;
      }
      catch (XmlBlasterException ex) {
         if (expectEx) log.info("createConnection: exception was OK since overflow was expected");
View Full Code Here

   private static Logger log = Logger.getLogger(HelloWorldMime.class.getName());

   public HelloWorldMime(Global glob) {

      try {
         I_XmlBlasterAccess con = glob.getXmlBlasterAccess();

         ConnectQos qos = new ConnectQos(glob); // name, passwd can be set on command line, try -help
         con.connect(qos, this)// Login to xmlBlaster, register for updates


         PublishKey pk = new PublishKey(glob, "HelloWorldMime", "text/xml");
         pk.setClientTags("<org.xmlBlaster><demo/></org.xmlBlaster>");
         PublishQos pq = new PublishQos(glob);
         MsgUnit msgUnit = new MsgUnit(pk, "<news type='sport'/>".getBytes(), pq);
         con.publish(msgUnit);


         GetKey gk = new GetKey(glob, "HelloWorldMime");
         GetQos gq = new GetQos(glob);
         gq.addAccessFilter(new AccessFilterQos(glob, "XPathFilter", "1.0", "/news[@type='sport']"));
         MsgUnit[] msgs = con.get(gk, gq);

         log.info("Accessed xmlBlaster message synchronous with get() with content '" + new String(msgs[0].getContent()) + "'");


         SubscribeKey sk = new SubscribeKey(glob, "HelloWorldMime");
         SubscribeQos sq = new SubscribeQos(glob);
         sq.addAccessFilter(new AccessFilterQos(glob, "XPathFilter", "1.0", "/news[@type='fishing']"));
         SubscribeReturnQos subRet = con.subscribe(sk, sq);


         msgUnit = new MsgUnit(pk, "<news type='fishing'/>".getBytes(), pq);
         con.publish(msgUnit);


         try { Thread.currentThread().sleep(1000); }
         catch( InterruptedException i) {} // wait a second to receive update()


         UnSubscribeKey uk = new UnSubscribeKey(glob, subRet.getSubscriptionId());
         UnSubscribeQos uq = new UnSubscribeQos(glob);
         con.unSubscribe(uk, uq);

         EraseKey ek = new EraseKey(glob, "HelloWorldMime");
         EraseQos eq = new EraseQos(glob);
         EraseReturnQos[] eraseArr = con.erase(ek, eq);

         DisconnectQos dq = new DisconnectQos(glob);
         con.disconnect(dq);
      }
      catch (Exception e) {
         log.severe(e.getMessage());
      }
   }
View Full Code Here

            log.severe(str);
            htmlOutput(str, response);
            return;
         }

         I_XmlBlasterAccess corbaConnection = BlasterHttpProxy.getXmlBlasterAccess(sessionId);
         if (corbaConnection == null) {
            String text = "Your Session ID is not valid, please try again with cookies enabled";
            log.severe(text);
            popupError(response, text);
            return;
         }

         // Expecting actionType = "cpuinfo" or "meminfo" but it could be
         // any valid key oid.
         log.info("Got request for " + actionType + ", sessionId=" + sessionId + " ...");

         SubscribeKey xmlKey = new SubscribeKey(null, actionType);
         SubscribeQos xmlQos = new SubscribeQos(null);

         String ret = corbaConnection.subscribe(xmlKey.toXml(), xmlQos.toXml()).getSubscriptionId();
         log.info("Subscribed to " + actionType + "=" + ret);

         // NOTE: The callback messages (update()) are handled by our
         // BlasterHttpProxyServlet framework and pushed to the browser.
         // Typically a browser (or applet) can subscribe itself directly at BlasterHttpProxyServlet
View Full Code Here

TOP

Related Classes of org.xmlBlaster.client.I_XmlBlasterAccess

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.