| Commit in servicemix/base/src/main/java/org/servicemix/jbi on MAIN | |||
| container/EnvironmentContext.java | +37 | -23 | 1.14 -> 1.15 |
| /JBIContainer.java | +2 | -2 | 1.50 -> 1.51 |
| framework/InstallationService.java | +10 | -2 | 1.21 -> 1.22 |
| /ComponentContextImpl.java | +9 | -1 | 1.4 -> 1.5 |
| +58 | -28 | ||
FIX FOR SM-53. Initlalization of ComponentEnvironment should happen earlier for archive components.
servicemix/base/src/main/java/org/servicemix/jbi/container
diff -u -r1.14 -r1.15 --- EnvironmentContext.java 23 Aug 2005 09:20:55 -0000 1.14 +++ EnvironmentContext.java 15 Sep 2005 12:19:21 -0000 1.15 @@ -39,7 +39,7 @@
/** * Holder for environment infomation *
- * @version $Revision: 1.14 $
+ * @version $Revision: 1.15 $
*/
public class EnvironmentContext extends BaseLifeCycle {
private static final Log log = LogFactory.getLog(EnvironmentContext.class);
@@ -251,32 +251,46 @@
*/
public ComponentEnvironment registerComponent(LocalComponentConnector connector) throws JBIException {
ComponentEnvironment result = new ComponentEnvironment();
- result.setLocalConnector(connector);
- String name = connector.getComponentNameSpace().getName();
- //add workspace root and stats root ..
- try {
- if (!connector.isPojo()) {
- File componentRoot = getComponentRootDirectory(name);
- FileUtil.buildDirectory(componentRoot);
- File privateWorkspace = createWorkspaceDirectory(name);
- result.setWorkspaceRoot(privateWorkspace);
- result.setComponentRoot(componentRoot);
- }
- envMap.put(connector, result);
- }
- catch (IOException e) {
- throw new JBIException(e);
- }
- return result;
+ return registerComponent(result,connector);
}
-
+
/**
- * Create root directory for a Component
+ * register the ComponentConnector
*
- * @param componentName - * @return directory for deployment/workspace etc - * @throws IOException
+ * @param connector + * @return the CompponentEnvironment + * @throws JBIException
*/
+ public ComponentEnvironment registerComponent(ComponentEnvironment result,
+ LocalComponentConnector connector) throws JBIException {
+ if (result == null) {
+ result = new ComponentEnvironment();
+ // add workspace root and stats root ..
+ try {
+ if (!connector.isPojo()) {
+ String name = connector.getComponentNameSpace().getName();
+ File componentRoot = getComponentRootDirectory(name);
+ FileUtil.buildDirectory(componentRoot);
+ File privateWorkspace = createWorkspaceDirectory(name);
+ result.setWorkspaceRoot(privateWorkspace);
+ result.setComponentRoot(componentRoot);
+ }
+ } catch (IOException e) {
+ throw new JBIException(e);
+ }
+ }
+ result.setLocalConnector(connector);
+ envMap.put(connector, result);
+ return result;
+ }
+
+ /**
+ * Create root directory for a Component
+ *
+ * @param componentName
+ * @return directory for deployment/workspace etc
+ * @throws IOException
+ */
public File getComponentRootDirectory(String componentName) throws IOException {
File result = FileUtil.getDirectoryPath(getComponentsDir(), componentName);
return result;
servicemix/base/src/main/java/org/servicemix/jbi/container
diff -u -r1.50 -r1.51 --- JBIContainer.java 23 Aug 2005 09:20:58 -0000 1.50 +++ JBIContainer.java 15 Sep 2005 12:19:21 -0000 1.51 @@ -67,7 +67,7 @@
/** * The main container *
- * @version $Revision: 1.50 $
+ * @version $Revision: 1.51 $
*/
public class JBIContainer extends BaseLifeCycle {
/**
@@ -898,7 +898,7 @@
if (lcc != null) {
dc.setConnector(lcc);
lcc.setPojo(pojo);
- ComponentEnvironment env = environmentContext.registerComponent(lcc);
+ ComponentEnvironment env = environmentContext.registerComponent(context.getEnvironment(),lcc);
env.setInstallRoot(installationDir);
context.activate(component, dc, env, activationSpec, installationDir);
lcc.setContext(context);
servicemix/base/src/main/java/org/servicemix/jbi/framework
diff -u -r1.21 -r1.22 --- InstallationService.java 23 Aug 2005 09:21:00 -0000 1.21 +++ InstallationService.java 15 Sep 2005 12:19:21 -0000 1.22 @@ -32,6 +32,7 @@
import javax.resource.spi.work.WorkException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory;
+import org.servicemix.jbi.container.ComponentEnvironment;
import org.servicemix.jbi.container.EnvironmentContext; import org.servicemix.jbi.container.JBIContainer; import org.servicemix.jbi.deployment.ClassPath;
@@ -50,7 +51,7 @@
/** * Installation Service - installs/uninstalls archives *
- * @version $Revision: 1.21 $
+ * @version $Revision: 1.22 $
*/
public class InstallationService extends BaseLifeCycle implements FrameworkInstallationService {
private static final Log log = LogFactory.getLog(InstallationService.class);
@@ -561,9 +562,16 @@
}
}
- protected ComponentContextImpl buildComponentContext(String name) {
+ protected ComponentContextImpl buildComponentContext(String name) throws IOException {
ComponentNameSpace cns = new ComponentNameSpace(container.getName(), name, name);
ComponentContextImpl context = new ComponentContextImpl(container, cns);
+ ComponentEnvironment env = new ComponentEnvironment(); + File componentRoot = environmentContext.getComponentRootDirectory(name); + FileUtil.buildDirectory(componentRoot); + File privateWorkspace = environmentContext.createWorkspaceDirectory(name); + env.setWorkspaceRoot(privateWorkspace); + env.setComponentRoot(componentRoot); + context.setEnvironment(env);
return context;
}
}
servicemix/base/src/main/java/org/servicemix/jbi/framework
diff -u -r1.4 -r1.5 --- ComponentContextImpl.java 1 Aug 2005 01:38:35 -0000 1.4 +++ ComponentContextImpl.java 15 Sep 2005 12:19:21 -0000 1.5 @@ -45,7 +45,7 @@
/** * This context provides access to data needed by all JBI components running in the JBI environment. *
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
*/
public class ComponentContextImpl implements ComponentContext, MBeanNames {
private static final Log log = LogFactory.getLog(ComponentContextImpl.class);
@@ -237,6 +237,14 @@
*/
public ComponentEnvironment getEnvironment() {
return environment;
+ }
+
+ /**
+ * Set the ComponentEnvironment
+ * @param ce
+ */
+ public void setEnvironment(ComponentEnvironment ce){
+ this.environment = ce;
}
/**
