Diff
Modified: trunk/core/project.xml (1021 => 1022)
--- trunk/core/project.xml 2005-12-06 15:24:10 UTC (rev 1021)
+++ trunk/core/project.xml 2005-12-06 16:05:01 UTC (rev 1022)
@@ -464,9 +464,6 @@
<exclude>**/ComponentAssemblyInstallationTest.*</exclude>
<exclude>**/DeploymentTest.*</exclude>
- <!-- Fail until management layer rework -->
- <exclude>**/InstallationTest.*</exclude>
-
</excludes>
</unitTest>
<resources>
Modified: trunk/core/src/main/java/org/servicemix/jbi/container/JBIContainer.java (1021 => 1022)
--- trunk/core/src/main/java/org/servicemix/jbi/container/JBIContainer.java 2005-12-06 15:24:10 UTC (rev 1021)
+++ trunk/core/src/main/java/org/servicemix/jbi/container/JBIContainer.java 2005-12-06 16:05:01 UTC (rev 1022)
@@ -907,17 +907,18 @@
context.activate(component, dc, env, activationSpec);
lcc.setContext(context);
lcc.setActivationSpec(activationSpec);
- lcc.getComponentMBean().init();
if (started.get() && lcc.isPojo()) {
//non-pojo's are either started by the auto deployer
//or manually
+ lcc.getComponentMBean().init();
lcc.getComponentMBean().start();
- }
- ComponentMBeanImpl mbean = new ComponentMBeanImpl(lcc);
- result = managementContext.createObjectName(mbean);
+ } else {
+ lcc.getComponentMBean().setCurrentState(LifeCycleMBean.SHUTDOWN);
+ }
+ result = managementContext.createObjectName(lcc.getComponentMBean());
try {
- managementContext.registerMBean(result, mbean, ComponentMBean.class);
+ managementContext.registerMBean(result, lcc.getComponentMBean(), ComponentMBean.class);
}
catch (JMException e) {
throw new JBIException(e);
Modified: trunk/core/src/main/java/org/servicemix/jbi/container/SpringJBIContainer.java (1021 => 1022)
--- trunk/core/src/main/java/org/servicemix/jbi/container/SpringJBIContainer.java 2005-12-06 15:24:10 UTC (rev 1021)
+++ trunk/core/src/main/java/org/servicemix/jbi/container/SpringJBIContainer.java 2005-12-06 16:05:01 UTC (rev 1022)
@@ -37,6 +37,10 @@
public void afterPropertiesSet() throws Exception {
init();
+
+ // Start the container first, so that activated components
+ // get activated in the order they are listed
+ start();
// lets iterate through all the component names and register them
if (componentNames != null) {
@@ -59,8 +63,6 @@
installArchive(archive);
}
}
-
- start();
}
public void stop() throws JBIException {
Modified: trunk/core/src/main/java/org/servicemix/jbi/framework/ComponentMBeanImpl.java (1021 => 1022)
--- trunk/core/src/main/java/org/servicemix/jbi/framework/ComponentMBeanImpl.java 2005-12-06 15:24:10 UTC (rev 1021)
+++ trunk/core/src/main/java/org/servicemix/jbi/framework/ComponentMBeanImpl.java 2005-12-06 16:05:01 UTC (rev 1022)
@@ -16,10 +16,9 @@
* limitations under the License.
*
**/
-
package org.servicemix.jbi.framework;
+
import javax.jbi.JBIException;
-import javax.jbi.management.LifeCycleMBean;
import javax.management.JMException;
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanOperationInfo;
@@ -91,8 +90,8 @@
* @exception javax.jbi.JBIException if the item fails to start.
*/
public void start() throws javax.jbi.JBIException {
- connector.writeRunningState();
doStart();
+ connector.writeRunningState();
}
/**
@@ -126,18 +125,8 @@
connector.init();
}
if(!isRunning()){
- boolean doTheStart=connector.isPojo();
- if(!doTheStart){
- // if the persisted state is running - we can run this
- String persistedRunningState=connector.getRunningStateFromStore();
- if(persistedRunningState!=null&&persistedRunningState.equals(LifeCycleMBean.RUNNING)){
- doTheStart=true;
- }
- }
- if(doTheStart){
- connector.getComponent().getLifeCycle().start();
- super.start();
- }
+ connector.getLifeCycle().start();
+ super.start();
}
}
@@ -149,7 +138,7 @@
*/
public void doStop() throws javax.jbi.JBIException {
if (isUnknown() || isRunning()){
- connector.getComponent().getLifeCycle().stop();
+ connector.getLifeCycle().stop();
super.stop();
}
@@ -161,7 +150,11 @@
* @exception javax.jbi.JBIException if the item fails to shut down.
*/
public void doShutDown() throws javax.jbi.JBIException {
- connector.getComponent().getLifeCycle().shutDown();
+ // Transition from UNKNOWN to SHUTDOWN is done at installation time
+ // In this case or if the component is already shut down, do nothing
+ if (!getCurrentState().equals(UNKNOWN) && !getCurrentState().equals(SHUTDOWN)) {
+ connector.getLifeCycle().shutDown();
+ }
super.shutDown();
}
@@ -171,7 +164,6 @@
* @throws JBIException
*/
public void setInitialRunningState() throws JBIException{
-
connector.setRunningStateFromStore();
}
@@ -352,4 +344,5 @@
helper.addOperation(getObjectToManage(), "reset", "reset statistic counters");
return OperationInfoHelper.join(super.getOperationInfos(),helper.getOperationInfos());
}
+
}
Modified: trunk/core/src/main/java/org/servicemix/jbi/framework/ComponentRegistry.java (1021 => 1022)
--- trunk/core/src/main/java/org/servicemix/jbi/framework/ComponentRegistry.java 2005-12-06 15:24:10 UTC (rev 1021)
+++ trunk/core/src/main/java/org/servicemix/jbi/framework/ComponentRegistry.java 2005-12-06 16:05:01 UTC (rev 1022)
@@ -113,10 +113,10 @@
* @throws JBIException
*/
public void shutDown() throws JBIException {
- stop();
for (Iterator i = getLocalComponentConnectors().iterator();i.hasNext();) {
LocalComponentConnector lcc = (LocalComponentConnector) i.next();
lcc.getComponentMBean().persistRunningState();
+ lcc.getComponentMBean().doStop();
lcc.getComponentMBean().doShutDown();
lcc.getDeliveryChannel().close();
}
Modified: trunk/core/src/main/java/org/servicemix/jbi/framework/InstallationService.java (1021 => 1022)
--- trunk/core/src/main/java/org/servicemix/jbi/framework/InstallationService.java 2005-12-06 15:24:10 UTC (rev 1021)
+++ trunk/core/src/main/java/org/servicemix/jbi/framework/InstallationService.java 2005-12-06 16:05:01 UTC (rev 1022)
@@ -91,13 +91,13 @@
installers.put(componentName,installer);
}
}else{
- log.info("An installer already exists for "+componentName);
+ throw new RuntimeException("An installer already exists for "+componentName);
}
}else{
- log.error("Could not find Component from: "+installJarURL);
+ throw new RuntimeException("Could not find Component from: "+installJarURL);
}
}else{
- log.warn("location: "+installJarURL+" isn't valid");
+ throw new RuntimeException("location: "+installJarURL+" isn't valid");
}
return result;
}catch(Throwable t){
@@ -511,45 +511,41 @@
}
}
- protected void buildComponent(File componentDirectory) throws DeploymentException{
- String componentName=componentDirectory.getName();
- try{
- File installationDirectory=environmentContext.getInstallationDirectory(componentName);
- if(installationDirectory!=null&&installationDirectory.exists()){
- Descriptor root=AutoDeploymentService.buildDescriptor(installationDirectory);
- if(root!=null){
- Component desc=root.getComponent();
- if(desc!=null){
- componentName=desc.getIdentification().getName();
- if(!installers.containsKey(componentName)){
- File componentRoot=environmentContext.getComponentRootDirectory(componentName);
- InstallerMBean installer=initializeInstaller(installationDirectory,componentRoot,desc);
- if(installer!=null){
- if(installer!=null){
- try{
- installer.install();
- }catch(JBIException e){
- throw new DeploymentException(e);
- }
- // now get and set running state
- ComponentNameSpace cns=new ComponentNameSpace(container.getName(),componentName,
- componentName);
- LocalComponentConnector lcc=container.getRegistry().getLocalComponentConnector(cns);
- if(lcc==null){
- log.error("Failed to get LocalComponentConnector for Component: "+componentName);
- }
- }
- installers.put(componentName,installer);
- log.info("Created installer for existing component: "+componentName);
- }
- }else{
- log.warn("Component "+componentName+" is already installed");
+ protected void buildComponent(File componentDirectory)
+ throws DeploymentException {
+ try {
+ File installationDirectory = environmentContext
+ .getInstallationDirectory(componentDirectory.getName());
+ if (installationDirectory != null && installationDirectory.exists()) {
+ Descriptor root = AutoDeploymentService
+ .buildDescriptor(installationDirectory);
+ if (root != null) {
+ Component descriptor = root.getComponent();
+ if (descriptor != null) {
+ String componentName = descriptor.getIdentification().getName();
+ File componentRoot = environmentContext.getComponentRootDirectory(componentName);
+ ComponentContextImpl context = buildComponentContext(componentRoot, componentName);
+ ClassLoader componentClassLoader = classLoaderService.buildClassLoader(installationDirectory,
+ descriptor.getComponentClassPath().getPathElements(),
+ descriptor.isComponentClassLoaderDelegationParentFirst(),
+ descriptor.getSharedLibraries());
+ Class componentClass = componentClassLoader.loadClass(descriptor.getComponentClassName());
+ if (componentClass != null) {
+ Object component = componentClass.newInstance();
+ container.activateComponent(installationDirectory,
+ (javax.jbi.component.Component) component, descriptor.getIdentification().getDescription(), context,
+ descriptor.isBindingComponent(), descriptor.isServiceEngine());
+ } else {
+ String err = "component class " + descriptor.getComponentClassName() + " not found";
+ log.error(err);
+ throw new DeploymentException(err);
}
}
}
}
- }catch(Throwable e){
- log.error("Failed to deploy component: "+componentName,e);
+ } catch (Throwable e) {
+ log.error("Failed to deploy component: "
+ + componentDirectory.getName(), e);
throw new DeploymentException(e);
}
}
Modified: trunk/core/src/main/java/org/servicemix/jbi/framework/LocalComponentConnector.java (1021 => 1022)
--- trunk/core/src/main/java/org/servicemix/jbi/framework/LocalComponentConnector.java 2005-12-06 15:24:10 UTC (rev 1021)
+++ trunk/core/src/main/java/org/servicemix/jbi/framework/LocalComponentConnector.java 2005-12-06 16:05:01 UTC (rev 1022)
@@ -25,6 +25,7 @@
import java.util.Set;
import javax.jbi.JBIException;
import javax.jbi.component.Component;
+import javax.jbi.component.ComponentLifeCycle;
import javax.jbi.management.LifeCycleMBean;
import javax.jbi.servicedesc.ServiceEndpoint;
import javax.management.ObjectName;
@@ -42,6 +43,7 @@
public class LocalComponentConnector extends ComponentConnector{
private static final Log log=LogFactory.getLog(LocalComponentConnector.class);
private Component component;
+ private ComponentLifeCycle lifeCycle;
private ComponentContextImpl context;
private ActivationSpec activationSpec;
private DeliveryChannelImpl deliveryChannel;
@@ -229,7 +231,7 @@
*/
public void init() throws JBIException{
if (context != null && component != null){
- component.getLifeCycle().init(context);
+ getLifeCycle().init(context);
}
}
@@ -248,6 +250,13 @@
this.pojo=pojo;
}
+ public ComponentLifeCycle getLifeCycle() {
+ if (lifeCycle == null) {
+ lifeCycle = component.getLifeCycle();
+ }
+ return lifeCycle;
+ }
+
/**
* write the current running state of the Component to disk
*/
Modified: trunk/core/src/test/java/org/servicemix/jbi/audit/jdbc/JdbcAuditorTest.java (1021 => 1022)
--- trunk/core/src/test/java/org/servicemix/jbi/audit/jdbc/JdbcAuditorTest.java 2005-12-06 15:24:10 UTC (rev 1021)
+++ trunk/core/src/test/java/org/servicemix/jbi/audit/jdbc/JdbcAuditorTest.java 2005-12-06 16:05:01 UTC (rev 1022)
@@ -57,6 +57,7 @@
JBIContainer container = new JBIContainer();
container.setFlowName("st");
container.init();
+ container.start();
SenderComponent sender = new SenderComponent();
ReceiverComponent receiver = new ReceiverComponent();
container.activateComponent(sender, "sender");
Modified: trunk/core/src/test/java/org/servicemix/jbi/installation/InstallationTest.java (1021 => 1022)
--- trunk/core/src/test/java/org/servicemix/jbi/installation/InstallationTest.java 2005-12-06 15:24:10 UTC (rev 1021)
+++ trunk/core/src/test/java/org/servicemix/jbi/installation/InstallationTest.java 2005-12-06 16:05:01 UTC (rev 1022)
@@ -20,6 +20,8 @@
package org.servicemix.jbi.installation;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.easymock.MockControl;
import org.servicemix.jbi.container.JBIContainer;
import org.servicemix.jbi.util.FileUtil;
@@ -49,6 +51,9 @@
* @version $Revision$
*/
public class InstallationTest extends TestCase {
+
+ private static Log logger = LogFactory.getLog(InstallationTest.class);
+
protected JBIContainer container;
/*
@@ -63,7 +68,11 @@
*/
protected void tearDown() throws Exception {
super.tearDown();
- shutdownContainer();
+ try {
+ shutdownContainer();
+ } catch (Exception e) {
+ logger.info("Error shutting down container", e);
+ }
}
protected void startContainer(boolean clean) throws Exception {