Package org.xmlBlaster.util.qos

Examples of org.xmlBlaster.util.qos.ClientProperty


      System.out.println(xml);
   }

   public void testClientPropertyTypes() throws Exception {
      {
         ClientProperty clientProperty = new ClientProperty("key", "int", null);
         assertEquals("", "key", clientProperty.getName());
         assertEquals("", "int", clientProperty.getType());
         assertEquals("", null, clientProperty.getEncoding());
         assertEquals("", null, clientProperty.getValueRaw());
         assertEquals("", null, clientProperty.getStringValue());
         assertEquals("", null, clientProperty.getObjectValue());

         clientProperty.setValue("9988");
         String xml = clientProperty.toXml();
         assertEquals("", "9988", clientProperty.getValueRaw());
         assertXMLEqual("comparing test xml to control xml",
                        "<clientProperty name='key' type='int'>9988</clientProperty>",
                        xml);
         assertEquals("", 9988, clientProperty.getIntValue());
         assertTrue("Expecting Integer", clientProperty.getObjectValue() instanceof Integer);
         System.out.println(xml);
      }
      {
         ClientProperty clientProperty = new ClientProperty("key", Constants.TYPE_BOOLEAN, null);
         assertEquals("", "key", clientProperty.getName());
         assertEquals("", "boolean", clientProperty.getType());
         assertEquals("", null, clientProperty.getEncoding());
         assertEquals("", null, clientProperty.getValueRaw());
         assertEquals("", null, clientProperty.getStringValue());
         assertEquals("", null, clientProperty.getObjectValue());

         clientProperty.setValue("true");
         String xml = clientProperty.toXml();
         assertEquals("", "true", clientProperty.getValueRaw());
         assertXMLEqual("comparing test xml to control xml",
                        "<clientProperty name='key' type='boolean'>true</clientProperty>",
                        xml);
         assertEquals("", true, clientProperty.getBooleanValue());
         assertTrue("", clientProperty.getObjectValue() instanceof Boolean);
         System.out.println(xml);
      }
      {
         ClientProperty clientProperty = new ClientProperty("key", Constants.TYPE_DOUBLE, null);
         assertEquals("", "key", clientProperty.getName());
         assertEquals("", "double", clientProperty.getType());
         assertEquals("", null, clientProperty.getEncoding());
         assertEquals("", null, clientProperty.getValueRaw());
         assertEquals("", null, clientProperty.getStringValue());
         assertEquals("", null, clientProperty.getObjectValue());

         clientProperty.setValue("12.78");
         String xml = clientProperty.toXml();
         assertEquals("", "12.78", clientProperty.getValueRaw());
         assertXMLEqual("comparing test xml to control xml",
                        "<clientProperty name='key' type='double'>12.78</clientProperty>",
                        xml);
         assertTrue("", 12.78 == clientProperty.getDoubleValue());
         assertTrue("", clientProperty.getObjectValue() instanceof Double);
         System.out.println(xml);
      }
      {
         ClientProperty clientProperty = new ClientProperty("key", Constants.TYPE_FLOAT, null);
         assertEquals("", "key", clientProperty.getName());
         assertEquals("", "float", clientProperty.getType());
         assertEquals("", null, clientProperty.getEncoding());
         assertEquals("", false, clientProperty.isBase64());
         assertEquals("", null, clientProperty.getValueRaw());
         assertEquals("", null, clientProperty.getStringValue());
         assertEquals("", null, clientProperty.getObjectValue());

         clientProperty.setValue("12.54");
         String xml = clientProperty.toXml();
         assertEquals("", "12.54", clientProperty.getValueRaw());
         assertXMLEqual("comparing test xml to control xml",
                        "<clientProperty name='key' type='float'>12.54</clientProperty>",
                        xml);
         assertTrue("", (float)12.54 == clientProperty.getFloatValue());
         assertTrue("", clientProperty.getObjectValue() instanceof Float);
         System.out.println(xml);
      }
      {
         ClientProperty clientProperty = new ClientProperty("key", Constants.TYPE_BYTE, null);
         assertEquals("", "key", clientProperty.getName());
         assertEquals("", "byte", clientProperty.getType());
         assertEquals("", null, clientProperty.getEncoding());
         assertEquals("", null, clientProperty.getValueRaw());
         assertEquals("", null, clientProperty.getStringValue());
         assertEquals("", null, clientProperty.getObjectValue());

         clientProperty.setValue("6");
         String xml = clientProperty.toXml();
         assertEquals("", "6", clientProperty.getValueRaw());
         assertXMLEqual("comparing test xml to control xml",
                        "<clientProperty name='key' type='byte'>6</clientProperty>",
                        xml);
         assertTrue("", (byte)6 == clientProperty.getByteValue());
         assertTrue("", clientProperty.getObjectValue() instanceof Byte);
         System.out.println(xml);
      }
      {
         ClientProperty clientProperty = new ClientProperty("key", Constants.TYPE_LONG, null);
         assertEquals("", "key", clientProperty.getName());
         assertEquals("", "long", clientProperty.getType());
         assertEquals("", null, clientProperty.getEncoding());
         assertEquals("", null, clientProperty.getValueRaw());
         assertEquals("", null, clientProperty.getStringValue());
         assertEquals("", null, clientProperty.getObjectValue());

         clientProperty.setValue("888888");
         String xml = clientProperty.toXml();
         assertEquals("", "888888", clientProperty.getValueRaw());
         assertXMLEqual("comparing test xml to control xml",
                        "<clientProperty name='key' type='long'>888888</clientProperty>",
                        xml);
         assertTrue("", 888888 == clientProperty.getLongValue());
         assertTrue("", clientProperty.getObjectValue() instanceof Long);
         System.out.println(xml);
      }
      {
         ClientProperty clientProperty = new ClientProperty("key", Constants.TYPE_SHORT, null);
         assertEquals("", "key", clientProperty.getName());
         assertEquals("", "short", clientProperty.getType());
         assertEquals("", null, clientProperty.getEncoding());
         assertEquals("", null, clientProperty.getValueRaw());
         assertEquals("", null, clientProperty.getStringValue());
         assertEquals("", null, clientProperty.getObjectValue());

         clientProperty.setValue("12");
         String xml = clientProperty.toXml();
         assertEquals("", "12", clientProperty.getValueRaw());
         assertXMLEqual("comparing test xml to control xml",
                        "<clientProperty name='key' type='short'>12</clientProperty>",
                        xml);
         assertTrue("", 12 == clientProperty.getShortValue());
         assertTrue("", clientProperty.getObjectValue() instanceof Short);
         System.out.println(xml);
      }
      {
         ClientProperty clientProperty = new ClientProperty("key", null, null);
         assertEquals("", "key", clientProperty.getName());
         assertEquals("", null, clientProperty.getType());
         assertEquals("", null, clientProperty.getEncoding());
         assertEquals("", null, clientProperty.getValueRaw());
         assertEquals("", null, clientProperty.getStringValue());
         assertEquals("", null, clientProperty.getObjectValue());

         byte[] bb = new byte[6];
         bb[0] = 0;
         bb[1] = 'A';
         bb[2] = 0;
         bb[3] = 99;
         bb[4] = 0;
         bb[5] = 0;
         clientProperty.setValue(bb);
         assertEquals("", "byte[]", clientProperty.getType());
         assertEquals("", Constants.ENCODING_BASE64, clientProperty.getEncoding());
         assertEquals("", true, clientProperty.isBase64());
         String xml = clientProperty.toXml();
         byte[] newVal = clientProperty.getBlobValue();
         for (int i=0; i<bb.length; i++)
            assertTrue("Index #"+i, bb[i] == newVal[i]);
         assertXpathExists("/clientProperty[@name='key']", xml);
         assertXpathExists("/clientProperty[@type='"+Constants.TYPE_BLOB+"']", xml);
         assertXpathExists("/clientProperty[@encoding='"+Constants.ENCODING_BASE64+"']", xml);
         assertEquals("", "AEEAYwAA", clientProperty.getValueRaw());
         assertXMLEqual("comparing test xml to control xml",
                        "<clientProperty name='key' type='byte[]' encoding='base64'>AEEAYwAA</clientProperty>",
                        xml);
         assertTrue("", clientProperty.getObjectValue() instanceof byte[]);
         newVal = (byte[])clientProperty.getObjectValue();
         for (int i=0; i<bb.length; i++)
            assertTrue("Index #"+i, bb[i] == newVal[i]);
         System.out.println(xml);
      }
   }
