Package org.xmlBlaster.client

Examples of org.xmlBlaster.client.XmlBlasterAccess


    */
   public I_XmlBlasterAccess getXmlBlasterAccess() {
      if (this.xmlBlasterAccess == null) {
         synchronized(this) {
            if (this.xmlBlasterAccess == null)
               this.xmlBlasterAccess = new XmlBlasterAccess(this);
         }
      }
      return this.xmlBlasterAccess;
   }
View Full Code Here


      try {
         while (true) {
            System.out.println("NO XmlBlasterAccess, Hit a key");
            try { System.in.read(); } catch(java.io.IOException e) {}
            XmlBlasterAccess a = new XmlBlasterAccess(glob);

            System.out.println("connecting ...");
            a.connect(null, null);
            System.out.println("connected ...");

            System.out.println("Hit a key");
            try { System.in.read(); } catch(java.io.IOException e) {}
            a.disconnect((DisconnectQos)null);

            System.out.println("All is shutdown: Hit a key");
            try { System.in.read(); } catch(java.io.IOException e) {}
         }
      }
View Full Code Here

*/
public class HelloWorld
{
   public HelloWorld(String[] args) {
      try {
         I_XmlBlasterAccess con = new XmlBlasterAccess(args);

         con.connect(null, null);    // Login to xmlBlaster as "guest"

         MsgUnit[] msgs = con.get("<key oid='__cmd:?freeMem'/>", null);

         System.out.println("\nHelloWorld: xmlBlaster has currently " +
                new String(msgs[0].getContent()) + " bytes of free memory\n");

         con.disconnect(null);
      }
      catch (Exception e) {
         System.err.println("HelloWorld: We have a problem: " + e.toString());
      }
   }
View Full Code Here

   /**
    * We login to xmlBlaster and check the free memory
    */
   private final void doSomething() {
      try {
         I_XmlBlasterAccess con = new XmlBlasterAccess(new String[0]);

         con.connect(null, null);    // Login to xmlBlaster

         MsgUnit[] msgs = con.get("<key oid='__cmd:?freeMem'/>", null);

         System.out.println("\n###ClientPlugin###: xmlBlaster has currently " +
                new String(msgs[0].getContent()) + " bytes of free memory\n");

         con.disconnect(null);
      }
      catch (Exception e) {
         System.err.println("ClientPlugin: We have a problem: " + e.toString());
      }
   }
View Full Code Here

