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 2009/02/25 13:59:24 UTC
svn commit: r747767 -
/servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/
Author: gnodet
Date: Wed Feb 25 12:59:23 2009
New Revision: 747767
URL: http://svn.apache.org/viewvc?rev=747767&view=rev
Log:
SMX4NMR-104: Each time the OSGi bundle is started / stopped, the JBI artifact is installed / uninstalled
Removed:
servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/AbstractBundleWatcher.java
Modified:
servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/AbstractInstaller.java
servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/AdminCommandsImpl.java
servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/ComponentInstaller.java
servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/Deployer.java
servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/DeploymentService.java
servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/InstallationService.java
servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/ServiceAssemblyInstaller.java
servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/SharedLibraryInstaller.java
Modified: servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/AbstractInstaller.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/AbstractInstaller.java?rev=747767&r1=747766&r2=747767&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/AbstractInstaller.java (original)
+++ servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/AbstractInstaller.java Wed Feb 25 12:59:23 2009
@@ -43,6 +43,8 @@
public abstract class AbstractInstaller {
+ public static final String LAST_INSTALL = "jbi.deployer.install";
+
protected final Log LOGGER = LogFactory.getLog(getClass());
protected Deployer deployer;
@@ -52,11 +54,13 @@
protected File jbiArtifact;
protected File installRoot;
protected boolean uninstallFromOsgi;
+ protected boolean isModified;
- protected AbstractInstaller(Deployer deployer, Descriptor descriptor, File jbiArtifact) {
+ protected AbstractInstaller(Deployer deployer, Descriptor descriptor, File jbiArtifact, boolean autoStart) {
this.deployer = deployer;
this.descriptor = descriptor;
this.jbiArtifact = jbiArtifact;
+ this.autoStart = autoStart;
}
public void setBundle(Bundle bundle) {
@@ -74,11 +78,24 @@
public abstract String getName();
public void init() throws Exception {
- extractBundle(installRoot, getBundle(), "/");
+ Preferences prefs = getPreferences();
+ long lastInstall = prefs.getLong(LAST_INSTALL, 0);
+ isModified = lastInstall == 0 || getBundle().getLastModified() > lastInstall;
+ if (isModified) {
+ extractBundle(installRoot, getBundle(), "/");
+ lastInstall = getBundle().getLastModified();
+ prefs.put(AbstractLifecycleJbiArtifact.STATE, isAutoStart()
+ ? AbstractLifecycleJbiArtifact.State.Started.name()
+ : AbstractLifecycleJbiArtifact.State.Shutdown.name());
+ }
+ prefs.putLong(LAST_INSTALL, lastInstall);
+ prefs.flush();
}
public abstract ObjectName install() throws JBIException;
+ public abstract void stop(boolean force) throws Exception;
+
public abstract void uninstall(boolean force) throws Exception;
public void installBundle() throws Exception {
@@ -122,18 +139,12 @@
return new File(base, "data/generated-bundles");
}
- protected void initializePreferences() throws BackingStoreException {
- PreferencesService preferencesService = deployer.getPreferencesService();
- Preferences prefs = preferencesService.getUserPreferences(getName());
- prefs.put(AbstractLifecycleJbiArtifact.STATE, isAutoStart()
- ? AbstractLifecycleJbiArtifact.State.Started.name()
- : AbstractLifecycleJbiArtifact.State.Shutdown.name());
- prefs.flush();
+ protected Preferences getPreferences() {
+ return deployer.getPreferencesService().getUserPreferences(getName());
}
protected void deletePreferences() throws BackingStoreException {
- PreferencesService preferencesService = deployer.getPreferencesService();
- Preferences prefs = preferencesService.getUserPreferences(getName());
+ Preferences prefs = getPreferences();
prefs.clear();
prefs.flush();
}
Modified: servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/AdminCommandsImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/AdminCommandsImpl.java?rev=747767&r1=747766&r2=747767&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/AdminCommandsImpl.java (original)
+++ servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/AdminCommandsImpl.java Wed Feb 25 12:59:23 2009
@@ -195,7 +195,6 @@
throw ManagementSupport.failure("start", "Service assembly does not exist: " + name);
}
try {
- // TODO: refactor
return getDeploymentService().undeploy(name);
} catch (Throwable e) {
throw ManagementSupport.failure("undeployServiceAssembly", name, e);
Modified: servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/ComponentInstaller.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/ComponentInstaller.java?rev=747767&r1=747766&r2=747767&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/ComponentInstaller.java (original)
+++ servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/ComponentInstaller.java Wed Feb 25 12:59:23 2009
@@ -38,6 +38,7 @@
import org.apache.servicemix.jbi.deployer.Component;
import org.apache.servicemix.jbi.deployer.SharedLibrary;
+import org.apache.servicemix.jbi.deployer.artifacts.ComponentImpl;
import org.apache.servicemix.jbi.deployer.descriptor.ComponentDesc;
import org.apache.servicemix.jbi.deployer.descriptor.Descriptor;
import org.apache.servicemix.jbi.deployer.descriptor.SharedLibraryList;
@@ -57,8 +58,8 @@
private Bootstrap bootstrap;
- public ComponentInstaller(Deployer deployer, Descriptor descriptor, File jbiArtifact) throws Exception {
- super(deployer, descriptor, jbiArtifact);
+ public ComponentInstaller(Deployer deployer, Descriptor descriptor, File jbiArtifact, boolean autoStart) throws Exception {
+ super(deployer, descriptor, jbiArtifact, autoStart);
this.installRoot = new File(System.getProperty("servicemix.base"), "data/jbi/" + getName() + "/install");
this.installRoot.mkdirs();
this.installationContext = new InstallationContextImpl(descriptor.getComponent(), deployer.getEnvironment(),
@@ -99,7 +100,9 @@
// Extract bundle
super.init();
// Init bootstrap
- initBootstrap();
+ if (isModified) {
+ initBootstrap();
+ }
}
/**
@@ -114,21 +117,20 @@
if (isInstalled()) {
throw new DeploymentException("Component is already installed");
}
- initBootstrap();
- bootstrap.onInstall();
- try {
+ if (isModified) {
+ initBootstrap();
+ bootstrap.onInstall();
try {
- initializePreferences();
- } catch (BackingStoreException e) {
- LOGGER.warn("Error initializing persistent state for component: " + getName(), e);
+ ObjectName name = initComponent();
+ cleanUpBootstrap();
+ installationContext.setInstall(false);
+ return name;
+ } catch (Exception e) {
+ cleanUpBootstrap();
+ throw e;
}
- ObjectName name = initComponent();
- cleanUpBootstrap();
- installationContext.setInstall(false);
- return name;
- } catch (Exception e) {
- cleanUpBootstrap();
- throw e;
+ } else {
+ return initComponent();
}
} catch (Exception e) {
LOGGER.error(e.getMessage());
@@ -161,8 +163,8 @@
}
}
- public void uninstall(boolean force) throws Exception {
- Component comp = deployer.getComponent(getName());
+ public void stop(boolean force) throws Exception {
+ ComponentImpl comp = deployer.getComponent(getName());
if (comp == null && !force) {
throw ManagementSupport.failure("uninstallComponent", "Component '" + getName() + "' is not installed.");
}
@@ -172,12 +174,22 @@
throw ManagementSupport.failure("uninstallComponent", "Component '" + getName() + "' is not shut down.");
}
if (LifeCycleMBean.STARTED.equals(comp.getCurrentState())) {
- comp.stop();
+ comp.stop(false);
}
if (LifeCycleMBean.STOPPED.equals(comp.getCurrentState())) {
- comp.shutDown();
+ comp.shutDown(false, force);
}
}
+ }
+
+ public void uninstall(boolean force) throws Exception {
+ // Shutdown component
+ stop(force);
+ // Retrieve component
+ Component comp = deployer.getComponent(getName());
+ if (comp == null && !force) {
+ throw ManagementSupport.failure("uninstallComponent", "Component '" + getName() + "' is not installed.");
+ }
// TODO: if there is any SA deployed onto this component, undeploy the SA and put it in a pending state
// Bootstrap stuff
try {
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=747767&r1=747766&r2=747767&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 Wed Feb 25 12:59:23 2009
@@ -23,6 +23,8 @@
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
+import java.util.Set;
+import java.util.HashSet;
import java.util.concurrent.ConcurrentHashMap;
import javax.jbi.JBIException;
@@ -54,15 +56,20 @@
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.SynchronousBundleListener;
+import org.osgi.framework.BundleEvent;
import org.osgi.service.prefs.Preferences;
import org.osgi.service.prefs.PreferencesService;
import org.osgi.util.tracker.ServiceTracker;
import org.springframework.osgi.util.OsgiStringUtils;
+import org.springframework.osgi.context.BundleContextAware;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.DisposableBean;
/**
* Deployer for JBI artifacts
*/
-public class Deployer extends AbstractBundleWatcher {
+public class Deployer implements BundleContextAware, InitializingBean, DisposableBean, SynchronousBundleListener {
public static final String NAME = "NAME";
public static final String TYPE = "TYPE";
@@ -71,6 +78,9 @@
private static final Log LOGGER = LogFactory.getLog(Deployer.class);
+ private BundleContext bundleContext;
+ private final Set<Bundle> bundles = new HashSet<Bundle>();
+
private final Map<String, SharedLibraryImpl> sharedLibraries = new ConcurrentHashMap<String, SharedLibraryImpl>();
private final Map<String, ComponentImpl> components = new ConcurrentHashMap<String, ComponentImpl>();
private final Map<String, ServiceAssemblyImpl> serviceAssemblies = new ConcurrentHashMap<String, ServiceAssemblyImpl>();
@@ -115,6 +125,14 @@
jbiRootDir.mkdirs();
}
+ public BundleContext getBundleContext() {
+ return bundleContext;
+ }
+
+ public void setBundleContext(BundleContext bundleContext) {
+ this.bundleContext = bundleContext;
+ }
+
public PreferencesService getPreferencesService() {
return preferencesService;
}
@@ -195,11 +213,16 @@
return name != null ? serviceAssemblies.get(name) : null;
}
- @Override
public void afterPropertiesSet() throws Exception {
- super.afterPropertiesSet();
+ // Track bundles
+ bundleContext.addBundleListener(this);
+ for (Bundle bundle : bundleContext.getBundles()) {
+ if (bundle.getState() == Bundle.ACTIVE) {
+ bundleChanged(new BundleEvent(BundleEvent.STARTED, bundle));
+ }
+ }
// Track deployed components
- deployedComponentsTracker = new ServiceTracker(getBundleContext(), javax.jbi.component.Component.class.getName(), null) {
+ deployedComponentsTracker = new ServiceTracker(bundleContext, javax.jbi.component.Component.class.getName(), null) {
public Object addingService(ServiceReference serviceReference) {
Object o = super.addingService(serviceReference);
registerDeployedComponent(serviceReference, (javax.jbi.component.Component) o);
@@ -213,7 +236,7 @@
};
deployedComponentsTracker.open();
// Track deployed service assemblies
- deployedAssembliesTracker = new ServiceTracker(getBundleContext(), DeployedAssembly.class.getName(), null) {
+ deployedAssembliesTracker = new ServiceTracker(bundleContext, DeployedAssembly.class.getName(), null) {
public Object addingService(ServiceReference serviceReference) {
Object o = super.addingService(serviceReference);
registerDeployedServiceAssembly(serviceReference, (DeployedAssembly) o);
@@ -228,14 +251,36 @@
deployedAssembliesTracker.open();
}
- @Override
- public void destroy() throws Exception {
+ public synchronized void destroy() throws Exception {
+ for (Bundle bundle : bundles) {
+ bundleChanged(new BundleEvent(BundleEvent.STOPPING, bundle));
+ }
deployedComponentsTracker.close();
deployedAssembliesTracker.close();
- super.destroy();
+ bundleContext.removeBundleListener(this);
+ }
+
+ public synchronized void bundleChanged(BundleEvent event) {
+ switch (event.getType()) {
+ case BundleEvent.STARTED:
+ if (match(event.getBundle())) {
+ bundles.add(event.getBundle());
+ onBundleStarted(event.getBundle());
+ }
+ break;
+ case BundleEvent.STOPPING:
+ if (bundles.contains(event.getBundle())) {
+ onBundleStopping(event.getBundle());
+ }
+ break;
+ case BundleEvent.UNINSTALLED:
+ if (bundles.remove(event.getBundle())) {
+ onBundleUninstalled(event.getBundle());
+ }
+ break;
+ }
}
- @Override
protected boolean match(Bundle bundle) {
LOGGER.debug("Checking bundle: '" + OsgiStringUtils.nullSafeNameAndSymName(bundle) + "'");
URL url = bundle.getResource(DescriptorFactory.DESCRIPTOR_FILE);
@@ -252,8 +297,7 @@
*
* @param bundle
*/
- @Override
- protected void register(Bundle bundle) {
+ protected void onBundleStarted(Bundle bundle) {
// If an installer has been registered, this means that we are using JMX or ant tasks to deploy the JBI artifact.
// In such a case, let the installer do the work.
// Else, the bundle has been deployed through the deploy folder or the command line or any other
@@ -270,17 +314,16 @@
DescriptorFactory.checkDescriptor(descriptor);
if (descriptor.getSharedLibrary() != null) {
LOGGER.info("Deploying bundle '" + OsgiStringUtils.nullSafeNameAndSymName(bundle) + "' as a JBI shared library");
- installer = new SharedLibraryInstaller(this, descriptor, null);
+ installer = new SharedLibraryInstaller(this, descriptor, null, true);
} else if (descriptor.getComponent() != null) {
LOGGER.info("Deploying bundle '" + OsgiStringUtils.nullSafeNameAndSymName(bundle) + "' as a JBI component");
- installer = new ComponentInstaller(this, descriptor, null);
+ installer = new ComponentInstaller(this, descriptor, null, true);
} else if (descriptor.getServiceAssembly() != null) {
LOGGER.info("Deploying bundle '" + OsgiStringUtils.nullSafeNameAndSymName(bundle) + "' as a JBI service assembly");
- installer = new ServiceAssemblyInstaller(this, descriptor, null);
+ installer = new ServiceAssemblyInstaller(this, descriptor, null, true);
} else {
throw new IllegalStateException("Unrecognized JBI descriptor: " + url);
}
- installer.setAutoStart(true);
installer.setBundle(bundle);
installer.init();
installer.install();
@@ -296,8 +339,22 @@
}
}
- @Override
- protected void unregister(Bundle bundle) {
+ protected void onBundleStopping(Bundle bundle) {
+ AbstractInstaller installer = getJmxManaged();
+ if (installer == null) {
+ installer = installers.get(bundle);
+ if (installer != null) {
+ try {
+ installer.stop(true);
+ } catch (Exception e) {
+ LOGGER.warn("Error shutting down JBI artifact", e);
+ }
+ }
+ }
+ unregisterServices(bundle);
+ }
+
+ protected void onBundleUninstalled(Bundle bundle) {
AbstractInstaller installer = getJmxManaged();
if (installer == null) {
installer = installers.get(bundle);
@@ -311,7 +368,6 @@
}
}
pendingBundles.remove(bundle);
- unregisterServices(bundle);
}
public ServiceUnitImpl createServiceUnit(ServiceUnitDesc sud, File suRootDir, ComponentImpl component) {
@@ -510,11 +566,18 @@
// Synchronous call because if using a separate thread
// we run into deadlocks
for (Bundle bundle : pending) {
- register(bundle);
+ onBundleStarted(bundle);
}
}
}
+ //===============================================================================
+ //
+ // OSGi Services registrations
+ //
+ //===============================================================================
+
+
/**
* Register and keep track of an OSGi service
*
Modified: servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/DeploymentService.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/DeploymentService.java?rev=747767&r1=747766&r2=747767&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/DeploymentService.java (original)
+++ servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/DeploymentService.java Wed Feb 25 12:59:23 2009
@@ -85,7 +85,7 @@
checkSus(sa.getServiceUnits());
String name = sa.getIdentification().getName();
LOG.info("Deploy ServiceAssembly " + name);
- ServiceAssemblyInstaller installer = new ServiceAssemblyInstaller(deployer, root, jarfile);
+ ServiceAssemblyInstaller installer = new ServiceAssemblyInstaller(deployer, root, jarfile, false);
installer.installBundle();
installer.init();
installer.install();
Modified: servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/InstallationService.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/InstallationService.java?rev=747767&r1=747766&r2=747767&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/InstallationService.java (original)
+++ servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/InstallationService.java Wed Feb 25 12:59:23 2009
@@ -184,7 +184,7 @@
if (deployer.getSharedLibrary(slName) != null) {
throw new DeploymentException("ShareLib " + slName + " is already installed");
}
- SharedLibraryInstaller installer = new SharedLibraryInstaller(deployer, desc, jarfile);
+ SharedLibraryInstaller installer = new SharedLibraryInstaller(deployer, desc, jarfile, false);
installer.installBundle();
installer.init();
installer.install();
@@ -214,9 +214,8 @@
String componentName = desc.getComponent().getIdentification().getName();
ComponentInstaller installer = getComponentInstaller(componentName);
if (installer == null) {
- installer = new ComponentInstaller(deployer, desc, jarfile);
+ installer = new ComponentInstaller(deployer, desc, jarfile, autoStart);
installer.installBundle();
- installer.setAutoStart(autoStart);
installer.init();
installer.register();
return installer;
Modified: servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/ServiceAssemblyInstaller.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/ServiceAssemblyInstaller.java?rev=747767&r1=747766&r2=747767&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/ServiceAssemblyInstaller.java (original)
+++ servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/ServiceAssemblyInstaller.java Wed Feb 25 12:59:23 2009
@@ -40,8 +40,8 @@
public class ServiceAssemblyInstaller extends AbstractInstaller {
- public ServiceAssemblyInstaller(Deployer deployer, Descriptor descriptor, File jbiArtifact) {
- super(deployer, descriptor, jbiArtifact);
+ public ServiceAssemblyInstaller(Deployer deployer, Descriptor descriptor, File jbiArtifact, boolean autoStart) {
+ super(deployer, descriptor, jbiArtifact, autoStart);
this.installRoot = new File(System.getProperty("servicemix.base"), "data/jbi/" + getName() + "/install");
this.installRoot.mkdirs();
}
@@ -68,11 +68,6 @@
public ObjectName install() throws JBIException {
try {
- try {
- initializePreferences();
- } catch (BackingStoreException e) {
- LOGGER.warn("Error initializing persistent state for service assembly: " + getName(), e);
- }
List<ServiceUnitImpl> sus = deploySUs();
ServiceAssembly sa = deployer.registerServiceAssembly(bundle, descriptor.getServiceAssembly(), sus);
return deployer.getNamingStrategy().getObjectName(sa);
@@ -82,7 +77,7 @@
}
}
- public void uninstall(boolean force) throws Exception {
+ public void stop(boolean force) throws Exception {
ServiceAssembly assembly = deployer.getServiceAssembly(getName());
if (assembly == null && !force) {
throw ManagementSupport.failure("undeployServiceAssembly", "ServiceAssembly '" + getName() + "' is not deployed.");
@@ -99,6 +94,16 @@
assembly.shutDown();
}
}
+ }
+
+ public void uninstall(boolean force) throws Exception {
+ // Shutdown SA
+ stop(force);
+ // Retrieve SA
+ ServiceAssembly assembly = deployer.getServiceAssembly(getName());
+ if (assembly == null && !force) {
+ throw ManagementSupport.failure("undeployServiceAssembly", "ServiceAssembly '" + getName() + "' is not deployed.");
+ }
// Undeploy SUs
for (ServiceUnit su : assembly.getServiceUnits()) {
((ServiceUnitImpl) su).undeploy();
@@ -140,7 +145,9 @@
ServiceUnitImpl su = deployer.createServiceUnit(sud, suRootDir, component);
try {
LOGGER.debug("Deploying SU " + su.getName());
- su.deploy();
+ if (isModified) {
+ su.deploy();
+ }
// Add it to the list
sus.add(su);
} catch (Exception e) {
Modified: servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/SharedLibraryInstaller.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/SharedLibraryInstaller.java?rev=747767&r1=747766&r2=747767&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/SharedLibraryInstaller.java (original)
+++ servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/SharedLibraryInstaller.java Wed Feb 25 12:59:23 2009
@@ -38,8 +38,8 @@
public class SharedLibraryInstaller extends AbstractInstaller {
- public SharedLibraryInstaller(Deployer deployer, Descriptor descriptor, File jbiArtifact) {
- super(deployer, descriptor, jbiArtifact);
+ public SharedLibraryInstaller(Deployer deployer, Descriptor descriptor, File jbiArtifact, boolean autoStart) {
+ super(deployer, descriptor, jbiArtifact, autoStart);
installRoot = new File(System.getProperty("servicemix.base"), "data/jbi/" + getName() + "/install");
installRoot.mkdirs();
}
@@ -68,7 +68,14 @@
}
}
+ public void stop(boolean force) throws Exception {
+ // Nothing to do for shared libraries
+ }
+
public void uninstall(boolean force) throws Exception {
+ // Shut down
+ stop(force);
+ // Retrieve shared library
SharedLibrary library = deployer.getSharedLibrary(getName());
if (library == null && !force) {
throw ManagementSupport.failure("uninstallSharedLibrary", "SharedLibrary '" + getName() + "' is not installed.");