View Full Code Here


         "  <clientProperty name='StringKey' type=''><![CDATA[Bla<BlaBla]]></clientProperty>\n" +
         "</qos>";     
     
      MsgQosSaxFactory parser = new MsgQosSaxFactory(this.glob);
      MsgQosData data = parser.readObject(xml);
      ClientProperty prop = data.getClientProperty("StringKey");
      System.out.println(prop.toXml());
      assertEquals("", true, prop.isBase64());
     
   }
View Full Code Here

      String val2 = "val2  ";
      String name3 = "bothSpaces";
      String val3 = "  val3  ";
      String name4 = "singleSpace";
      String val4 = " val4 ";
      ClientProperty prop1 = new ClientProperty(name1, null, null, val1);
      ClientProperty prop2 = new ClientProperty(name2, null, null, val2);
      ClientProperty prop3 = new ClientProperty(name3, null, null, val3);
      ClientProperty prop4 = new ClientProperty(name4, null, null, val4);
      data.addClientProperty(prop1);
      data.addClientProperty(prop2);
      data.addClientProperty(prop3);
      data.addClientProperty(prop4);
      String xml = data.toXml();
View Full Code Here

         "  <clientProperty name='StringKey' type=''><BlaBla attr1='val1' attr2=' val2 '> Something </BlaBla></clientProperty>\n" +
         "</qos>";     
     
      MsgQosSaxFactory parser = new MsgQosSaxFactory(this.glob);
      MsgQosData data = parser.readObject(xml);
      ClientProperty prop = data.getClientProperty("StringKey");
      System.out.println(prop.toXml());
      // assertEquals("", true, prop.isBase64());
     
     
      String val = "<BlaBla attr1='val1' attr2=' val2 '> Something </BlaBla>";
      prop = new ClientProperty("StringKey", null, Constants.ENCODING_FORCE_PLAIN, val);
      System.out.println(prop.toXml());

      xml =  "<qos>\n" +
      "  <isPublish/>\n" +
      "  <clientProperty name='StringKey' type='' encoding='forcePlain'><qos attr1='val1' attr2=' val2 '> Something </qos></clientProperty>\n" +
      "</qos>";     
     
      parser = new MsgQosSaxFactory(this.glob);
      data = parser.readObject(xml);
      prop = data.getClientProperty("StringKey");
      System.out.println(prop.toXml());
     
      xml =  "<qos>\n" +
      "  <isPublish/>\n" +
      "  <clientProperty name='StringKey' type='' encoding='forcePlain'><clientProperty name='aaa' type='' encoding=''>Something</clientProperty></clientProperty>\n" +
      "</qos>";     
     
      parser = new MsgQosSaxFactory(this.glob);
      data = parser.readObject(xml);
      prop = data.getClientProperty("StringKey");
      System.out.println(prop.toXml());
     
      System.out.println("END");
   }
