Package org.xmlBlaster.client

Examples of org.xmlBlaster.client.I_XmlBlasterAccess


   private Global glob;

   private final void doLogin() {
      try {
         System.err.println("HelloWorldNative: Connecting with protocol 'LOCAL' to xmlBlaster\n");
         I_XmlBlasterAccess con = new XmlBlasterAccess(glob);

         ConnectQos qos = new ConnectQos(this.glob); /* Client side object */
         qos.setPtpAllowed(false);
         qos.setUserId("A-NATIVE-CLIENT-PLUGIN");
         qos.getSessionQos().setSessionTimeout(0L);
         con.connect(qos, null);    // Login to xmlBlaster as "A-NATIVE-CLIENT-PLUGIN"
         //Here we can publish or subscribe etc., see HelloWorld3.java how to do it
         con.publish(new MsgUnit(glob, "<key oid='TEST'/>", "Hi", "<qos/>"));
         //con.disconnect(null);
      }
      catch (Exception e) {
         System.err.println("HelloWorldNative: We have a problem: " + e.toString());
      }
View Full Code Here


         System.exit(1);
      }

      StopWatch stop = new StopWatch();
      try {
         I_XmlBlasterAccess blasterConnection = glob.getXmlBlasterAccess();

         // Login and install the Callback server
         ConnectQos qos = new ConnectQos(glob);
         blasterConnection.connect(qos, this);


         String publishOid = "";
         String xmlKey = "<key oid='' contentMime='text/xml'>\n" +
                         "<AGENT id='192.168.124.10' subId='1' type='generic'>" +
                         "<DRIVER id='FileProof' pollingFreq='10'>" +
                         "</DRIVER>"+
                         "</AGENT>" +
                         "</key>";


         //----------- Construct a message and publish it ---------
         {
            String content = "<person><name>Ghandi</name></person>";
            MsgUnit msgUnit = new MsgUnit(xmlKey, content.getBytes(), "");
            log.fine("Publishing ...");
            stop.restart();
            try {
               publishOid = blasterConnection.publish(msgUnit).getKeyOid();
               log.info("   Returned oid=" + publishOid);
               log.fine("Publishing done" + stop.nice());
            } catch(XmlBlasterException e) {
               log.severe("Punlishing failed, XmlBlasterException: " + e.getMessage());
            }
         }


         //----------- Subscribe to the previous message OID -------
         log.fine("Subscribing using the exact oid ...");
         xmlKey = "<?xml version='1.0' encoding='ISO-8859-1' ?>\n" +
                  "<key oid='" + publishOid + "' queryType='EXACT'>\n" +
                  "</key>";
         stop.restart();
         try {
            String subId = blasterConnection.subscribe(xmlKey, "<qos></qos>").getSubscriptionId();
            log.fine("Subscribed to '" + subId + "' ..." + stop.nice());
         } catch(XmlBlasterException e) {
            log.severe("Subscribe failed, XmlBlasterException: " + e.getMessage());
         }

         try { Thread.currentThread().sleep(2000); } catch( InterruptedException i) {} // Wait a second


         //----------- Unsubscribe from the previous message --------
         log.fine("Unsubscribe ...");
         stop.restart();
         try {
            blasterConnection.unSubscribe(xmlKey, "<qos></qos>");
            log.info("Unsubscribe done" + stop.nice());
         } catch(XmlBlasterException e) {
            log.severe("Unsubscribe failed, XmlBlasterException: " + e.getMessage());
         }


         //----------- Subscribe to the previous message XPATH -------
         log.fine("Subscribing using XPath syntax ...");
         xmlKey = "<?xml version='1.0' encoding='ISO-8859-1' ?>\n" +
                  "<key oid='' queryType='XPATH'>\n" +
                  "/xmlBlaster/key/AGENT" +
                  "</key>";
         stop.restart();
         try {
            blasterConnection.subscribe(xmlKey, "<qos></qos>");
            log.fine("Subscribe done, there should be a Callback");
         } catch(XmlBlasterException e) {
            log.severe("subscribe failed, XmlBlasterException: " + e.getMessage());
         }

         try { Thread.currentThread().sleep(2000); } catch( InterruptedException i) {} // Wait a second

         log.fine("Publishing 10 times ...");
         {
            for (int ii=0; ii<10; ii++) {
               //----------- Construct a message and publish it ---------
               String content = "<person><name>Castro</name><age>" + ii + "</age></person>";
               xmlKey = "<key oid='" + publishOid + "' contentMime='text/xml'>\n</key>";
               MsgUnit msgUnit = new MsgUnit(xmlKey, content.getBytes(), "");
               log.fine("Publishing ...");
               stop.restart();
               try {
                  String str = blasterConnection.publish(msgUnit).getKeyOid();
                  log.fine("Publishing done" + stop.nice());
               } catch(XmlBlasterException e) {
                  log.severe("Publishing failed, XmlBlasterException: " + e.getMessage());
               }
            }
         }

         try { Thread.currentThread().sleep(2000); } catch( InterruptedException i) {} // Wait a second
         blasterConnection.disconnect(null);
      }
      catch (Exception e) {
          e.printStackTrace();
      }
