summaryrefslogtreecommitdiff
path: root/qpid/java
diff options
context:
space:
mode:
authorMartin Ritchie <ritchiem@apache.org>2010-05-07 15:13:44 +0000
committerMartin Ritchie <ritchiem@apache.org>2010-05-07 15:13:44 +0000
commit7c7d88195037c6a5cb82296433bd2e9c1d5a9c6a (patch)
tree3c58b559d08df7f3636dec826a04549eab2fbfa6 /qpid/java
parentc05345ab26e6fba2d4a83fcdb7e2c04c8fbce3cc (diff)
downloadqpid-python-7c7d88195037c6a5cb82296433bd2e9c1d5a9c6a.tar.gz
QPID-2585 : Upgrade to Felix 2.0.5
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@942114 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java')
-rw-r--r--qpid/java/broker/etc/config.xml2
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/PluginManager.java267
-rw-r--r--qpid/java/build.deps2
-rwxr-xr-xqpid/java/lib/org.apache.felix.framework-1.0.0.jarbin320272 -> 0 bytes
-rw-r--r--qpid/java/lib/org.apache.felix.framework-2.0.5.jarbin0 -> 391763 bytes
5 files changed, 190 insertions, 81 deletions
diff --git a/qpid/java/broker/etc/config.xml b/qpid/java/broker/etc/config.xml
index fd5d84a1e8..2f78003afb 100644
--- a/qpid/java/broker/etc/config.xml
+++ b/qpid/java/broker/etc/config.xml
@@ -23,6 +23,8 @@
<prefix>${QPID_HOME}</prefix>
<work>${QPID_WORK}</work>
<conf>${prefix}/etc</conf>
+
+ <plugin-directory>${QPID_HOME}/lib/plugins</plugin-directory>
<connector>
<!-- To enable SSL edit the keystorePath and keystorePassword
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/PluginManager.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/PluginManager.java
index 0911c73fe7..171de7a701 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/PluginManager.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/PluginManager.java
@@ -19,16 +19,12 @@
package org.apache.qpid.server.plugins;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import org.apache.commons.configuration.ConfigurationException;
import org.apache.felix.framework.Felix;
import org.apache.felix.framework.cache.BundleCache;
import org.apache.felix.framework.util.FelixConstants;
import org.apache.felix.framework.util.StringMap;
+import org.apache.qpid.server.configuration.plugin.ConfigurationPluginFactory;
import org.apache.qpid.server.exchange.ExchangeType;
import org.apache.qpid.server.security.access.ACLPlugin;
import org.apache.qpid.server.security.access.ACLPluginFactory;
@@ -37,155 +33,266 @@ import org.apache.qpid.server.security.access.plugins.DenyAll;
import org.apache.qpid.server.security.access.plugins.LegacyAccessPlugin;
import org.apache.qpid.server.security.access.plugins.SimpleXML;
import org.apache.qpid.server.security.access.plugins.network.FirewallPlugin;
+import org.apache.qpid.server.virtualhost.plugin.VirtualHostPluginFactory;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleException;
import org.osgi.util.tracker.ServiceTracker;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
/**
- *
* @author aidan
- *
- * Provides access to pluggable elements, such as exchanges
+ *
+ * Provides access to pluggable elements, such as exchanges
*/
public class PluginManager
{
- private Felix _felix = null;
private ServiceTracker _exchangeTracker = null;
private ServiceTracker _securityTracker = null;
- private Activator _activator = null;
- private boolean _empty;
+ private ServiceTracker _configTracker = null;
+ private ServiceTracker _virtualHostTracker = null;
+
+ private Felix _felix;
+
+ Activator _activator;
+
private Map<String, ACLPluginFactory> _securityPlugins;
+ private static final int FELIX_STOP_TIMEOUT = 30000;
public PluginManager(String plugindir) throws Exception
{
StringMap configMap = new StringMap(false);
- // Tell felix it's being embedded
- configMap.put(FelixConstants.EMBEDDED_EXECUTION_PROP, "true");
// Add the bundle provided service interface package and the core OSGi
// packages to be exported from the class path via the system bundle.
- configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES, "org.osgi.framework; version=1.3.0,"
- + "org.osgi.service.packageadmin; version=1.2.0," +
- "org.osgi.service.startlevel; version=1.0.0," +
- "org.osgi.service.url; version=1.0.0," +
- "org.osgi.util.tracker; version=1.0.0,"+
- "org.apache.qpid.junit.extensions.util; version=0.7," +
- "org.apache.qpid; version=0.7," +
- "org.apache.qpid.framing; version=0.7," +
- "org.apache.qpid.protocol; version=0.7," +
- "org.apache.qpid.server.exchange; version=0.7," +
- "org.apache.qpid.server.management; version=0.7,"+
- "org.apache.qpid.server.protocol; version=0.7,"+
- "org.apache.qpid.server.virtualhost; version=0.7," +
- "org.apache.qpid.server.registry; version=0.7," +
- "org.apache.qpid.server.queue; version=0.7," +
- "org.apache.qpid.server.binding; version=0.7," +
- "org.apache.qpid.server.configuration; version=0.7," +
- "org.apache.qpid.server.configuration.management; version=0.7," +
- "org.apache.qpid.server.persistent; version=0.7," +
- "org.apache.qpid.server.plugins; version=0.7," +
- "org.apache.qpid.server.queue; version=0.7," +
- "org.apache.qpid.server.security; version=0.7," +
- "org.apache.qpid.framing.AMQShortString; version=0.7," +
- "org.apache.qpid.server.queue.AMQQueue; version=0.7," +
- "org.apache.qpid.server.security.access; version=0.7,"+
- "org.apache.commons.configuration; version=0.7," +
- "javax.management.openmbean; version=1.0.0,"+
- "javax.management; version=1.0.0,"
- );
-
+ configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES,
+ "org.osgi.framework; version=1.3.0," +
+ "org.osgi.service.packageadmin; version=1.2.0," +
+ "org.osgi.service.startlevel; version=1.0.0," +
+ "org.osgi.service.url; version=1.0.0," +
+ "org.osgi.util.tracker; version=1.0.0," +
+ "org.apache.qpid.junit.extensions.util; version=0.7," +
+ "org.apache.qpid; version=0.7," +
+ "org.apache.qpid.framing; version=0.7," +
+ "org.apache.qpid.protocol; version=0.7," +
+ "org.apache.qpid.server.exchange; version=0.7," +
+ "org.apache.qpid.server.management; version=0.7," +
+ "org.apache.qpid.server.protocol; version=0.7," +
+ "org.apache.qpid.server.virtualhost; version=0.7," +
+ "org.apache.qpid.server.virtualhost.plugin; version=0.7," +
+ "org.apache.qpid.server.registry; version=0.7," +
+ "org.apache.qpid.server.queue; version=0.7," +
+ "org.apache.qpid.server.binding; version=0.7," +
+ "org.apache.qpid.server.configuration; version=0.7," +
+ "org.apache.qpid.server.configuration.plugin; version=0.7," +
+ "org.apache.qpid.server.configuration.management; version=0.7," +
+ "org.apache.qpid.server.persistent; version=0.7," +
+ "org.apache.qpid.server.plugins; version=0.7," +
+ "org.apache.qpid.server.queue; version=0.7," +
+ "org.apache.qpid.server.security; version=0.7," +
+ "org.apache.qpid.framing.AMQShortString; version=0.7," +
+ "org.apache.qpid.server.queue.AMQQueue; version=0.7," +
+ "org.apache.qpid.server.security.access; version=0.7," +
+ "org.apache.commons.configuration; version=0.7," +
+ "org.apache.log4j; version=1.2.12," +
+ "javax.management.openmbean; version=1.0.0," +
+ "javax.management; version=1.0.0,"
+ );
+
if (plugindir == null)
{
- _empty = true;
return;
}
-
+
// Set the list of bundles to load
File dir = new File(plugindir);
if (!dir.exists())
- {
- _empty = true;
+ {
return;
- }
-
+ }
+
StringBuffer pluginJars = new StringBuffer();
-
+
if (dir.isDirectory())
{
for (String child : dir.list())
{
if (child.endsWith("jar"))
{
- pluginJars.append(String.format(" file:%s%s%s", plugindir,File.separator,child));
+ pluginJars.append(String.format(" file:%s%s%s", plugindir, File.separator, child));
}
}
}
-
+
if (pluginJars.length() == 0)
{
- _empty = true;
return;
}
-
- configMap.put(FelixConstants.AUTO_START_PROP + ".1", pluginJars.toString());
- configMap.put(BundleCache.CACHE_PROFILE_DIR_PROP, plugindir);
-
+
+// configMap.put(FelixConstants.AUTO_START_PROP + ".1", pluginJars.toString());
+// configMap.put(BundleCache.CACHE_PROFILE_DIR_PROP, plugindir);
+
+ configMap.put("felix.auto.start.1", pluginJars.toString());
+ configMap.put("felix.shutdown.hook","false");
+ configMap.put(FelixConstants.FRAMEWORK_STORAGE, plugindir);
+
+
List<BundleActivator> activators = new ArrayList<BundleActivator>();
_activator = new Activator();
activators.add(_activator);
+ configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, activators);
- _felix = new Felix(configMap, activators);
+ _felix = new Felix(configMap);
try
{
+ System.out.println("Starting Plugin manager");
+
_felix.start();
-
+
+ System.out.println("Started Plugin manager");
+
_exchangeTracker = new ServiceTracker(_activator.getContext(), ExchangeType.class.getName(), null);
_exchangeTracker.open();
-
+
_securityTracker = new ServiceTracker(_activator.getContext(), ACLPlugin.class.getName(), null);
_securityTracker.open();
-
+
+ _configTracker = new ServiceTracker(_activator.getContext(), ConfigurationPluginFactory.class.getName(), null);
+ _configTracker.open();
+
+ _virtualHostTracker = new ServiceTracker(_activator.getContext(), VirtualHostPluginFactory.class.getName(), null);
+ _virtualHostTracker.open();
+
}
catch (BundleException e)
{
- throw new Exception("Could not create bundle");
+ throw new ConfigurationException("Could not start PluginManager:" + e.getMessage(), e);
}
}
private <T> Map<String, T> getServices(ServiceTracker tracker)
- {
- Map<String, T>services = new HashMap<String, T>();
-
+ {
+ Map<String, T> services = new HashMap<String, T>();
+
if ((tracker != null) && (tracker.getServices() != null))
{
for (Object service : tracker.getServices())
{
- services.put(service.getClass().getName(), (T) service);
+ if (service instanceof PluginFactory)
+ {
+ services.put(((PluginFactory) service).getPluginName(), (T) service);
+ }
+ else
+ {
+ services.put(service.getClass().getName(), (T) service);
+ }
}
- }
-
+ }
+
return services;
}
-
+
public Map<String, ExchangeType<?>> getExchanges()
{
return getServices(_exchangeTracker);
}
-
+
public Map<String, ACLPluginFactory> getSecurityPlugins()
{
- if (_securityPlugins == null)
+ _securityPlugins = getServices(_securityTracker);
+ // A little gross that we have to add them here, but not all the plugins are OSGIfied
+ _securityPlugins.put(SimpleXML.class.getName(), SimpleXML.FACTORY);
+ _securityPlugins.put(AllowAll.class.getName(), AllowAll.FACTORY);
+ _securityPlugins.put(DenyAll.class.getName(), DenyAll.FACTORY);
+ _securityPlugins.put(LegacyAccessPlugin.class.getName(), LegacyAccessPlugin.FACTORY);
+ _securityPlugins.put(FirewallPlugin.class.getName(), FirewallPlugin.FACTORY);
+
+ return _securityPlugins;
+ }
+
+ public Map<String, ConfigurationPluginFactory> getConfigurationPlugins()
+ {
+ Map<String, ConfigurationPluginFactory> services = new HashMap<String, ConfigurationPluginFactory>();
+
+ if ((_configTracker != null) && (_configTracker.getServices() != null))
{
- _securityPlugins = getServices(_securityTracker);
- // A little gross that we have to add them here, but not all the plugins are OSGIfied
- _securityPlugins.put(SimpleXML.class.getName(), SimpleXML.FACTORY);
- _securityPlugins.put(AllowAll.class.getName(), AllowAll.FACTORY);
- _securityPlugins.put(DenyAll.class.getName(), DenyAll.FACTORY);
- _securityPlugins.put(LegacyAccessPlugin.class.getName(), LegacyAccessPlugin.FACTORY);
- _securityPlugins.put(FirewallPlugin.class.getName(), FirewallPlugin.FACTORY);
+ for (Object service : _configTracker.getServices())
+ {
+ for (String parent : ((ConfigurationPluginFactory) service).getParentPaths())
+ {
+ services.put(parent, ((ConfigurationPluginFactory) service));
+ }
+ }
+ }
+
+ return services;
+
+ }
+
+ public Map<String, VirtualHostPluginFactory> getVirtualHostPlugins()
+ {
+ return getServices(_virtualHostTracker);
+ }
+
+ public <P extends PluginFactory> Map<String, P> getPlugins(Class<P> plugin)
+ {
+ ServiceTracker tracker = new ServiceTracker(_activator.getContext(), plugin.getName(), null);
+ tracker.open();
+
+ try
+ {
+ return getServices(tracker);
+ }
+ finally
+ {
+ tracker.close();
+ }
+ }
+
+ public void close()
+ {
+ if (_felix != null)
+ {
+ try
+ {
+ _exchangeTracker.close();
+
+ _securityTracker.close();
+
+ _configTracker.close();
+
+ _virtualHostTracker.close();
+ }
+ finally
+ {
+ System.out.println("Stopping Plugin manager");
+ //fixme should be stopAndWait() but hangs VM, need upgrade in felix
+ try
+ {
+ _felix.stop();
+ }
+ catch (BundleException e)
+ {
+ //ignore
+ }
+
+ try
+ {
+ _felix.waitForStop(FELIX_STOP_TIMEOUT);
+ }
+ catch (InterruptedException e)
+ {
+ //ignore
+ }
+
+ System.out.println("Stopped Plugin manager");
+ }
}
- return _securityPlugins;
}
}
diff --git a/qpid/java/build.deps b/qpid/java/build.deps
index 13b19e34bc..692d5d78ec 100644
--- a/qpid/java/build.deps
+++ b/qpid/java/build.deps
@@ -68,7 +68,7 @@ ${muse-wsx-api} ${muse-wsx-impl} ${wsdl4j} ${xercesImpl} ${xml-apis} ${jetty} ${
jsp.libs = ${jsp-api} ${jsp-impl} ${core-lib}
osgi-core=lib/org.osgi.core-1.0.0.jar
-felix-framework=lib/org.apache.felix.framework-1.0.0.jar
+felix-framework=lib/org.apache.felix.framework-2.0.5.jar
geronimo-servlet=lib/geronimo-servlet_2.5_spec-1.2.jar
felix.libs=${osgi-core} ${felix-framework}
diff --git a/qpid/java/lib/org.apache.felix.framework-1.0.0.jar b/qpid/java/lib/org.apache.felix.framework-1.0.0.jar
deleted file mode 100755
index 51401807bb..0000000000
--- a/qpid/java/lib/org.apache.felix.framework-1.0.0.jar
+++ /dev/null
Binary files differ
diff --git a/qpid/java/lib/org.apache.felix.framework-2.0.5.jar b/qpid/java/lib/org.apache.felix.framework-2.0.5.jar
new file mode 100644
index 0000000000..71e5a84231
--- /dev/null
+++ b/qpid/java/lib/org.apache.felix.framework-2.0.5.jar
Binary files differ