View Full Code Here

               address.setRetries(-1);
               address.setPingInterval(20000L);
               address.setType(type);
               address.setVersion(version);
               //address.addClientProperty(new ClientProperty("useRemoteLoginAsTunnel", true));
               address.addClientProperty(new ClientProperty("acceptRemoteLoginAsTunnel", true));
               address.setRawAddress(rawAddress); // Address to find ourself
               //address.addClientProperty(new ClientProperty("acceptRemoteLoginAsTunnel", "", "", ""+true));
               prop.setAddress(address);
               tmpQos.addClientQueueProperty(prop);
               CallbackAddress cbAddress = new CallbackAddress(glob);
               cbAddress.setDelay(40000L);
               cbAddress.setRetries(-1);
               cbAddress.setPingInterval(20000L);
               cbAddress.setDispatcherActive(false);
               cbAddress.setType(type);
               cbAddress.setVersion(version);
               //cbAddress.addClientProperty(new ClientProperty("useRemoteLoginAsTunnel", true));
               cbAddress.addClientProperty(new ClientProperty("acceptRemoteLoginAsTunnel", true));
               tmpQos.addCallbackAddress(cbAddress);
               tmpQos.setPersistent(true);
               glob.getXmlBlasterAccess().setServerNodeId(getId());
               log.info("Creating temporary session " + sessionName.getRelativeName() + " until real cluster node "
                     + glob.getXmlBlasterAccess().getServerNodeId() + " arrives");
