Package org.xmlBlaster.engine.runlevel

Examples of org.xmlBlaster.engine.runlevel.PluginHolder


   public void testPluginHolder() {
      String me = ME + "-testPluginHolder";
      try {
         log.info("start");

         PluginHolder holder = new PluginHolder(this.glob);
        
         PluginConfig tmp = new PluginConfig(this.glob, "queueJDBC", true, "org.xmlBlaster.util.queue.jdbc.JDBCQueueCommonTablePlugin");
         holder.addDefaultPluginConfig(tmp);
         tmp = new PluginConfig(this.glob, "queueRAM", true, "org.xmlBlaster.util.queue.ram.RAMQueuePlugin");
         holder.addPluginConfig("avalon", tmp);

         tmp = holder.getPluginConfig("avalon", "queueRAM");
         if (tmp == null) assertTrue(me + " getting 'avalon queueRAM'", false);
         log.info(tmp.toXml());

         tmp = holder.getPluginConfig("avalon", "queueJDBC");
         if (tmp == null) assertTrue(me + " getting 'avalon queueJDBC'", false);
         log.info(tmp.toXml());

         PluginConfig[] help = holder.getAllPluginConfig("avalon");
         assertEquals(me + " get all plugins for avalon", 2, help.length);


         String xml = new String();
         xml += "<xmlBlaster>\n" +
                "   <!-- A typical plugin which is loaded by client request -->\n" +
                "   <plugin id='dispatchPriority'\n" +
                "           className='org.xmlBlaster.util.dispatch.plugins.prio.PriorizedDispatchPlugin'\n" +
                "           jar='/tmp/my.jar'>\n" +
                "      <attribute id='config'>\n" +
                "         <![CDATA[\n" +
                "         <msgDispatch defaultStatus='64k' defaultAction='send'>\n" +
                "         <onStatus oid='_bandwidth.status' content='64k' defaultAction='destroy'>\n" +
                "            <action do='send'  ifPriority='7-9'/>\n" +
                "            <action do='queue'  ifPriority='2-6'/>\n" +
                "         </onStatus>\n" +
                "         <onStatus oid='_bandwidth.status' content='2M'>\n" +
                "            <action do='send'  ifPriority='0-9'/>\n" +
                "         </onStatus>\n" +
                "         </msgDispatch>\n" +
                "         ]]>\n" +
                "      </attribute>\n" +
                "   </plugin>\n" +
                "\n" +
                "   <plugin id='queueCACHE' className='org.xmlBlaster.util.queue.cache.CacheQueueInterceptorPlugin'>\n" +
                "      <attribute id='transientQueue'>queueRAM</attribute>\n" +
                "      <attribute id='persistentQueue'>queueJDBC</attribute>\n" +
                "   </plugin>\n" +
                "   \n" +
                "  <plugin id='queueRAM' className='org.xmlBlaster.util.queue.ram.RamQueuePlugin'/>\n" +
                "\n" +
                "   <plugin id='storage:CACHE' className='org.xmlBlaster.engine.msgstore.cache.PersistenceCachePlugin'>\n" +
                "      <attribute id='transientQueue'>storage:RAM</attribute>\n" +
                "      <attribute id='persistentQueue'>storage:JDBC</attribute>\n" +
                "   </plugin>\n" +
                "   \n" +
                "   <plugin id='storage:RAM' className='org.xmlBlaster.engine.msgstore.ram.MapPlugin'/>\n" +
                "   \n" +
                "   <!-- and here the declarations which are specific to the given nodes -->\n" +
                "   <node id='heron'>\n" +
                "      <plugin id='protocol:SOCKET:admin' \n" +
                "              className='org.xmlBlaster.protocol.socket.SocketDriver'>\n" +
                "         <attribute id='port'>69000</attribute>\n" +
                "      </plugin>\n" +
                "     \n" +
                "      <!-- /node/heron/plugin/protocol:SOCKET:users/attribute/port=6901 -->\n" +
                "      <!-- /node/heron/plugin/protocol:SOCKET:users/action/LOAD/onStartupRunlevel=3 -->\n" +
                "      <!-- /node/heron/plugin/protocol:SOCKET:users/action/LOAD/sequence=5 -->\n" +
                "      <plugin id='protocol:SOCKET:users' className='org.xmlBlaster.protocol.socket.SocketDriver'>\n" +
                "         <attribute id='port'>6901</attribute>\n" +
                "         <action do='LOAD' onStartupRunlevel='3' sequence='5' onFail='resource.configuration.pluginFailed'/>\n" +
                "         <action do='STOP' onShutdownRunlevel='2' sequence='4'/>\n" +
                "      </plugin>\n" +
                "     \n" +
                "      <plugin id='queueJDBC' className='org.xmlBlaster.util.queue.jdbc.JDBCQueueCommonTablePlugin'>\n" +
                "         <attribute id='url'>jdbc:oracle:thin:@localhost:1521:noty</attribute>\n" +
                "         <attribute id='user'>joe</attribute>\n" +
                "         <attribute id='password'>secret</attribute>\n" +
                "         <attribute id='connectionBusyTimeout'>90000</attribute>\n" +
                "         <attribute id='maxWaitingThreads'>300</attribute>\n" +
                "      </plugin>\n" +
                "     \n" +
                "      <plugin id='storage:JDBC' className='org.xmlBlaster.engine.msgstore.cache.PersistenceCachePlugin'>\n" +
                "         <attribute id='url'>jdbc:oracle:thin:@localhost:1521:noty</attribute>\n" +
                "         <attribute id='user'>joe</attribute>\n" +
                "         <attribute id='password'>secret</attribute>\n" +
                "         <attribute id='connectionBusyTimeout'>90000</attribute>\n" +
                "         <attribute id='maxWaitingThreads'>300</attribute>\n" +
                "      </plugin>\n" +
                "    </node> <!-- heron -->\n" +
                " \n" +
                "    <node id='avalon'>\n" +
                "       ...\n" +
                "      <plugin id='queueJDBC' className='org.xmlBlaster.util.queue.jdbc.JDBCQueueCommonTablePlugin'>\n" +
                "         <attribute id='url'>jdbc:oracle:thin:@localhost:1521:noty</attribute>\n" +
                "         <attribute id='user'>joe</attribute>\n" +
                "         <attribute id='password'>secret</attribute>\n" +
                "         <attribute id='connectionBusyTimeout'>90000</attribute>\n" +
                "         <attribute id='maxWaitingThreads'>300</attribute>\n" +
                "        <attribute id='tableNamePrefix'>AVALON_</attribute>\n" +
                "      </plugin>\n" +
                "      ...\n" +
                "    </node>\n" +
                "</xmlBlaster>\n"

         PluginHolderSaxFactory factory = new PluginHolderSaxFactory(this.glob);
         PluginHolder pluginHolder = null;
         for (int i=0; i < 2; i++) {
            log.info("looping through the loop. sweep '" + i + "'");
            pluginHolder = factory.readObject(xml);
            PluginConfig[] plugins = pluginHolder.getAllPluginConfig("avalon");
            assertEquals(me + " number of plugins for 'avalon' in plugin holder", 6, plugins.length);

            PluginConfig pluginConfig = null;
            pluginConfig = pluginHolder.getPluginConfig("avalon","dispatchPriority");
            if (pluginConfig == null)
               assertTrue(me + " getting plugin 'dispatchPriority' for avalon gives null", false);
            String id = pluginConfig.getId();
            assertEquals(me + " id for avalon/dispatchPriority", "dispatchPriority", id);
            String className = pluginConfig.getClassName();
            assertEquals(me + " className for avalon/dispatchPriority", "org.xmlBlaster.util.dispatch.plugins.prio.PriorizedDispatchPlugin", className);

            pluginConfig = pluginHolder.getPluginConfig("avalon","queueCACHE");
            pluginConfig = pluginHolder.getPluginConfig("avalon","queueRAM");
            pluginConfig = pluginHolder.getPluginConfig("avalon","queueJDBC");
            pluginConfig = pluginHolder.getPluginConfig("avalon","storage:CACHE");
            pluginConfig = pluginHolder.getPluginConfig("avalon","storage:RAM");

            //should not exist
            pluginConfig = pluginHolder.getPluginConfig("avalon","storage:JDBC");

            //should be the individual of heron (not from xmlBlaster)
            pluginConfig = pluginHolder.getPluginConfig("heron","queueJDBC");

            xml = pluginHolder.toXml();
            log.info(xml);
         }
      }
      catch (XmlBlasterException e) {
         fail(me + " failed: " + e.toString());
View Full Code Here

TOP

Related Classes of org.xmlBlaster.engine.runlevel.PluginHolder

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.