         this.xmlBlasterConnection = this.remoteGlob.getXmlBlasterAccess();
         this.xmlBlasterConnection.setUserObject(this);
         // force client side queue unique name, instead of setStorageIdStr()
         this.xmlBlasterConnection.setServerNodeId(getId());
         this.xmlBlasterConnection.registerConnectionListener(this);
         final XmlBlasterAccess xbAccess = (XmlBlasterAccess)this.xmlBlasterConnection;
         this.xmlBlasterConnection.registerPostSendListener(new I_PostSendListener() {
            public void postSend(MsgQueueEntry[] msgQueueEntries) {
             
            }
            // For example on user.security.authorization.notAuthorized
            public boolean sendingFailed(MsgQueueEntry[] entries,
          XmlBlasterException exception) {
               try {
                  for (int i=0; i<entries.length; i++) {
                     MsgUnit msgUnit = entries[i].getMsgUnit();              
                     String fn = xbAccess.getFileDumper().dumpMessage(msgUnit.getKeyData(), msgUnit.getContent(), msgUnit.getQosData());
                     log.severe("Async sending of cluster message failed for " + msgUnit.getKeyOid() +", is dumped to " + fn + ": " + exception.getMessage());
                  }
               }
               catch (Throwable e) {
                  e.printStackTrace();
View Full Code Here

   private void excuteStartupTasks() throws XmlBlasterException {
      if (this.scriptFileUrl == null) {
         return;
      }
      try {
         this.connection = new XmlBlasterAccess(this.global);

         if (this.doConnect) {
            this.connection.connect(this.connectQos, new I_Callback() {
               public String update(String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos) {
                  log.warning("Ignoring received message '" + updateKey.getOid() + "'");
View Full Code Here

         CallbackAddress cbAddr = new CallbackAddress(this.global);
         cbAddr.setDelay(5000L);
         cbAddr.setPingInterval(5000L);
         cbAddr.setRetries(-1);
         connectQos.addCallbackAddress(cbAddr);
         XmlBlasterAccess access = (XmlBlasterAccess)this.connGlobal.getXmlBlasterAccess();
         ConnectReturnQos retQos = access.connect(connectQos, this.updateInterceptor, withQueue);
         log.info("connect return qos: " + retQos.toXml());
        
         SubscribeQos subQos = new SubscribeQos(this.connGlobal);
         subQos.setWantInitialUpdate(false);
         subQos.setMultiSubscribe(false);
View Full Code Here

      System.out.println("***XmlBlasterAccessTest: testCreation ...");
      I_XmlBlasterAccess xmlBlasterAccess = null;
      for (int i=0; i<3; i++) {
         if (i == 0) {
            Global nullGlobal = null;
            xmlBlasterAccess = new XmlBlasterAccess(nullGlobal);
         }
         else if (i == 1) {
            String[] nullArgs = null;
            xmlBlasterAccess = new XmlBlasterAccess(nullArgs);
         }
         else {
            xmlBlasterAccess = glob.getXmlBlasterAccess();
         }

View Full Code Here

   }

   public void testDefaultConnectWithoutServer() throws Exception {
      System.out.println("***XmlBlasterAccessTest: testDefaultConnectWithoutServer ...");
      Global nullGlobal = null;
      I_XmlBlasterAccess xmlBlasterAccess = new XmlBlasterAccess(nullGlobal);

      assertEquals("", false, xmlBlasterAccess.isConnected());

      ConnectQos q = new ConnectQos(null);
      log.info("Default ConnectQos=" + q.toXml() + " retries=" + q.getAddress().getRetries() + " delay=" + q.getAddress().getDelay());
      assertEquals("", -1, q.getAddress().getRetries()); // retry forever
      assertEquals("", q.getAddress().getDefaultDelay(), q.getAddress().getDelay()); // 5000L
View Full Code Here

            }
           
            if (ret == 'q')
               break;

            I_XmlBlasterAccess con = new XmlBlasterAccess(glob.getClone(null));

            con.registerConnectionListener(new I_ConnectionStateListener() {

               public void reachedAlive(ConnectionStateEnum oldState,
                     I_XmlBlasterAccess connection) {
                  log.info("I_ConnectionStateListener: Connected");
               }

               public void reachedPolling(ConnectionStateEnum oldState,
                     I_XmlBlasterAccess connection) {
                  log
                        .warning("I_ConnectionStateListener: No connection to xmlBlaster server, we are polling ...");
               }

               public void reachedDead(ConnectionStateEnum oldState,
                     I_XmlBlasterAccess connection) {
                  log.warning("I_ConnectionStateListener: Connection from "
                        + connection.getGlobal().getId()
                        + " to xmlBlaster is DEAD, doing exit.");
               }
               public void reachedAliveSync(ConnectionStateEnum oldState, I_XmlBlasterAccess connection) {
               }

            });

            ConnectQos qos = new ConnectQos(glob);
            if (connectPersistent) {
               qos.setPersistent(connectPersistent);
            }
            if (connectQosClientPropertyMap != null) {
               Iterator it = connectQosClientPropertyMap.keySet().iterator();
               while (it.hasNext()) {
                  String key = (String) it.next();
                  qos.addClientProperty(key, connectQosClientPropertyMap.get(
                        key).toString());
               }
            }
            //log.info("ConnectQos is " + qos.toXml());
            /* ConnectReturnQos crq = */con.connect(qos, new I_Callback() {
               public String update(String cbSessionId, UpdateKey updateKey,
                     byte[] content, UpdateQos updateQos)
                     throws XmlBlasterException {
                  try {
                     log.info("Received '" + updateKey.getOid() + "':"
                           + new String(content, "UTF-8"));
                  } catch (UnsupportedEncodingException e) {
                     log.severe("Update failed: " + e.toString());
                  }
                  return "";
               }
            }); // Login to xmlBlaster, register for updates
            log.info("Connect success");

            if (ret == 'd') {
               DisconnectQos dq = new DisconnectQos(glob);
               con.disconnect(dq);
               log.info("Disconnected from server, all resources released");
            } else {
               con.leaveServer(null);
               ret = 0;
               log.info("Left server, our server side session remains, bye");
            }
            con = null;

View Full Code Here

TOP

Related Classes of org.xmlBlaster.client.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.