Author: heiko.braun(a)jboss.com
Date: 2009-12-11 07:55:57 -0500 (Fri, 11 Dec 2009)
New Revision: 903
Modified:
bpm-console/trunk/server/integration/src/main/java/org/jboss/bpm/console/server/plugin/PluginMgr.java
Log:
Fix BPMC-43: Blacklist plugins that cannot be resolved
Modified:
bpm-console/trunk/server/integration/src/main/java/org/jboss/bpm/console/server/plugin/PluginMgr.java
===================================================================
---
bpm-console/trunk/server/integration/src/main/java/org/jboss/bpm/console/server/plugin/PluginMgr.java 2009-12-10
14:47:54 UTC (rev 902)
+++
bpm-console/trunk/server/integration/src/main/java/org/jboss/bpm/console/server/plugin/PluginMgr.java 2009-12-11
12:55:57 UTC (rev 903)
@@ -26,6 +26,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
/**
* Loads plugins through the {@link org.jboss.bpm.console.server.util.ServiceLoader}.
*
@@ -35,7 +38,7 @@
{
private static final Log log = LogFactory.getLog(PluginMgr.class);
-
+ private static List<String> failedToResolve = new
CopyOnWriteArrayList<String>();
/**
* Load a plugin through the {@link org.jboss.bpm.console.server.util.ServiceLoader}.
* The plugin interface name acts as the service key.
@@ -45,10 +48,14 @@
*/
public static <T> T load(Class<T> type)
{
+ boolean failedBefore = failedToResolve.contains(type.getName());
+ if(failedBefore) return null;
+
T pluginImpl = (T) ServiceLoader.loadService(
type.getName(), null
);
+
if(pluginImpl!=null)
{
log.info("Successfully loaded plugin '" +type.getName()+ "':
"+pluginImpl.getClass());
@@ -58,6 +65,7 @@
else
{
log.warn("Unable to load plugin: '" + type.getName() +
"'");
+ failedToResolve.add(type.getName());
return null;
}
}