You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2008/01/17 18:06:35 UTC
svn commit: r612871 - in
/servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl:
ComponentImpl.java Deployer.java
Author: gnodet
Date: Thu Jan 17 09:06:32 2008
New Revision: 612871
URL: http://svn.apache.org/viewvc?rev=612871&view=rev
Log:
SMX4NMR-7 / SMX4NMR-8: handle JBI artifacts state correcty
Modified:
servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/ComponentImpl.java
servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/Deployer.java
Modified: servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/ComponentImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/ComponentImpl.java?rev=612871&r1=612870&r2=612871&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/ComponentImpl.java (original)
+++ servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/ComponentImpl.java Thu Jan 17 09:06:32 2008
@@ -61,15 +61,18 @@
private State state = State.Unknown;
private Preferences prefs;
private State runningState;
+ private Deployer deployer;
public ComponentImpl(ComponentDesc componentDesc,
javax.jbi.component.Component component,
Preferences prefs,
- boolean autoStart) {
+ boolean autoStart,
+ Deployer deployer) {
this.componentDesc = componentDesc;
this.component = new ComponentWrapper(component);
this.prefs = prefs;
this.runningState = State.valueOf(this.prefs.get(STATE, (autoStart ? State.Started : State.Initialized).name()));
+ this.deployer = deployer;
}
public String getName() {
@@ -95,6 +98,7 @@
}
public void stop() throws JBIException {
+ // TODO: stop deployed SAs
if (state == State.Started) {
component.getLifeCycle().stop();
state = State.Stopped;
@@ -103,6 +107,7 @@
}
public void shutDown() throws JBIException {
+ // TODO: shutdown deployed SAs
if (state == State.Started) {
stop();
}
@@ -193,6 +198,7 @@
shutDown();
state = State.Shutdown;
}
+ deployer.checkPendingBundles();
} finally {
Thread.currentThread().setContextClassLoader(cl);
}
Modified: servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/Deployer.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/Deployer.java?rev=612871&r1=612870&r2=612871&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/Deployer.java (original)
+++ servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/Deployer.java Thu Jan 17 09:06:32 2008
@@ -26,6 +26,7 @@
import java.util.concurrent.ConcurrentHashMap;
import javax.jbi.JBIException;
+import javax.jbi.management.LifeCycleMBean;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -116,7 +117,7 @@
}
@Override
- protected void register(Bundle bundle) {
+ protected synchronized void register(Bundle bundle) {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
@@ -174,7 +175,7 @@
Preferences prefs = preferencesService.getUserPreferences(componentDesc.getIdentification().getName());
Class clazz = classLoader.loadClass(componentDesc.getComponentClassName());
javax.jbi.component.Component innerComponent = (javax.jbi.component.Component) clazz.newInstance();
- ComponentImpl component = new ComponentImpl(componentDesc, innerComponent, prefs, autoStart);
+ ComponentImpl component = new ComponentImpl(componentDesc, innerComponent, prefs, autoStart, this);
// populate props from the component meta-data
Dictionary<String, String> props = new Hashtable<String, String>();
props.put(NAME, componentDesc.getIdentification().getName());
@@ -183,8 +184,6 @@
LOGGER.debug("Registering JBI component");
registerService(bundle, Component.class.getName(), component, props);
registerService(bundle, javax.jbi.component.Component.class.getName(), component.getComponent(), props);
- // Check pending bundles
- checkPendingBundles();
}
protected void deployServiceAssembly(ServiceAssemblyDesc serviceAssembyDesc, Bundle bundle) throws Exception {
@@ -196,6 +195,9 @@
if (component == null) {
throw new PendingException(bundle, "Component not installed: " + componentName);
}
+ if (LifeCycleMBean.UNKNOWN.equals(component.getCurrentState())) {
+ throw new PendingException(bundle, "Component is in an unknown state: " + componentName);
+ }
}
// Create the SA directory
File saDir = new File(jbiRootDir, Long.toString(bundle.getBundleId()));
@@ -245,11 +247,19 @@
checkPendingBundles();
}
- protected void checkPendingBundles() {
- List<Bundle> pending = pendingBundles;
- pendingBundles = new ArrayList<Bundle>();
- for (Bundle bundle : pending) {
- register(bundle);
+ protected synchronized void checkPendingBundles() {
+ if (!pendingBundles.isEmpty()) {
+ final List<Bundle> pending = pendingBundles;
+ pendingBundles = new ArrayList<Bundle>();
+ Thread th = new Thread() {
+ public void run() {
+ for (Bundle bundle : pending) {
+ register(bundle);
+ }
+ }
+ };
+ th.setDaemon(true);
+ th.start();
}
}