exo-jcr SVN: r2374 - in kernel/trunk/exo.kernel.container/src/main: resources and 1 other directory.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-05-12 13:07:26 -0400 (Wed, 12 May 2010)
New Revision: 2374
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/Component.java
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/ComponentLifecyclePlugin.java
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/ComponentPlugin.java
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/ContainerLifecyclePlugin.java
kernel/trunk/exo.kernel.container/src/main/resources/binding.xml
Log:
EXOJCR-719: Now the method Configuration.toXML() add the source URL of the components and the plugins as comment to the XML content
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/Component.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/Component.java 2010-05-12 16:29:51 UTC (rev 2373)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/Component.java 2010-05-12 17:07:26 UTC (rev 2374)
@@ -19,6 +19,7 @@
package org.exoplatform.container.xml;
import org.exoplatform.container.configuration.ConfigurationManagerImpl;
+import org.jibx.runtime.IMarshallingContext;
import java.net.URL;
import java.util.ArrayList;
@@ -170,4 +171,8 @@
multiInstance = b;
}
+ public void preGet(IMarshallingContext ictx)
+ {
+ ConfigurationMarshallerUtil.addURLToContent(documentURL, ictx);
+ }
}
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/ComponentLifecyclePlugin.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/ComponentLifecyclePlugin.java 2010-05-12 16:29:51 UTC (rev 2373)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/ComponentLifecyclePlugin.java 2010-05-12 17:07:26 UTC (rev 2374)
@@ -18,18 +18,31 @@
*/
package org.exoplatform.container.xml;
+import org.exoplatform.container.configuration.ConfigurationManagerImpl;
+import org.jibx.runtime.IMarshallingContext;
+
+import java.net.URL;
+
/**
* Created by The eXo Platform SAS Author : Tuan Nguyen
* tuan08(a)users.sourceforge.net Sep 8, 2005
*/
public class ComponentLifecyclePlugin
{
+
+ final URL documentURL;
+
private String type;
private ManageableComponents manageableComponents;
private InitParams initParams;
+ public ComponentLifecyclePlugin()
+ {
+ documentURL = ConfigurationManagerImpl.getCurrentURL();
+ }
+
public String getType()
{
return type;
@@ -60,4 +73,8 @@
this.initParams = initParams;
}
+ public void preGet(IMarshallingContext ictx)
+ {
+ ConfigurationMarshallerUtil.addURLToContent(documentURL, ictx);
+ }
}
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/ComponentPlugin.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/ComponentPlugin.java 2010-05-12 16:29:51 UTC (rev 2373)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/ComponentPlugin.java 2010-05-12 17:07:26 UTC (rev 2374)
@@ -18,6 +18,11 @@
*/
package org.exoplatform.container.xml;
+import org.exoplatform.container.configuration.ConfigurationManagerImpl;
+import org.jibx.runtime.IMarshallingContext;
+
+import java.net.URL;
+
/**
* @author Tuan Nguyen (tuan08(a)users.sourceforge.net)
* @since Apr 18, 2005
@@ -25,6 +30,9 @@
*/
public class ComponentPlugin implements Comparable<ComponentPlugin>
{
+
+ final URL documentURL;
+
String name;
String type;
@@ -37,6 +45,11 @@
int priority;
+ public ComponentPlugin()
+ {
+ documentURL = ConfigurationManagerImpl.getCurrentURL();
+ }
+
public String getName()
{
return name;
@@ -104,4 +117,9 @@
{
return getPriority() - o.getPriority();
}
+
+ public void preGet(IMarshallingContext ictx)
+ {
+ ConfigurationMarshallerUtil.addURLToContent(documentURL, ictx);
+ }
}
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/ContainerLifecyclePlugin.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/ContainerLifecyclePlugin.java 2010-05-12 16:29:51 UTC (rev 2373)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/ContainerLifecyclePlugin.java 2010-05-12 17:07:26 UTC (rev 2374)
@@ -18,12 +18,20 @@
*/
package org.exoplatform.container.xml;
+import org.exoplatform.container.configuration.ConfigurationManagerImpl;
+import org.jibx.runtime.IMarshallingContext;
+
+import java.net.URL;
+
/**
* Created by The eXo Platform SAS Author : Tuan Nguyen
* tuan08(a)users.sourceforge.net Sep 8, 2005
*/
public class ContainerLifecyclePlugin implements Comparable<ContainerLifecyclePlugin>
{
+
+ final URL documentURL;
+
private String name;
private String type;
@@ -34,6 +42,11 @@
private InitParams initParams;
+ public ContainerLifecyclePlugin()
+ {
+ documentURL = ConfigurationManagerImpl.getCurrentURL();
+ }
+
public String getName()
{
return name;
@@ -88,4 +101,9 @@
{
return getPriority() - o.getPriority();
}
+
+ public void preGet(IMarshallingContext ictx)
+ {
+ ConfigurationMarshallerUtil.addURLToContent(documentURL, ictx);
+ }
}
Modified: kernel/trunk/exo.kernel.container/src/main/resources/binding.xml
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/resources/binding.xml 2010-05-12 16:29:51 UTC (rev 2373)
+++ kernel/trunk/exo.kernel.container/src/main/resources/binding.xml 2010-05-12 17:07:26 UTC (rev 2374)
@@ -137,7 +137,7 @@
add-method="addParam" iter-method="getObjectParamIterator"/>
</mapping>
- <mapping name="component-plugin" class="org.exoplatform.container.xml.ComponentPlugin">
+ <mapping name="component-plugin" class="org.exoplatform.container.xml.ComponentPlugin" pre-get="preGet">
<value name="name" field="name" />
<value name="set-method" field="setMethod" />
<value name="type" field="type" />
@@ -152,7 +152,7 @@
<collection item-type="org.exoplatform.container.xml.ComponentPlugin" field="componentPlugins"/>
</mapping>
- <mapping name="container-lifecycle-plugin" class="org.exoplatform.container.xml.ContainerLifecyclePlugin">
+ <mapping name="container-lifecycle-plugin" class="org.exoplatform.container.xml.ContainerLifecyclePlugin" pre-get="preGet">
<value name="name" field="name" usage="optional" />
<value name="type" field="type" />
<value name="description" field="description" usage="optional" />
@@ -168,7 +168,7 @@
</collection>
</mapping>
- <mapping name="component-lifecycle-plugin" class="org.exoplatform.container.xml.ComponentLifecyclePlugin">
+ <mapping name="component-lifecycle-plugin" class="org.exoplatform.container.xml.ComponentLifecyclePlugin" pre-get="preGet">
<value name="type" field="type" />
<structure map-as="org.exoplatform.container.xml.ManageableComponents"
get-method="getManageableComponents" set-method="setManageableComponents"/>
@@ -176,7 +176,7 @@
get-method="getInitParams" set-method="setInitParams"/>
</mapping>
- <mapping name="component" class="org.exoplatform.container.xml.Component">
+ <mapping name="component" class="org.exoplatform.container.xml.Component" pre-get="preGet">
<value name="key" field="key" usage="optional" />
<value name="jmx-name" field="jmxName" usage="optional" />
<value name="type" field="type" />
16 years, 2 months
exo-jcr SVN: r2373 - kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-05-12 12:29:51 -0400 (Wed, 12 May 2010)
New Revision: 2373
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/PortalContainer.java
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/RootContainer.java
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/StandaloneContainer.java
Log:
EXOJCR-718: Rest end-points added:
* pcontainer for PortalContainer
* rcontainer for RootContainer
* scontainer for StandaloneContainer
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/PortalContainer.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/PortalContainer.java 2010-05-12 14:54:13 UTC (rev 2372)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/PortalContainer.java 2010-05-12 16:29:51 UTC (rev 2373)
@@ -28,6 +28,7 @@
import org.exoplatform.management.jmx.annotations.NameTemplate;
import org.exoplatform.management.jmx.annotations.NamingContext;
import org.exoplatform.management.jmx.annotations.Property;
+import org.exoplatform.management.rest.annotations.RESTEndpoint;
import java.util.Collections;
import java.util.Comparator;
@@ -47,6 +48,7 @@
@Managed
@NamingContext(@Property(key = "portal", value = "{Name}"))
@NameTemplate({@Property(key = "container", value = "portal"), @Property(key = "name", value = "{Name}")})
+@RESTEndpoint(path = "pcontainer")
public class PortalContainer extends ExoContainer implements SessionManagerContainer
{
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-12 14:54:13 UTC (rev 2372)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/RootContainer.java 2010-05-12 16:29:51 UTC (rev 2373)
@@ -31,6 +31,7 @@
import org.exoplatform.management.annotations.ManagedDescription;
import org.exoplatform.management.jmx.annotations.NamingContext;
import org.exoplatform.management.jmx.annotations.Property;
+import org.exoplatform.management.rest.annotations.RESTEndpoint;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.exoplatform.test.mocks.servlet.MockServletContext;
@@ -55,6 +56,7 @@
*/
@Managed
@NamingContext(@Property(key = "container", value = "root"))
+@RESTEndpoint(path = "rcontainer")
public class RootContainer extends ExoContainer
{
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/StandaloneContainer.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/StandaloneContainer.java 2010-05-12 14:54:13 UTC (rev 2372)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/StandaloneContainer.java 2010-05-12 16:29:51 UTC (rev 2373)
@@ -29,6 +29,7 @@
import org.exoplatform.management.annotations.ManagedDescription;
import org.exoplatform.management.jmx.annotations.NamingContext;
import org.exoplatform.management.jmx.annotations.Property;
+import org.exoplatform.management.rest.annotations.RESTEndpoint;
import java.io.File;
import java.net.MalformedURLException;
@@ -51,6 +52,7 @@
*/
@Managed
@NamingContext(@Property(key = "container", value = "standalone"))
+@RESTEndpoint(path = "scontainer")
public class StandaloneContainer extends ExoContainer implements SessionManagerContainer
{
16 years, 2 months
exo-jcr SVN: r2372 - kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/monitor/jvm.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-05-12 10:54:13 -0400 (Wed, 12 May 2010)
New Revision: 2372
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/monitor/jvm/J2EEServerInfo.java
Log:
EXOJCR-726: patch proposed has been applied and tested
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/monitor/jvm/J2EEServerInfo.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/monitor/jvm/J2EEServerInfo.java 2010-05-12 14:05:44 UTC (rev 2371)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/monitor/jvm/J2EEServerInfo.java 2010-05-12 14:54:13 UTC (rev 2372)
@@ -24,7 +24,7 @@
import java.io.File;
import java.lang.management.ManagementFactory;
import java.lang.reflect.Method;
-import java.net.URL;
+import java.net.URI;
import javax.management.MBeanServer;
@@ -95,7 +95,7 @@
{
try
{
- exoConfDir_ = new File(new URL(jbossConfigUrl).getFile() + "/" + confDirName).getAbsolutePath();
+ exoConfDir_ = new File(new File(new URI(jbossConfigUrl)), confDirName).getAbsolutePath();
}
catch (Throwable e)
{
16 years, 2 months
exo-jcr SVN: r2371 - ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl.
by do-not-reply@jboss.org
Author: aparfonov
Date: 2010-05-12 10:05:44 -0400 (Wed, 12 May 2010)
New Revision: 2371
Modified:
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ResourceBinder.java
Log:
EXOJCR-722 :
Modified: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ResourceBinder.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ResourceBinder.java 2010-05-12 10:31:43 UTC (rev 2370)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ResourceBinder.java 2010-05-12 14:05:44 UTC (rev 2371)
@@ -113,7 +113,7 @@
*/
protected final RuntimeDelegate rd;
- private final MethodInvokerFactory invokerFactory;
+ protected final MethodInvokerFactory invokerFactory;
/**
* @param containerContext eXo container context
16 years, 2 months
exo-jcr SVN: r2370 - jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/kernel.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-05-12 06:31:43 -0400 (Wed, 12 May 2010)
New Revision: 2370
Modified:
jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/kernel/configuration.xml
Log:
Since changes made for EXOJCR-166, the configuration adding process is reported using a logger instead of the standard output.
Modified: jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/kernel/configuration.xml
===================================================================
--- jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/kernel/configuration.xml 2010-05-12 10:19:45 UTC (rev 2369)
+++ jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/kernel/configuration.xml 2010-05-12 10:31:43 UTC (rev 2370)
@@ -248,8 +248,8 @@
be used.<programlisting>java -Dorg.exoplatform.container.configuration.debug ...</programlisting></para>
<para>If the property is enabled the container configuration manager
- will report the configuration adding process to the standard output
- (System.out).<programlisting>......
+ will log the configuration adding process at <emphasis>INFO</emphasis>
+ level.<programlisting>......
Add configuration jar:file:/D:/Projects/eXo/dev/exo-working/exo-tomcat/lib/exo.kernel.container-trunk.jar!/conf/portal/configuration.xml
Add configuration jar:file:/D:/Projects/eXo/dev/exo-working/exo-tomcat/lib/exo.kernel.component.cache-trunk.jar!/conf/portal/configuration.xml
Add configuration jndi:/localhost/portal/WEB-INF/conf/configuration.xml
16 years, 2 months
exo-jcr SVN: r2369 - kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/configuration.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-05-12 06:19:45 -0400 (Wed, 12 May 2010)
New Revision: 2369
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/ConfigurationManagerImpl.java
Log:
EXOJCR-724: The current URL is now set to the URL of the imported configuration file before trying to unmarshall it.
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/ConfigurationManagerImpl.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/ConfigurationManagerImpl.java 2010-05-12 10:17:56 UTC (rev 2368)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/ConfigurationManagerImpl.java 2010-05-12 10:19:45 UTC (rev 2369)
@@ -176,10 +176,12 @@
URL urlObject = getURL(uri);
if (urlObject != null)
{
+ if (LOG_DEBUG)
+ log.info("\timport " + urlObject);
+ // Set the URL of imported file
+ currentURL.set(urlObject);
conf = unmarshaller.unmarshall(urlObject);
configurations_.mergeConfiguration(conf);
- if (LOG_DEBUG)
- log.info("\timport " + urlObject);
}
else
{
16 years, 2 months
exo-jcr SVN: r2368 - ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl.
by do-not-reply@jboss.org
Author: aparfonov
Date: 2010-05-12 06:17:56 -0400 (Wed, 12 May 2010)
New Revision: 2368
Modified:
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ProviderBinder.java
Log:
EXOJCR-722 :
Modified: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ProviderBinder.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ProviderBinder.java 2010-05-12 09:51:45 UTC (rev 2367)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ProviderBinder.java 2010-05-12 10:17:56 UTC (rev 2368)
@@ -118,7 +118,7 @@
/**
* Add prepared providers.
*/
- void init()
+ protected void init()
{
// TODO remove this hard code
ByteEntityProvider baep = new ByteEntityProvider();
16 years, 2 months
exo-jcr SVN: r2367 - in ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl: method and 1 other directories.
by do-not-reply@jboss.org
Author: aparfonov
Date: 2010-05-12 05:51:45 -0400 (Wed, 12 May 2010)
New Revision: 2367
Added:
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/method/MethodInvokerFactory.java
Modified:
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/RequestDispatcher.java
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ResourceBinder.java
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/method/DefaultMethodInvoker.java
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/resource/AbstractResourceDescriptorImpl.java
Log:
EXOJCR-722 :
Modified: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/RequestDispatcher.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/RequestDispatcher.java 2010-05-12 09:02:25 UTC (rev 2366)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/RequestDispatcher.java 2010-05-12 09:51:45 UTC (rev 2367)
@@ -27,6 +27,7 @@
import org.exoplatform.services.rest.SingletonObjectFactory;
import org.exoplatform.services.rest.impl.header.HeaderHelper;
import org.exoplatform.services.rest.impl.header.MediaTypeHelper;
+import org.exoplatform.services.rest.impl.method.MethodInvokerFactory;
import org.exoplatform.services.rest.impl.resource.AbstractResourceDescriptorImpl;
import org.exoplatform.services.rest.method.MethodInvoker;
import org.exoplatform.services.rest.resource.AbstractResourceDescriptor;
@@ -54,7 +55,7 @@
/**
* Lookup resource which can serve request.
- *
+ *
* @author <a href="mailto:andrew00x@gmail.com">Andrey Parfonov</a>
* @version $Id: $
*/
@@ -71,19 +72,32 @@
*/
protected final ResourceBinder resourceBinder;
+ private final MethodInvokerFactory invokerFactory;
+
/**
* Constructs new instance of RequestDispatcher.
- *
+ *
* @param resourceBinder See {@link ResourceBinder}
*/
- public RequestDispatcher(ResourceBinder resourceBinder)
+ public RequestDispatcher(ResourceBinder resourceBinder, MethodInvokerFactory invokerFactory)
{
this.resourceBinder = resourceBinder;
+ this.invokerFactory = invokerFactory;
}
/**
+ * Constructs new instance of RequestDispatcher.
+ *
+ * @param resourceBinder See {@link ResourceBinder}
+ */
+ public RequestDispatcher(ResourceBinder resourceBinder)
+ {
+ this(resourceBinder, null);
+ }
+
+ /**
* Dispatch {@link ContainerRequest} to resource which can serve request.
- *
+ *
* @param request See {@link GenericContainerRequest}
* @param response See {@link GenericContainerResponse}
*/
@@ -114,7 +128,7 @@
/**
* Get last element from path parameters. This element will be used as request
* path for child resources.
- *
+ *
* @param parameterValues See
* {@link ApplicationContextImpl#getParameterValues()}
* @return last element from given list or empty string if last element is
@@ -129,7 +143,7 @@
/**
* Process resource methods, sub-resource methods and sub-resource locators to
* find the best one for serve request.
- *
+ *
* @param request See {@link GenericContainerRequest}
* @param response See {@link GenericContainerResponse}
* @param context See {@link ApplicationContextImpl}
@@ -163,7 +177,9 @@
if (!match)
{
if (LOG.isDebugEnabled())
+ {
LOG.debug("Not found resource method for method " + request.getMethod());
+ }
return; // Error Response is preset
}
@@ -190,8 +206,10 @@
if (!match && !hasAcceptableLocator)
{
if (LOG.isDebugEnabled())
+ {
LOG.debug("Not found sub-resource methods nor sub-resource locators for path " + requestPath
+ " and method " + request.getMethod());
+ }
return; // Error Response is preset
}
@@ -219,7 +237,7 @@
/**
* Invoke resource methods.
- *
+ *
* @param rmd See {@link ResourceMethodDescriptor}
* @param resource instance of resource class
* @param context See {@link ApplicationContextImpl}
@@ -241,7 +259,7 @@
/**
* Invoke sub-resource methods.
- *
+ *
* @param requestPath request path
* @param srmd See {@link SubResourceMethodDescriptor}
* @param resource instance of resource class
@@ -269,7 +287,7 @@
/**
* Invoke sub-resource locators.
- *
+ *
* @param requestPath request path
* @param srld See {@link SubResourceLocatorDescriptor}
* @param resource instance of resource class
@@ -295,7 +313,7 @@
MethodInvoker invoker = srld.getMethodInvoker();
resource = invoker.invokeMethod(resource, srld, context);
- AbstractResourceDescriptor descriptor = new AbstractResourceDescriptorImpl(resource);
+ AbstractResourceDescriptor descriptor = new AbstractResourceDescriptorImpl(resource, invokerFactory);
SingletonObjectFactory<AbstractResourceDescriptor> locResource =
new SingletonObjectFactory<AbstractResourceDescriptor>(descriptor, resource);
@@ -313,7 +331,7 @@
* then SubResourceLocatorDescriptor has higher priority. And finally if zero
* was returned then UriPattern is equals, in this case
* SubResourceMethodDescriptor must be selected.
- *
+ *
* @param srmd See {@link SubResourceMethodDescriptor}
* @param srld See {@link SubResourceLocatorDescriptor}
* @return result of comparison sub-resources
@@ -323,14 +341,16 @@
int r = UriPattern.URIPATTERN_COMPARATOR.compare(srmd.getUriPattern(), srld.getUriPattern());
// NOTE If patterns are the same sub-resource method has priority
if (r == 0)
+ {
return -1;
+ }
return r;
}
/**
* Process result of invoked method, and set {@link Response} parameters
* dependent of returned object.
- *
+ *
* @param o result of invoked method
* @param returnType type of returned object
* @param request See {@link GenericContainerRequest}
@@ -356,7 +376,9 @@
Response r = (Response)o;
// If content-type is not set then add it
if (r.getMetadata().getFirst(HttpHeaders.CONTENT_TYPE) == null && r.getEntity() != null)
+ {
r.getMetadata().putSingle(HttpHeaders.CONTENT_TYPE, contentType);
+ }
response.setResponse(r);
@@ -405,7 +427,9 @@
for (T rmd : rmds)
{
if (MediaTypeHelper.isConsume(rmd.consumes(), contentType))
+ {
methods.add(rmd);
+ }
}
}
@@ -444,7 +468,9 @@
{
i.next();
if (n == p)
+ {
break; // get index p in list then stop removing
+ }
}
}
@@ -457,7 +483,7 @@
/**
* Process sub-resource methods.
- *
+ *
* @param srmm See {@link SubResourceLocatorMap}
* @param requestedPath part of requested path
* @param request See {@link GenericContainerRequest}
@@ -479,7 +505,9 @@
{
int len = capturingValues.size();
if (capturingValues.get(len - 1) != null && !"/".equals(capturingValues.get(len - 1)))
+ {
continue;
+ }
rmm = e.getValue();
break;
@@ -500,7 +528,9 @@
// for cast, Iterator contains SubResourceMethodDescriptor
Iterator i = l.iterator();
while (i.hasNext())
+ {
methods.add((SubResourceMethodDescriptor)i.next());
+ }
}
return match;
@@ -508,7 +538,7 @@
/**
* Process sub-resource locators.
- *
+ *
* @param srlm See {@link SubResourceLocatorMap}
* @param requestedPath part of requested path
* @param capturingValues the list for keeping template values
@@ -522,18 +552,20 @@
for (Map.Entry<UriPattern, SubResourceLocatorDescriptor> e : srlm.entrySet())
{
if (e.getKey().match(requestedPath, capturingValues))
+ {
locators.add(e.getValue());
+ }
}
return !locators.isEmpty();
}
-
+
/**
* Get root resource
- *
- * @param parameterValues is taken from context
+ *
+ * @param parameterValues is taken from context
* @param requestPath is taken from context
- * @return root resource
+ * @return root resource
*/
protected ObjectFactory<AbstractResourceDescriptor> getRootResourse(List<String> parameterValues, String requestPath)
{
@@ -557,7 +589,9 @@
rc.getObjectModel().getSubResourceMethods().size()
+ rc.getObjectModel().getSubResourceLocators().size();
if (subresnum == 0)
+ {
continue;
+ }
}
resourceFactory = rc;
break;
@@ -570,12 +604,16 @@
{
if (LOG.isDebugEnabled())
+ {
LOG.debug("Root resource not found for " + requestPath);
+ }
// Stop here, there is no matched root resource
throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build());
}
else
+ {
return resourceFactory;
+ }
}
}
Modified: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ResourceBinder.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ResourceBinder.java 2010-05-12 09:02:25 UTC (rev 2366)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ResourceBinder.java 2010-05-12 09:51:45 UTC (rev 2367)
@@ -28,6 +28,7 @@
import org.exoplatform.services.rest.RequestFilter;
import org.exoplatform.services.rest.ResponseFilter;
import org.exoplatform.services.rest.SingletonObjectFactory;
+import org.exoplatform.services.rest.impl.method.MethodInvokerFactory;
import org.exoplatform.services.rest.impl.resource.AbstractResourceDescriptorImpl;
import org.exoplatform.services.rest.impl.resource.ResourceDescriptorValidator;
import org.exoplatform.services.rest.method.MethodInvokerFilter;
@@ -54,7 +55,7 @@
/**
* Lookup for root resource eXo container components at startup and
* register/unregister resources via specified methods.
- *
+ *
* @see AbstractResourceDescriptor
* @see SingletonResourceFactory
* @author <a href="mailto:andrew00x@gmail.com">Andrey Parfonov</a>
@@ -78,7 +79,7 @@
{
/**
* Compare two ResourceClass for order.
- *
+ *
* @param o1 first ResourceClass to be compared
* @param o2 second ResourceClass to be compared
* @return positive , zero or negative dependent of {@link UriPattern}
@@ -112,13 +113,17 @@
*/
protected final RuntimeDelegate rd;
+ private final MethodInvokerFactory invokerFactory;
+
/**
* @param containerContext eXo container context
* @throws Exception if can't set instance of {@link RuntimeDelegate}
*/
@SuppressWarnings("unchecked")
- public ResourceBinder(ExoContainerContext containerContext) throws Exception
+ public ResourceBinder(ExoContainerContext containerContext, MethodInvokerFactory invokerFactory) throws Exception
{
+ this.invokerFactory = invokerFactory;
+
// Initialize RuntimeDelegate instance
// This is first component in life cycle what needs.
// TODO better solution to initialize RuntimeDelegate
@@ -150,6 +155,11 @@
}
+ public ResourceBinder(ExoContainerContext containerContext) throws Exception
+ {
+ this(containerContext, null);
+ }
+
/**
* @param application Application
* @see Application
@@ -250,7 +260,7 @@
* Register supplied Object as root resource if it has valid JAX-RS
* annotations and no one resource with the same UriPattern already
* registered.
- *
+ *
* @param resource candidate to be root resource
* @return true if resource was bound and false if resource was not bound
* cause it is not root resource
@@ -264,7 +274,7 @@
{
try
{
- descriptor = new AbstractResourceDescriptorImpl(resource);
+ descriptor = new AbstractResourceDescriptorImpl(resource, invokerFactory);
}
catch (Exception e)
{
@@ -335,7 +345,7 @@
{
try
{
- descriptor = new AbstractResourceDescriptorImpl(resourceClass);
+ descriptor = new AbstractResourceDescriptorImpl(resourceClass, invokerFactory);
}
catch (Exception e)
{
@@ -394,7 +404,7 @@
/**
* Remove root resource of supplied class from root resource collection.
- *
+ *
* @param clazz root resource class
* @return true if resource was unbound false otherwise
*/
@@ -476,7 +486,9 @@
synchronized (rootResources)
{
for (ObjectFactory<AbstractResourceDescriptor> f : rootResources)
+ {
l.add(f.getObjectModel());
+ }
}
return l;
}
Modified: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/method/DefaultMethodInvoker.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/method/DefaultMethodInvoker.java 2010-05-12 09:02:25 UTC (rev 2366)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/method/DefaultMethodInvoker.java 2010-05-12 09:51:45 UTC (rev 2367)
@@ -44,11 +44,11 @@
/**
* Invoker for Resource Method, Sub-Resource Method and SubResource Locator.
- *
+ *
* @author <a href="mailto:andrew00x@gmail.com">Andrey Parfonov</a>
* @version $Id: $
*/
-public final class DefaultMethodInvoker implements MethodInvoker
+public class DefaultMethodInvoker implements MethodInvoker
{
/**
@@ -86,7 +86,9 @@
Class<?> ac = a.annotationType();
if (ac == MatrixParam.class || ac == QueryParam.class || ac == PathParam.class)
+ {
throw new WebApplicationException(e, Response.status(Response.Status.NOT_FOUND).build());
+ }
throw new WebApplicationException(e, Response.status(Response.Status.BAD_REQUEST).build());
@@ -98,7 +100,9 @@
InputStream entityStream = context.getContainerRequest().getEntityStream();
if (entityStream == null)
+ {
p[i++] = null;
+ }
else
{
MediaType contentType = context.getContainerRequest().getMediaType();
@@ -110,14 +114,15 @@
if (entityReader == null)
{
if (LOG.isDebugEnabled())
+ {
LOG.warn("Unsupported media type. ");
+ }
throw new WebApplicationException(Response.status(Response.Status.UNSUPPORTED_MEDIA_TYPE).build());
}
try
{
-
p[i++] =
entityReader.readFrom(mp.getParameterClass(), mp.getGenericType(), mp.getAnnotations(),
contentType, headers, entityStream);
@@ -126,7 +131,9 @@
{
if (LOG.isDebugEnabled())
+ {
e.printStackTrace();
+ }
throw new InternalException(e);
@@ -135,6 +142,11 @@
}
}
+ return invokeMethod(resource, methodResource, p);
+ }
+
+ protected Object invokeMethod(Object resource, GenericMethodResource methodResource, Object[] p)
+ {
try
{
return methodResource.getMethod().invoke(resource, p);
@@ -152,12 +164,16 @@
catch (InvocationTargetException invExc)
{
if (LOG.isDebugEnabled())
+ {
invExc.printStackTrace();
+ }
// get cause of exception that method produces
Throwable cause = invExc.getCause();
// if WebApplicationException than it may contain response
if (WebApplicationException.class == cause.getClass())
+ {
throw (WebApplicationException)cause;
+ }
throw new InternalException(cause);
}
Added: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/method/MethodInvokerFactory.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/method/MethodInvokerFactory.java (rev 0)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/method/MethodInvokerFactory.java 2010-05-12 09:51:45 UTC (rev 2367)
@@ -0,0 +1,36 @@
+/**
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.services.rest.impl.method;
+
+import org.exoplatform.services.rest.method.MethodInvoker;
+
+/**
+ * @author <a href="mailto:andrew00x@gmail.com">Andrey Parfonov</a>
+ * @version $Id$
+ */
+public interface MethodInvokerFactory
+{
+
+ /**
+ * @return {@link MethodInvoker}
+ */
+ MethodInvoker getMethodInvoker();
+
+}
Property changes on: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/method/MethodInvokerFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/resource/AbstractResourceDescriptorImpl.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/resource/AbstractResourceDescriptorImpl.java 2010-05-12 09:02:25 UTC (rev 2366)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/resource/AbstractResourceDescriptorImpl.java 2010-05-12 09:51:45 UTC (rev 2367)
@@ -18,7 +18,6 @@
*/
package org.exoplatform.services.rest.impl.resource;
-import org.exoplatform.services.rest.impl.MultivaluedMapImpl;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.exoplatform.services.rest.ComponentLifecycleScope;
@@ -26,11 +25,14 @@
import org.exoplatform.services.rest.FieldInjector;
import org.exoplatform.services.rest.impl.ConstructorDescriptorImpl;
import org.exoplatform.services.rest.impl.FieldInjectorImpl;
+import org.exoplatform.services.rest.impl.MultivaluedMapImpl;
import org.exoplatform.services.rest.impl.header.MediaTypeHelper;
import org.exoplatform.services.rest.impl.method.DefaultMethodInvoker;
+import org.exoplatform.services.rest.impl.method.MethodInvokerFactory;
import org.exoplatform.services.rest.impl.method.MethodParameterImpl;
import org.exoplatform.services.rest.impl.method.OptionsRequestMethodInvoker;
import org.exoplatform.services.rest.impl.method.ParameterHelper;
+import org.exoplatform.services.rest.method.MethodInvoker;
import org.exoplatform.services.rest.method.MethodParameter;
import org.exoplatform.services.rest.resource.AbstractResourceDescriptor;
import org.exoplatform.services.rest.resource.ResourceDescriptorVisitor;
@@ -98,28 +100,28 @@
/**
* Sub-resource methods. Sub-resource method has path annotation.
- *
+ *
* @see SubResourceMethodDescriptor
*/
private final SubResourceMethodMap subResourceMethods;
/**
* Sub-resource locators. Sub-resource locator has path annotation.
- *
+ *
* @see SubResourceLocatorDescriptor
*/
private final SubResourceLocatorMap subResourceLocators;
/**
* Resource methods. Resource method has not own path annotation.
- *
+ *
* @see ResourceMethodDescriptor
*/
private final ResourceMethodMap<ResourceMethodDescriptor> resourceMethods;
/**
* Resource class constructors.
- *
+ *
* @see ConstructorDescriptor
*/
private final List<ConstructorDescriptor> constructors;
@@ -128,32 +130,55 @@
* Resource class fields.
*/
private final List<FieldInjector> fields;
-
+
/**
* Optional data
*/
private MultivaluedMap<String, String> properties;
+ private final MethodInvokerFactory invokerFactory;
+
/**
- * Constructs new instance of AbstractResourceDescriptor without path
- * (sub-resource).
- *
+ * Constructs new instance of AbstractResourceDescriptor.
+ *
* @param resourceClass resource class
+ * @param invokerFactory invoker factory
*/
+ public AbstractResourceDescriptorImpl(Class<?> resourceClass, MethodInvokerFactory invokerFactory)
+ {
+ this(resourceClass.getAnnotation(Path.class), resourceClass, ComponentLifecycleScope.PER_REQUEST, invokerFactory);
+ }
+
+ /**
+ * Constructs new instance of AbstractResourceDescriptor.
+ *
+ * @param resource resource instance
+ * @param invokerFactory invoker factory
+ */
+ public AbstractResourceDescriptorImpl(Object resource, MethodInvokerFactory invokerFactory)
+ {
+ this(resource.getClass().getAnnotation(Path.class), resource.getClass(), ComponentLifecycleScope.SINGLETON,
+ invokerFactory);
+ }
+
+ /**
+ * Constructs new instance of AbstractResourceDescriptor.
+ *
+ * @param resourceClass resource class
+ */
public AbstractResourceDescriptorImpl(Class<?> resourceClass)
{
- this(resourceClass.getAnnotation(Path.class), resourceClass, ComponentLifecycleScope.PER_REQUEST);
+ this(resourceClass.getAnnotation(Path.class), resourceClass, ComponentLifecycleScope.PER_REQUEST, null);
}
/**
- * Constructs new instance of AbstractResourceDescriptor without path
- * (sub-resource).
- *
+ * Constructs new instance of AbstractResourceDescriptor.
+ *
* @param resource resource instance
*/
public AbstractResourceDescriptorImpl(Object resource)
{
- this(resource.getClass().getAnnotation(Path.class), resource.getClass(), ComponentLifecycleScope.SINGLETON);
+ this(resource.getClass().getAnnotation(Path.class), resource.getClass(), ComponentLifecycleScope.SINGLETON, null);
}
/**
@@ -162,7 +187,8 @@
* @param scope resource scope
* @see ComponentLifecycleScope
*/
- private AbstractResourceDescriptorImpl(Path path, Class<?> resourceClass, ComponentLifecycleScope scope)
+ private AbstractResourceDescriptorImpl(Path path, Class<?> resourceClass, ComponentLifecycleScope scope,
+ MethodInvokerFactory invokerFactory)
{
if (path != null)
{
@@ -210,7 +236,7 @@
if (Modifier.isPublic(modif) || Modifier.isProtected(modif))
{
FieldInjector inj = new FieldInjectorImpl(resourceClass, jfield);
- // Skip not annotated field. They will be not injected from container.
+ // Skip not annotated field. They will be not injected from container.
if (inj.getAnnotation() != null)
{
fields.add(new FieldInjectorImpl(resourceClass, jfield));
@@ -221,6 +247,8 @@
}
}
+ this.invokerFactory = invokerFactory;
+
this.resourceMethods = new ResourceMethodMap<ResourceMethodDescriptor>();
this.subResourceMethods = new SubResourceMethodMap();
this.subResourceLocators = new SubResourceLocatorMap();
@@ -233,7 +261,9 @@
public MultivaluedMap<String, String> getProperties()
{
if (properties == null)
+ {
properties = new MultivaluedMapImpl();
+ }
return properties;
}
@@ -243,10 +273,12 @@
public List<String> getProperty(String key)
{
if (properties != null)
+ {
return properties.get(key);
+ }
return null;
}
-
+
/**
* {@inheritDoc}
*/
@@ -365,13 +397,17 @@
Produces p = getMethodAnnotation(method, resourceClass, Produces.class, false);
if (p == null)
+ {
p = resourceClass.getAnnotation(Produces.class); // from resource
+ }
// class
List<MediaType> produces = MediaTypeHelper.createProducesList(p);
Consumes c = getMethodAnnotation(method, resourceClass, Consumes.class, false);
if (c == null)
+ {
c = resourceClass.getAnnotation(Consumes.class); // from resource
+ }
// class
List<MediaType> consumes = MediaTypeHelper.createConsumesList(c);
@@ -380,7 +416,7 @@
// resource method
ResourceMethodDescriptor res =
new ResourceMethodDescriptorImpl(method, httpMethod.value(), params, this, consumes, produces,
- new DefaultMethodInvoker());
+ getMethodInvoker());
ResourceMethodDescriptor exist =
findMethodResourceMediaType(resourceMethods.getList(httpMethod.value()), res.consumes(), res
.produces());
@@ -401,11 +437,10 @@
// sub-resource method
SubResourceMethodDescriptor subRes =
new SubResourceMethodDescriptorImpl(new PathValue(subPath.value()), method, httpMethod.value(),
- params, this, consumes, produces, new DefaultMethodInvoker());
+ params, this, consumes, produces, getMethodInvoker());
SubResourceMethodDescriptor exist = null;
ResourceMethodMap<SubResourceMethodDescriptor> rmm =
- (ResourceMethodMap<SubResourceMethodDescriptor>)subResourceMethods.getMethodMap(subRes
- .getUriPattern());
+ subResourceMethods.getMethodMap(subRes.getUriPattern());
// rmm is never null, empty map instead
List<SubResourceMethodDescriptor> l = rmm.getList(httpMethod.value());
@@ -431,7 +466,7 @@
// sub-resource locator
SubResourceLocatorDescriptor loc =
new SubResourceLocatorDescriptorImpl(new PathValue(subPath.value()), method, params, this,
- new DefaultMethodInvoker());
+ getMethodInvoker());
if (!subResourceLocators.containsKey(loc.getUriPattern()))
{
subResourceLocators.put(loc.getUriPattern(), loc);
@@ -464,12 +499,12 @@
resourceMethods.sort();
subResourceMethods.sort();
- // sub-resource locators already sorted
+ // sub-resource locators already sorted
}
/**
* Create list of {@link MethodParameter} .
- *
+ *
* @param resourceClass class
* @param method See {@link Method}
* @return list of {@link MethodParameter}
@@ -478,7 +513,9 @@
{
Class<?>[] parameterClasses = method.getParameterTypes();
if (parameterClasses.length == 0)
+ {
return java.util.Collections.emptyList();
+ }
Type[] parameterGenTypes = method.getGenericParameterTypes();
Annotation[][] annotations = method.getParameterAnnotations();
@@ -543,8 +580,8 @@
* <p>
* On receipt of a HEAD request an implementation MUST either: 1. Call method
* annotated with request method designation for HEAD or, if none present, 2.
- * Call method annotated with a request method designation GET and discard any
- * returned entity.
+ * Call method annotated with a request method designation GET and discard
+ * any returned entity.
* </p>
*/
protected void resolveHeadRequest()
@@ -552,7 +589,9 @@
List<ResourceMethodDescriptor> getRes = resourceMethods.get(HttpMethod.GET);
if (getRes == null || getRes.size() == 0)
+ {
return; // nothing to do, there is not 'GET' methods
+ }
// If there is no methods for 'HEAD' anyway never return null.
// Instead null empty List will be returned.
@@ -561,15 +600,19 @@
for (ResourceMethodDescriptor rmd : getRes)
{
if (findMethodResourceMediaType(headRes, rmd.consumes(), rmd.produces()) == null)
+ {
headRes.add(new ResourceMethodDescriptorImpl(rmd.getMethod(), HttpMethod.HEAD, rmd.getMethodParameters(),
this, rmd.consumes(), rmd.produces(), rmd.getMethodInvoker()));
+ }
}
for (ResourceMethodMap<SubResourceMethodDescriptor> rmm : subResourceMethods.values())
{
List<SubResourceMethodDescriptor> getSubres = rmm.get(HttpMethod.GET);
if (getSubres == null || getSubres.size() == 0)
+ {
continue; // nothing to do, there is not 'GET' methods
+ }
// If there is no methods for 'HEAD' anyway never return null.
// Instead null empty List will be returned.
@@ -578,12 +621,12 @@
Iterator<SubResourceMethodDescriptor> i = getSubres.iterator();
while (i.hasNext())
{
- SubResourceMethodDescriptor srmd = (SubResourceMethodDescriptor)i.next();
+ SubResourceMethodDescriptor srmd = i.next();
if (findMethodResourceMediaType(headSubres, srmd.consumes(), srmd.produces()) == null)
{
headSubres.add(new SubResourceMethodDescriptorImpl(srmd.getPathValue(), srmd.getMethod(),
HttpMethod.HEAD, srmd.getMethodParameters(), this, srmd.consumes(), srmd.produces(),
- new DefaultMethodInvoker()));
+ getMethodInvoker()));
}
}
}
@@ -610,14 +653,14 @@
o.add(new OptionsRequestResourceMethodDescriptorImpl(null, "OPTIONS", mps, this, consumes, produces,
new OptionsRequestMethodInvoker()));
}
- // TODO need process sub-resources ?
+ // TODO need process sub-resources ?
}
/**
* Get all method with at least one annotation which has annotation
* <i>annotation</i>. It is useful for annotation {@link javax.ws.rs.GET},
* etc. All HTTP method annotations has annotation {@link HttpMethod}.
- *
+ *
* @param <T> annotation type
* @param m method
* @param annotation annotation class
@@ -629,7 +672,9 @@
{
T endPoint = null;
if ((endPoint = a.annotationType().getAnnotation(annotation)) != null)
+ {
return endPoint;
+ }
}
return null;
}
@@ -637,13 +682,13 @@
/**
* Tries to get JAX-RS annotation on method from the root resource class's
* superclass or implemented interfaces.
- *
+ *
* @param <T> annotation type
* @param method method for discovering
* @param resourceClass class that contains discovered method
* @param annotationClass annotation type what we are looking for
* @param metaAnnotation false if annotation should be on method and true in
- * method should contain annotations that has supplied annotation
+ * method should contain annotations that has supplied annotation
* @return annotation from class or its ancestor or null if nothing found
*/
protected <T extends Annotation> T getMethodAnnotation(Method method, Class<?> resourceClass,
@@ -652,9 +697,13 @@
T annotation = null;
if (metaAnnotation)
+ {
annotation = getMetaAnnotation(method, annotationClass);
+ }
else
+ {
annotation = method.getAnnotation(annotationClass);
+ }
if (annotation == null)
{
@@ -694,9 +743,13 @@
if (inhMethod != null)
{
if (metaAnnotation)
+ {
annotation = getMetaAnnotation(inhMethod, annotationClass);
+ }
else
+ {
annotation = inhMethod.getAnnotation(annotationClass);
+ }
}
}
@@ -706,7 +759,7 @@
/**
* Check is collection of {@link ResourceMethodDescriptor} already contains
* ResourceMethodDescriptor with the same media types.
- *
+ *
* @param rmds {@link Set} of {@link ResourceMethodDescriptor}
* @param consumes resource method consumed media type
* @param produces resource method produced media type
@@ -720,9 +773,13 @@
for (T rmd : rmds)
{
if (rmd.consumes().size() != consumes.size())
+ {
return null;
+ }
if (rmd.produces().size() != produces.size())
+ {
return null;
+ }
for (MediaType c1 : rmd.consumes())
{
boolean eq = false;
@@ -735,7 +792,9 @@
}
}
if (!eq)
+ {
return null;
+ }
}
for (MediaType p1 : rmd.produces())
@@ -750,7 +809,9 @@
}
}
if (!eq)
+ {
return null;
+ }
}
matched = rmd; // matched resource method
@@ -760,6 +821,15 @@
return matched;
}
+ protected MethodInvoker getMethodInvoker()
+ {
+ if (invokerFactory != null)
+ {
+ return invokerFactory.getMethodInvoker();
+ }
+ return new DefaultMethodInvoker();
+ }
+
/**
* {@inheritDoc}
*/
16 years, 2 months
exo-jcr SVN: r2366 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/statistics.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-05-12 05:02:25 -0400 (Wed, 12 May 2010)
New Revision: 2366
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/statistics/JCRStatisticsManager.java
Log:
EXOJCR-723: arguments of the methods are now described
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/statistics/JCRStatisticsManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/statistics/JCRStatisticsManager.java 2010-05-12 08:54:46 UTC (rev 2365)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/statistics/JCRStatisticsManager.java 2010-05-12 09:02:25 UTC (rev 2366)
@@ -21,6 +21,7 @@
import org.exoplatform.management.ManagementContext;
import org.exoplatform.management.annotations.Managed;
import org.exoplatform.management.annotations.ManagedDescription;
+import org.exoplatform.management.annotations.ManagedName;
import org.exoplatform.management.jmx.annotations.NameTemplate;
import org.exoplatform.management.jmx.annotations.Property;
import org.exoplatform.management.rest.annotations.RESTEndpoint;
@@ -375,7 +376,9 @@
*/
@Managed
@ManagedDescription("The minimum value of the time spent for one call.")
- public static long getMin(String category, String name)
+ public static long getMin(
+ @ManagedDescription("The name of the category of the statistics") @ManagedName("categoryName") String category,
+ @ManagedDescription("The name of the expected method or global for the global value") @ManagedName("statisticsName") String name)
{
Statistics statistics = getStatistics(category, name);
return statistics == null ? 0l : statistics.getMin();
@@ -387,7 +390,9 @@
*/
@Managed
@ManagedDescription("The maximum value of the time spent for one call.")
- public static long getMax(String category, String name)
+ public static long getMax(
+ @ManagedDescription("The name of the category of the statistics") @ManagedName("categoryName") String category,
+ @ManagedDescription("The name of the expected method or global for the global value") @ManagedName("statisticsName") String name)
{
Statistics statistics = getStatistics(category, name);
return statistics == null ? 0l : statistics.getMax();
@@ -399,7 +404,9 @@
*/
@Managed
@ManagedDescription("The total time spent for all the calls.")
- public static long getTotal(String category, String name)
+ public static long getTotal(
+ @ManagedDescription("The name of the category of the statistics") @ManagedName("categoryName") String category,
+ @ManagedDescription("The name of the expected method or global for the global value") @ManagedName("statisticsName") String name)
{
Statistics statistics = getStatistics(category, name);
return statistics == null ? 0l : statistics.getTotal();
@@ -411,7 +418,9 @@
*/
@Managed
@ManagedDescription("The total amount of calls.")
- public static long getTimes(String category, String name)
+ public static long getTimes(
+ @ManagedDescription("The name of the category of the statistics") @ManagedName("categoryName") String category,
+ @ManagedDescription("The name of the expected method or global for the global value") @ManagedName("statisticsName") String name)
{
Statistics statistics = getStatistics(category, name);
return statistics == null ? 0l : statistics.getTimes();
@@ -423,7 +432,9 @@
*/
@Managed
@ManagedDescription("The average value of the time spent for one call.")
- public static float getAvg(String category, String name)
+ public static float getAvg(
+ @ManagedDescription("The name of the category of the statistics") @ManagedName("categoryName") String category,
+ @ManagedDescription("The name of the expected method or global for the global value") @ManagedName("statisticsName") String name)
{
Statistics statistics = getStatistics(category, name);
return statistics == null ? 0l : statistics.getAvg();
@@ -436,7 +447,9 @@
*/
@Managed
@ManagedDescription("Reset the statistics.")
- public static void reset(String category, String name)
+ public static void reset(
+ @ManagedDescription("The name of the category of the statistics") @ManagedName("categoryName") String category,
+ @ManagedDescription("The name of the expected method or global for the global value") @ManagedName("statisticsName") String name)
{
Statistics statistics = getStatistics(category, name);
if (statistics != null)
@@ -451,7 +464,8 @@
*/
@Managed
@ManagedDescription("Reset all the statistics.")
- public static void resetAll(String category)
+ public static void resetAll(
+ @ManagedDescription("The name of the category of the statistics") @ManagedName("categoryName") String category)
{
StatisticsContext context = getContext(category);
if (context != null)
16 years, 2 months
exo-jcr SVN: r2365 - jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/kernel.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-05-12 04:54:46 -0400 (Wed, 12 May 2010)
New Revision: 2365
Modified:
jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/kernel/configuration.xml
Log:
EXOJCR-718: Doc
Modified: jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/kernel/configuration.xml
===================================================================
--- jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/kernel/configuration.xml 2010-05-12 08:54:02 UTC (rev 2364)
+++ jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/kernel/configuration.xml 2010-05-12 08:54:46 UTC (rev 2365)
@@ -1,1330 +1,1343 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
-"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
-<chapter>
- <?dbhtml filename="ch-configuration.html"?>
- <title>Configuration</title>
-
- <section>
- <title>Kernel configuration namespace</title>
-
- <para>To be effective the namespace URI <link
- linkend="???">http://www.exoplaform.org/xml/ns/kernel_1_1.xsd</link> must
- be target namespace of the XML configuration file.</para>
-
- <programlisting><xsd:schema
- targetNamespace="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"
- xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- elementFormDefault="qualified"
- attributeFormDefault="unqualified"
- version="1.0">
-
- ...
-</xsd:schema></programlisting>
- </section>
-
- <section>
- <title>Understanding How configuration files are loaded</title>
-
- <para>eXo Portal uses PicoContainer, which implements the Inversion of
- Control (IoC) design pattern. All eXo containers inherit from a
- PicoContainer. There are mainly two eXo containers used, each of them can
- provide one or several services. Each container service is delivered in a
- JAR file. This JAR file may contain a default configuration. The use of
- default configurations is recommended and most services provide it.</para>
-
- <para>When a Pico Container searches for services and its configurations,
- each configurable service may be reconfigured to override default values
- or set additional parameters. If the service is configured in two or more
- places the configuration override mechanism will be used.</para>
-
- <section>
- <title>Configuration Retrieval</title>
-
- <para>The container performs the following steps making eXo Container
- configuration retrieval depending on the container type.</para>
-
- <section>
- <title>Configuration retrieval order for the
- <envar>PortalContainer</envar></title>
-
- <para>The container is initialized by looking into different
- locations. This container is used by portal applications.
- Configurations are overloaded in the following lookup sequence:</para>
-
- <orderedlist>
- <listitem>
- <para>Services default <envar>RootContainer</envar> configurations
- from JAR files <emphasis>/conf/configuration.xml</emphasis></para>
- </listitem>
-
- <listitem>
- <para>External <envar>RootContainer</envar> configuration, if will
- be found at
- <emphasis>$AS_HOME/exo-conf/configuration.xml</emphasis></para>
- </listitem>
-
- <listitem>
- <para>Services default <envar>PortalContainer</envar>
- configurations from JAR files
- <emphasis>/conf/portal/configuration.xml</emphasis></para>
- </listitem>
-
- <listitem>
- <para>Web applications configurations from WAR files
- <emphasis>/WEB-INF/conf/configuration.xml</emphasis></para>
- </listitem>
-
- <listitem>
- <para>External configuration for services of named portal, if will
- be found at
- <emphasis>$AS_HOME/exo-conf/portal/$PORTAL_NAME/configuration.xml</emphasis></para>
- </listitem>
- </orderedlist>
- </section>
-
- <section>
- <title>Configuration retrieval for a
- <envar>StandaloneContainer</envar></title>
-
- <para>The container is initialized by looking into different
- locations. This container is used by non portal applications.
- Configurations are overloaded in the following lookup sequence:</para>
-
- <orderedlist>
- <listitem>
- <para>Services default <envar>RootContainer</envar> configurations
- from JAR files <emphasis>/conf/configuration.xml</emphasis></para>
- </listitem>
-
- <listitem>
- <para>External <envar>RootContainer</envar> configuration, if will
- be found at
- <emphasis>$AS_HOME/exo-conf/configuration.xml</emphasis></para>
- </listitem>
-
- <listitem>
- <para>Services default <envar>StandaloneContainer</envar>
- configurations from JAR files
- <emphasis>/conf/portal/configuration.xml</emphasis></para>
- </listitem>
-
- <listitem>
- <para>Web applications configurations from WAR files
- <emphasis>/WEB-INF/conf/configuration.xml</emphasis></para>
- </listitem>
-
- <listitem>
- <para>Then depending on the <envar>StandaloneContainer</envar>
- configuration URL initialization:</para>
-
- <itemizedlist>
- <listitem>
- <para>if configuration URL was initialized to be added to
- services defaults, as below:<programlisting>// add configuration to the default services configurations from JARs/WARs
-StandaloneContainer.addConfigurationURL(containerConf);</programlisting></para>
-
- <para>Configuration from added URL
- <emphasis>containerConf</emphasis> will override only services
- configured in the file</para>
- </listitem>
-
- <listitem>
- <para>if configuration URL not initialized at all, it will be
- found at <emphasis>$AS_HOME/exo-configuration.xml</emphasis>.
- If <emphasis>$AS_HOME/exo-configuration.xml</emphasis> doesn't
- exist the container will try find it at
- <emphasis>$AS_HOME/exo-conf/exo-configuration.xml</emphasis>
- location and if it's still not found and the
- <envar>StandaloneContainer</envar> instance obtained with the
- dedicated configuration <envar>ClassLoader</envar> the
- container will try to retrieve the resource
- <emphasis>conf/exo-configuration.xml</emphasis> within the
- given <envar>ClassLoader</envar>.</para>
- </listitem>
- </itemizedlist>
- </listitem>
- </orderedlist>
- </section>
-
- <section>
- <title>General notes about the configuration retrieval</title>
-
- <note>
- <para><emphasis>$AS_HOME</emphasis> - application server home
- directory, or <emphasis>user.dir</emphasis> JVM system property
- value in case of Java Standalone application.</para>
- </note>
-
- <note>
- <para><emphasis>$PORTAL_NAME</emphasis> - portal web application
- name.</para>
- </note>
-
- <note>
- <para>External configuration location can be overridden with System
- property <emphasis>exo.conf.dir</emphasis>. If the property exists
- its value will be used as path to eXo configuration directory, i.e.
- to <emphasis>$AS_HOME/exo-conf</emphasis> alternative. E.g. put
- property in command line java
- <emphasis>-Dexo.conf.dir=/path/to/exo/conf</emphasis>. In this
- particular use case, you have no need to use any prefix to import
- other files. For instance, if your configuration file is
- <emphasis>$AS_HOME/exo-conf/portal/PORTAL_NAME/configuration.xml</emphasis>
- and you want to import the configuration file
- <emphasis>$AS_HOME/exo-conf/portal/PORTAL_NAME/mySubConfDir/myConfig.xml</emphasis>,
- you can do it by adding
- <emphasis><import>mySubConfDir/myConfig.xml</import></emphasis>
- to your configuration file.</para>
- </note>
-
- <note>
- <para>The name of the configuration folder that is by default
- <emphasis>"exo-conf"</emphasis>, can be changed thanks to the System
- property <emphasis>exo.conf.dir.name</emphasis>.</para>
- </note>
-
- <note>
- <para>Under JBoss application server <emphasis>exo-conf</emphasis>
- will be looked up in directory described by JBoss System property
- <emphasis>jboss.server.config.url</emphasis>. If the property is not
- found or empty <emphasis>$AS_HOME/exo-conf</emphasis> will be
- asked.</para>
- </note>
-
- <note>
- <para>The search looks for a configuration file in each JAR/WAR
- available from the classpath using the current thread context
- classloader. During the search these configurations are added to a
- set. If the service was configured previously and the current JAR
- contains a new configuration of that service the latest (from the
- current JAR/WAR) will replace the previous one. The last one will be
- applied to the service during the services start phase.</para>
- </note>
-
- <warning>
- <para>Take care to have no dependencies between configurations from
- JAR files (<emphasis>/conf/portal/configuration.xml</emphasis> and
- <emphasis>/conf/configuration.xml</emphasis>) since we have no way
- to know in advance the loading order of those configurations. In
- other words, if you want to overload some configuration located in
- the file <emphasis>/conf/portal/configuration.xml</emphasis> of a
- given JAR file, you must not do it from the file
- <emphasis>/conf/portal/configuration.xml</emphasis> of another JAR
- file but from another configuration file loaded after configurations
- from JAR files
- <emphasis>/conf/portal/configuration.xml.</emphasis></para>
- </warning>
-
- <para>After the processing of all configurations available in system
- the container will initialize it and start each service in order of
- the dependency injection (DI).</para>
-
- <para>The user/developer should be careful when configuring the same
- service in different configuration files. It's recommended to
- configure a service in its own JAR only. Or, in case of a portal
- configuration, strictly reconfigure the services in portal WAR files
- or in an external configuration.</para>
-
- <para>There are services that can be (or should be) configured more
- than one time. This depends on business logic of the service. A
- service may initialize the same resource (shared with other services)
- or may add a particular object to a set of objects (shared with other
- services too). In the first case it's critical who will be the last,
- i.e. whose configuration will be used. In the second case it's no
- matter who is the first and who is the last (if the parameter objects
- are independent).</para>
- </section>
-
- <section>
- <title>Configuration retrieval log</title>
-
- <para>In case of problems with service configuration it's important to
- know from which JAR/WAR it comes. For that purpose the JVM system
- property
- <emphasis>org.exoplatform.container.configuration.debug</emphasis> can
- be used.<programlisting>java -Dorg.exoplatform.container.configuration.debug ...</programlisting></para>
-
- <para>If the property is enabled the container configuration manager
- will report the configuration adding process to the standard output
- (System.out).<programlisting>......
- Add configuration jar:file:/D:/Projects/eXo/dev/exo-working/exo-tomcat/lib/exo.kernel.container-trunk.jar!/conf/portal/configuration.xml
- Add configuration jar:file:/D:/Projects/eXo/dev/exo-working/exo-tomcat/lib/exo.kernel.component.cache-trunk.jar!/conf/portal/configuration.xml
- Add configuration jndi:/localhost/portal/WEB-INF/conf/configuration.xml
- import jndi:/localhost/portal/WEB-INF/conf/common/common-configuration.xml
- import jndi:/localhost/portal/WEB-INF/conf/database/database-configuration.xml
- import jndi:/localhost/portal/WEB-INF/conf/ecm/jcr-component-plugins-configuration.xml
- import jndi:/localhost/portal/WEB-INF/conf/jcr/jcr-configuration.xml
- ......</programlisting></para>
- </section>
- </section>
-
- <section>
- <title>Advanced concepts for the
- <emphasis>PortalContainers</emphasis></title>
-
- <para>Since eXo JCR 1.12, we added a set of new features that have been
- designed to extend portal applications such as GateIn.</para>
-
- <section>
- <title>Add new configuration files from a WAR file</title>
-
- <para>A <envar>ServletContextListener</envar> called
- <envar>org.exoplatform.container.web.PortalContainerConfigOwner</envar>
- has been added in order to notify the application that a given web
- application provides some configuration to the portal container, and
- this configuration file is the file
- <emphasis>WEB-INF/conf/configuration.xml</emphasis> available in the
- web application itself.</para>
-
- <para>If your war file contains some configuration to add to the
- <envar>PortalContainer</envar> simply add the following lines in your
- <emphasis>web.xml</emphasis> file.</para>
-
- <programlisting><?xml version="1.0" encoding="ISO-8859-1" ?>
-<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2_3.dtd">
-<web-app>
-...
- <!-- ================================================================== -->
- <!-- LISTENER -->
- <!-- ================================================================== -->
- <listener>
- <listener-class>org.exoplatform.container.web.PortalContainerConfigOwner</listener-class>
- </listener>
-...
-</web-app></programlisting>
- </section>
-
- <section>
- <title>Create your <emphasis>PortalContainers</emphasis> from a WAR
- file</title>
-
- <para>A <envar>ServletContextListener</envar> called
- <envar>org.exoplatform.container.web.PortalContainerCreator</envar>
- has been added in order to create the current portal containers that
- have been registered. We assume that all the web applications have
- already been loaded before calling
- <envar>PortalContainerCreator.contextInitialized<replaceable><optional>.</optional></replaceable></envar></para>
-
- <para><note>
- <para>In GateIn, the <envar>PortalContainerCreator</envar> is
- already managed by the file
- <emphasis>starter.war/ear.</emphasis></para>
- </note></para>
- </section>
-
- <section>
- <title>Define a <emphasis>PortalContainer</emphasis> with its
- dependencies and its settings</title>
-
- <para>Now we can define precisely a portal container and its
- dependencies and settings thanks to the
- <envar>PortalContainerDefinition</envar> that currently contains the
- name of the portal container, the name of the rest context, the name
- of the realm he web application dependencies ordered by loading
- priority (i.e. the first dependency must be loaded at first and so
- on..) and the settings.</para>
-
- <para>To be able to define a <envar>PortalContainerDefinition</envar>,
- we need to ensure first of all that a
- <envar>PortalContainerConfig</envar> has been defined at the
- <envar>RootContainer</envar> level, see below an example:</para>
-
- <programlisting> <component>
- <!-- The full qualified name of the PortalContainerConfig -->
- <type>org.exoplatform.container.definition.PortalContainerConfig</type>
- <init-params>
- <!-- The name of the default portal container -->
- <value-param>
- <name>default.portal.container</name>
- <value>myPortal</value>
- </value-param>
- <!-- The name of the default rest ServletContext -->
- <value-param>
- <name>default.rest.context</name>
- <value>myRest</value>
- </value-param>
- <!-- The name of the default realm -->
- <value-param>
- <name>default.realm.name</name>
- <value>my-exo-domain</value>
- </value-param>
- <!-- The default portal container definition -->
- <!-- It cans be used to avoid duplicating configuration -->
- <object-param>
- <name>default.portal.definition</name>
- <object type="org.exoplatform.container.definition.PortalContainerDefinition">
- <!-- All the dependencies of the portal container ordered by loading priority -->
- <field name="dependencies">
- <collection type="java.util.ArrayList">
- <value>
- <string>foo</string>
- </value>
- <value>
- <string>foo2</string>
- </value>
- <value>
- <string>foo3</string>
- </value>
- </collection>
- </field>
- <!-- A map of settings tied to the default portal container -->
- <field name="settings">
- <map type="java.util.HashMap">
- <entry>
- <key>
- <string>foo5</string>
- </key>
- <value>
- <string>value</string>
- </value>
- </entry>
- <entry>
- <key>
- <string>string</string>
- </key>
- <value>
- <string>value0</string>
- </value>
- </entry>
- <entry>
- <key>
- <string>int</string>
- </key>
- <value>
- <int>100</int>
- </value>
- </entry>
- </map>
- </field>
- <!-- The path to the external properties file -->
- <field name="externalSettingsPath">
- <string>classpath:/org/exoplatform/container/definition/default-settings.properties</string>
- </field>
- </object>
- </object-param>
- </init-params>
- </component></programlisting>
-
- <table>
- <title>Descriptions of the fields of
- <envar>PortalContainerConfig</envar></title>
-
- <tgroup cols="2">
- <tbody>
- <row>
- <entry>default.portal.container</entry>
-
- <entry>The name of the default portal container. This field is
- optional.</entry>
- </row>
-
- <row>
- <entry>default.rest.context</entry>
-
- <entry>The name of the default rest
- <envar>ServletContext</envar>. This field is optional.</entry>
- </row>
-
- <row>
- <entry>default.realm.name</entry>
-
- <entry>The name of the default realm. This field is
- optional.</entry>
- </row>
-
- <row>
- <entry>default.portal.definition</entry>
-
- <entry>The definition of the default portal container. This
- field is optional. The expected type is
- <envar>org.exoplatform.container.definition.PortalContainerDefinition</envar>
- that is described below. Allow the parameters defined in this
- default <envar>PortalContainerDefinition</envar> will be the
- default values.</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
- <para>A new <envar>PortalContainerDefinition</envar> can be defined at
- the <envar>RootContainer</envar> level thanks to an external plugin,
- see below an example:<programlisting> <external-component-plugins>
- <!-- The full qualified name of the PortalContainerConfig -->
- <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
- <component-plugin>
- <!-- The name of the plugin -->
- <name>Add PortalContainer Definitions</name>
- <!-- The name of the method to call on the PortalContainerConfig in order to register the PortalContainerDefinitions -->
- <set-method>registerPlugin</set-method>
- <!-- The full qualified name of the PortalContainerDefinitionPlugin -->
- <type>org.exoplatform.container.definition.PortalContainerDefinitionPlugin</type>
- <init-params>
- <object-param>
- <name>portal</name>
- <object type="org.exoplatform.container.definition.PortalContainerDefinition">
- <!-- The name of the portal container -->
- <field name="name">
- <string>myPortal</string>
- </field>
- <!-- The name of the context name of the rest web application -->
- <field name="restContextName">
- <string>myRest</string>
- </field>
- <!-- The name of the realm -->
- <field name="realmName">
- <string>my-domain</string>
- </field>
- <!-- All the dependencies of the portal container ordered by loading priority -->
- <field name="dependencies">
- <collection type="java.util.ArrayList">
- <value>
- <string>foo</string>
- </value>
- <value>
- <string>foo2</string>
- </value>
- <value>
- <string>foo3</string>
- </value>
- </collection>
- </field>
- <!-- A map of settings tied to the portal container -->
- <field name="settings">
- <map type="java.util.HashMap">
- <entry>
- <key>
- <string>foo</string>
- </key>
- <value>
- <string>value</string>
- </value>
- </entry>
- <entry>
- <key>
- <string>int</string>
- </key>
- <value>
- <int>10</int>
- </value>
- </entry>
- <entry>
- <key>
- <string>long</string>
- </key>
- <value>
- <long>10</long>
- </value>
- </entry>
- <entry>
- <key>
- <string>double</string>
- </key>
- <value>
- <double>10</double>
- </value>
- </entry>
- <entry>
- <key>
- <string>boolean</string>
- </key>
- <value>
- <boolean>true</boolean>
- </value>
- </entry>
- </map>
- </field>
- <!-- The path to the external properties file -->
- <field name="externalSettingsPath">
- <string>classpath:/org/exoplatform/container/definition/settings.properties</string>
- </field>
- </object>
- </object-param>
- </init-params>
- </component-plugin>
- </external-component-plugins></programlisting></para>
-
- <table>
- <title>Descriptions of the fields of
- <envar>PortalContainerDefinition</envar> when it is used to define a
- new portal container</title>
-
- <tgroup cols="2">
- <tbody>
- <row>
- <entry>name</entry>
-
- <entry>The name of the portal container. This field is
- mandatory .</entry>
- </row>
-
- <row>
- <entry>restContextName</entry>
-
- <entry>The name of the context name of the rest web
- application. This field is optional. The default value will
- the value define at the <envar>PortalContainerConfig</envar>
- level.</entry>
- </row>
-
- <row>
- <entry>realmName</entry>
-
- <entry>The name of the realm. This field is optional. The
- default value will the value define at the
- <envar>PortalContainerConfig</envar> level.</entry>
- </row>
-
- <row>
- <entry>dependencies</entry>
-
- <entry>All the dependencies of the portal container ordered by
- loading priority. This field is optional. The default value
- will the value define at the
- <envar>PortalContainerConfig</envar> level. The dependencies
- are in fact the list of the context names of the web
- applications from which the portal container depends. This
- field is optional. The dependency order is really crucial
- since it will be interpreted the same way by several
- components of the platform. All those components, will
- consider the 1st element in the list less important than the
- second element and so on. It is currently used
- to:<itemizedlist>
- <listitem>
- <para>Know the loading order of all the
- dependencies.</para>
- </listitem>
-
- <listitem>
- <para>If we have several
- <envar>PortalContainerConfigOwner</envar><itemizedlist>
- <listitem>
- <para>The <envar>ServletContext</envar> of all the
- <envar>PortalContainerConfigOwner</envar> will be
- unified, if we use the unified
- <envar>ServletContext</envar>
- (<emphasis>PortalContainer.getPortalContext()</emphasis>)
- to get a resource, it will try to get the resource
- in the <envar>ServletContext</envar> of the most
- important <envar>PortalContainerConfigOwner</envar>
- (i.e. last in the dependency list) and if it cans
- find it, it will try with the second most important
- <envar>PortalContainerConfigOwner</envar> and so
- on.</para>
- </listitem>
-
- <listitem>
- <para>The <envar>ClassLoader</envar> of all the
- <envar>PortalContainerConfigOwner</envar> will be
- unified, if we use the unified
- <envar>ClassLoader</envar>
- (<emphasis>PortalContainer.getPortalClassLoader()</emphasis>)
- to get a resource, it will try to get the resource
- in the <envar>ClassLoader</envar> of the most
- important <envar>PortalContainerConfigOwner</envar>
- (i.e. last in the dependency list) and if it cans
- find it, it will try with the second most important
- <envar>PortalContainerConfigOwner</envar> and so
- on.</para>
- </listitem>
- </itemizedlist></para>
- </listitem>
- </itemizedlist></entry>
- </row>
-
- <row>
- <entry>settings</entry>
-
- <entry>A <envar>java.util.Map</envar> of internal parameters
- that we would like to tie the portal container. Those
- parameters could have any type of value. This field is
- optional. If some internal settings are defined at the
- <envar>PortalContainerConfig</envar> level, the two maps of
- settings will be merged. If a setting with the same name is
- defined in both maps, it will keep the value defined at the
- <envar>PortalContainerDefinition</envar> level.</entry>
- </row>
-
- <row>
- <entry>externalSettingsPath</entry>
-
- <entry>The path of the external properties file to load as
- default settings to the portal container. This field is
- optional. If some external settings are defined at the
- <envar>PortalContainerConfig</envar> level, the two maps of
- settings will be merged. If a setting with the same name is
- defined in both maps, it will keep the value defined at the
- <envar>PortalContainerDefinition</envar> level. The external
- properties files can be either of type "properties" or of type
- "xml". The path will be interpreted as follows:<orderedlist>
- <listitem>
- <para>The path doesn't contain any prefix of type
- "classpath:", "jar:" or "file:", we assume that the file
- could be externalized so we apply the following
- rules:<orderedlist>
- <listitem>
- <para>A file exists at
- <emphasis>${exo-conf-dir}/portal/${portalContainerName}/${externalSettingsPath}</emphasis>,
- we will load this file.</para>
- </listitem>
-
- <listitem>
- <para>No file exists at the previous path, we then
- assume that the path cans be interpreted by the
- <envar>ConfigurationManager</envar>.</para>
- </listitem>
- </orderedlist></para>
- </listitem>
-
- <listitem>
- <para>The path contains a prefix, we then assume that
- the path cans be interpreted by the
- <envar>ConfigurationManager</envar>.</para>
- </listitem>
- </orderedlist></entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
- <table>
- <title>Descriptions of the fields of
- <envar>PortalContainerDefinition</envar> when it is used to define
- the default portal container</title>
-
- <tgroup cols="2">
- <tbody>
- <row>
- <entry>name</entry>
-
- <entry>The name of the portal container. This field is
- optional. The default portal name will be:<orderedlist>
- <listitem>
- <para>If this field is not empty, then the default value
- will be the value of this field.</para>
- </listitem>
-
- <listitem>
- <para>If this field is empty and the value of the
- parameter <emphasis>default.portal.container</emphasis>
- is not empty, then the default value will be the value
- of the parameter.</para>
- </listitem>
-
- <listitem>
- <para>If this field and the parameter
- <emphasis>default.portal.container</emphasis> are both
- empty, the default value will be
- <emphasis>"portal".</emphasis></para>
- </listitem>
- </orderedlist></entry>
- </row>
-
- <row>
- <entry>restContextName</entry>
-
- <entry>The name of the context name of the rest web
- application. This field is optional. The default value wil
- be:<orderedlist>
- <listitem>
- <para>If this field is not empty, then the default value
- will be the value of this field.</para>
- </listitem>
-
- <listitem>
- <para>f this field is empty and the value of the
- parameter <emphasis>default.rest.context</emphasis> is
- not empty, then the default value will be the value of
- the parameter.</para>
- </listitem>
-
- <listitem>
- <para>f this field and the parameter
- <emphasis>default.rest.context</emphasis> are both
- empty, the default value will be
- <emphasis>"rest".</emphasis></para>
- </listitem>
- </orderedlist></entry>
- </row>
-
- <row>
- <entry>realmName</entry>
-
- <entry>The name of the realm. This field is optional. The
- default value wil be:<orderedlist>
- <listitem>
- <para>If this field is not empty, then the default value
- will be the value of this field.</para>
- </listitem>
-
- <listitem>
- <para>f this field is empty and the value of the
- parameter <emphasis>default.realm.name</emphasis> is not
- empty, then the default value will be the value of the
- parameter.</para>
- </listitem>
-
- <listitem>
- <para>f this field and the parameter
- <emphasis>default.realm.name</emphasis> are both empty,
- the default value will be
- <emphasis>"exo-domain".</emphasis></para>
- </listitem>
- </orderedlist></entry>
- </row>
-
- <row>
- <entry>dependencies</entry>
-
- <entry>All the dependencies of the portal container ordered by
- loading priority. This field is optional. If this field has a
- non empty value, it will be the default list of
- dependencies.</entry>
- </row>
-
- <row>
- <entry>settings</entry>
-
- <entry>A <envar>java.util.Map</envar> of internal parameters
- that we would like to tie the default portal container. Those
- parameters could have any type of value. This field is
- optional.</entry>
- </row>
-
- <row>
- <entry>externalSettingsPath</entry>
-
- <entry>The path of the external properties file to load as
- default settings to the default portal container. This field
- is optional. The external properties files can be either of
- type "properties" or of type "xml". The path will be
- interpreted as follows:<orderedlist>
- <listitem>
- <para>The path doesn't contain any prefix of type
- "classpath:", "jar:" or "file:", we assume that the file
- could be externalized so we apply the following
- rules:<orderedlist>
- <listitem>
- <para>A file exists at
- <emphasis>${exo-conf-dir}/portal/${externalSettingsPath}</emphasis>,
- we will load this file.</para>
- </listitem>
-
- <listitem>
- <para>No file exists at the previous path, we then
- assume that the path cans be interpreted by the
- <envar>ConfigurationManager</envar>.</para>
- </listitem>
- </orderedlist></para>
- </listitem>
-
- <listitem>
- <para>The path contains a prefix, we then assume that
- the path cans be interpreted by the
- <envar>ConfigurationManager</envar>.</para>
- </listitem>
- </orderedlist></entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
- <para>Internal and external settings are both optional, but if we give
- a non empty value for both the application will merge the settings. If
- the same setting name exists in both settings, we apply the following
- rules:</para>
-
- <orderedlist>
- <listitem>
- <para>The value of the external setting is
- <emphasis>null</emphasis>, we ignore the value.</para>
- </listitem>
-
- <listitem>
- <para>The value of the external setting is not
- <emphasis>null</emphasis> and the value of the internal setting is
- <emphasis>null</emphasis>, the final value will be the external
- setting value that is of type <envar>String</envar>.</para>
- </listitem>
-
- <listitem>
- <para>Both values are not <envar>null</envar>, we will have to
- convert the external setting value into the target type which is
- the type of the internal setting value, thanks to the static
- method <emphasis>valueOf(String)</emphasis>, the following
- sub-rules are then applied:</para>
-
- <orderedlist>
- <listitem>
- <para>The method cannot be found, the final value will be the
- external setting value that is of type
- <envar>String</envar>.</para>
- </listitem>
-
- <listitem>
- <para>The method can be found and the external setting value
- is an empty <envar>String</envar>, we ignore the external
- setting value.</para>
- </listitem>
-
- <listitem>
- <para>The method can be found and the external setting value
- is not an empty <envar>String</envar> but the method call
- fails, we ignore the external setting value.</para>
- </listitem>
-
- <listitem>
- <para>The method can be found and the external setting value
- is not an empty <envar>String</envar> and the method call
- succeeds, the final value will be the external setting value
- that is of type of the internal setting value.</para>
- </listitem>
- </orderedlist>
- </listitem>
- </orderedlist>
- </section>
-
- <section>
- <title><envar>PortalContainer</envar> settings</title>
-
- <para>We can inject the value of the portal container settings into
- the portal container configuration files thanks to the variables which
- name start with "<emphasis>portal.container.</emphasis>", so to get
- the value of a setting called "<emphasis>foo</emphasis>" just use the
- following syntax <emphasis>${portal.container.foo}</emphasis>. You can
- also use internal variables, such as:</para>
-
- <table>
- <title>Definition of the internal variables</title>
-
- <tgroup cols="2">
- <tbody>
- <row>
- <entry>portal.container.name</entry>
-
- <entry>Gives the name of the current portal container.</entry>
- </row>
-
- <row>
- <entry>portal.container.rest</entry>
-
- <entry>Gives the context name of the rest web application of
- the current portal container.</entry>
- </row>
-
- <row>
- <entry>portal.container.realm</entry>
-
- <entry>Gives the realm name of the current portal
- container.</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
- <para>You can find below an example of how to use the
- variables:<programlisting><configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"
- xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd">
- <component>
- <type>org.exoplatform.container.TestPortalContainer$MyComponent</type>
- <init-params>
- <!-- The name of the portal container -->
- <value-param>
- <name>portal</name>
- <value>${portal.container.name}</value>
- </value-param>
- <!-- The name of the rest ServletContext -->
- <value-param>
- <name>rest</name>
- <value>${portal.container.rest}</value>
- </value-param>
- <!-- The name of the realm -->
- <value-param>
- <name>realm</name>
- <value>${portal.container.realm}</value>
- </value-param>
- <value-param>
- <name>foo</name>
- <value>${portal.container.foo}</value>
- </value-param>
- <value-param>
- <name>before foo after</name>
- <value>before ${portal.container.foo} after</value>
- </value-param>
- </init-params>
- </component>
-</configuration></programlisting></para>
-
- <para>In the properties file corresponding to the external settings,
- you can reuse variables previously defined (in the external settings
- or in the internal settings) to create a new variable. In this case
- the prefix "<emphasis>portal.container.</emphasis>" is not needed, see
- an example below:<programlisting>my-var1=value 1
-my-var2=value 2
-complex-value=${my-var1}-${my-var2}</programlisting></para>
-
- <para>In the external and internal settings, you can also use create
- variables based on value of System paramaters. The System parameters
- can either be defined at launch time or thanks to the
- <envar>PropertyConfigurator</envar> (see next section for more
- details). See an example below:</para>
-
- <programlisting>temp-dir=${java.io.tmpdir}${file.separator}my-temp</programlisting>
-
- <para>However, for the internal settings you can use System parameters
- only to define settings of type
- <envar>java.lang.String</envar>.</para>
-
- <para>It cans be also very usefull to define a generic variable in the
- settings of the default portal container, the value of this variable
- will change according to the current portal container. See below an
- example:<programlisting>my-generic-var=value of the portal container "${name}"</programlisting></para>
-
- <para>If this variable is defined at the default portal container
- level, the value of this variable for a portal container called
- <emphasis>"foo"</emphasis> will be <emphasis>value of the portal
- container "foo"</emphasis>.</para>
- </section>
- </section>
- </section>
-
- <section>
- <title>System property configuration</title>
-
- <para>A new property configurator service has been developed for taking
- care of configuring system properties from the inline kernel configuration
- or from specified property files.</para>
-
- <para>The services is scoped at the root container level because it is
- used by all the services in the different portal containers in the
- application runtime.</para>
-
- <section>
- <title>Properties init param</title>
-
- <para>The properties init param takes a property declared to configure
- various properties.</para>
-
- <programlisting><component>
- <key>PropertyManagerConfigurator</key>
- <type>org.exoplatform.container.PropertyConfigurator</type>
- <init-params>
- <properties-param>
- <name>properties</name>
- <property name="foo" value="bar"/>
- </properties-param>
- </init-params>
-</component></programlisting>
- </section>
-
- <section>
- <title>Properties URL init param</title>
-
- <para>The properties URL init param allow to load an external file by
- specifying its URL. Both property and XML format are supported, see the
- javadoc of the <emphasis><envar>java.util.Properties</envar></emphasis>
- class for more information. When a property file is loaded the various
- property declarations are loaded in the order in which the properties
- are declared sequentially in the file.</para>
-
- <programlisting><component>
- <key>PropertyManagerConfigurator</key>
- <type>org.exoplatform.container.PropertyConfigurator</type>
- <init-params>
- <value-param>
- <name>properties.url</name>
- <value>classpath:configuration.properties</value>
- </value-param>
- </init-params>
-</component></programlisting>
-
- <para>In the properties file corresponding to the external properties,
- you can reuse variables previously defined to create a new variable. In
- this case the prefix "<emphasis>portal.container.</emphasis>" is not
- needed, see an example below:<programlisting>my-var1=value 1
-my-var2=value 2
-complex-value=${my-var1}-${my-var2}</programlisting></para>
- </section>
-
- <section>
- <title>System Property configuration of the properties URL</title>
-
- <para>It is possible to replace the properties URL init param by a
- system property that overwrites it. The name of that property is
- <emphasis>exo.properties.url</emphasis>.</para>
- </section>
- </section>
-
- <section>
- <title>Runtime configuration profiles</title>
-
- <para>The kernel configuration is able to handle configuration profiles at
- runtime (as opposed to packaging time).</para>
-
- <section>
- <title>Profiles activation</title>
-
- <para>An active profile list is obtained during the boot of the root
- container and is composed of the system property
- <emphasis>exo.profiles</emphasis> sliced according the "," delimiter and
- also a server specific profile value (tomcat for tomcat, jboss for
- jboss, etc...).</para>
-
- <programlisting># runs GateIn on Tomcat with the profiles tomcat and foo
-sh gatein.sh -Dexo.profiles=foo
-
-# runs GateIn on JBoss with the profiles jboss, foo and bar
-sh run.sh -Dexo.profiles=foo,bar</programlisting>
- </section>
-
- <section>
- <title>Profiles configuration</title>
-
- <para>Profiles are configured in the configuration files of the eXo
- kernel.</para>
-
- <section>
- <title>Profiles definition</title>
-
- <para>Profile activation occurs at XML to configuration object
- unmarshalling time. It is based on an "profile" attribute that is
- present on some of the XML element of the configuration files. To
- enable this the kernel configuration schema has been upgraded to
- kernel_1_1.xsd. The configuration is based on the following
- rules:</para>
-
- <orderedlist>
- <listitem>
- <para>Any kernel element with the no <emphasis>profiles</emphasis>
- attribute will create a configuration object</para>
- </listitem>
-
- <listitem>
- <para>Any kernel element having a <emphasis>profiles</emphasis>
- attribute containing at least one of the active profiles will
- create a configuration object</para>
- </listitem>
-
- <listitem>
- <para>Any kernel element having a <emphasis>profiles</emphasis>
- attribute matching none of the active profile will not create a
- configuration object</para>
- </listitem>
-
- <listitem>
- <para>Resolution of duplicates (such as two components with same
- type) is left up to the kernel</para>
- </listitem>
- </orderedlist>
- </section>
-
- <section>
- <title>Profiles capable configuration elements</title>
-
- <para>A configuration element is <emphasis>profiles</emphasis> capable
- when it carries a profiles element.</para>
-
- <section>
- <title>Component element</title>
-
- <para>The component element declares a component when activated. It
- will shadow any element with the same key declared before in the
- same configuration file:</para>
-
- <programlisting><component>
- <key>Component</key>
- <type>Component</type>
-</component>
-
-<component profile="foo">
- <key>Component</key>
- <type>FooComponent</type>
-</component></programlisting>
- </section>
-
- <section>
- <title>Import element</title>
-
- <para>The import element imports a referenced configuration file
- when activated:</para>
-
- <programlisting><import>empty</import>
-<import profile="foo">foo</import>
-<import profile="bar">bar</import></programlisting>
- </section>
-
- <section>
- <title>Init param element</title>
-
- <para>The init param element configures the parameter argument of
- the construction of a component service:</para>
-
- <programlisting><component>
- <key>Component</key>
- <type>ComponentImpl</type>
- <init-params>
- <value-param>
- <name>param</name>
- <value>empty</value>
- </value-param>
- <value-param profile="foo">
- <name>param</name>
- <value>foo</value>
- </value-param>
- <value-param profile="bar">
- <name>param</name>
- <value>bar</value>
- </value-param>
- </init-params>
-</component></programlisting>
- </section>
-
- <section>
- <title>Value collection element</title>
-
- <para>The value collection element configures one of the value of
- collection data:</para>
-
- <programlisting><object type="org.exoplatform.container.configuration.ConfigParam">
- <field name="role">
- <collection type="java.util.ArrayList">
- <value><string>manager</string></value>
- <value profile="foo"><string>foo_manager</string></value>
- <value profile="foo,bar"><string>foo_bar_manager</string></value>
- </collection>
- </field>
-</object></programlisting>
- </section>
-
- <section>
- <title>Field configuration element</title>
-
- <para>The field configuration element configures the field of an
- object:</para>
-
- <programlisting><object-param>
- <name>test.configuration</name>
- <object type="org.exoplatform.container.configuration.ConfigParam">
- <field name="role">
- <collection type="java.util.ArrayList">
- <value><string>manager</string></value>
- </collection>
- </field>
- <field name="role" profile="foo,bar">
- <collection type="java.util.ArrayList">
- <value><string>foo_bar_manager</string></value>
- </collection>
- </field>
- <field name="role" profile="foo">
- <collection type="java.util.ArrayList">
- <value><string>foo_manager</string></value>
- </collection>
- </field>
- </object>
-</object-param></programlisting>
- </section>
- </section>
- </section>
- </section>
-
- <section>
- <title>Component request life cycle</title>
-
- <section>
- <title>Component request life cycle contract</title>
-
- <para>The component request life cycle is an interface that defines a
- contract for a component for being involved into a
- request:<programlisting>public interface ComponentRequestLifecycle
-{
- /**
- * Start a request.
- * @param container the related container
- */
- void startRequest(ExoContainer container);
-
- /**
- * Ends a request.
- * @param container the related container
- */
- void endRequest(ExoContainer container);
-}</programlisting></para>
-
- <para>The container passed is the container to which the component is
- related. This contract is often used to setup a thread local based
- context that will be demarcated by a request.</para>
-
- <para>For instance in the GateIn portal context, a component request
- life cycle is triggered for user requests. Another example is the
- initial data import in GateIn that demarcates using callbacks made to
- that interface.</para>
- </section>
-
- <section>
- <title>Request life cycle</title>
-
- <para>The <envar>RequestLifeCycle</envar> class has several statics
- methods that are used to schedule the component request life cycle of
- components. Its main responsability is to perform scheduling while
- respecting the constraint to execute the request life cycle of a
- component only once even if it can be scheduled several times.</para>
-
- <section>
- <title>Scheduling a component request life cycle</title>
-
- <programlisting>RequestLifeCycle.begin(component);
-try
-{
- // Do something
-}
-finally
-{
- RequestLifeCycle.end();
-}</programlisting>
- </section>
-
- <section>
- <title>Scheduling a container request life cycle</title>
-
- <para>Scheduling a container triggers the component request life cyle
- of all the components that implement the interface
- <envar>ComponentRequestLifeCycle</envar>. If one of the component has
- already been scheduled before then that component will not be
- scheduled again. When the local value is true then the looked
- components will be those of the container, when it is false then the
- scheduler will also look at the components in the ancestor
- containers.<programlisting>RequestLifeCycle.begin(container, local);
-try
-{
- // Do something
-}
-finally
-{
- RequestLifeCycle.end();
-}</programlisting></para>
- </section>
- </section>
-
- <section>
- <title>When request life cycle is triggered</title>
-
- <section>
- <title>Portal request life cycle</title>
-
- <para>Each portal request triggers the life cycle of the associated
- portal container.</para>
- </section>
-
- <section>
- <title>JMX request Life Cycle</title>
-
- <para>When a JMX bean is invoked, the request life cycle of the
- container to which it belongs it scheduled. Indeed JMX is an entry
- point of the system that may need component to have a request life
- cycle triggered.</para>
- </section>
- </section>
- </section>
-</chapter>
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<chapter>
+ <?dbhtml filename="ch-configuration.html"?>
+
+ <title>Configuration</title>
+
+ <section>
+ <title>Kernel configuration namespace</title>
+
+ <para>To be effective the namespace URI <link
+ linkend="???">http://www.exoplaform.org/xml/ns/kernel_1_1.xsd</link> must
+ be target namespace of the XML configuration file.</para>
+
+ <programlisting><xsd:schema
+ targetNamespace="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"
+ xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="1.0">
+
+ ...
+</xsd:schema></programlisting>
+ </section>
+
+ <section>
+ <title>Understanding How configuration files are loaded</title>
+
+ <para>eXo Portal uses PicoContainer, which implements the Inversion of
+ Control (IoC) design pattern. All eXo containers inherit from a
+ PicoContainer. There are mainly two eXo containers used, each of them can
+ provide one or several services. Each container service is delivered in a
+ JAR file. This JAR file may contain a default configuration. The use of
+ default configurations is recommended and most services provide it.</para>
+
+ <para>When a Pico Container searches for services and its configurations,
+ each configurable service may be reconfigured to override default values
+ or set additional parameters. If the service is configured in two or more
+ places the configuration override mechanism will be used.</para>
+
+ <section>
+ <title>Configuration Retrieval</title>
+
+ <para>The container performs the following steps making eXo Container
+ configuration retrieval depending on the container type.</para>
+
+ <section>
+ <title>Configuration retrieval order for the
+ <envar>PortalContainer</envar></title>
+
+ <para>The container is initialized by looking into different
+ locations. This container is used by portal applications.
+ Configurations are overloaded in the following lookup sequence:</para>
+
+ <orderedlist>
+ <listitem>
+ <para>Services default <envar>RootContainer</envar> configurations
+ from JAR files <emphasis>/conf/configuration.xml</emphasis></para>
+ </listitem>
+
+ <listitem>
+ <para>External <envar>RootContainer</envar> configuration, if will
+ be found at
+ <emphasis>$AS_HOME/exo-conf/configuration.xml</emphasis></para>
+ </listitem>
+
+ <listitem>
+ <para>Services default <envar>PortalContainer</envar>
+ configurations from JAR files
+ <emphasis>/conf/portal/configuration.xml</emphasis></para>
+ </listitem>
+
+ <listitem>
+ <para>Web applications configurations from WAR files
+ <emphasis>/WEB-INF/conf/configuration.xml</emphasis></para>
+ </listitem>
+
+ <listitem>
+ <para>External configuration for services of named portal, if will
+ be found at
+ <emphasis>$AS_HOME/exo-conf/portal/$PORTAL_NAME/configuration.xml</emphasis></para>
+ </listitem>
+ </orderedlist>
+ </section>
+
+ <section>
+ <title>Configuration retrieval for a
+ <envar>StandaloneContainer</envar></title>
+
+ <para>The container is initialized by looking into different
+ locations. This container is used by non portal applications.
+ Configurations are overloaded in the following lookup sequence:</para>
+
+ <orderedlist>
+ <listitem>
+ <para>Services default <envar>RootContainer</envar> configurations
+ from JAR files <emphasis>/conf/configuration.xml</emphasis></para>
+ </listitem>
+
+ <listitem>
+ <para>External <envar>RootContainer</envar> configuration, if will
+ be found at
+ <emphasis>$AS_HOME/exo-conf/configuration.xml</emphasis></para>
+ </listitem>
+
+ <listitem>
+ <para>Services default <envar>StandaloneContainer</envar>
+ configurations from JAR files
+ <emphasis>/conf/portal/configuration.xml</emphasis></para>
+ </listitem>
+
+ <listitem>
+ <para>Web applications configurations from WAR files
+ <emphasis>/WEB-INF/conf/configuration.xml</emphasis></para>
+ </listitem>
+
+ <listitem>
+ <para>Then depending on the <envar>StandaloneContainer</envar>
+ configuration URL initialization:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>if configuration URL was initialized to be added to
+ services defaults, as below:<programlisting>// add configuration to the default services configurations from JARs/WARs
+StandaloneContainer.addConfigurationURL(containerConf);</programlisting></para>
+
+ <para>Configuration from added URL
+ <emphasis>containerConf</emphasis> will override only services
+ configured in the file</para>
+ </listitem>
+
+ <listitem>
+ <para>if configuration URL not initialized at all, it will be
+ found at <emphasis>$AS_HOME/exo-configuration.xml</emphasis>.
+ If <emphasis>$AS_HOME/exo-configuration.xml</emphasis> doesn't
+ exist the container will try find it at
+ <emphasis>$AS_HOME/exo-conf/exo-configuration.xml</emphasis>
+ location and if it's still not found and the
+ <envar>StandaloneContainer</envar> instance obtained with the
+ dedicated configuration <envar>ClassLoader</envar> the
+ container will try to retrieve the resource
+ <emphasis>conf/exo-configuration.xml</emphasis> within the
+ given <envar>ClassLoader</envar>.</para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </orderedlist>
+ </section>
+
+ <section>
+ <title>General notes about the configuration retrieval</title>
+
+ <note>
+ <para><emphasis>$AS_HOME</emphasis> - application server home
+ directory, or <emphasis>user.dir</emphasis> JVM system property
+ value in case of Java Standalone application.</para>
+ </note>
+
+ <note>
+ <para><emphasis>$PORTAL_NAME</emphasis> - portal web application
+ name.</para>
+ </note>
+
+ <note>
+ <para>External configuration location can be overridden with System
+ property <emphasis>exo.conf.dir</emphasis>. If the property exists
+ its value will be used as path to eXo configuration directory, i.e.
+ to <emphasis>$AS_HOME/exo-conf</emphasis> alternative. E.g. put
+ property in command line java
+ <emphasis>-Dexo.conf.dir=/path/to/exo/conf</emphasis>. In this
+ particular use case, you have no need to use any prefix to import
+ other files. For instance, if your configuration file is
+ <emphasis>$AS_HOME/exo-conf/portal/PORTAL_NAME/configuration.xml</emphasis>
+ and you want to import the configuration file
+ <emphasis>$AS_HOME/exo-conf/portal/PORTAL_NAME/mySubConfDir/myConfig.xml</emphasis>,
+ you can do it by adding
+ <emphasis><import>mySubConfDir/myConfig.xml</import></emphasis>
+ to your configuration file.</para>
+ </note>
+
+ <note>
+ <para>The name of the configuration folder that is by default
+ <emphasis>"exo-conf"</emphasis>, can be changed thanks to the System
+ property <emphasis>exo.conf.dir.name</emphasis>.</para>
+ </note>
+
+ <note>
+ <para>Under JBoss application server <emphasis>exo-conf</emphasis>
+ will be looked up in directory described by JBoss System property
+ <emphasis>jboss.server.config.url</emphasis>. If the property is not
+ found or empty <emphasis>$AS_HOME/exo-conf</emphasis> will be
+ asked.</para>
+ </note>
+
+ <note>
+ <para>The search looks for a configuration file in each JAR/WAR
+ available from the classpath using the current thread context
+ classloader. During the search these configurations are added to a
+ set. If the service was configured previously and the current JAR
+ contains a new configuration of that service the latest (from the
+ current JAR/WAR) will replace the previous one. The last one will be
+ applied to the service during the services start phase.</para>
+ </note>
+
+ <warning>
+ <para>Take care to have no dependencies between configurations from
+ JAR files (<emphasis>/conf/portal/configuration.xml</emphasis> and
+ <emphasis>/conf/configuration.xml</emphasis>) since we have no way
+ to know in advance the loading order of those configurations. In
+ other words, if you want to overload some configuration located in
+ the file <emphasis>/conf/portal/configuration.xml</emphasis> of a
+ given JAR file, you must not do it from the file
+ <emphasis>/conf/portal/configuration.xml</emphasis> of another JAR
+ file but from another configuration file loaded after configurations
+ from JAR files
+ <emphasis>/conf/portal/configuration.xml.</emphasis></para>
+ </warning>
+
+ <para>After the processing of all configurations available in system
+ the container will initialize it and start each service in order of
+ the dependency injection (DI).</para>
+
+ <para>The user/developer should be careful when configuring the same
+ service in different configuration files. It's recommended to
+ configure a service in its own JAR only. Or, in case of a portal
+ configuration, strictly reconfigure the services in portal WAR files
+ or in an external configuration.</para>
+
+ <para>There are services that can be (or should be) configured more
+ than one time. This depends on business logic of the service. A
+ service may initialize the same resource (shared with other services)
+ or may add a particular object to a set of objects (shared with other
+ services too). In the first case it's critical who will be the last,
+ i.e. whose configuration will be used. In the second case it's no
+ matter who is the first and who is the last (if the parameter objects
+ are independent).</para>
+ </section>
+
+ <section>
+ <title>Configuration retrieval log</title>
+
+ <para>In case of problems with service configuration it's important to
+ know from which JAR/WAR it comes. For that purpose the JVM system
+ property
+ <emphasis>org.exoplatform.container.configuration.debug</emphasis> can
+ be used.<programlisting>java -Dorg.exoplatform.container.configuration.debug ...</programlisting></para>
+
+ <para>If the property is enabled the container configuration manager
+ will report the configuration adding process to the standard output
+ (System.out).<programlisting>......
+ Add configuration jar:file:/D:/Projects/eXo/dev/exo-working/exo-tomcat/lib/exo.kernel.container-trunk.jar!/conf/portal/configuration.xml
+ Add configuration jar:file:/D:/Projects/eXo/dev/exo-working/exo-tomcat/lib/exo.kernel.component.cache-trunk.jar!/conf/portal/configuration.xml
+ Add configuration jndi:/localhost/portal/WEB-INF/conf/configuration.xml
+ import jndi:/localhost/portal/WEB-INF/conf/common/common-configuration.xml
+ import jndi:/localhost/portal/WEB-INF/conf/database/database-configuration.xml
+ import jndi:/localhost/portal/WEB-INF/conf/ecm/jcr-component-plugins-configuration.xml
+ import jndi:/localhost/portal/WEB-INF/conf/jcr/jcr-configuration.xml
+ ......</programlisting></para>
+ </section>
+
+ <section>
+ <title>Get the effective configuration at Runtime</title>
+
+ <para>The effective configuration of the StandaloneContainer,
+ RootContainer and/or PortalContainer can be known thanks to the method
+ <emphasis>getConfigurationXML</emphasis>() that is exposed through JMX
+ at the container's level. This method will give you the effective
+ configuration in XML format that has been really interpreted by the
+ kernel. This could be helpful to understand how a given component or
+ plugin has been initialized.</para>
+ </section>
+ </section>
+
+ <section>
+ <title>Advanced concepts for the
+ <emphasis>PortalContainers</emphasis></title>
+
+ <para>Since eXo JCR 1.12, we added a set of new features that have been
+ designed to extend portal applications such as GateIn.</para>
+
+ <section>
+ <title>Add new configuration files from a WAR file</title>
+
+ <para>A <envar>ServletContextListener</envar> called
+ <envar>org.exoplatform.container.web.PortalContainerConfigOwner</envar>
+ has been added in order to notify the application that a given web
+ application provides some configuration to the portal container, and
+ this configuration file is the file
+ <emphasis>WEB-INF/conf/configuration.xml</emphasis> available in the
+ web application itself.</para>
+
+ <para>If your war file contains some configuration to add to the
+ <envar>PortalContainer</envar> simply add the following lines in your
+ <emphasis>web.xml</emphasis> file.</para>
+
+ <programlisting><?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+...
+ <!-- ================================================================== -->
+ <!-- LISTENER -->
+ <!-- ================================================================== -->
+ <listener>
+ <listener-class>org.exoplatform.container.web.PortalContainerConfigOwner</listener-class>
+ </listener>
+...
+</web-app></programlisting>
+ </section>
+
+ <section>
+ <title>Create your <emphasis>PortalContainers</emphasis> from a WAR
+ file</title>
+
+ <para>A <envar>ServletContextListener</envar> called
+ <envar>org.exoplatform.container.web.PortalContainerCreator</envar>
+ has been added in order to create the current portal containers that
+ have been registered. We assume that all the web applications have
+ already been loaded before calling
+ <envar>PortalContainerCreator.contextInitialized<replaceable><optional>.</optional></replaceable></envar></para>
+
+ <para><note>
+ <para>In GateIn, the <envar>PortalContainerCreator</envar> is
+ already managed by the file
+ <emphasis>starter.war/ear.</emphasis></para>
+ </note></para>
+ </section>
+
+ <section>
+ <title>Define a <emphasis>PortalContainer</emphasis> with its
+ dependencies and its settings</title>
+
+ <para>Now we can define precisely a portal container and its
+ dependencies and settings thanks to the
+ <envar>PortalContainerDefinition</envar> that currently contains the
+ name of the portal container, the name of the rest context, the name
+ of the realm he web application dependencies ordered by loading
+ priority (i.e. the first dependency must be loaded at first and so
+ on..) and the settings.</para>
+
+ <para>To be able to define a <envar>PortalContainerDefinition</envar>,
+ we need to ensure first of all that a
+ <envar>PortalContainerConfig</envar> has been defined at the
+ <envar>RootContainer</envar> level, see below an example:</para>
+
+ <programlisting> <component>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <type>org.exoplatform.container.definition.PortalContainerConfig</type>
+ <init-params>
+ <!-- The name of the default portal container -->
+ <value-param>
+ <name>default.portal.container</name>
+ <value>myPortal</value>
+ </value-param>
+ <!-- The name of the default rest ServletContext -->
+ <value-param>
+ <name>default.rest.context</name>
+ <value>myRest</value>
+ </value-param>
+ <!-- The name of the default realm -->
+ <value-param>
+ <name>default.realm.name</name>
+ <value>my-exo-domain</value>
+ </value-param>
+ <!-- The default portal container definition -->
+ <!-- It cans be used to avoid duplicating configuration -->
+ <object-param>
+ <name>default.portal.definition</name>
+ <object type="org.exoplatform.container.definition.PortalContainerDefinition">
+ <!-- All the dependencies of the portal container ordered by loading priority -->
+ <field name="dependencies">
+ <collection type="java.util.ArrayList">
+ <value>
+ <string>foo</string>
+ </value>
+ <value>
+ <string>foo2</string>
+ </value>
+ <value>
+ <string>foo3</string>
+ </value>
+ </collection>
+ </field>
+ <!-- A map of settings tied to the default portal container -->
+ <field name="settings">
+ <map type="java.util.HashMap">
+ <entry>
+ <key>
+ <string>foo5</string>
+ </key>
+ <value>
+ <string>value</string>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>string</string>
+ </key>
+ <value>
+ <string>value0</string>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>int</string>
+ </key>
+ <value>
+ <int>100</int>
+ </value>
+ </entry>
+ </map>
+ </field>
+ <!-- The path to the external properties file -->
+ <field name="externalSettingsPath">
+ <string>classpath:/org/exoplatform/container/definition/default-settings.properties</string>
+ </field>
+ </object>
+ </object-param>
+ </init-params>
+ </component></programlisting>
+
+ <table>
+ <title>Descriptions of the fields of
+ <envar>PortalContainerConfig</envar></title>
+
+ <tgroup cols="2">
+ <tbody>
+ <row>
+ <entry>default.portal.container</entry>
+
+ <entry>The name of the default portal container. This field is
+ optional.</entry>
+ </row>
+
+ <row>
+ <entry>default.rest.context</entry>
+
+ <entry>The name of the default rest
+ <envar>ServletContext</envar>. This field is optional.</entry>
+ </row>
+
+ <row>
+ <entry>default.realm.name</entry>
+
+ <entry>The name of the default realm. This field is
+ optional.</entry>
+ </row>
+
+ <row>
+ <entry>default.portal.definition</entry>
+
+ <entry>The definition of the default portal container. This
+ field is optional. The expected type is
+ <envar>org.exoplatform.container.definition.PortalContainerDefinition</envar>
+ that is described below. Allow the parameters defined in this
+ default <envar>PortalContainerDefinition</envar> will be the
+ default values.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <para>A new <envar>PortalContainerDefinition</envar> can be defined at
+ the <envar>RootContainer</envar> level thanks to an external plugin,
+ see below an example:<programlisting> <external-component-plugins>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
+ <component-plugin>
+ <!-- The name of the plugin -->
+ <name>Add PortalContainer Definitions</name>
+ <!-- The name of the method to call on the PortalContainerConfig in order to register the PortalContainerDefinitions -->
+ <set-method>registerPlugin</set-method>
+ <!-- The full qualified name of the PortalContainerDefinitionPlugin -->
+ <type>org.exoplatform.container.definition.PortalContainerDefinitionPlugin</type>
+ <init-params>
+ <object-param>
+ <name>portal</name>
+ <object type="org.exoplatform.container.definition.PortalContainerDefinition">
+ <!-- The name of the portal container -->
+ <field name="name">
+ <string>myPortal</string>
+ </field>
+ <!-- The name of the context name of the rest web application -->
+ <field name="restContextName">
+ <string>myRest</string>
+ </field>
+ <!-- The name of the realm -->
+ <field name="realmName">
+ <string>my-domain</string>
+ </field>
+ <!-- All the dependencies of the portal container ordered by loading priority -->
+ <field name="dependencies">
+ <collection type="java.util.ArrayList">
+ <value>
+ <string>foo</string>
+ </value>
+ <value>
+ <string>foo2</string>
+ </value>
+ <value>
+ <string>foo3</string>
+ </value>
+ </collection>
+ </field>
+ <!-- A map of settings tied to the portal container -->
+ <field name="settings">
+ <map type="java.util.HashMap">
+ <entry>
+ <key>
+ <string>foo</string>
+ </key>
+ <value>
+ <string>value</string>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>int</string>
+ </key>
+ <value>
+ <int>10</int>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>long</string>
+ </key>
+ <value>
+ <long>10</long>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>double</string>
+ </key>
+ <value>
+ <double>10</double>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>boolean</string>
+ </key>
+ <value>
+ <boolean>true</boolean>
+ </value>
+ </entry>
+ </map>
+ </field>
+ <!-- The path to the external properties file -->
+ <field name="externalSettingsPath">
+ <string>classpath:/org/exoplatform/container/definition/settings.properties</string>
+ </field>
+ </object>
+ </object-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins></programlisting></para>
+
+ <table>
+ <title>Descriptions of the fields of
+ <envar>PortalContainerDefinition</envar> when it is used to define a
+ new portal container</title>
+
+ <tgroup cols="2">
+ <tbody>
+ <row>
+ <entry>name</entry>
+
+ <entry>The name of the portal container. This field is
+ mandatory .</entry>
+ </row>
+
+ <row>
+ <entry>restContextName</entry>
+
+ <entry>The name of the context name of the rest web
+ application. This field is optional. The default value will
+ the value define at the <envar>PortalContainerConfig</envar>
+ level.</entry>
+ </row>
+
+ <row>
+ <entry>realmName</entry>
+
+ <entry>The name of the realm. This field is optional. The
+ default value will the value define at the
+ <envar>PortalContainerConfig</envar> level.</entry>
+ </row>
+
+ <row>
+ <entry>dependencies</entry>
+
+ <entry>All the dependencies of the portal container ordered by
+ loading priority. This field is optional. The default value
+ will the value define at the
+ <envar>PortalContainerConfig</envar> level. The dependencies
+ are in fact the list of the context names of the web
+ applications from which the portal container depends. This
+ field is optional. The dependency order is really crucial
+ since it will be interpreted the same way by several
+ components of the platform. All those components, will
+ consider the 1st element in the list less important than the
+ second element and so on. It is currently used
+ to:<itemizedlist>
+ <listitem>
+ <para>Know the loading order of all the
+ dependencies.</para>
+ </listitem>
+
+ <listitem>
+ <para>If we have several
+ <envar>PortalContainerConfigOwner</envar><itemizedlist>
+ <listitem>
+ <para>The <envar>ServletContext</envar> of all the
+ <envar>PortalContainerConfigOwner</envar> will be
+ unified, if we use the unified
+ <envar>ServletContext</envar>
+ (<emphasis>PortalContainer.getPortalContext()</emphasis>)
+ to get a resource, it will try to get the resource
+ in the <envar>ServletContext</envar> of the most
+ important <envar>PortalContainerConfigOwner</envar>
+ (i.e. last in the dependency list) and if it cans
+ find it, it will try with the second most important
+ <envar>PortalContainerConfigOwner</envar> and so
+ on.</para>
+ </listitem>
+
+ <listitem>
+ <para>The <envar>ClassLoader</envar> of all the
+ <envar>PortalContainerConfigOwner</envar> will be
+ unified, if we use the unified
+ <envar>ClassLoader</envar>
+ (<emphasis>PortalContainer.getPortalClassLoader()</emphasis>)
+ to get a resource, it will try to get the resource
+ in the <envar>ClassLoader</envar> of the most
+ important <envar>PortalContainerConfigOwner</envar>
+ (i.e. last in the dependency list) and if it cans
+ find it, it will try with the second most important
+ <envar>PortalContainerConfigOwner</envar> and so
+ on.</para>
+ </listitem>
+ </itemizedlist></para>
+ </listitem>
+ </itemizedlist></entry>
+ </row>
+
+ <row>
+ <entry>settings</entry>
+
+ <entry>A <envar>java.util.Map</envar> of internal parameters
+ that we would like to tie the portal container. Those
+ parameters could have any type of value. This field is
+ optional. If some internal settings are defined at the
+ <envar>PortalContainerConfig</envar> level, the two maps of
+ settings will be merged. If a setting with the same name is
+ defined in both maps, it will keep the value defined at the
+ <envar>PortalContainerDefinition</envar> level.</entry>
+ </row>
+
+ <row>
+ <entry>externalSettingsPath</entry>
+
+ <entry>The path of the external properties file to load as
+ default settings to the portal container. This field is
+ optional. If some external settings are defined at the
+ <envar>PortalContainerConfig</envar> level, the two maps of
+ settings will be merged. If a setting with the same name is
+ defined in both maps, it will keep the value defined at the
+ <envar>PortalContainerDefinition</envar> level. The external
+ properties files can be either of type "properties" or of type
+ "xml". The path will be interpreted as follows:<orderedlist>
+ <listitem>
+ <para>The path doesn't contain any prefix of type
+ "classpath:", "jar:" or "file:", we assume that the file
+ could be externalized so we apply the following
+ rules:<orderedlist>
+ <listitem>
+ <para>A file exists at
+ <emphasis>${exo-conf-dir}/portal/${portalContainerName}/${externalSettingsPath}</emphasis>,
+ we will load this file.</para>
+ </listitem>
+
+ <listitem>
+ <para>No file exists at the previous path, we then
+ assume that the path cans be interpreted by the
+ <envar>ConfigurationManager</envar>.</para>
+ </listitem>
+ </orderedlist></para>
+ </listitem>
+
+ <listitem>
+ <para>The path contains a prefix, we then assume that
+ the path cans be interpreted by the
+ <envar>ConfigurationManager</envar>.</para>
+ </listitem>
+ </orderedlist></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <table>
+ <title>Descriptions of the fields of
+ <envar>PortalContainerDefinition</envar> when it is used to define
+ the default portal container</title>
+
+ <tgroup cols="2">
+ <tbody>
+ <row>
+ <entry>name</entry>
+
+ <entry>The name of the portal container. This field is
+ optional. The default portal name will be:<orderedlist>
+ <listitem>
+ <para>If this field is not empty, then the default value
+ will be the value of this field.</para>
+ </listitem>
+
+ <listitem>
+ <para>If this field is empty and the value of the
+ parameter <emphasis>default.portal.container</emphasis>
+ is not empty, then the default value will be the value
+ of the parameter.</para>
+ </listitem>
+
+ <listitem>
+ <para>If this field and the parameter
+ <emphasis>default.portal.container</emphasis> are both
+ empty, the default value will be
+ <emphasis>"portal".</emphasis></para>
+ </listitem>
+ </orderedlist></entry>
+ </row>
+
+ <row>
+ <entry>restContextName</entry>
+
+ <entry>The name of the context name of the rest web
+ application. This field is optional. The default value wil
+ be:<orderedlist>
+ <listitem>
+ <para>If this field is not empty, then the default value
+ will be the value of this field.</para>
+ </listitem>
+
+ <listitem>
+ <para>f this field is empty and the value of the
+ parameter <emphasis>default.rest.context</emphasis> is
+ not empty, then the default value will be the value of
+ the parameter.</para>
+ </listitem>
+
+ <listitem>
+ <para>f this field and the parameter
+ <emphasis>default.rest.context</emphasis> are both
+ empty, the default value will be
+ <emphasis>"rest".</emphasis></para>
+ </listitem>
+ </orderedlist></entry>
+ </row>
+
+ <row>
+ <entry>realmName</entry>
+
+ <entry>The name of the realm. This field is optional. The
+ default value wil be:<orderedlist>
+ <listitem>
+ <para>If this field is not empty, then the default value
+ will be the value of this field.</para>
+ </listitem>
+
+ <listitem>
+ <para>f this field is empty and the value of the
+ parameter <emphasis>default.realm.name</emphasis> is not
+ empty, then the default value will be the value of the
+ parameter.</para>
+ </listitem>
+
+ <listitem>
+ <para>f this field and the parameter
+ <emphasis>default.realm.name</emphasis> are both empty,
+ the default value will be
+ <emphasis>"exo-domain".</emphasis></para>
+ </listitem>
+ </orderedlist></entry>
+ </row>
+
+ <row>
+ <entry>dependencies</entry>
+
+ <entry>All the dependencies of the portal container ordered by
+ loading priority. This field is optional. If this field has a
+ non empty value, it will be the default list of
+ dependencies.</entry>
+ </row>
+
+ <row>
+ <entry>settings</entry>
+
+ <entry>A <envar>java.util.Map</envar> of internal parameters
+ that we would like to tie the default portal container. Those
+ parameters could have any type of value. This field is
+ optional.</entry>
+ </row>
+
+ <row>
+ <entry>externalSettingsPath</entry>
+
+ <entry>The path of the external properties file to load as
+ default settings to the default portal container. This field
+ is optional. The external properties files can be either of
+ type "properties" or of type "xml". The path will be
+ interpreted as follows:<orderedlist>
+ <listitem>
+ <para>The path doesn't contain any prefix of type
+ "classpath:", "jar:" or "file:", we assume that the file
+ could be externalized so we apply the following
+ rules:<orderedlist>
+ <listitem>
+ <para>A file exists at
+ <emphasis>${exo-conf-dir}/portal/${externalSettingsPath}</emphasis>,
+ we will load this file.</para>
+ </listitem>
+
+ <listitem>
+ <para>No file exists at the previous path, we then
+ assume that the path cans be interpreted by the
+ <envar>ConfigurationManager</envar>.</para>
+ </listitem>
+ </orderedlist></para>
+ </listitem>
+
+ <listitem>
+ <para>The path contains a prefix, we then assume that
+ the path cans be interpreted by the
+ <envar>ConfigurationManager</envar>.</para>
+ </listitem>
+ </orderedlist></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <para>Internal and external settings are both optional, but if we give
+ a non empty value for both the application will merge the settings. If
+ the same setting name exists in both settings, we apply the following
+ rules:</para>
+
+ <orderedlist>
+ <listitem>
+ <para>The value of the external setting is
+ <emphasis>null</emphasis>, we ignore the value.</para>
+ </listitem>
+
+ <listitem>
+ <para>The value of the external setting is not
+ <emphasis>null</emphasis> and the value of the internal setting is
+ <emphasis>null</emphasis>, the final value will be the external
+ setting value that is of type <envar>String</envar>.</para>
+ </listitem>
+
+ <listitem>
+ <para>Both values are not <envar>null</envar>, we will have to
+ convert the external setting value into the target type which is
+ the type of the internal setting value, thanks to the static
+ method <emphasis>valueOf(String)</emphasis>, the following
+ sub-rules are then applied:</para>
+
+ <orderedlist>
+ <listitem>
+ <para>The method cannot be found, the final value will be the
+ external setting value that is of type
+ <envar>String</envar>.</para>
+ </listitem>
+
+ <listitem>
+ <para>The method can be found and the external setting value
+ is an empty <envar>String</envar>, we ignore the external
+ setting value.</para>
+ </listitem>
+
+ <listitem>
+ <para>The method can be found and the external setting value
+ is not an empty <envar>String</envar> but the method call
+ fails, we ignore the external setting value.</para>
+ </listitem>
+
+ <listitem>
+ <para>The method can be found and the external setting value
+ is not an empty <envar>String</envar> and the method call
+ succeeds, the final value will be the external setting value
+ that is of type of the internal setting value.</para>
+ </listitem>
+ </orderedlist>
+ </listitem>
+ </orderedlist>
+ </section>
+
+ <section>
+ <title><envar>PortalContainer</envar> settings</title>
+
+ <para>We can inject the value of the portal container settings into
+ the portal container configuration files thanks to the variables which
+ name start with "<emphasis>portal.container.</emphasis>", so to get
+ the value of a setting called "<emphasis>foo</emphasis>" just use the
+ following syntax <emphasis>${portal.container.foo}</emphasis>. You can
+ also use internal variables, such as:</para>
+
+ <table>
+ <title>Definition of the internal variables</title>
+
+ <tgroup cols="2">
+ <tbody>
+ <row>
+ <entry>portal.container.name</entry>
+
+ <entry>Gives the name of the current portal container.</entry>
+ </row>
+
+ <row>
+ <entry>portal.container.rest</entry>
+
+ <entry>Gives the context name of the rest web application of
+ the current portal container.</entry>
+ </row>
+
+ <row>
+ <entry>portal.container.realm</entry>
+
+ <entry>Gives the realm name of the current portal
+ container.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <para>You can find below an example of how to use the
+ variables:<programlisting><configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"
+ xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd">
+ <component>
+ <type>org.exoplatform.container.TestPortalContainer$MyComponent</type>
+ <init-params>
+ <!-- The name of the portal container -->
+ <value-param>
+ <name>portal</name>
+ <value>${portal.container.name}</value>
+ </value-param>
+ <!-- The name of the rest ServletContext -->
+ <value-param>
+ <name>rest</name>
+ <value>${portal.container.rest}</value>
+ </value-param>
+ <!-- The name of the realm -->
+ <value-param>
+ <name>realm</name>
+ <value>${portal.container.realm}</value>
+ </value-param>
+ <value-param>
+ <name>foo</name>
+ <value>${portal.container.foo}</value>
+ </value-param>
+ <value-param>
+ <name>before foo after</name>
+ <value>before ${portal.container.foo} after</value>
+ </value-param>
+ </init-params>
+ </component>
+</configuration></programlisting></para>
+
+ <para>In the properties file corresponding to the external settings,
+ you can reuse variables previously defined (in the external settings
+ or in the internal settings) to create a new variable. In this case
+ the prefix "<emphasis>portal.container.</emphasis>" is not needed, see
+ an example below:<programlisting>my-var1=value 1
+my-var2=value 2
+complex-value=${my-var1}-${my-var2}</programlisting></para>
+
+ <para>In the external and internal settings, you can also use create
+ variables based on value of System paramaters. The System parameters
+ can either be defined at launch time or thanks to the
+ <envar>PropertyConfigurator</envar> (see next section for more
+ details). See an example below:</para>
+
+ <programlisting>temp-dir=${java.io.tmpdir}${file.separator}my-temp</programlisting>
+
+ <para>However, for the internal settings you can use System parameters
+ only to define settings of type
+ <envar>java.lang.String</envar>.</para>
+
+ <para>It cans be also very usefull to define a generic variable in the
+ settings of the default portal container, the value of this variable
+ will change according to the current portal container. See below an
+ example:<programlisting>my-generic-var=value of the portal container "${name}"</programlisting></para>
+
+ <para>If this variable is defined at the default portal container
+ level, the value of this variable for a portal container called
+ <emphasis>"foo"</emphasis> will be <emphasis>value of the portal
+ container "foo"</emphasis>.</para>
+ </section>
+ </section>
+ </section>
+
+ <section>
+ <title>System property configuration</title>
+
+ <para>A new property configurator service has been developed for taking
+ care of configuring system properties from the inline kernel configuration
+ or from specified property files.</para>
+
+ <para>The services is scoped at the root container level because it is
+ used by all the services in the different portal containers in the
+ application runtime.</para>
+
+ <section>
+ <title>Properties init param</title>
+
+ <para>The properties init param takes a property declared to configure
+ various properties.</para>
+
+ <programlisting><component>
+ <key>PropertyManagerConfigurator</key>
+ <type>org.exoplatform.container.PropertyConfigurator</type>
+ <init-params>
+ <properties-param>
+ <name>properties</name>
+ <property name="foo" value="bar"/>
+ </properties-param>
+ </init-params>
+</component></programlisting>
+ </section>
+
+ <section>
+ <title>Properties URL init param</title>
+
+ <para>The properties URL init param allow to load an external file by
+ specifying its URL. Both property and XML format are supported, see the
+ javadoc of the <emphasis><envar>java.util.Properties</envar></emphasis>
+ class for more information. When a property file is loaded the various
+ property declarations are loaded in the order in which the properties
+ are declared sequentially in the file.</para>
+
+ <programlisting><component>
+ <key>PropertyManagerConfigurator</key>
+ <type>org.exoplatform.container.PropertyConfigurator</type>
+ <init-params>
+ <value-param>
+ <name>properties.url</name>
+ <value>classpath:configuration.properties</value>
+ </value-param>
+ </init-params>
+</component></programlisting>
+
+ <para>In the properties file corresponding to the external properties,
+ you can reuse variables previously defined to create a new variable. In
+ this case the prefix "<emphasis>portal.container.</emphasis>" is not
+ needed, see an example below:<programlisting>my-var1=value 1
+my-var2=value 2
+complex-value=${my-var1}-${my-var2}</programlisting></para>
+ </section>
+
+ <section>
+ <title>System Property configuration of the properties URL</title>
+
+ <para>It is possible to replace the properties URL init param by a
+ system property that overwrites it. The name of that property is
+ <emphasis>exo.properties.url</emphasis>.</para>
+ </section>
+ </section>
+
+ <section>
+ <title>Runtime configuration profiles</title>
+
+ <para>The kernel configuration is able to handle configuration profiles at
+ runtime (as opposed to packaging time).</para>
+
+ <section>
+ <title>Profiles activation</title>
+
+ <para>An active profile list is obtained during the boot of the root
+ container and is composed of the system property
+ <emphasis>exo.profiles</emphasis> sliced according the "," delimiter and
+ also a server specific profile value (tomcat for tomcat, jboss for
+ jboss, etc...).</para>
+
+ <programlisting># runs GateIn on Tomcat with the profiles tomcat and foo
+sh gatein.sh -Dexo.profiles=foo
+
+# runs GateIn on JBoss with the profiles jboss, foo and bar
+sh run.sh -Dexo.profiles=foo,bar</programlisting>
+ </section>
+
+ <section>
+ <title>Profiles configuration</title>
+
+ <para>Profiles are configured in the configuration files of the eXo
+ kernel.</para>
+
+ <section>
+ <title>Profiles definition</title>
+
+ <para>Profile activation occurs at XML to configuration object
+ unmarshalling time. It is based on an "profile" attribute that is
+ present on some of the XML element of the configuration files. To
+ enable this the kernel configuration schema has been upgraded to
+ kernel_1_1.xsd. The configuration is based on the following
+ rules:</para>
+
+ <orderedlist>
+ <listitem>
+ <para>Any kernel element with the no <emphasis>profiles</emphasis>
+ attribute will create a configuration object</para>
+ </listitem>
+
+ <listitem>
+ <para>Any kernel element having a <emphasis>profiles</emphasis>
+ attribute containing at least one of the active profiles will
+ create a configuration object</para>
+ </listitem>
+
+ <listitem>
+ <para>Any kernel element having a <emphasis>profiles</emphasis>
+ attribute matching none of the active profile will not create a
+ configuration object</para>
+ </listitem>
+
+ <listitem>
+ <para>Resolution of duplicates (such as two components with same
+ type) is left up to the kernel</para>
+ </listitem>
+ </orderedlist>
+ </section>
+
+ <section>
+ <title>Profiles capable configuration elements</title>
+
+ <para>A configuration element is <emphasis>profiles</emphasis> capable
+ when it carries a profiles element.</para>
+
+ <section>
+ <title>Component element</title>
+
+ <para>The component element declares a component when activated. It
+ will shadow any element with the same key declared before in the
+ same configuration file:</para>
+
+ <programlisting><component>
+ <key>Component</key>
+ <type>Component</type>
+</component>
+
+<component profile="foo">
+ <key>Component</key>
+ <type>FooComponent</type>
+</component></programlisting>
+ </section>
+
+ <section>
+ <title>Import element</title>
+
+ <para>The import element imports a referenced configuration file
+ when activated:</para>
+
+ <programlisting><import>empty</import>
+<import profile="foo">foo</import>
+<import profile="bar">bar</import></programlisting>
+ </section>
+
+ <section>
+ <title>Init param element</title>
+
+ <para>The init param element configures the parameter argument of
+ the construction of a component service:</para>
+
+ <programlisting><component>
+ <key>Component</key>
+ <type>ComponentImpl</type>
+ <init-params>
+ <value-param>
+ <name>param</name>
+ <value>empty</value>
+ </value-param>
+ <value-param profile="foo">
+ <name>param</name>
+ <value>foo</value>
+ </value-param>
+ <value-param profile="bar">
+ <name>param</name>
+ <value>bar</value>
+ </value-param>
+ </init-params>
+</component></programlisting>
+ </section>
+
+ <section>
+ <title>Value collection element</title>
+
+ <para>The value collection element configures one of the value of
+ collection data:</para>
+
+ <programlisting><object type="org.exoplatform.container.configuration.ConfigParam">
+ <field name="role">
+ <collection type="java.util.ArrayList">
+ <value><string>manager</string></value>
+ <value profile="foo"><string>foo_manager</string></value>
+ <value profile="foo,bar"><string>foo_bar_manager</string></value>
+ </collection>
+ </field>
+</object></programlisting>
+ </section>
+
+ <section>
+ <title>Field configuration element</title>
+
+ <para>The field configuration element configures the field of an
+ object:</para>
+
+ <programlisting><object-param>
+ <name>test.configuration</name>
+ <object type="org.exoplatform.container.configuration.ConfigParam">
+ <field name="role">
+ <collection type="java.util.ArrayList">
+ <value><string>manager</string></value>
+ </collection>
+ </field>
+ <field name="role" profile="foo,bar">
+ <collection type="java.util.ArrayList">
+ <value><string>foo_bar_manager</string></value>
+ </collection>
+ </field>
+ <field name="role" profile="foo">
+ <collection type="java.util.ArrayList">
+ <value><string>foo_manager</string></value>
+ </collection>
+ </field>
+ </object>
+</object-param></programlisting>
+ </section>
+ </section>
+ </section>
+ </section>
+
+ <section>
+ <title>Component request life cycle</title>
+
+ <section>
+ <title>Component request life cycle contract</title>
+
+ <para>The component request life cycle is an interface that defines a
+ contract for a component for being involved into a
+ request:<programlisting>public interface ComponentRequestLifecycle
+{
+ /**
+ * Start a request.
+ * @param container the related container
+ */
+ void startRequest(ExoContainer container);
+
+ /**
+ * Ends a request.
+ * @param container the related container
+ */
+ void endRequest(ExoContainer container);
+}</programlisting></para>
+
+ <para>The container passed is the container to which the component is
+ related. This contract is often used to setup a thread local based
+ context that will be demarcated by a request.</para>
+
+ <para>For instance in the GateIn portal context, a component request
+ life cycle is triggered for user requests. Another example is the
+ initial data import in GateIn that demarcates using callbacks made to
+ that interface.</para>
+ </section>
+
+ <section>
+ <title>Request life cycle</title>
+
+ <para>The <envar>RequestLifeCycle</envar> class has several statics
+ methods that are used to schedule the component request life cycle of
+ components. Its main responsability is to perform scheduling while
+ respecting the constraint to execute the request life cycle of a
+ component only once even if it can be scheduled several times.</para>
+
+ <section>
+ <title>Scheduling a component request life cycle</title>
+
+ <programlisting>RequestLifeCycle.begin(component);
+try
+{
+ // Do something
+}
+finally
+{
+ RequestLifeCycle.end();
+}</programlisting>
+ </section>
+
+ <section>
+ <title>Scheduling a container request life cycle</title>
+
+ <para>Scheduling a container triggers the component request life cyle
+ of all the components that implement the interface
+ <envar>ComponentRequestLifeCycle</envar>. If one of the component has
+ already been scheduled before then that component will not be
+ scheduled again. When the local value is true then the looked
+ components will be those of the container, when it is false then the
+ scheduler will also look at the components in the ancestor
+ containers.<programlisting>RequestLifeCycle.begin(container, local);
+try
+{
+ // Do something
+}
+finally
+{
+ RequestLifeCycle.end();
+}</programlisting></para>
+ </section>
+ </section>
+
+ <section>
+ <title>When request life cycle is triggered</title>
+
+ <section>
+ <title>Portal request life cycle</title>
+
+ <para>Each portal request triggers the life cycle of the associated
+ portal container.</para>
+ </section>
+
+ <section>
+ <title>JMX request Life Cycle</title>
+
+ <para>When a JMX bean is invoked, the request life cycle of the
+ container to which it belongs it scheduled. Indeed JMX is an entry
+ point of the system that may need component to have a request life
+ cycle triggered.</para>
+ </section>
+ </section>
+ </section>
+</chapter>
16 years, 2 months