Author: gnodet
Date: Mon Feb 25 13:41:26 2008
New Revision: 631009
URL: http://svn.apache.org/viewvc?rev=631009&view=rev
Log:
SMX4NMR-19: Service assemblies state is not persisted
Modified:
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/ServiceAssemblyImpl.java
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=631009&r1=631008&r2=631009&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
Mon Feb 25 13:41:26 2008
@@ -140,7 +140,7 @@
}
} catch (PendingException e) {
pendingBundles.add(e.getBundle());
- LOGGER.warn("JBI artifact requirements not met. Installation
pending.");
+ LOGGER.warn("Requirements not met for JBI artifact in bundle " +
OsgiStringUtils.nullSafeNameAndSymName(bundle) + ". Installation pending.");
} catch (Exception e) {
LOGGER.error("Error handling bundle start event", e);
} finally {
@@ -177,7 +177,7 @@
}
protected void installComponent(ComponentDesc componentDesc, Bundle
bundle) throws Exception {
- LOGGER.debug("Bundle '" +
OsgiStringUtils.nullSafeNameAndSymName(bundle) + "' is a JBI component");
+ LOGGER.info("Deploying bundle '" +
OsgiStringUtils.nullSafeNameAndSymName(bundle) + "' as a JBI component");
// Check requirements
if (componentDesc.getSharedLibraries() != null) {
for (SharedLibraryList sl : componentDesc.getSharedLibraries()) {
@@ -231,7 +231,7 @@
}
protected void deployServiceAssembly(ServiceAssemblyDesc
serviceAssembyDesc, Bundle bundle) throws Exception {
- LOGGER.debug("Bundle '" +
OsgiStringUtils.nullSafeNameAndSymName(bundle) + "' is a JBI service assembly");
+ LOGGER.info("Deploying bundle '" +
OsgiStringUtils.nullSafeNameAndSymName(bundle) + "' as a JBI service assembly");
// Check requirements
for (ServiceUnitDesc sud : serviceAssembyDesc.getServiceUnits()) {
String componentName = sud.getTarget().getComponentName();
@@ -300,7 +300,7 @@
}
protected void installSharedLibrary(SharedLibraryDesc sharedLibraryDesc,
Bundle bundle) {
- LOGGER.debug("Bundle '" +
OsgiStringUtils.nullSafeNameAndSymName(bundle) + "' is a JBI shared library");
+ LOGGER.info("Deploying bundle '" +
OsgiStringUtils.nullSafeNameAndSymName(bundle) + "' as a JBI shared library");
SharedLibraryImpl sl = new SharedLibraryImpl(sharedLibraryDesc,
bundle);
sharedLibraries.put(sl.getName(), sl);
Dictionary<String, String> props = new Hashtable<String, String>();
@@ -321,10 +321,10 @@
ServiceAssemblyImpl sa =
serviceAssemblies.remove(serviceAssembyDesc.getIdentification().getName());
if (sa != null) {
if (sa.getState() == ServiceAssemblyImpl.State.Started) {
- sa.stop();
+ sa.stop(false);
}
if (sa.getState() == ServiceAssemblyImpl.State.Stopped) {
- sa.shutDown();
+ sa.shutDown(false);
}
for (ServiceUnit su : sa.getServiceUnits()) {
((ServiceUnitImpl) su).undeploy();
Modified:
servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/ServiceAssemblyImpl.java
URL:
http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/ServiceAssemblyImpl.java?rev=631009&r1=631008&r2=631009&view=diff
==============================================================================
---
servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/ServiceAssemblyImpl.java
(original)
+++
servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/ServiceAssemblyImpl.java
Mon Feb 25 13:41:26 2008
@@ -39,6 +39,8 @@
private static final String STATE = "state";
+
+
protected enum State {
Unknown,
Initialized,
@@ -110,18 +112,36 @@
}
public void start() throws JBIException {
+ start(true);
+ }
+
+ public void start(boolean persist) throws JBIException {
transition(State.Started);
- saveState();
+ if (persist) {
+ saveState();
+ }
+ }
+
+ public void stop() throws JBIException {
+ stop(true);
}
- public void stop() throws JBIException {
+ public void stop(boolean persist) throws JBIException {
transition(State.Stopped);
- saveState();
- }
+ if (persist) {
+ saveState();
+ }
+ }
public void shutDown() throws JBIException {
+ shutDown(true);
+ }
+
+ public void shutDown(boolean persist) throws JBIException {
transition(State.Shutdown);
- saveState();
+ if (persist) {
+ saveState();
+ }
}
private void saveState() {
@@ -136,6 +156,7 @@
protected void transition(State to) throws JBIException {
// TODO: reject invalid transitions, for example Started -> Shutdown
// we need to either automatically follow the intermediate steps, or
just throw an exception
+ LOGGER.info("Changing SA state to " + to);
State from = state;
List<ServiceUnitImpl> success = new ArrayList<ServiceUnitImpl>();
for (ServiceUnitImpl su : serviceUnits) {