View Full Code Here

     
      // get the query properties
      //if (querySpec.getQuery() != null) query = querySpec.getQuery().getQuery();
      // "maxEntries=3&maxSize=1000&consumable=true&waitingDelay=1000"     
      Map props = StringPairTokenizer.parseToStringClientPropertyPairs(query, "&", "=");
      ClientProperty prop = (ClientProperty)props.get("maxEntries");
      if (prop != null) maxEntries = prop.getIntValue();
      prop = (ClientProperty)props.get("maxSize");
      if (prop != null) maxSize = prop.getLongValue();
      if (maxSize > -1L) {
         log.warning(" Query specification of maxSize is not implemented, please use the default value -1 or leave it untouched: '" + query + "'");
         throw new XmlBlasterException(this.global, ErrorCode.USER_ILLEGALARGUMENT, ME, "Query specification of maxSize is not implemented, please use the default value -1 or leave it untouched");
      }
      prop = (ClientProperty)props.get("consumable");
      if (prop != null) consumable = prop.getBooleanValue();
      prop = (ClientProperty)props.get("waitingDelay");
      if (prop != null) waitingDelay = prop.getLongValue();

      if (log.isLoggable(Level.FINE))
      log.fine("query: waitingDelay='" + waitingDelay + "' consumable='" + consumable + "' maxEntries='" + maxEntries + "' maxSize='" + maxSize + "'");
     
      if (waitingDelay != 0L) {
View Full Code Here

    * @param key
    * @param row
    * @return
    */
   private String getStringAttribute(String key, SqlRow row, SqlDescription description) {
      ClientProperty prop = null;
      if (row != null)
         prop = row.getAttribute(key);
      if (prop == null && description != null) {
         prop = description.getAttribute(key);
      }
      if (prop == null)
         return null;
      return prop.getStringValue();
   }
View Full Code Here

    * Checks weather an entry has already been processed, in which case it will not be processed anymore
    * @param dbInfo
    * @return
    */
   private boolean checkIfAlreadyProcessed(SqlInfo dbInfo) {
      ClientProperty prop = dbInfo.getDescription().getAttribute(ReplicationConstants.ALREADY_PROCESSED_ATTR);
      if (prop != null)
         return true;
      List rows = dbInfo.getRows();
      for (int i=0; i < rows.size(); i++) {
         SqlRow row = (SqlRow)rows.get(i);
View Full Code Here

      if (description == null) {
         log.warning("store: The message was a dbInfo but lacked description. " + dbInfo.toString());
         return;
      }
      boolean keepTransactionOpen = false;
      ClientProperty keepOpenProp = description.getAttribute(ReplicationConstants.KEEP_TRANSACTION_OPEN);
      if (keepOpenProp != null) {
         keepTransactionOpen = keepOpenProp.getBooleanValue();
         log.fine("Keep transaction open is '" + keepTransactionOpen + "'");
      }
      if (!keepTransactionOpen)
         this.exceptionInTransaction = false; // make sure we reset it here, otherwise it will not store anything anymore
      ClientProperty endOfTransition = description.getAttribute(ReplicationConstants.END_OF_TRANSITION);
      if (endOfTransition != null && endOfTransition.getBooleanValue()) {
         ClientProperty filenameProp =  description.getAttribute(ReplicationConstants.FILENAME_ATTR);
         String filename = null;
         if (filenameProp != null)
            filename = filenameProp.getStringValue();
         if (filename != null && filename.length() > 0) {
            deleteFiles(filename);
         }
         else
            log.warning("Could not cleanup since the '" + ReplicationConstants.FILENAME_ATTR + "' attribute was not set");
         return;
      }
     
      String command = description.getCommand();
      if (command.equals(INITIAL_XML_CMD)) {
         // "_filename"
         // "_timestamp"
         // XBMessage.get
        
         // "JMSXGroupSeq";
         // "JMSXGroupEof";
         // "JMSXGroupEx";
        
         // XBConnectionMetaData.JMSX_GROUP_SEQ
         // XBConnectionMetaData.JMSX_GROUP_EOF
         // XBConnectionMetaData.JMSX_GROUP_EX
         ClientProperty filename = description.getAttribute(FILENAME_ATTR);
         ClientProperty timestamp = description.getAttribute(TIMESTAMP_ATTR);
         ClientProperty contentProp = description.getAttribute(DUMP_CONTENT_ATTR);
         ClientProperty groupSeq = description.getAttribute(XBConnectionMetaData.JMSX_GROUP_SEQ);
         ClientProperty groupEof = description.getAttribute(XBConnectionMetaData.JMSX_GROUP_EOF);
         ClientProperty groupEx = description.getAttribute(XBConnectionMetaData.JMSX_GROUP_EX);

         byte[] content = contentProp.getBlobValue();
         Map map = new HashMap();
         if (filename != null)
            map.put(FILENAME_ATTR, filename);
View Full Code Here

            log.warning("could not delete the file '" + completeFilename + "' please delete it manually");
      }
   }
  
   private void deleteFiles(Map attrMap) {
      ClientProperty filenameProp =  (ClientProperty)attrMap.get(ReplicationConstants.FILENAME_ATTR);
      String filename = null;
      if (filenameProp != null)
         filename = filenameProp.getStringValue();
      if (filename != null && filename.length() > 0) {
         deleteFiles(filename);
      }
      else
         log.warning("Could not cleanup since the '" + ReplicationConstants.FILENAME_ATTR + "' attribute was not set");
View Full Code Here

TOP

Related Classes of org.xmlBlaster.util.qos.ClientProperty

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.