Author: nfilotto
Date: 2010-05-10 06:33:07 -0400 (Mon, 10 May 2010)
New Revision: 2357
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/ExoContainer.java
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/RootContainer.java
kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/jmx/TestContainerScoping.java
Log:
EXOJCR-714: The methods initContainer, startContainer, stopContainer and destroyContainer
are now deprecated since they must not be explicitly called because they are part of the
container lifecycle.
The method start(boolean init) has been added to allow to start and initialize if needed
the container
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/ExoContainer.java
===================================================================
---
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/ExoContainer.java 2010-05-10
10:32:56 UTC (rev 2356)
+++
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/ExoContainer.java 2010-05-10
10:33:07 UTC (rev 2357)
@@ -46,6 +46,11 @@
{
/**
+ * Serial Version UID
+ */
+ private static final long serialVersionUID = -8068506531004854036L;
+
+ /**
* Returns an unmodifable set of profiles defined by the value returned by invoking
* {@link PropertyManager#getProperty(String)} with the {@link
org.exoplatform.commons.utils.PropertyManager#RUNTIME_PROFILES}
* property.
@@ -126,7 +131,15 @@
return name;
}
+ /**
+ * Explicit calls are not allowed anymore
+ */
+ @Deprecated
public void initContainer() throws Exception
+ {
+ }
+
+ private void initContainerInternal()
{
ConfigurationManager manager =
(ConfigurationManager)getComponentInstanceOfType(ConfigurationManager.class);
ContainerUtil.addContainerLifecyclePlugin(this, manager);
@@ -148,25 +161,47 @@
@Override
public void dispose()
{
- destroyContainer();
+ destroyContainerInternal();
super.dispose();
}
+ /**
+ * Starts the container
+ * @param init indicates if the container must be initialized first
+ */
+ public void start(boolean init)
+ {
+ if (init)
+ {
+ // Initialize the container first
+ initContainerInternal();
+ }
+ start();
+ }
+
@Override
public void start()
{
super.start();
- startContainer();
+ startContainerInternal();
}
@Override
public void stop()
{
- stopContainer();
+ stopContainerInternal();
super.stop();
}
- public void startContainer()
+ /**
+ * Explicit calls are not allowed anymore
+ */
+ @Deprecated
+ public void startContainer() throws Exception
+ {
+ }
+
+ private void startContainerInternal()
{
for (ContainerLifecyclePlugin plugin : containerLifecyclePlugin_)
{
@@ -181,7 +216,15 @@
}
}
- public void stopContainer()
+ /**
+ * Explicit calls are not allowed anymore
+ */
+ @Deprecated
+ public void stopContainer() throws Exception
+ {
+ }
+
+ private void stopContainerInternal()
{
for (ContainerLifecyclePlugin plugin : containerLifecyclePlugin_)
{
@@ -196,7 +239,15 @@
}
}
- public void destroyContainer()
+ /**
+ * Explicit calls are not allowed anymore
+ */
+ @Deprecated
+ public void destroyContainer() throws Exception
+ {
+ }
+
+ private void destroyContainerInternal()
{
for (ContainerLifecyclePlugin plugin : containerLifecyclePlugin_)
{
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/RootContainer.java
===================================================================
---
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/RootContainer.java 2010-05-10
10:32:56 UTC (rev 2356)
+++
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/RootContainer.java 2010-05-10
10:33:07 UTC (rev 2357)
@@ -32,7 +32,6 @@
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.exoplatform.test.mocks.servlet.MockServletContext;
-import org.picocontainer.ComponentAdapter;
import java.io.File;
import java.util.Collection;
@@ -160,9 +159,8 @@
cService.addConfiguration(ContainerUtil.getConfigurationURL("conf/portal/test-configuration.xml"));
cService.processRemoveConfiguration();
pcontainer.registerComponentInstance(ConfigurationManager.class,
cService);
- pcontainer.initContainer();
registerComponentInstance(name, pcontainer);
- pcontainer.start();
+ pcontainer.start(true);
}
catch (Exception ex)
{
@@ -326,10 +324,9 @@
}
cService.processRemoveConfiguration();
- ComponentAdapter adapter =
pcontainer.registerComponentInstance(ConfigurationManager.class, cService);
- pcontainer.initContainer();
+ pcontainer.registerComponentInstance(ConfigurationManager.class, cService);
registerComponentInstance(portalContainerName, pcontainer);
- pcontainer.start();
+ pcontainer.start(true);
// Register the portal as an mbean
getManagementContext().register(pcontainer);
@@ -397,13 +394,11 @@
}
service.processRemoveConfiguration();
rootContainer.registerComponentInstance(ConfigurationManager.class, service);
- rootContainer.initContainer();
- rootContainer.start();
+ rootContainer.start(true);
return rootContainer;
}
catch (Exception e)
{
- e.printStackTrace();
log.error("Could not build root container", e);
return null;
}
Modified:
kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/jmx/TestContainerScoping.java
===================================================================
---
kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/jmx/TestContainerScoping.java 2010-05-10
10:32:56 UTC (rev 2356)
+++
kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/jmx/TestContainerScoping.java 2010-05-10
10:33:07 UTC (rev 2357)
@@ -35,8 +35,7 @@
//
ManagedContainer child = new ManagedContainer(root);
- child.initContainer();
- child.start();
+ child.start(true);
//
MBeanServer server = root.getMBeanServer();
Show replies by date