1 /*------------------------------------------------------------------------------
  2 Name:      CbServerPluginManager.java
  3 Project:   xmlBlaster.org
  4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
  5 ------------------------------------------------------------------------------*/
  6 package org.xmlBlaster.client.protocol;
  7 
  8 import java.util.logging.Logger;
  9 import java.util.logging.Level;
 10 import org.xmlBlaster.util.plugin.PluginManagerBase;
 11 import org.xmlBlaster.util.plugin.PluginInfo;
 12 import org.xmlBlaster.util.plugin.I_Plugin;
 13 import org.xmlBlaster.util.Global;
 14 import org.xmlBlaster.util.XmlBlasterException;
 15 import org.xmlBlaster.client.protocol.I_CallbackServer;
 16 
 17 /**
 18  * CbServerPluginManager loads the callback protocol plugins like CORBA/RMI/XmlRpc on client side
 19  * to be able to receive callbacks from xmlBlaster. 
 20  * <p />
 21  * <pre>
 22  * A typical xmlBlaster.properties entry:
 23  *
 24  * ClientCbServerProtocolPlugin[IOR][1.0]=org.xmlBlaster.client.protocol.corba.CorbaCallbackServer
 25  * </pre>
 26  * @author <a href="mailto:xmlBlaster@marcelruff.info">Marcel Ruff</a>.
 27  * @see <a href="http://www.xmlblaster.org/xmlBlaster/doc/requirements/protocol.html" target="others">protocol</a>
 28  */
 29 public class CbServerPluginManager extends PluginManagerBase
 30 {
 31    private final String ME;
 32    private final Global glob;
 33    private static Logger log = Logger.getLogger(CbServerPluginManager.class.getName());
 34    private static final String defaultPluginName = "org.xmlBlaster.client.protocol.corba.CorbaCallbackServer";
 35    public static final String pluginPropertyName = "ClientCbServerProtocolPlugin";
 36 
 37    public CbServerPluginManager(Global glob) {
 38       super(glob);
 39       this.glob = glob;
 40 
 41       this.ME = "CbServerPluginManager" + this.glob.getLogPrefixDashed();
 42       if (log.isLoggable(Level.FINER)) log.finer("Constructor CbServerPluginManager");
 43    }
 44 
 45    /**
 46     * Enforced by PluginManagerBase. 
 47     * @return The name of the property in xmlBlaster.property "LoadBalancerPlugin"
 48     * for "LoadBalancerPlugin[RoundRobin][1.0]"
 49     */
 50    protected String getPluginPropertyName() {
 51       return pluginPropertyName;
 52    }
 53 
 54    /**
 55     * @return please return your default plugin classname or null if not specified
 56     */
 57    public String getDefaultPluginName(String type, String version) {
 58       return defaultPluginName;
 59    }
 60 
 61    /**
 62     * Creates a new instance of the given protocol driver type. 
 63     * <p />
 64     * You need to call clientDriver.init(glob, address) on it.
 65     * @param driverType e.g. "RMI"
 66     * @return The uninitialized driver, never null
 67     * @exception XmlBlasterException on problems
 68     */
 69    public final I_CallbackServer getNewProtocolDriverInstance(String driverType) throws XmlBlasterException {
 70       return getPlugin(driverType, "1.0");
 71    }
 72 
 73    /**
 74     * Return a specific plugin, every call will create a new plugin instance. 
 75     * <p/>
 76     * @param String The type of the requested plugin.
 77     * @param String The version of the requested plugin.
 78     * @return The plugin for this type and version or null if none is specified
 79     */
 80    public I_CallbackServer getPlugin(String type, String version) throws XmlBlasterException {
 81       if (log.isLoggable(Level.FINER)) log.finer("Creating instance of " + createPluginPropertyKey(type, version));
 82 
 83       // We need a new instance every time! (no caching in base class)
 84       PluginInfo pluginInfo = new PluginInfo(glob, this, type, version);
 85       I_CallbackServer driver = (I_CallbackServer)super.instantiatePlugin(pluginInfo, false);
 86       if (driver == null) log.warning("Creating instance of " + createPluginPropertyKey(type, version) + " failed, no such plugin found.");
 87       return driver;
 88    }
 89 
 90    public void postInstantiate(I_Plugin plugin, PluginInfo pluginInfo) {}
 91 
 92    public void activateDrivers() throws XmlBlasterException {
 93       if (log.isLoggable(Level.FINE)) log.fine("Don't know how to activate the calback server protocol drivers, they are created for each client and session separately");
 94    }
 95 
 96    public final void deactivateDrivers(boolean force) {
 97       if (log.isLoggable(Level.FINE)) log.fine("Don't know how to deactivate the calback server protocol drivers, they are created for each client and session separately");
 98    }
 99 
100    public void shutdownDrivers(boolean force) throws XmlBlasterException {
101       if (log.isLoggable(Level.FINE)) log.fine("Don't know how to shutdown the calback server protocol drivers, they are created for each client and session separately");
102    }
103 }


syntax highlighted by Code2HTML, v. 0.9.1