Package org.xmlBlaster.client.key

Examples of org.xmlBlaster.client.key.GetKey


      String passwd="secret";
      try {
         Global gAdmin = glob.getClone(null);
         connAdmin = gAdmin.getXmlBlasterAccess();
         connAdmin.connect(new ConnectQos(gAdmin, user, passwd), null);
         GetKey gk = new GetKey(glob, command);
         GetQos gq = new GetQos(glob);
         MsgUnit[] msgs = connAdmin.get(gk, gq);
         return msgs;
      }
      finally {
View Full Code Here


            if (key == 'p') {
               publishMessages();
               continue;
            }
            else if (key == 'g') {
               GetKey gk = new GetKey(glob, "Banking");
               GetQos gq = new GetQos(glob);
               try {
                  MsgUnit[] msgs = con.get(gk, gq);
                  if (msgs.length > 0) {
                     GetReturnQos grq = new GetReturnQos(glob, msgs[0].getQos());
                     log.info("Accessed xmlBlaster message with content '" + new String(msgs[0].getContent()) +
                               "' and status=" + grq.getState());
                  }
                  else {
                     log.info("No message matched get() call on " + gk.getOid());
                  }
               }
               catch (XmlBlasterException e) {
                  log.warning("get() failed:" + e.getMessage());
               }
View Full Code Here

      if (con == null) {
         if (log.isLoggable(Level.FINE)) log.fine("forwardGet - Nothing to forward");
         return null;
      }

      return con.get(new GetKey(glob, xmlKey), new GetQos(glob, getQos.getData()));
   }
View Full Code Here

      MsgUnit[] msgs = null;

      try {
         // starts the get request for the given oid
         msgs = connection.get(new GetKey(glob, oid, Constants.EXACT).toXml(),
               new GetQos(glob).toXml());
      } catch (XmlBlasterException xe) {
         log.throwing(this.getClass().getName(), "run", xe);
      }
View Full Code Here

         MsgUnit msgUnit = new MsgUnit(pk, "Hi", pq);
         con.publish(msgUnit);

         // This should not be possible as the message was volatile
         try {
            GetKey gk = new GetKey(glob, "HelloWorldVolatile");
            GetQos gq = new GetQos(glob);
            MsgUnit[] msgs = con.get(gk, gq);
            if (msgs.length > 0) {
               GetReturnQos grq = new GetReturnQos(glob, msgs[0].getQos());
               log.severe("Did not expect any message as it was volatile");
View Full Code Here

            PublishQos pq = new PublishQos(con.getGlobal());
            MsgUnit msgUnit = new MsgUnit(pk, "Hi", pq);
            con.publish(msgUnit);


            GetKey gk = new GetKey(con.getGlobal(), "AllProtocols");
            GetQos gq = new GetQos(con.getGlobal());
            MsgUnit[] msgs = con.get(gk.toXml(), gq.toXml());
            GetReturnQos grq = new GetReturnQos(con.getGlobal(), msgs[0].getQos());

            log.info("Accessed xmlBlaster message with content '" + new String(msgs[0].getContent()) +
                         "' and status=" + grq.getState());
View Full Code Here

         try {
            publishMsg(publishOidArr[0], contentArr[0]);
            publishMsg(publishOidArr[2], contentArr[2]);
            try { Thread.sleep(200L); } catch( InterruptedException i) {}   // Wait 200 milli seconds, until all updates are processed ...

            GetKey gk = new GetKey(glob, publishOidArr[0]);
            GetQos gq = new GetQos(glob);

            for (int i=0; i<10; i++) {
               MsgUnit[] msgs = con.getCached(gk, gq);
               assertEquals(this.synchronousCache.toXml(""), 1, msgs.length);
               GetReturnQos grq = new GetReturnQos(glob, msgs[0].getQos());
               assertEquals("", 1, this.synchronousCache.getNumQueriesCached());
               log.info("Accessed xmlBlaster message with content '" + new String(msgs[0].getContent()) +
                              "' and status=" + grq.getState());
            }

            sendErase(publishOidArr[0]);
            assertEquals("", 0, this.synchronousCache.getNumQueriesCached());
            sendErase(publishOidArr[2]);
         }
         catch (XmlBlasterException e) {
            log.severe("testCachedAccess() failed: " + e.getMessage());
            fail(e.getMessage());
         }
         assertEquals("Unexpected update arrived", 0, this.updateInterceptor.waitOnUpdate(1000L, 0));
      }

      {
         log.info("Entering testCachedAccess with updated MsgUnit ...");
         try {
            PublishReturnQos publishReturnQos = publishMsg(publishOidArr[0], contentArr[0]);

            GetKey gk = new GetKey(glob, publishOidArr[0]);
            GetQos gq = new GetQos(glob);

            for (int i=0; i<5; i++) {
               MsgUnit[] msgs = con.getCached(gk, gq);
               GetReturnQos grq = new GetReturnQos(glob, msgs[0].getQos());
               assertEquals(this.synchronousCache.toXml(""), 1, msgs.length);
               assertEquals("", 1, this.synchronousCache.getNumQueriesCached());
               assertEquals("", publishReturnQos.getRcvTimestamp(), grq.getRcvTimestamp());
               assertEquals("", contentArr[0], msgs[0].getContentStr());
               log.info("Accessed xmlBlaster message with content '" + new String(msgs[0].getContent()) +
                              "' and status=" + grq.getState() + " rcv=" + grq.getRcvTimestamp());
            }

            // Now publish again an check if cache is updated
            String contentNew = contentArr[0]+"-NEW";
            publishReturnQos = publishMsg(publishOidArr[0], contentNew);
            try { Thread.sleep(200L); } catch( InterruptedException i) {}   // Wait 200 milli seconds, until all updates are processed ...
            for (int i=0; i<5; i++) {
               MsgUnit[] msgs = con.getCached(gk, gq);
               GetReturnQos grq = new GetReturnQos(glob, msgs[0].getQos());
               assertEquals(this.synchronousCache.toXml(""), 1, msgs.length);
               assertEquals("", 1, this.synchronousCache.getNumQueriesCached());
               assertEquals("", publishReturnQos.getRcvTimestamp().getTimestamp(), grq.getRcvTimestamp().getTimestamp());
               assertEquals("", publishReturnQos.getKeyOid(), msgs[0].getKeyOid());
               assertEquals("", contentNew, msgs[0].getContentStr());
               log.info("Accessed xmlBlaster message with content '" + new String(msgs[0].getContent()) +
                              "' and status=" + grq.getState() + " rcv=" + grq.getRcvTimestamp());
            }

            sendErase(publishOidArr[0]);
            assertEquals("", 0, this.synchronousCache.getNumQueriesCached());
         }
         catch (XmlBlasterException e) {
            log.severe("testCachedAccess() failed: " + e.getMessage());
            fail(e.getMessage());
         }
         assertEquals("Unexpected update arrived", 0, this.updateInterceptor.waitOnUpdate(1000L, 0));
      }

      {
         log.info("Entering testCachedAccess with XPATH ...");
         try {
            PublishReturnQos publishReturnQos0 = publishMsg(publishOidArr[0], contentArr[0]);
            PublishReturnQos publishReturnQos1 = publishMsg(publishOidArr[1], contentArr[1]);
            publishMsg(publishOidArr[2], contentArr[2]);
            try { Thread.sleep(200L); } catch( InterruptedException i) {}   // Wait 200 milli seconds, until all updates are processed ...

            // This should match [0] and [1] msg:
            GetKey gk = new GetKey(glob, "//key[starts-with(@oid,'oid-')]", Constants.XPATH);
            GetQos gq = new GetQos(glob);

            for (int i=0; i<10; i++) {
               MsgUnit[] msgs = con.getCached(gk, gq);
               assertEquals("", 2, msgs.length);
View Full Code Here

      this.glob.getXmlBlasterAccess().publish(msgUnit);
      log.info("Success: Publishing of " + oid + " done");
   }

   private void doGet(String oid, int expect) {
      GetKey key = new GetKey(this.glob, oid);
      GetQos qos = new GetQos(this.glob);
      HistoryQos histQos = new HistoryQos(this.glob, 2);
      qos.setHistoryQos(histQos);
      try {
         MsgUnit[] msg = this.glob.getXmlBlasterAccess().get(key, qos);
View Full Code Here

         return;
      }

      publishMessage("I am retrieving the connected users list (ignore this)");
      try {
         GetKey getKeyWrapper = new GetKey(glob, "__sys__UserList");
         MsgUnit[] msgUnit = xmlBlasterConnection.get(getKeyWrapper.toXml(),"<qos></qos>");
         if (msgUnit != null) {
            for (int i=0; i < msgUnit.length; i++) {
                appendOutput("users: " + System.getProperty("line.separator") +
                            new String(msgUnit[i].getContent()) +
                            System.getProperty("line.separator"));
View Full Code Here

    * get() blocks until the SQL query is finished ...
    */
   private String invokeSyncQuery(XmlDbMessageWrapper wrap, int numResultRowsExpected, String token) {
      try {
         if (log.isLoggable(Level.FINE)) log.fine("Sending command string:\n" + wrap.toXml()); // Junit report does not like it
         GetKey key = new GetKey(glob, "__sys__jdbc");
         key.wrap(wrap.toXml());
         GetQos qos = new GetQos(glob);
         MsgUnit[] msgUnitArr = con.get(key.toXml(), qos.toXml());
         if (msgUnitArr.length > 0) {
            String result = new String(msgUnitArr[0].getContent());
            if (log.isLoggable(Level.FINE)) log.fine(result);
            if (token != null && result.indexOf(token) < 0)
               fail("Token " + token + " not found in result");
View Full Code Here

TOP

Related Classes of org.xmlBlaster.client.key.GetKey

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.