Author: julien_viet
Date: 2009-12-17 10:23:11 -0500 (Thu, 17 Dec 2009)
New Revision: 1051
Modified:
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ApplicationRegistryServiceImpl.java
portal/trunk/component/application-registry/src/test/java/conf/application-registry-configuration.xml
portal/trunk/component/application-registry/src/test/java/org/exoplatform/application/registry/TestApplicationRegistryService.java
portal/trunk/component/common/pom.xml
portal/trunk/component/common/src/main/java/org/exoplatform/commons/chromattic/ChromatticLifeCycle.java
portal/trunk/component/common/src/main/java/org/exoplatform/commons/chromattic/ChromatticManager.java
portal/trunk/component/common/src/main/java/org/exoplatform/commons/chromattic/Synchronization.java
portal/trunk/component/common/src/test/resources/conf/test-configuration.xml
portal/trunk/component/portal/src/test/java/conf/portal/portal-configuration.xml
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/AbstractPortalTest.java
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/common/autologin-configuration.xml
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/application-registry-configuration.xml
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml
Log:
- on Synchronization rename "save" attribute to "saveOnClose" name
- rename "name" on chromattic life cycle to "domain-name"
- added logging in chromattic life cycle
- trim entity class names before they are loaded from class loader in chromattic life
cycle
Modified:
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ApplicationRegistryServiceImpl.java
===================================================================
---
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ApplicationRegistryServiceImpl.java 2009-12-17
15:00:38 UTC (rev 1050)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ApplicationRegistryServiceImpl.java 2009-12-17
15:23:11 UTC (rev 1051)
@@ -620,7 +620,7 @@
finally
{
// lifeCycle.closeContext(context, true);
- manager.getSynchronization().setSave(save);
+ manager.getSynchronization().setSaveOnClose(save);
RequestLifeCycle.end();
}
}
Modified:
portal/trunk/component/application-registry/src/test/java/conf/application-registry-configuration.xml
===================================================================
---
portal/trunk/component/application-registry/src/test/java/conf/application-registry-configuration.xml 2009-12-17
15:00:38 UTC (rev 1050)
+++
portal/trunk/component/application-registry/src/test/java/conf/application-registry-configuration.xml 2009-12-17
15:23:11 UTC (rev 1051)
@@ -229,7 +229,7 @@
<type>org.exoplatform.application.registry.impl.ApplicationRegistryChromatticLifeCycle</type>
<init-params>
<value-param>
- <name>name</name>
+ <name>domain-name</name>
<value>app</value>
</value-param>
<value-param>
Modified:
portal/trunk/component/application-registry/src/test/java/org/exoplatform/application/registry/TestApplicationRegistryService.java
===================================================================
---
portal/trunk/component/application-registry/src/test/java/org/exoplatform/application/registry/TestApplicationRegistryService.java 2009-12-17
15:00:38 UTC (rev 1050)
+++
portal/trunk/component/application-registry/src/test/java/org/exoplatform/application/registry/TestApplicationRegistryService.java 2009-12-17
15:23:11 UTC (rev 1051)
@@ -85,7 +85,7 @@
@Override
protected void tearDown() throws Exception
{
- chromatticManager.getSynchronization().setSave(false);
+ chromatticManager.getSynchronization().setSaveOnClose(false);
end();
}
Modified: portal/trunk/component/common/pom.xml
===================================================================
--- portal/trunk/component/common/pom.xml 2009-12-17 15:00:38 UTC (rev 1050)
+++ portal/trunk/component/common/pom.xml 2009-12-17 15:23:11 UTC (rev 1051)
@@ -32,6 +32,11 @@
<dependencies>
<dependency>
+ <groupId>org.gatein.common</groupId>
+ <artifactId>common-logging</artifactId>
+ <version>${org.gatein.common.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>exo.kernel.commons</artifactId>
<version>${org.exoplatform.kernel.version}</version>
Modified:
portal/trunk/component/common/src/main/java/org/exoplatform/commons/chromattic/ChromatticLifeCycle.java
===================================================================
---
portal/trunk/component/common/src/main/java/org/exoplatform/commons/chromattic/ChromatticLifeCycle.java 2009-12-17
15:00:38 UTC (rev 1050)
+++
portal/trunk/component/common/src/main/java/org/exoplatform/commons/chromattic/ChromatticLifeCycle.java 2009-12-17
15:23:11 UTC (rev 1051)
@@ -22,6 +22,8 @@
import org.chromattic.api.ChromatticBuilder;
import org.exoplatform.container.component.BaseComponentPlugin;
import org.exoplatform.container.xml.InitParams;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
import java.util.List;
@@ -33,14 +35,14 @@
* or {@link #onCloseSession(SessionContext)} to perform additional treatment on the
session context at a precise
* phase of its life cycle.</p>
*
- * <p>The life cycle name uniquely identifies the chromattic domain among all
domain registered against the
+ * <p>The life cycle domain uniquely identifies the chromattic domain among all
domain registered against the
* {@link org.exoplatform.commons.chromattic.ChromatticManager} manager.</p>
*
* <p>The plugin takes an instance of {@link
org.exoplatform.container.xml.InitParams} as parameter that contains
* the following entries:
*
* <ul>
- * <li>The <code>name</code> string that is the life cycle
name</li>
+ * <li>The <code>domain-name</code> string that is the life cycle
domain name</li>
* <li>The <code>workspace-name</code> string that is the repository
workspace name associated with this life cycle</li>
* <li>The <code>entities</code> list value that contains the list of
chromattic entities that will be registered
* against the builder chromattic builder</li>
@@ -54,7 +56,7 @@
{
/** . */
- private final String name;
+ private final String domainName;
/** . */
private final String workspaceName;
@@ -74,16 +76,19 @@
/** . */
final ThreadLocal<LocalContext> currentContext = new
ThreadLocal<LocalContext>();
+ /** . */
+ final Logger log = LoggerFactory.getLogger(ChromatticLifeCycle.class);
+
public ChromatticLifeCycle(InitParams params)
{
- this.name = params.getValueParam("name").getValue();
+ this.domainName = params.getValueParam("domain-name").getValue();
this.workspaceName = params.getValueParam("workspace-name").getValue();
this.entityClassNames = params.getValuesParam("entities").getValues();
}
- public final String getName()
+ public String getDomainName()
{
- return name;
+ return domainName;
}
public final String getWorkspaceName()
@@ -120,25 +125,37 @@
*/
public final SessionContext getContext(boolean peek)
{
+ log.trace("Requesting context");
Synchronization sync = manager.getSynchronization();
//
if (sync != null)
{
- GlobalContext context = sync.getContext(name);
+ log.trace("Found synchronization about to get the current context for
chromattic " + domainName);
+ GlobalContext context = sync.getContext(domainName);
//
if (context == null && !peek)
{
+ log.trace("No current context found, about to open one");
context = sync.openContext(this);
}
+ else
+ {
+ log.trace("Found a context and will return it");
+ }
//
return context;
}
//
- return currentContext.get();
+ log.trace("No active synchronization about to try the current local
context");
+ LocalContext localContext = currentContext.get();
+ log.trace("Found local context " + localContext);
+
+ //
+ return localContext;
}
LoginContext getLoginContext()
@@ -157,24 +174,31 @@
final SessionContext openGlobalContext()
{
+ log.trace("Opening a global context");
AbstractContext context = (AbstractContext)getContext(true);
//
if (context != null)
{
- throw new IllegalStateException("A session is already opened.");
+ String msg = "A global context is already opened";
+ log.trace(msg);
+ throw new IllegalStateException(msg);
}
// Attempt to get the synchronization
+ log.trace("Ok, no global context found, asking current
synchronization");
Synchronization sync = manager.getSynchronization();
//
if (sync == null)
{
- throw new IllegalStateException("Need global synchronization");
+ String msg = "Need global synchronization for opening a global
context";
+ log.trace(msg);
+ throw new IllegalStateException(msg);
}
//
+ log.trace("Opening a global context for the related sync");
return sync.openContext(this);
}
@@ -186,24 +210,30 @@
*/
public final SessionContext openContext()
{
+ log.trace("Opening a context");
AbstractContext context = (AbstractContext)getContext(true);
//
if (context != null)
{
- throw new IllegalStateException("A session is already opened.");
+ String msg = "A context is already opened";
+ log.trace(msg);
+ throw new IllegalStateException(msg);
}
//
+ log.trace("Ok, no context found, asking current synchronization");
Synchronization sync = manager.getSynchronization();
//
if (sync != null)
{
+ log.trace("Found a synchronization, about to open a global context");
context = sync.openContext(this);
}
else
{
+ log.trace("Not synchronization found, about to a local context");
LocalContext localContext = new LocalContext(this);
currentContext.set(localContext);
onOpenSession(localContext);
@@ -216,12 +246,15 @@
public final void closeContext(boolean save)
{
+ log.trace("Requesting for context close with save=" + save + " going
to look for any context");
AbstractContext context = (AbstractContext)getContext(true);
//
if (context == null)
{
- throw new IllegalStateException("No current context existing");
+ String msg = "Cannot close non existing context";
+ log.trace(msg);
+ throw new IllegalStateException(msg);
}
//
@@ -238,13 +271,16 @@
public final void start() throws Exception
{
+ log.debug("About to setup Chromattic life cycle " + domainName);
ChromatticBuilder builder = ChromatticBuilder.create();
//
ClassLoader cl = Thread.currentThread().getContextClassLoader();
for (String className : entityClassNames)
{
- Class<?> entityClass = cl.loadClass(className);
+ String fqn = className.trim();
+ log.debug("Adding class " + fqn + " to life cycle " +
domainName);
+ Class<?> entityClass = cl.loadClass(fqn);
builder.add(entityClass);
}
@@ -258,12 +294,13 @@
builder.setOption(ChromatticBuilder.SESSION_LIFECYCLE_CLASSNAME,
PortalSessionLifeCycle.class.getName());
//
+ log.debug("Building Chromattic " + domainName);
realChromattic = builder.build();
chromattic = new ChromatticImpl(this);
}
catch (Exception e)
{
- e.printStackTrace();
+ log.error("Could not start Chromattic " + domainName, e);
}
finally
{
Modified:
portal/trunk/component/common/src/main/java/org/exoplatform/commons/chromattic/ChromatticManager.java
===================================================================
---
portal/trunk/component/common/src/main/java/org/exoplatform/commons/chromattic/ChromatticManager.java 2009-12-17
15:00:38 UTC (rev 1050)
+++
portal/trunk/component/common/src/main/java/org/exoplatform/commons/chromattic/ChromatticManager.java 2009-12-17
15:23:11 UTC (rev 1051)
@@ -63,7 +63,7 @@
{
lifeCycle.manager = this;
lifeCycle.start();
- lifeCycles.put(lifeCycle.getName(), lifeCycle);
+ lifeCycles.put(lifeCycle.getDomainName(), lifeCycle);
}
catch (Exception e)
{
@@ -130,7 +130,7 @@
public void endRequest(ExoContainer container)
{
Synchronization sync = currentSynchronization.get();
- boolean save = sync.isSave();
+ boolean save = sync.getSaveOnClose();
endRequest(save);
}
}
Modified:
portal/trunk/component/common/src/main/java/org/exoplatform/commons/chromattic/Synchronization.java
===================================================================
---
portal/trunk/component/common/src/main/java/org/exoplatform/commons/chromattic/Synchronization.java 2009-12-17
15:00:38 UTC (rev 1050)
+++
portal/trunk/component/common/src/main/java/org/exoplatform/commons/chromattic/Synchronization.java 2009-12-17
15:23:11 UTC (rev 1051)
@@ -38,7 +38,7 @@
private final Map<String, GlobalContext> contexts = new HashMap<String,
GlobalContext>();
/** . */
- private boolean save = true;
+ private boolean saveOnClose = true;
/**
* Returns a specified global context by its name.
@@ -68,7 +68,7 @@
{
throw new NullPointerException();
}
- String name = lifeCycle.getName();
+ String name = lifeCycle.getDomainName();
GlobalContext context = contexts.get(name);
if (context != null)
{
@@ -100,13 +100,13 @@
}
}
- public boolean isSave()
+ public boolean getSaveOnClose()
{
- return save;
+ return saveOnClose;
}
- public void setSave(boolean save)
+ public void setSaveOnClose(boolean saveOnClose)
{
- this.save = save;
+ this.saveOnClose = saveOnClose;
}
}
Modified: portal/trunk/component/common/src/test/resources/conf/test-configuration.xml
===================================================================
---
portal/trunk/component/common/src/test/resources/conf/test-configuration.xml 2009-12-17
15:00:38 UTC (rev 1050)
+++
portal/trunk/component/common/src/test/resources/conf/test-configuration.xml 2009-12-17
15:23:11 UTC (rev 1051)
@@ -35,7 +35,7 @@
<type>org.exoplatform.commons.chromattic.ChromatticLifeCycle</type>
<init-params>
<value-param>
- <name>name</name>
+ <name>domain-name</name>
<value>test</value>
</value-param>
<value-param>
Modified:
portal/trunk/component/portal/src/test/java/conf/portal/portal-configuration.xml
===================================================================
---
portal/trunk/component/portal/src/test/java/conf/portal/portal-configuration.xml 2009-12-17
15:00:38 UTC (rev 1050)
+++
portal/trunk/component/portal/src/test/java/conf/portal/portal-configuration.xml 2009-12-17
15:23:11 UTC (rev 1051)
@@ -141,7 +141,7 @@
<type>org.exoplatform.portal.pom.config.MOPChromatticLifeCycle</type>
<init-params>
<value-param>
- <name>name</name>
+ <name>domain-name</name>
<value>mop</value>
</value-param>
<value-param>
Modified:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/AbstractPortalTest.java
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/AbstractPortalTest.java 2009-12-17
15:00:38 UTC (rev 1050)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/AbstractPortalTest.java 2009-12-17
15:23:11 UTC (rev 1051)
@@ -57,7 +57,7 @@
{
PortalContainer container = getContainer();
ChromatticManager manager =
(ChromatticManager)container.getComponentInstanceOfType(ChromatticManager.class);
- manager.getSynchronization().setSave(save);
+ manager.getSynchronization().setSaveOnClose(save);
super.end();
}
Modified:
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/common/autologin-configuration.xml
===================================================================
---
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/common/autologin-configuration.xml 2009-12-17
15:00:38 UTC (rev 1050)
+++
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/common/autologin-configuration.xml 2009-12-17
15:23:11 UTC (rev 1051)
@@ -59,7 +59,7 @@
<type>org.exoplatform.commons.chromattic.ChromatticLifeCycle</type>
<init-params>
<value-param>
- <name>name</name>
+ <name>domain-name</name>
<value>autologin</value>
</value-param>
<value-param>
Modified:
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/application-registry-configuration.xml
===================================================================
---
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/application-registry-configuration.xml 2009-12-17
15:00:38 UTC (rev 1050)
+++
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/application-registry-configuration.xml 2009-12-17
15:23:11 UTC (rev 1051)
@@ -529,7 +529,7 @@
<type>org.exoplatform.application.registry.impl.ApplicationRegistryChromatticLifeCycle</type>
<init-params>
<value-param>
- <name>name</name>
+ <name>domain-name</name>
<value>app</value>
</value-param>
<value-param>
Modified:
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml
===================================================================
---
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml 2009-12-17
15:00:38 UTC (rev 1050)
+++
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml 2009-12-17
15:23:11 UTC (rev 1051)
@@ -182,7 +182,7 @@
<type>org.exoplatform.portal.pom.config.MOPChromatticLifeCycle</type>
<init-params>
<value-param>
- <name>name</name>
+ <name>domain-name</name>
<value>mop</value>
</value-param>
<value-param>