View Full Code Here

      glob.init(Util.getOtherServerPorts(serverPort));

      serverThread = EmbeddedXmlBlaster.startXmlBlaster(glob);
      log.info("XmlBlaster is ready for testing on bootstrapPort " + serverPort);
      try {
         I_XmlBlasterAccess con = this.glob.getXmlBlasterAccess(); // Find orb
         String passwd = "secret";
         ConnectQos connectQos = new ConnectQos(glob, senderName, passwd); // == "<qos>...</qos>";
         // 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(500L); // switched off
         connectQos.setAddress(addressProp);
         con.connect(connectQos, null)// 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

    * Tears down the fixture.
    * <p />
    * cleaning up .... erase() the previous message OID and logout
    */
   protected void tearDown() {
      I_XmlBlasterAccess con = this.glob.getXmlBlasterAccess();
      try {
         log.info("Entering tearDown(), test is finished");
         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());
         EraseKey eraseKey = new EraseKey(this.glob, "//airport", "XPATH");     
         EraseQos eraseQos = new EraseQos(this.glob);
         con.erase(eraseKey, eraseQos);
      }
      catch (XmlBlasterException ex) {
         ex.printStackTrace();
      }
      finally {
         con.disconnect(null);
         try {
            Thread.sleep(1000L);
         }
         catch (Exception ex) {
         }
View Full Code Here

      System.out.println("***XmlBlasterClassloaderTest: testClassloader ...");

      try {
         EmbeddedXmlBlaster embed = EmbeddedXmlBlaster.startXmlBlaster(glob);

         I_XmlBlasterAccess conn = glob.getXmlBlasterAccess();
         ConnectQos qos = new ConnectQos(glob, "marcel", "secret");
         conn.connect( qos, null ); // Login to xmlBlaster

         // a sample message unit
         String xmlKey = "<key oid='123' contentMime='text/plain' contentMimeExtended='myMime'>\n" +
                           "   <TestLogin-AGENT>" +
                           "   </TestLogin-AGENT>" +
                           "</key>";
         String senderContent = "Some content";
         MsgUnit msgUnit = new MsgUnit(xmlKey, senderContent.getBytes(), "<qos></qos>");
         conn.publish(msgUnit);

      }
      catch (Throwable t) {
         assertTrue( "Some error occured:"+t.toString(), true );
      }
View Full Code Here

   /** Connect in fail save mode to a server node (as given in glob.getId()) */
   public I_XmlBlasterAccess connect(final Global glob, I_Callback cb) throws XmlBlasterException {
      final String clientName = "ClientTo[" + glob.getId() + "]";
      if (glob.getId() == null || glob.getId().length() < 1) log.severe("glob.getId() is not set");
      I_XmlBlasterAccess con = glob.getXmlBlasterAccess();

      con.registerConnectionListener(new I_ConnectionStateListener() {
            public void reachedAlive(ConnectionStateEnum oldState, I_XmlBlasterAccess connection) {
               log.info("Changed from connection state " + oldState +
                                     " to " + ConnectionStateEnum.ALIVE + " with " +
                                     connection.getQueue().getNumOfEntries() + " queue entries pending" +
                                     ": We were lucky, reconnected to " + connection.getGlobal().getId());
            }
            public void reachedPolling(ConnectionStateEnum oldState, I_XmlBlasterAccess connection) {
               log.warning("DEBUG ONLY: Changed from connection state " + oldState + " to " +
                                    ConnectionStateEnum.POLLING + ": Lost connection to " + connection.getGlobal().getId());
            }
            public void reachedDead(ConnectionStateEnum oldState, I_XmlBlasterAccess connection) {
               log.severe("DEBUG ONLY: Changed from connection state " + oldState + " to " +
                                     ConnectionStateEnum.DEAD + ": Lost connection to " + connection.getGlobal().getId());
            }
            public void reachedAliveSync(ConnectionStateEnum oldState, I_XmlBlasterAccess connection) {
            }

         });

      ConnectQos qos = new ConnectQos(glob, clientName, "secret");
      con.connect(qos, cb);

      log.info("Connected to xmlBlaster.");
      return con;
   }
View Full Code Here

    */
   String connect() throws JMSException {
      if (log.isLoggable(Level.FINER))
         log.finer("connect");
      try {
         I_XmlBlasterAccess accessor = this.global.getXmlBlasterAccess();
         if (!accessor.isConnected())
            this.sessionName = accessor.connect(this.connection.getConnectQos(), this).getSessionName().getRelativeName();
         else
            this.sessionName = accessor.getConnectReturnQos().getSessionName().getRelativeName();
         // activateDispatcher(false);
         return this.sessionName;
      }
      catch (XmlBlasterException ex) {
         throw new XBException(ex, ME + ".connect");  
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.