exo-jcr SVN: r2364 - in kernel/trunk/exo.kernel.container/src: main/java/org/exoplatform/container/jmx and 7 other directories.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-05-12 04:54:02 -0400 (Wed, 12 May 2010)
New Revision: 2364
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/ConcurrentPicoContainer.java
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/ExoContainer.java
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
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/jmx/MX4JComponentAdapter.java
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/util/ContainerUtil.java
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/ComponentPlugin.java
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/Configuration.java
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/ExternalComponentPlugins.java
kernel/trunk/exo.kernel.container/src/main/resources/org/exoplatform/container/configuration/kernel-configuration_1_2.xsd
kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/TestExoContainer.java
kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/xml/test/TestConfigurationXML.java
kernel/trunk/exo.kernel.container/src/test/resources/conf/test-configuration.xml
kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/test-exo-container.xml
Log:
EXOJCR-718:
1. For this feature, it was required to review the sorts of plugins, now the ComponentPlugin and ContainerLifecyclePlugin are comparable and the sort is done by the class that owns the plugins (i.e. Component and ExternalComponentPlugins for the ComponentPlugin and Configuration for the ContainerLifecyclePlugin)
2. The unit tests that check that the plugins are properly sorted, have been reviewed since they passed even without sorting them
3. The field priority is now defined as an integer in the classes ComponentPlugin and ContainerLifecyclePlugin, and into the version 1.2 of the xsd
4. In ConcurrentPicoContainer, no IlleagalStateException are thrown when we try to start, stop or dispose the container in an invalid state, now it is silently ignored
5. The method getConfigurationXML has been added to the Standalone, Root and Portal containers. This method is exposed through JMX at the container level.
6. The object configuration is now cloneable and the methods toXML and merge have been added.
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/ConcurrentPicoContainer.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/ConcurrentPicoContainer.java 2010-05-12 06:50:23 UTC (rev 2363)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/ConcurrentPicoContainer.java 2010-05-12 08:54:02 UTC (rev 2364)
@@ -448,10 +448,8 @@
*/
public void start()
{
- if (disposed.get())
- throw new IllegalStateException("Already disposed");
- if (started.get())
- throw new IllegalStateException("Already started");
+ if (disposed.get() || started.get())
+ return;
LifecycleVisitor.start(this);
started.set(true);
}
@@ -465,10 +463,8 @@
*/
public void stop()
{
- if (disposed.get())
- throw new IllegalStateException("Already disposed");
- if (!started.get())
- throw new IllegalStateException("Not started");
+ if (disposed.get() || !started.get())
+ return;
LifecycleVisitor.stop(this);
started.set(false);
}
@@ -483,7 +479,7 @@
public void dispose()
{
if (disposed.get())
- throw new IllegalStateException("Already disposed");
+ return;
LifecycleVisitor.dispose(this);
disposed.set(true);
}
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/ExoContainer.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/ExoContainer.java 2010-05-12 06:50:23 UTC (rev 2363)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/ExoContainer.java 2010-05-12 08:54:02 UTC (rev 2364)
@@ -23,6 +23,7 @@
import org.exoplatform.container.configuration.ConfigurationManager;
import org.exoplatform.container.management.ManageableContainer;
import org.exoplatform.container.util.ContainerUtil;
+import org.exoplatform.container.xml.Configuration;
import org.exoplatform.container.xml.InitParams;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -321,4 +322,14 @@
}
throw new Exception("Cannot find a satisfying constructor for " + clazz + " with parameter " + unknownParameter);
}
+
+ /**
+ * Gets the {@link ConfigurationManager} from the given {@link ExoContainer} if it exists,
+ * then returns the nested {@link Configuration} otherwise it returns <code>null</code>
+ */
+ protected Configuration getConfiguration()
+ {
+ ConfigurationManager cm = (ConfigurationManager)getComponentInstanceOfType(ConfigurationManager.class);
+ return cm == null ? null : cm.getConfiguration();
+ }
}
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 06:50:23 UTC (rev 2363)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/PortalContainer.java 2010-05-12 08:54:02 UTC (rev 2364)
@@ -21,6 +21,7 @@
import org.exoplatform.container.RootContainer.PortalContainerInitTask;
import org.exoplatform.container.definition.PortalContainerConfig;
import org.exoplatform.container.jmx.MX4JComponentAdapterFactory;
+import org.exoplatform.container.xml.Configuration;
import org.exoplatform.container.xml.PortalContainerInfo;
import org.exoplatform.management.annotations.Managed;
import org.exoplatform.management.annotations.ManagedDescription;
@@ -50,6 +51,11 @@
{
/**
+ * Serial Version UID
+ */
+ private static final long serialVersionUID = -9110532469581690803L;
+
+ /**
* The default name of the portal container
*/
public static final String DEFAULT_PORTAL_CONTAINER_NAME;
@@ -271,6 +277,25 @@
return name;
}
+ @Managed
+ @ManagedDescription("The configuration of the container in XML format.")
+ public String getConfigurationXML()
+ {
+ Configuration conf = getConfiguration();
+ if (conf == null)
+ {
+ log.warn("The configuration of the PortalContainer could not be found");
+ return null;
+ }
+ Configuration result = Configuration.merge(((ExoContainer)parent).getConfiguration(), conf);
+ if (result == null)
+ {
+ log.warn("The configurations could not be merged");
+ return null;
+ }
+ return result.toXML();
+ }
+
public SessionContainer createSessionContainer(String id, String owner)
{
SessionContainer scontainer = getSessionManager().getSessionContainer(id);
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 06:50:23 UTC (rev 2363)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/RootContainer.java 2010-05-12 08:54:02 UTC (rev 2364)
@@ -26,7 +26,9 @@
import org.exoplatform.container.monitor.jvm.J2EEServerInfo;
import org.exoplatform.container.monitor.jvm.OperatingSystemInfo;
import org.exoplatform.container.util.ContainerUtil;
+import org.exoplatform.container.xml.Configuration;
import org.exoplatform.management.annotations.Managed;
+import org.exoplatform.management.annotations.ManagedDescription;
import org.exoplatform.management.jmx.annotations.NamingContext;
import org.exoplatform.management.jmx.annotations.Property;
import org.exoplatform.services.log.ExoLogger;
@@ -56,6 +58,11 @@
public class RootContainer extends ExoContainer
{
+ /**
+ * Serial Version UID
+ */
+ private static final long serialVersionUID = 812448359436635438L;
+
/** The field is volatile to properly implement the double checked locking pattern. */
private static volatile RootContainer singleton_;
@@ -101,7 +108,7 @@
//
Runtime.getRuntime().addShutdownHook(new ShutdownThread(this));
- this.profiles= profiles;
+ this.profiles = profiles;
this.registerComponentInstance(J2EEServerInfo.class, serverenv_);
}
@@ -461,6 +468,19 @@
singleton_ = rcontainer;
}
+ @Managed
+ @ManagedDescription("The configuration of the container in XML format.")
+ public String getConfigurationXML()
+ {
+ Configuration config = getConfiguration();
+ if (config == null)
+ {
+ log.warn("The configuration of the RootContainer could not be found");
+ return null;
+ }
+ return config.toXML();
+ }
+
/**
* Calls the other method <code>addInitTask</code> with <code>ServletContext.getServletContextName()</code>
* as portal container name
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 06:50:23 UTC (rev 2363)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/StandaloneContainer.java 2010-05-12 08:54:02 UTC (rev 2364)
@@ -18,20 +18,22 @@
*/
package org.exoplatform.container;
-import org.exoplatform.commons.utils.PropertyManager;
import org.exoplatform.container.configuration.ConfigurationException;
import org.exoplatform.container.configuration.ConfigurationManager;
import org.exoplatform.container.configuration.ConfigurationManagerImpl;
import org.exoplatform.container.jmx.MX4JComponentAdapterFactory;
import org.exoplatform.container.monitor.jvm.J2EEServerInfo;
import org.exoplatform.container.util.ContainerUtil;
+import org.exoplatform.container.xml.Configuration;
+import org.exoplatform.management.annotations.Managed;
+import org.exoplatform.management.annotations.ManagedDescription;
+import org.exoplatform.management.jmx.annotations.NamingContext;
+import org.exoplatform.management.jmx.annotations.Property;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
/**
* Created by The eXo Platform SAS .
@@ -47,14 +49,13 @@
* it is AS server home in a case of AS env or just current directory
* (from where JVM is started) for standalone. See
*/
-
+@Managed
+@NamingContext(@Property(key = "container", value = "standalone"))
public class StandaloneContainer extends ExoContainer implements SessionManagerContainer
{
private static final long serialVersionUID = 12L;
- private static final String CONFIGURATION_URL_ATTR = "configurationURL";
-
private static StandaloneContainer container;
// TODO use ONLY attribute from context instead
@@ -199,7 +200,7 @@
{
if ((path == null) || (path.length() == 0))
return;
- URL confURL = new File(path).getAbsoluteFile().toURL();
+ URL confURL = new File(path).toURI().toURL();
configurationURL = fileExists(confURL) ? confURL : null;
}
@@ -266,6 +267,19 @@
return configurationURL;
}
+ @Managed
+ @ManagedDescription("The configuration of the container in XML format.")
+ public String getConfigurationXML()
+ {
+ Configuration config = getConfiguration();
+ if (config == null)
+ {
+ log.warn("The configuration of the StandaloneContainer could not be found");
+ return null;
+ }
+ return config.toXML();
+ }
+
/**
* {@inheritDoc}
*/
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/jmx/MX4JComponentAdapter.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/jmx/MX4JComponentAdapter.java 2010-05-12 06:50:23 UTC (rev 2363)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/jmx/MX4JComponentAdapter.java 2010-05-12 08:54:02 UTC (rev 2364)
@@ -31,8 +31,6 @@
import org.picocontainer.defaults.AbstractComponentAdapter;
import java.lang.reflect.Method;
-import java.util.Collections;
-import java.util.Comparator;
import java.util.List;
/**
@@ -129,30 +127,11 @@
return instance_;
}
- private static final Comparator<org.exoplatform.container.xml.ComponentPlugin> COMPARATOR =
- new Comparator<org.exoplatform.container.xml.ComponentPlugin>()
- {
-
- public int compare(org.exoplatform.container.xml.ComponentPlugin o1,
- org.exoplatform.container.xml.ComponentPlugin o2)
- {
- return getPriority(o1) - getPriority(o2);
- }
-
- private int getPriority(org.exoplatform.container.xml.ComponentPlugin p)
- {
- // return p.getPriority() == null ? Integer.MAX_VALUE : Integer.parseInt(p.getPriority());
- return p.getPriority() == null ? 0 : Integer.parseInt(p.getPriority());
- }
-
- };
-
private void addComponentPlugin(boolean debug, Object component,
List<org.exoplatform.container.xml.ComponentPlugin> plugins, ExoContainer container) throws Exception
{
if (plugins == null)
return;
- Collections.sort(plugins, COMPARATOR);
for (org.exoplatform.container.xml.ComponentPlugin plugin : plugins)
{
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/util/ContainerUtil.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/util/ContainerUtil.java 2010-05-12 06:50:23 UTC (rev 2363)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/util/ContainerUtil.java 2010-05-12 08:54:02 UTC (rev 2364)
@@ -34,14 +34,11 @@
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.net.URL;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
-import java.util.List;
import java.util.Map;
/**
@@ -106,32 +103,13 @@
static public void addContainerLifecyclePlugin(ExoContainer container, ConfigurationManager conf)
{
- List plugins = new ArrayList(conf.getConfiguration().getContainerLifecyclePlugins());
- Collections.sort(plugins, COMPARATOR_CONTAINER_PLUGIN);
- Iterator i = plugins.iterator();
+ Iterator i = conf.getConfiguration().getContainerLifecyclePluginIterator();
while (i.hasNext())
{
ContainerLifecyclePlugin plugin = (ContainerLifecyclePlugin)i.next();
addContainerLifecyclePlugin(container, plugin);
}
}
-
- private static final Comparator<org.exoplatform.container.xml.ContainerLifecyclePlugin> COMPARATOR_CONTAINER_PLUGIN =
- new Comparator<org.exoplatform.container.xml.ContainerLifecyclePlugin>()
- {
-
- public int compare(org.exoplatform.container.xml.ContainerLifecyclePlugin o1,
- org.exoplatform.container.xml.ContainerLifecyclePlugin o2)
- {
- return getPriority(o1) - getPriority(o2);
- }
-
- private int getPriority(org.exoplatform.container.xml.ContainerLifecyclePlugin p)
- {
- return p.getPriority() == null ? 0 : Integer.parseInt(p.getPriority());
- }
-
- };
private static void addContainerLifecyclePlugin(ExoContainer container, ContainerLifecyclePlugin plugin)
{
@@ -178,8 +156,6 @@
Collection components = conf.getComponents();
if (components == null)
return;
- if (components == null)
- return;
Iterator i = components.iterator();
ClassLoader loader = Thread.currentThread().getContextClassLoader();
while (i.hasNext())
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 06:50:23 UTC (rev 2363)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/Component.java 2010-05-12 08:54:02 UTC (rev 2364)
@@ -22,6 +22,7 @@
import java.net.URL;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
/**
@@ -44,7 +45,7 @@
ArrayList plugins;
- ArrayList<ComponentPlugin> componentPlugins;
+ private ArrayList<ComponentPlugin> componentPlugins;
ArrayList listeners;
@@ -114,13 +115,18 @@
plugins = list;
}
- public List getComponentPlugins()
+ public List<ComponentPlugin> getComponentPlugins()
{
return componentPlugins;
}
- public void setComponentPlugins(ArrayList list)
+ public void setComponentPlugins(ArrayList<ComponentPlugin> list)
{
+ if (list != null)
+ {
+ // Sort the list of component plugins first
+ Collections.sort(list);
+ }
componentPlugins = list;
}
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 06:50:23 UTC (rev 2363)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/ComponentPlugin.java 2010-05-12 08:54:02 UTC (rev 2364)
@@ -23,7 +23,7 @@
* @since Apr 18, 2005
* @version $Id: ComponentPlugin.java 5799 2006-05-28 17:55:42Z geaz $
*/
-public class ComponentPlugin
+public class ComponentPlugin implements Comparable<ComponentPlugin>
{
String name;
@@ -35,7 +35,7 @@
InitParams initParams;
- String priority;
+ int priority;
public String getName()
{
@@ -87,13 +87,21 @@
this.initParams = ips;
}
- public String getPriority()
+ public int getPriority()
{
return priority;
}
- public void setPriority(String priority)
+ public void setPriority(int priority)
{
this.priority = priority;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public int compareTo(ComponentPlugin o)
+ {
+ return getPriority() - o.getPriority();
+ }
}
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/Configuration.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/Configuration.java 2010-05-12 06:50:23 UTC (rev 2363)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/Configuration.java 2010-05-12 08:54:02 UTC (rev 2364)
@@ -18,8 +18,18 @@
*/
package org.exoplatform.container.xml;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.jibx.runtime.BindingDirectory;
+import org.jibx.runtime.IBindingFactory;
+import org.jibx.runtime.IMarshallingContext;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -32,11 +42,13 @@
* @email: tuan08(a)users.sourceforge.net
* @version: $Id: Configuration.java 5799 2006-05-28 17:55:42Z geaz $
*/
-public class Configuration
+public class Configuration implements Cloneable
{
public static final String KERNEL_CONFIGURATION_1_0_URI = "http://www.exoplaform.org/xml/ns/kernel_1_0.xsd";
+ private static final Log log = ExoLogger.getLogger("exo.kernel.container.Configuration");
+
private Map<String, ContainerLifecyclePlugin> containerLifecyclePlugin_ =
new HashMap<String, ContainerLifecyclePlugin>();
@@ -52,9 +64,12 @@
private ArrayList<String> removeConfiguration_;
- public Collection getContainerLifecyclePlugins()
+ public Collection<ContainerLifecyclePlugin> getContainerLifecyclePlugins()
{
- return containerLifecyclePlugin_.values();
+ List<ContainerLifecyclePlugin> plugins =
+ new ArrayList<ContainerLifecyclePlugin>(containerLifecyclePlugin_.values());
+ Collections.sort(plugins);
+ return plugins;
}
public void addContainerLifecyclePlugin(Object object)
@@ -64,9 +79,9 @@
containerLifecyclePlugin_.put(key, plugin);
}
- public Iterator getContainerLifecyclePluginIterator()
+ public Iterator<ContainerLifecyclePlugin> getContainerLifecyclePluginIterator()
{
- return containerLifecyclePlugin_.values().iterator();
+ return getContainerLifecyclePlugins().iterator();
}
public boolean hasContainerLifecyclePlugin()
@@ -135,8 +150,7 @@
public void addExternalComponentPlugins(Object o)
{
-
- if (o != null)
+ if (o instanceof ExternalComponentPlugins)
{
ExternalComponentPlugins eps = (ExternalComponentPlugins)o;
@@ -211,19 +225,8 @@
Iterator i = other.externalComponentPlugins_.values().iterator();
while (i.hasNext())
{
- ExternalComponentPlugins eplugins = (ExternalComponentPlugins)i.next();
- ExternalComponentPlugins foundExternalComponentPlugins =
- externalComponentPlugins_.get(eplugins.getTargetComponent());
- if (foundExternalComponentPlugins == null)
- {
- externalComponentPlugins_.put(eplugins.getTargetComponent(), eplugins);
- }
- else
- {
- foundExternalComponentPlugins.merge(eplugins);
- }
+ addExternalComponentPlugins(i.next());
}
- // externalListeners_.putAll(other.externalListeners_) ;
if (other.getRemoveConfiguration() == null)
return;
@@ -231,4 +234,93 @@
removeConfiguration_ = new ArrayList<String>();
removeConfiguration_.addAll(other.getRemoveConfiguration());
}
+
+ /**
+ * Merge all the given configurations and return a safe copy of the result
+ * @param configs the list of configurations to merge ordered by priority, the second
+ * configuration will override the configuration of the first one and so on.
+ * @return the merged configuration
+ */
+ public static Configuration merge(Configuration... configs)
+ {
+ if (configs == null || configs.length == 0)
+ {
+ return null;
+ }
+ Configuration result = null;
+ for (Configuration conf : configs)
+ {
+ if (conf == null)
+ {
+ // Ignore the null configuration
+ continue;
+ }
+ else if (result == null)
+ {
+ try
+ {
+ // Initialize with the clone of the first non null configuration
+ result = (Configuration)conf.clone();
+ }
+ catch (CloneNotSupportedException e)
+ {
+ log.warn("Could not clone the configuration", e);
+ break;
+ }
+ }
+ else
+ {
+ // The merge the current configuration with this new configuration
+ result.mergeConfiguration(conf);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Dumps the configuration in XML format into the given {@link Writer}
+ */
+ public void toXML(Writer w)
+ {
+ try
+ {
+ IBindingFactory bfact = BindingDirectory.getFactory(Configuration.class);
+ IMarshallingContext mctx = bfact.createMarshallingContext();
+ mctx.setIndent(2);
+ mctx.marshalDocument(this, "UTF-8", null, w);
+ }
+ catch (Exception e)
+ {
+ log.warn("Couldn't dump the runtime configuration in XML Format", e);
+ }
+ }
+
+ /**
+ * Dumps the configuration in XML format into a {@link StringWriter} and
+ * returns the content
+ */
+ public String toXML()
+ {
+ StringWriter sw = new StringWriter();
+ try
+ {
+ toXML(sw);
+ }
+ catch (Exception e)
+ {
+ log.warn("Cannot convert the configuration to XML format", e);
+ return null;
+ }
+ finally
+ {
+ try
+ {
+ sw.close();
+ }
+ catch (IOException ignore)
+ {
+ }
+ }
+ return sw.toString();
+ }
}
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 06:50:23 UTC (rev 2363)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/ContainerLifecyclePlugin.java 2010-05-12 08:54:02 UTC (rev 2364)
@@ -22,7 +22,7 @@
* Created by The eXo Platform SAS Author : Tuan Nguyen
* tuan08(a)users.sourceforge.net Sep 8, 2005
*/
-public class ContainerLifecyclePlugin
+public class ContainerLifecyclePlugin implements Comparable<ContainerLifecyclePlugin>
{
private String name;
@@ -30,7 +30,7 @@
private String description;
- private String priority;
+ private int priority;
private InitParams initParams;
@@ -64,12 +64,12 @@
this.description = desc;
}
- public String getPriority()
+ public int getPriority()
{
return priority;
}
- public void setPriority(String priority)
+ public void setPriority(int priority)
{
this.priority = priority;
}
@@ -83,4 +83,9 @@
{
this.initParams = initParams;
}
+
+ public int compareTo(ContainerLifecyclePlugin o)
+ {
+ return getPriority() - o.getPriority();
+ }
}
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/ExternalComponentPlugins.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/ExternalComponentPlugins.java 2010-05-12 06:50:23 UTC (rev 2363)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/ExternalComponentPlugins.java 2010-05-12 08:54:02 UTC (rev 2364)
@@ -19,6 +19,7 @@
package org.exoplatform.container.xml;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
/**
@@ -30,7 +31,12 @@
{
String targetComponent;
- ArrayList<ComponentPlugin> componentPlugins;
+ /**
+ * Indicates whether it has to be sorted or not
+ */
+ private boolean dirty;
+
+ private ArrayList<ComponentPlugin> componentPlugins;
public String getTargetComponent()
{
@@ -42,25 +48,33 @@
targetComponent = s;
}
- public List getComponentPlugins()
+ public List<ComponentPlugin> getComponentPlugins()
{
+ if (dirty && componentPlugins != null)
+ {
+ // Sort the list of component plugins first
+ Collections.sort(componentPlugins);
+ dirty = false;
+ }
return componentPlugins;
}
public void setComponentPlugins(ArrayList<ComponentPlugin> list)
{
componentPlugins = list;
+ dirty = true;
}
public void merge(ExternalComponentPlugins other)
{
if (other == null)
return;
- List otherPlugins = other.getComponentPlugins();
+ List<ComponentPlugin> otherPlugins = other.getComponentPlugins();
if (otherPlugins == null)
return;
if (componentPlugins == null)
- componentPlugins = new ArrayList();
+ componentPlugins = new ArrayList<ComponentPlugin>();
componentPlugins.addAll(otherPlugins);
+ dirty = true;
}
}
Modified: kernel/trunk/exo.kernel.container/src/main/resources/org/exoplatform/container/configuration/kernel-configuration_1_2.xsd
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/resources/org/exoplatform/container/configuration/kernel-configuration_1_2.xsd 2010-05-12 06:50:23 UTC (rev 2363)
+++ kernel/trunk/exo.kernel.container/src/main/resources/org/exoplatform/container/configuration/kernel-configuration_1_2.xsd 2010-05-12 08:54:02 UTC (rev 2364)
@@ -160,7 +160,7 @@
<xsd:element name="set-method" type="xsd:string" minOccurs="1" maxOccurs="1"/>
<xsd:element name="type" type="xsd:string" minOccurs="1" maxOccurs="1"/>
<xsd:element name="description" type="xsd:string" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="priority" type="xsd:string" minOccurs="0" maxOccurs="1"/>
+ <xsd:element name="priority" type="xsd:int" minOccurs="0" maxOccurs="1"/>
<xsd:element name="init-params" type="initParamsType" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
<xsd:attribute name="profiles" type="xsd:string"/>
@@ -178,7 +178,7 @@
<xsd:element name="name" type="xsd:string" minOccurs="0" maxOccurs="1"/>
<xsd:element name="type" type="xsd:string" minOccurs="1" maxOccurs="1"/>
<xsd:element name="description" type="xsd:string" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="priority" type="xsd:string" minOccurs="0" maxOccurs="1"/>
+ <xsd:element name="priority" type="xsd:int" minOccurs="0" maxOccurs="1"/>
<xsd:element name="init-params" type="initParamsType" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
Modified: kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/TestExoContainer.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/TestExoContainer.java 2010-05-12 06:50:23 UTC (rev 2363)
+++ kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/TestExoContainer.java 2010-05-12 08:54:02 UTC (rev 2364)
@@ -49,18 +49,20 @@
final RootContainer container = createRootContainer("test-exo-container.xml");
MyCounter counter = (MyCounter)container.getComponentInstanceOfType(MyCounter.class);
assertNotNull(counter);
- assertEquals(2, counter.init.size());
- assertEquals(2, counter.start.size());
+ assertEquals(3, counter.init.size());
+ assertEquals(3, counter.start.size());
container.stop();
- assertEquals(2, counter.stop.size());
+ assertEquals(3, counter.stop.size());
container.dispose();
- assertEquals(2, counter.destroy.size());
+ assertEquals(3, counter.destroy.size());
// Check order
assertTrue(counter.init.get(0) instanceof MyContainerLifecyclePlugin2);
MyContainerLifecyclePlugin2 plugin = (MyContainerLifecyclePlugin2)counter.init.get(0);
assertNotNull(plugin.getName());
assertNotNull(plugin.getDescription());
assertNotNull(plugin.param);
+ assertTrue(counter.init.get(1) instanceof MyContainerLifecyclePlugin3);
+ assertTrue(counter.init.get(2) instanceof MyContainerLifecyclePlugin1);
}
public void testStackOverFlow()
@@ -421,4 +423,42 @@
if (counter != null) counter.stop.add(this);
}
}
+
+
+ public static class MyContainerLifecyclePlugin3 extends BaseContainerLifecyclePlugin
+ {
+
+ public MyContainerLifecyclePlugin3()
+ {
+ }
+
+ @Override
+ public void destroyContainer(ExoContainer container) throws Exception
+ {
+ MyCounter counter = (MyCounter)container.getComponentInstanceOfType(MyCounter.class);
+ if (counter != null) counter.destroy.add(this);
+ }
+
+ @Override
+ public void initContainer(ExoContainer container) throws Exception
+ {
+ MyCounter counter = (MyCounter)container.getComponentInstanceOfType(MyCounter.class);
+ if (counter != null) counter.init.add(this);
+ }
+
+ @Override
+ public void startContainer(ExoContainer container) throws Exception
+ {
+ MyCounter counter = (MyCounter)container.getComponentInstanceOfType(MyCounter.class);
+ if (counter != null) counter.start.add(this);
+ }
+
+ @Override
+ public void stopContainer(ExoContainer container) throws Exception
+ {
+ MyCounter counter = (MyCounter)container.getComponentInstanceOfType(MyCounter.class);
+ if (counter != null) counter.stop.add(this);
+ }
+
+ }
}
\ No newline at end of file
Modified: kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/xml/test/TestConfigurationXML.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/xml/test/TestConfigurationXML.java 2010-05-12 06:50:23 UTC (rev 2363)
+++ kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/xml/test/TestConfigurationXML.java 2010-05-12 08:54:02 UTC (rev 2364)
@@ -113,7 +113,7 @@
assertEquals("component-plugins-name", cp.getName());
assertEquals("set-method-name", cp.getSetMethod());
assertEquals("component-plugins-type", cp.getType());
- assertEquals("1", cp.getPriority());
+ assertEquals(1, cp.getPriority());
it = conf.getExternalComponentPluginsIterator();
assertNotNull(it);
assertTrue(it.hasNext());
@@ -126,7 +126,7 @@
assertEquals("component-plugins-name", cp.getName());
assertEquals("set-method-name", cp.getSetMethod());
assertEquals("component-plugins-type", cp.getType());
- assertEquals("1", cp.getPriority());
+ assertEquals(1, cp.getPriority());
list = conf.getImports();
assertNotNull(list);
assertFalse(list.isEmpty());
Modified: kernel/trunk/exo.kernel.container/src/test/resources/conf/test-configuration.xml
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/resources/conf/test-configuration.xml 2010-05-12 06:50:23 UTC (rev 2363)
+++ kernel/trunk/exo.kernel.container/src/test/resources/conf/test-configuration.xml 2010-05-12 08:54:02 UTC (rev 2364)
@@ -92,10 +92,11 @@
<external-component-plugins>
<target-component>org.exoplatform.mocks.PriorityService</target-component>
<component-plugin>
- <name>PluginPriority3</name>
+ <name>PluginPriority2</name>
<set-method>addPlugin</set-method>
- <type>org.exoplatform.mocks.PluginPriority3</type>
- <description>PluginPriority3 description</description>
+ <type>org.exoplatform.mocks.PluginPriority2</type>
+ <description>PluginPriority2 description</description>
+ <priority>2</priority>
</component-plugin>
</external-component-plugins>
<external-component-plugins>
@@ -108,11 +109,10 @@
<priority>1</priority>
</component-plugin>
<component-plugin>
- <name>PluginPriority2</name>
+ <name>PluginPriority3</name>
<set-method>addPlugin</set-method>
- <type>org.exoplatform.mocks.PluginPriority2</type>
- <description>PluginPriority2 description</description>
- <priority>2</priority>
+ <type>org.exoplatform.mocks.PluginPriority3</type>
+ <description>PluginPriority3 description</description>
</component-plugin>
</external-component-plugins>
Modified: kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/test-exo-container.xml
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/test-exo-container.xml 2010-05-12 06:50:23 UTC (rev 2363)
+++ kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/test-exo-container.xml 2010-05-12 08:54:02 UTC (rev 2364)
@@ -25,6 +25,10 @@
</value-param>
</init-params>
</container-lifecycle-plugin>
+ <container-lifecycle-plugin>
+ <type>org.exoplatform.container.TestExoContainer$MyContainerLifecyclePlugin3</type>
+ <priority>-5</priority>
+ </container-lifecycle-plugin>
<component>
<type>org.exoplatform.container.TestExoContainer$MyCounter</type>
</component>
16 years, 2 months
exo-jcr SVN: r2363 - in jcr/branches/1.12-LIC-709: applications and 22 other directories.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-05-12 02:50:23 -0400 (Wed, 12 May 2010)
New Revision: 2363
Modified:
jcr/branches/1.12-LIC-709/applications/exo.jcr.applications.backupconsole/pom.xml
jcr/branches/1.12-LIC-709/applications/exo.jcr.applications.browser/pom.xml
jcr/branches/1.12-LIC-709/applications/exo.jcr.applications.config/pom.xml
jcr/branches/1.12-LIC-709/applications/exo.jcr.applications.fckeditor/pom.xml
jcr/branches/1.12-LIC-709/applications/exo.jcr.applications.rest/pom.xml
jcr/branches/1.12-LIC-709/applications/exo.jcr.cluster.testclient/pom.xml
jcr/branches/1.12-LIC-709/applications/exo.jcr.ear/pom.xml
jcr/branches/1.12-LIC-709/applications/pom.xml
jcr/branches/1.12-LIC-709/docs/pom.xml
jcr/branches/1.12-LIC-709/docs/reference/en/pom.xml
jcr/branches/1.12-LIC-709/docs/reference/pom.xml
jcr/branches/1.12-LIC-709/docs/userguide/en/pom.xml
jcr/branches/1.12-LIC-709/docs/userguide/pom.xml
jcr/branches/1.12-LIC-709/exo.jcr.component.core/pom.xml
jcr/branches/1.12-LIC-709/exo.jcr.component.ext/pom.xml
jcr/branches/1.12-LIC-709/exo.jcr.component.ftp/pom.xml
jcr/branches/1.12-LIC-709/exo.jcr.component.statistics/pom.xml
jcr/branches/1.12-LIC-709/exo.jcr.component.webdav/pom.xml
jcr/branches/1.12-LIC-709/exo.jcr.connectors.localadapter/pom.xml
jcr/branches/1.12-LIC-709/exo.jcr.framework.command/pom.xml
jcr/branches/1.12-LIC-709/exo.jcr.framework.ftpclient/pom.xml
jcr/branches/1.12-LIC-709/exo.jcr.framework.web/pom.xml
jcr/branches/1.12-LIC-709/packaging/module/pom.xml
jcr/branches/1.12-LIC-709/pom.xml
Log:
EXOJCR-709 Versions updated
Modified: jcr/branches/1.12-LIC-709/applications/exo.jcr.applications.backupconsole/pom.xml
===================================================================
--- jcr/branches/1.12-LIC-709/applications/exo.jcr.applications.backupconsole/pom.xml 2010-05-12 06:43:10 UTC (rev 2362)
+++ jcr/branches/1.12-LIC-709/applications/exo.jcr.applications.backupconsole/pom.xml 2010-05-12 06:50:23 UTC (rev 2363)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-applications-parent</artifactId>
- <version>1.12.2-GA-SNAPSHOT</version>
+ <version>1.12-LIC-709</version>
</parent>
<artifactId>exo.jcr.applications.backupconsole</artifactId>
<name>eXo JCR :: Applications :: Backup Console</name>
Modified: jcr/branches/1.12-LIC-709/applications/exo.jcr.applications.browser/pom.xml
===================================================================
--- jcr/branches/1.12-LIC-709/applications/exo.jcr.applications.browser/pom.xml 2010-05-12 06:43:10 UTC (rev 2362)
+++ jcr/branches/1.12-LIC-709/applications/exo.jcr.applications.browser/pom.xml 2010-05-12 06:50:23 UTC (rev 2363)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-applications-parent</artifactId>
- <version>1.12.2-GA-SNAPSHOT</version>
+ <version>1.12-LIC-709</version>
</parent>
<artifactId>exo.jcr.applications.browser</artifactId>
<packaging>war</packaging>
Modified: jcr/branches/1.12-LIC-709/applications/exo.jcr.applications.config/pom.xml
===================================================================
--- jcr/branches/1.12-LIC-709/applications/exo.jcr.applications.config/pom.xml 2010-05-12 06:43:10 UTC (rev 2362)
+++ jcr/branches/1.12-LIC-709/applications/exo.jcr.applications.config/pom.xml 2010-05-12 06:50:23 UTC (rev 2363)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-applications-parent</artifactId>
- <version>1.12.2-GA-SNAPSHOT</version>
+ <version>1.12-LIC-709</version>
</parent>
<artifactId>exo.jcr.applications.config</artifactId>
<packaging>pom</packaging>
Modified: jcr/branches/1.12-LIC-709/applications/exo.jcr.applications.fckeditor/pom.xml
===================================================================
--- jcr/branches/1.12-LIC-709/applications/exo.jcr.applications.fckeditor/pom.xml 2010-05-12 06:43:10 UTC (rev 2362)
+++ jcr/branches/1.12-LIC-709/applications/exo.jcr.applications.fckeditor/pom.xml 2010-05-12 06:50:23 UTC (rev 2363)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-applications-parent</artifactId>
- <version>1.12.2-GA-SNAPSHOT</version>
+ <version>1.12-LIC-709</version>
</parent>
<artifactId>exo.jcr.applications.fckeditor</artifactId>
<packaging>war</packaging>
Modified: jcr/branches/1.12-LIC-709/applications/exo.jcr.applications.rest/pom.xml
===================================================================
--- jcr/branches/1.12-LIC-709/applications/exo.jcr.applications.rest/pom.xml 2010-05-12 06:43:10 UTC (rev 2362)
+++ jcr/branches/1.12-LIC-709/applications/exo.jcr.applications.rest/pom.xml 2010-05-12 06:50:23 UTC (rev 2363)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-applications-parent</artifactId>
- <version>1.12.2-GA-SNAPSHOT</version>
+ <version>1.12-LIC-709</version>
</parent>
<artifactId>exo.jcr.applications.rest</artifactId>
<packaging>war</packaging>
Modified: jcr/branches/1.12-LIC-709/applications/exo.jcr.cluster.testclient/pom.xml
===================================================================
--- jcr/branches/1.12-LIC-709/applications/exo.jcr.cluster.testclient/pom.xml 2010-05-12 06:43:10 UTC (rev 2362)
+++ jcr/branches/1.12-LIC-709/applications/exo.jcr.cluster.testclient/pom.xml 2010-05-12 06:50:23 UTC (rev 2363)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-applications-parent</artifactId>
- <version>1.12.2-GA-SNAPSHOT</version>
+ <version>1.12-LIC-709</version>
</parent>
<artifactId>exo.jcr.cluster.testclient</artifactId>
<name>eXo JCR :: Cluster :: Test Client</name>
Modified: jcr/branches/1.12-LIC-709/applications/exo.jcr.ear/pom.xml
===================================================================
--- jcr/branches/1.12-LIC-709/applications/exo.jcr.ear/pom.xml 2010-05-12 06:43:10 UTC (rev 2362)
+++ jcr/branches/1.12-LIC-709/applications/exo.jcr.ear/pom.xml 2010-05-12 06:50:23 UTC (rev 2363)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-applications-parent</artifactId>
- <version>1.12.2-GA-SNAPSHOT</version>
+ <version>1.12-LIC-709</version>
</parent>
<artifactId>exo.jcr.ear</artifactId>
<packaging>ear</packaging>
Modified: jcr/branches/1.12-LIC-709/applications/pom.xml
===================================================================
--- jcr/branches/1.12-LIC-709/applications/pom.xml 2010-05-12 06:43:10 UTC (rev 2362)
+++ jcr/branches/1.12-LIC-709/applications/pom.xml 2010-05-12 06:50:23 UTC (rev 2363)
@@ -22,12 +22,12 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.2-GA-SNAPSHOT</version>
+ <version>1.12-LIC-709</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jcr-applications-parent</artifactId>
- <version>1.12.2-GA-SNAPSHOT</version>
+ <version>1.12-LIC-709</version>
<name>eXo JCR :: Applications :: Reactor</name>
<packaging>pom</packaging>
Modified: jcr/branches/1.12-LIC-709/docs/pom.xml
===================================================================
--- jcr/branches/1.12-LIC-709/docs/pom.xml 2010-05-12 06:43:10 UTC (rev 2362)
+++ jcr/branches/1.12-LIC-709/docs/pom.xml 2010-05-12 06:50:23 UTC (rev 2363)
@@ -22,7 +22,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.2-GA-SNAPSHOT</version>
+ <version>1.12-LIC-709</version>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: jcr/branches/1.12-LIC-709/docs/reference/en/pom.xml
===================================================================
--- jcr/branches/1.12-LIC-709/docs/reference/en/pom.xml 2010-05-12 06:43:10 UTC (rev 2362)
+++ jcr/branches/1.12-LIC-709/docs/reference/en/pom.xml 2010-05-12 06:50:23 UTC (rev 2363)
@@ -22,7 +22,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>reference-docs</artifactId>
- <version>1.12.2-GA-SNAPSHOT</version>
+ <version>1.12-LIC-709</version>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: jcr/branches/1.12-LIC-709/docs/reference/pom.xml
===================================================================
--- jcr/branches/1.12-LIC-709/docs/reference/pom.xml 2010-05-12 06:43:10 UTC (rev 2362)
+++ jcr/branches/1.12-LIC-709/docs/reference/pom.xml 2010-05-12 06:50:23 UTC (rev 2363)
@@ -22,7 +22,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>docs</artifactId>
- <version>1.12.2-GA-SNAPSHOT</version>
+ <version>1.12-LIC-709</version>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: jcr/branches/1.12-LIC-709/docs/userguide/en/pom.xml
===================================================================
--- jcr/branches/1.12-LIC-709/docs/userguide/en/pom.xml 2010-05-12 06:43:10 UTC (rev 2362)
+++ jcr/branches/1.12-LIC-709/docs/userguide/en/pom.xml 2010-05-12 06:50:23 UTC (rev 2363)
@@ -22,7 +22,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>userguide-docs</artifactId>
- <version>1.12.2-GA-SNAPSHOT</version>
+ <version>1.12-LIC-709</version>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: jcr/branches/1.12-LIC-709/docs/userguide/pom.xml
===================================================================
--- jcr/branches/1.12-LIC-709/docs/userguide/pom.xml 2010-05-12 06:43:10 UTC (rev 2362)
+++ jcr/branches/1.12-LIC-709/docs/userguide/pom.xml 2010-05-12 06:50:23 UTC (rev 2363)
@@ -22,7 +22,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>docs</artifactId>
- <version>1.12.2-GA-SNAPSHOT</version>
+ <version>1.12-LIC-709</version>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: jcr/branches/1.12-LIC-709/exo.jcr.component.core/pom.xml
===================================================================
--- jcr/branches/1.12-LIC-709/exo.jcr.component.core/pom.xml 2010-05-12 06:43:10 UTC (rev 2362)
+++ jcr/branches/1.12-LIC-709/exo.jcr.component.core/pom.xml 2010-05-12 06:50:23 UTC (rev 2363)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.2-GA-SNAPSHOT</version>
+ <version>1.12-LIC-709</version>
</parent>
<artifactId>exo.jcr.component.core</artifactId>
<name>eXo JCR :: Component :: Core Service</name>
Modified: jcr/branches/1.12-LIC-709/exo.jcr.component.ext/pom.xml
===================================================================
--- jcr/branches/1.12-LIC-709/exo.jcr.component.ext/pom.xml 2010-05-12 06:43:10 UTC (rev 2362)
+++ jcr/branches/1.12-LIC-709/exo.jcr.component.ext/pom.xml 2010-05-12 06:50:23 UTC (rev 2363)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.2-GA-SNAPSHOT</version>
+ <version>1.12-LIC-709</version>
</parent>
<artifactId>exo.jcr.component.ext</artifactId>
<name>eXo JCR :: Component :: Extension Service</name>
Modified: jcr/branches/1.12-LIC-709/exo.jcr.component.ftp/pom.xml
===================================================================
--- jcr/branches/1.12-LIC-709/exo.jcr.component.ftp/pom.xml 2010-05-12 06:43:10 UTC (rev 2362)
+++ jcr/branches/1.12-LIC-709/exo.jcr.component.ftp/pom.xml 2010-05-12 06:50:23 UTC (rev 2363)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.2-GA-SNAPSHOT</version>
+ <version>1.12-LIC-709</version>
</parent>
<artifactId>exo.jcr.component.ftp</artifactId>
<name>eXo JCR :: Component :: FTP Service</name>
Modified: jcr/branches/1.12-LIC-709/exo.jcr.component.statistics/pom.xml
===================================================================
--- jcr/branches/1.12-LIC-709/exo.jcr.component.statistics/pom.xml 2010-05-12 06:43:10 UTC (rev 2362)
+++ jcr/branches/1.12-LIC-709/exo.jcr.component.statistics/pom.xml 2010-05-12 06:50:23 UTC (rev 2363)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.2-GA-SNAPSHOT</version>
+ <version>1.12-LIC-709</version>
</parent>
<artifactId>exo.jcr.component.statistics</artifactId>
<name>eXo JCR :: Component :: Statistics Provider</name>
Modified: jcr/branches/1.12-LIC-709/exo.jcr.component.webdav/pom.xml
===================================================================
--- jcr/branches/1.12-LIC-709/exo.jcr.component.webdav/pom.xml 2010-05-12 06:43:10 UTC (rev 2362)
+++ jcr/branches/1.12-LIC-709/exo.jcr.component.webdav/pom.xml 2010-05-12 06:50:23 UTC (rev 2363)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.2-GA-SNAPSHOT</version>
+ <version>1.12-LIC-709</version>
</parent>
<artifactId>exo.jcr.component.webdav</artifactId>
<name>eXo JCR :: Component :: Webdav Service</name>
Modified: jcr/branches/1.12-LIC-709/exo.jcr.connectors.localadapter/pom.xml
===================================================================
--- jcr/branches/1.12-LIC-709/exo.jcr.connectors.localadapter/pom.xml 2010-05-12 06:43:10 UTC (rev 2362)
+++ jcr/branches/1.12-LIC-709/exo.jcr.connectors.localadapter/pom.xml 2010-05-12 06:50:23 UTC (rev 2363)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.2-GA-SNAPSHOT</version>
+ <version>1.12-LIC-709</version>
</parent>
<artifactId>exo.jcr.connectors.localadapter</artifactId>
<packaging>rar</packaging>
Modified: jcr/branches/1.12-LIC-709/exo.jcr.framework.command/pom.xml
===================================================================
--- jcr/branches/1.12-LIC-709/exo.jcr.framework.command/pom.xml 2010-05-12 06:43:10 UTC (rev 2362)
+++ jcr/branches/1.12-LIC-709/exo.jcr.framework.command/pom.xml 2010-05-12 06:50:23 UTC (rev 2363)
@@ -12,7 +12,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.2-GA-SNAPSHOT</version>
+ <version>1.12-LIC-709</version>
</parent>
<artifactId>exo.jcr.framework.command</artifactId>
<name>eXo JCR :: Framework :: Command</name>
Modified: jcr/branches/1.12-LIC-709/exo.jcr.framework.ftpclient/pom.xml
===================================================================
--- jcr/branches/1.12-LIC-709/exo.jcr.framework.ftpclient/pom.xml 2010-05-12 06:43:10 UTC (rev 2362)
+++ jcr/branches/1.12-LIC-709/exo.jcr.framework.ftpclient/pom.xml 2010-05-12 06:50:23 UTC (rev 2363)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.2-GA-SNAPSHOT</version>
+ <version>1.12-LIC-709</version>
</parent>
<artifactId>exo.jcr.framework.ftpclient</artifactId>
<name>eXo JCR :: Framework :: FTP Client</name>
Modified: jcr/branches/1.12-LIC-709/exo.jcr.framework.web/pom.xml
===================================================================
--- jcr/branches/1.12-LIC-709/exo.jcr.framework.web/pom.xml 2010-05-12 06:43:10 UTC (rev 2362)
+++ jcr/branches/1.12-LIC-709/exo.jcr.framework.web/pom.xml 2010-05-12 06:50:23 UTC (rev 2363)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.2-GA-SNAPSHOT</version>
+ <version>1.12-LIC-709</version>
</parent>
<artifactId>exo.jcr.framework.web</artifactId>
<name>eXo JCR :: Framework :: Web</name>
Modified: jcr/branches/1.12-LIC-709/packaging/module/pom.xml
===================================================================
--- jcr/branches/1.12-LIC-709/packaging/module/pom.xml 2010-05-12 06:43:10 UTC (rev 2362)
+++ jcr/branches/1.12-LIC-709/packaging/module/pom.xml 2010-05-12 06:50:23 UTC (rev 2363)
@@ -4,7 +4,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.2-GA-SNAPSHOT</version>
+ <version>1.12-LIC-709</version>
</parent>
<artifactId>jcr.packaging.module</artifactId>
<packaging>pom</packaging>
Modified: jcr/branches/1.12-LIC-709/pom.xml
===================================================================
--- jcr/branches/1.12-LIC-709/pom.xml 2010-05-12 06:43:10 UTC (rev 2362)
+++ jcr/branches/1.12-LIC-709/pom.xml 2010-05-12 06:50:23 UTC (rev 2363)
@@ -29,7 +29,7 @@
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.2-GA-SNAPSHOT</version>
+ <version>1.12-LIC-709</version>
<packaging>pom</packaging>
<name>eXo JCR</name>
16 years, 2 months
exo-jcr SVN: r2362 - jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy.
by do-not-reply@jboss.org
Author: aparfonov
Date: 2010-05-12 02:43:10 -0400 (Wed, 12 May 2010)
New Revision: 2362
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScript2RestLoader.java
Log:
EXOJCR-720 : cleanup
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScript2RestLoader.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScript2RestLoader.java 2010-05-12 06:38:24 UTC (rev 2361)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScript2RestLoader.java 2010-05-12 06:43:10 UTC (rev 2362)
@@ -167,7 +167,7 @@
/**
* Remove script with specified URL from ResourceBinder.
- *
+ *
* @param url the URL. The <code>url.toString()</code> must be corresponded to
* script class.
* @see GroovyScriptRestLoader#loadScript(URL).
@@ -179,7 +179,7 @@
/**
* Remove script by specified key from ResourceBinder.
- *
+ *
* @param key the key with which script was created.
* @see GroovyScript2RestLoader#loadScript(String, InputStream)
* @see GroovyScript2RestLoader#loadScript(String, String, InputStream)
@@ -242,13 +242,15 @@
/**
* Get node type for store scripts, may throw {@link IllegalStateException} if
* <tt>nodeType</tt> not initialized yet.
- *
+ *
* @return return node type
*/
public String getNodeType()
{
if (nodeType == null)
+ {
throw new IllegalStateException("Node type not initialized, yet. ");
+ }
return nodeType;
}
@@ -274,7 +276,7 @@
/**
* Load script from given stream.
- *
+ *
* @param key the key which must be corresponded to object class name.
* @param stream the stream which represents groovy script.
* @return if script loaded false otherwise
@@ -289,7 +291,7 @@
/**
* Load script from given stream.
- *
+ *
* @param key the key which must be corresponded to object class name.
* @param name this name will be passed to compiler to get understandable if
* compilation failed
@@ -389,7 +391,9 @@
Node node = nodeIterator.nextNode();
if (node.getPath().startsWith("/jcr:system"))
+ {
continue;
+ }
loadScript(new NodeScriptKey(repositoryName, workspaceName, node), node.getPath(), node.getProperty(
"jcr:data").getStream());
@@ -434,7 +438,9 @@
if (cp instanceof GroovyScript2RestLoaderPlugin)
{
if (loadPlugins == null)
+ {
loadPlugins = new ArrayList<GroovyScript2RestLoaderPlugin>();
+ }
loadPlugins.add((GroovyScript2RestLoaderPlugin)cp);
}
}
@@ -445,13 +451,17 @@
protected void addScripts()
{
if (loadPlugins == null || loadPlugins.size() == 0)
+ {
return;
+ }
for (GroovyScript2RestLoaderPlugin loadPlugin : loadPlugins)
{
// If no one script configured then skip this item,
// there is no reason to do anything.
if (loadPlugin.getXMLConfigs().size() == 0)
+ {
continue;
+ }
Session session = null;
try
@@ -473,9 +483,13 @@
{
String t = tokens.nextToken();
if (node.hasNode(t))
+ {
node = node.getNode(t);
+ }
else
+ {
node = node.addNode(t, "nt:folder");
+ }
}
}
@@ -499,14 +513,16 @@
finally
{
if (session != null)
+ {
session.logout();
+ }
}
}
}
/**
* Create JCR node.
- *
+ *
* @param parent parent node
* @param name name of node to be created
* @param stream data stream for property jcr:data
@@ -526,7 +542,7 @@
/**
* Read parameters from RegistryService.
- *
+ *
* @param sessionProvider the SessionProvider
* @throws RepositoryException
* @throws PathNotFoundException
@@ -536,7 +552,9 @@
{
if (LOG.isDebugEnabled())
+ {
LOG.debug("<<< Read init parametrs from registry service.");
+ }
observationListenerConfiguration = new ObservationListenerConfiguration();
@@ -574,7 +592,7 @@
/**
* Write parameters to RegistryService.
- *
+ *
* @param sessionProvider the SessionProvider
* @throws ParserConfigurationException
* @throws SAXException
@@ -585,7 +603,9 @@
ParserConfigurationException, RepositoryException
{
if (LOG.isDebugEnabled())
+ {
LOG.debug(">>> Save init parametrs in registry service.");
+ }
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element root = doc.createElement(SERVICE_NAME);
@@ -599,7 +619,9 @@
for (String workspace : observationListenerConfiguration.getWorkspaces())
{
if (sb.length() > 0)
+ {
sb.append(';');
+ }
sb.append(workspace);
}
element = doc.createElement("workspaces");
@@ -616,7 +638,7 @@
/**
* Get attribute value.
- *
+ *
* @param element The element to get attribute value
* @param attr The attribute name
* @return Value of attribute if present and null in other case
@@ -628,7 +650,7 @@
/**
* Set attribute value. If value is null the attribute will be removed.
- *
+ *
* @param element The element to set attribute value
* @param attr The attribute name
* @param value The value of attribute
@@ -665,20 +687,11 @@
LOG.info("Workspaces node from configuration file: " + observationListenerConfiguration.getWorkspaces());
}
- // ///////////////////
-
- // FIXME
- // For following resource methods use POST instead GET even there is no
- // entity in request to prevent browsers cache when use ajax. Using no cache
- // may not have sense currently when use gadgets.io cause apache shindig
- // implementation ignores all headers except Set-Cookie and Location
- // (see https://issues.apache.org/jira/browse/SHINDIG-882)
-
/**
* This method is useful for clients that can send script in request body
* without form-data. At required to set specific Content-type header
* 'script/groovy'.
- *
+ *
* @param stream the stream that contains groovy source code
* @param uriInfo see {@link UriInfo}
* @param repository repository name
@@ -718,7 +731,9 @@
finally
{
if (ses != null)
+ {
ses.logout();
+ }
}
}
@@ -735,11 +750,17 @@
try
{
if (name != null && name.startsWith("/"))
+ {
name = name.substring(1);
+ }
if (name == null || name.length() == 0)
+ {
groovyScriptInstantiator.instantiateScript(script);
+ }
else
+ {
groovyScriptInstantiator.instantiateScript(script, name);
+ }
return Response.status(Response.Status.OK).build();
}
catch (Exception e)
@@ -755,7 +776,7 @@
* This method is useful for clients that can send script in request body
* without form-data. At required to set specific Content-type header
* 'script/groovy'.
- *
+ *
* @param stream the stream that contains groovy source code
* @param uriInfo see {@link UriInfo}
* @param repository repository name
@@ -796,7 +817,9 @@
finally
{
if (ses != null)
+ {
ses.logout();
+ }
}
}
@@ -806,7 +829,7 @@
* only one, rule one address - one script. This method is created just for
* comfort loading script from HTML form. NOT use this script for uploading
* few files in body of 'multipart/form-data' or other type of multipart.
- *
+ *
* @param items iterator {@link FileItem}
* @param uriInfo see {@link UriInfo}
* @param repository repository name
@@ -835,9 +858,13 @@
FileItem fitem = items.next();
if (fitem.isFormField() && fitem.getFieldName() != null
&& fitem.getFieldName().equalsIgnoreCase("autoload"))
+ {
autoload = Boolean.valueOf(fitem.getString());
- else if (!fitem.isFormField()) // accept files
+ }
+ else if (!fitem.isFormField())
+ {
stream = fitem.getInputStream();
+ }
}
createScript(node, getName(path), autoload, stream);
@@ -859,7 +886,9 @@
finally
{
if (ses != null)
+ {
ses.logout();
+ }
}
}
@@ -869,7 +898,7 @@
* only one, rule one address - one script. This method is created just for
* comfort loading script from HTML form. NOT use this script for uploading
* few files in body of 'multipart/form-data' or other type of multipart.
- *
+ *
* @param items iterator {@link FileItem}
* @param uriInfo see {@link UriInfo}
* @param repository repository name
@@ -889,8 +918,10 @@
{
FileItem fitem = items.next();
InputStream stream = null;
- if (!fitem.isFormField()) // if file
+ if (!fitem.isFormField())
+ {
stream = fitem.getInputStream();
+ }
ses =
sessionProviderService.getSessionProvider(null).getSession(workspace,
repositoryService.getRepository(repository));
@@ -914,13 +945,15 @@
finally
{
if (ses != null)
+ {
ses.logout();
+ }
}
}
/**
* Get source code of groovy script.
- *
+ *
* @param repository repository name
* @param workspace workspace name
* @param path JCR path to node that contains script
@@ -957,13 +990,15 @@
finally
{
if (ses != null)
+ {
ses.logout();
+ }
}
}
/**
* Get groovy script's meta-information.
- *
+ *
* @param repository repository name
* @param workspace workspace name
* @param path JCR path to node that contains script
@@ -1003,13 +1038,15 @@
finally
{
if (ses != null)
+ {
ses.logout();
+ }
}
}
/**
* Remove node that contains groovy script.
- *
+ *
* @param repository repository name
* @param workspace workspace name
* @param path JCR path to node that contains script
@@ -1043,7 +1080,9 @@
finally
{
if (ses != null)
+ {
ses.logout();
+ }
}
}
@@ -1051,7 +1090,7 @@
* Change exo:autoload property. If this property is 'true' script will be
* deployed automatically when JCR repository startup and automatically
* re-deployed when script source code changed.
- *
+ *
* @param repository repository name
* @param workspace workspace name
* @param path JCR path to node that contains script
@@ -1090,7 +1129,9 @@
finally
{
if (ses != null)
+ {
ses.logout();
+ }
}
}
@@ -1099,7 +1140,7 @@
* script will be deployed as REST service if 'false' the script will be
* undeployed. NOTE is script already deployed and <tt>state</tt> is
* <tt>true</tt> script will be re-deployed.
- *
+ *
* @param repository repository name
* @param workspace workspace name
* @param path the path to JCR node that contains groovy script to be deployed
@@ -1120,7 +1161,9 @@
if (state)
{
if (isLoaded(key))
+ {
unloadScript(key);
+ }
if (!loadScript(key, path, script.getProperty("jcr:data").getStream()))
{
String message =
@@ -1155,13 +1198,15 @@
finally
{
if (ses != null)
+ {
ses.logout();
+ }
}
}
/**
* Returns the list of all groovy-scripts found in workspace.
- *
+ *
* @param repository Repository name.
* @param workspace Workspace name.
* @param name Additional search parameter. If not emtpy method returns the
@@ -1209,9 +1254,13 @@
{
char c = name.charAt(i);
if (c == '*' || c == '?')
+ {
p.append('.');
+ }
if (".()[]^$|".indexOf(c) != -1)
+ {
p.append('\\');
+ }
p.append(c);
}
// add '.*' pattern at he end
@@ -1243,13 +1292,15 @@
finally
{
if (ses != null)
+ {
ses.logout();
+ }
}
}
/**
* Extract path to node's parent from full path.
- *
+ *
* @param fullPath full path to node
* @return node's parent path
*/
@@ -1261,7 +1312,7 @@
/**
* Extract node's name from full node path.
- *
+ *
* @param fullPath full path to node
* @return node's name
*/
@@ -1351,7 +1402,7 @@
/**
* Returns the list of scripts.
- *
+ *
* @return the list of scripts.
*/
public List<String> getList()
@@ -1361,7 +1412,7 @@
/**
* ScriptList constructor.
- *
+ *
* @param the list of scripts
*/
public ScriptList(List<String> scriptList)
16 years, 2 months
exo-jcr SVN: r2361 - jcr/branches.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-05-12 02:38:24 -0400 (Wed, 12 May 2010)
New Revision: 2361
Added:
jcr/branches/1.12-LIC-709/
Log:
EXOJCR-709 Branch for researchment.
Copied: jcr/branches/1.12-LIC-709 (from rev 2360, jcr/trunk)
16 years, 2 months
exo-jcr SVN: r2360 - core/trunk/exo.core.component.script.groovy/src/main/java/org/exoplatform/services/script/groovy.
by do-not-reply@jboss.org
Author: aparfonov
Date: 2010-05-12 02:25:23 -0400 (Wed, 12 May 2010)
New Revision: 2360
Modified:
core/trunk/exo.core.component.script.groovy/src/main/java/org/exoplatform/services/script/groovy/GroovyScriptInstantiator.java
Log:
EXOJCR-721: add method with GroovyClassLoader as parameter
Modified: core/trunk/exo.core.component.script.groovy/src/main/java/org/exoplatform/services/script/groovy/GroovyScriptInstantiator.java
===================================================================
--- core/trunk/exo.core.component.script.groovy/src/main/java/org/exoplatform/services/script/groovy/GroovyScriptInstantiator.java 2010-05-11 11:19:08 UTC (rev 2359)
+++ core/trunk/exo.core.component.script.groovy/src/main/java/org/exoplatform/services/script/groovy/GroovyScriptInstantiator.java 2010-05-12 06:25:23 UTC (rev 2360)
@@ -50,7 +50,7 @@
{
/** Our logger. */
- private static final Log LOG = ExoLogger.getLogger("exo.core.component.script.groovy.GroovyScriptInstantiator");
+ private static final Log LOG = ExoLogger.getLogger(GroovyScriptInstantiator.class);
/**
* eXo Container.
@@ -71,11 +71,11 @@
/**
* Load script from given address.
- *
+ *
* @param spec the resource's address.
* @return the object created from groovy script.
* @throws MalformedURLException if parameter <code>url</code> have wrong
- * format.
+ * format.
* @throws IOException if can't load script from given <code>url</code>.
* @see GroovyScriptInstantiator#instantiateScript(URL)
* @see GroovyScriptInstantiator#instantiateScript(InputStream)
@@ -87,7 +87,7 @@
/**
* Load script from given address.
- *
+ *
* @param url the resource's address.
* @return the object created from groovy script.
* @throws IOException if can't load script from given <code>url</code>.
@@ -101,10 +101,11 @@
/**
* Parse given stream, the stream must represents groovy script.
- *
+ *
* @param stream the stream represented groovy script.
* @return the object created from groovy script.
- * @throws IOException if stream can't be parsed or object can't be created.
+ * @throws IOException if stream can't be parsed or object can't be created
+ * cause to illegal content of stream
*/
public Object instantiateScript(InputStream stream) throws IOException
{
@@ -113,12 +114,13 @@
/**
* Parse given stream, the stream must represents groovy script.
- *
+ *
* @param stream the stream represented groovy script.
* @param name script name is null or empty string that groovy completer will
- * use default name
+ * use default name
* @return the object created from groovy script.
- * @throws IOException if stream can't be parsed or object can't be created.
+ * @throws IOException if stream can't be parsed or object can't be created
+ * cause to illegal content of stream
*/
public Object instantiateScript(InputStream stream, String name) throws IOException
{
@@ -133,13 +135,39 @@
{
loader = new GroovyClassLoader();
}
+ return instantiateScript(stream, name, loader);
+ }
+
+ /**
+ * Parse given stream, the stream must represents groovy script and use given
+ * class-loader. If <code>loader == null</code> then
+ * {@link groovy.lang.GroovyClassLoader} will be is use.
+ *
+ * @param stream the stream represented groovy script.
+ * @param name script name is null or empty string that groovy completer will
+ * use default name
+ * @param loader GroovyClassLoader or <code>null</code>
+ * @return the object created from groovy script.
+ * @throws IOException if stream can't be parsed or object can't be created
+ * cause to illegal content of stream
+ */
+ public Object instantiateScript(InputStream stream, String name, GroovyClassLoader loader) throws IOException
+ {
+ if (loader == null)
+ {
+ loader = new GroovyClassLoader();
+ }
Class<?> clazz = null;
try
{
if (name != null && name.length() > 0)
+ {
clazz = loader.parseClass(stream, name);
+ }
else
+ {
clazz = loader.parseClass(stream);
+ }
}
catch (CompilationFailedException e)
{
@@ -162,7 +190,7 @@
/**
* Created object from given class, if class has parameters in constructor,
* then this parameters will be searched in container.
- *
+ *
* @param clazz java-groovy class
*/
private Object createObject(Class<?> clazz) throws Exception
@@ -180,7 +208,9 @@
{
Class<?>[] parameterTypes = c.getParameterTypes();
if (parameterTypes.length == 0)
+ {
return c.newInstance();
+ }
List<Object> parameters = new ArrayList<Object>(parameterTypes.length);
@@ -188,7 +218,9 @@
{
Object param = container.getComponentInstanceOfType(parameterType);
if (param == null)
+ {
continue l;
+ }
parameters.add(param);
}
@@ -214,9 +246,13 @@
int c1 = constructor1.getParameterTypes().length;
int c2 = constructor2.getParameterTypes().length;
if (c1 < c2)
+ {
return 1;
+ }
if (c1 > c2)
+ {
return -1;
+ }
return 0;
}
@@ -227,7 +263,10 @@
if (plugin instanceof GroovyScriptJarJarPlugin)
{
GroovyScriptJarJarPlugin jarjarPlugin = (GroovyScriptJarJarPlugin)plugin;
- LOG.debug("Add mapping to groovy instantiator:" + jarjarPlugin.getMapping());
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Add mapping to groovy instantiator:" + jarjarPlugin.getMapping());
+ }
mapping.putAll(jarjarPlugin.getMapping());
}
}
16 years, 2 months
exo-jcr SVN: r2359 - jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy.
by do-not-reply@jboss.org
Author: yakimenko
Date: 2010-05-11 07:19:08 -0400 (Tue, 11 May 2010)
New Revision: 2359
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScript2RestLoader.java
Log:
EXOJCR-720 : Make possibility extends classe GroovyScript2RestLoader
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScript2RestLoader.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScript2RestLoader.java 2010-05-11 09:30:45 UTC (rev 2358)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScript2RestLoader.java 2010-05-11 11:19:08 UTC (rev 2359)
@@ -94,37 +94,37 @@
private static final String SERVICE_NAME = "GroovyScript2RestLoader";
/** See {@link InitParams}. */
- private InitParams initParams;
+ protected InitParams initParams;
/** See {@link ResourceBinder}. */
- private ResourceBinder binder;
+ protected ResourceBinder binder;
/** See {@link GroovyScriptInstantiator}. */
- private GroovyScriptInstantiator groovyScriptInstantiator;
+ protected GroovyScriptInstantiator groovyScriptInstantiator;
/** See {@link RepositoryService}. */
- private RepositoryService repositoryService;
+ protected RepositoryService repositoryService;
/** See {@link ConfigurationManager}. */
- private ConfigurationManager configurationManager;
+ protected ConfigurationManager configurationManager;
/** See {@link RegistryService}. */
- private RegistryService registryService;
+ protected RegistryService registryService;
/**
* See {@link SessionProviderService},
* {@link ThreadLocalSessionProviderService}.
*/
- private ThreadLocalSessionProviderService sessionProviderService;
+ protected ThreadLocalSessionProviderService sessionProviderService;
/** Keeps configuration for observation listener. */
- private ObservationListenerConfiguration observationListenerConfiguration;
+ protected ObservationListenerConfiguration observationListenerConfiguration;
/** Node type for Groovy scripts. */
- private String nodeType;
+ protected String nodeType;
/** Mapping scripts URL (or other key) to classes. */
- private Map<ScriptKey, Class<?>> scriptsURL2ClassMap = new HashMap<ScriptKey, Class<?>>();
+ protected Map<ScriptKey, Class<?>> scriptsURL2ClassMap = new HashMap<ScriptKey, Class<?>>();
/**
* @param binder binder for RESTful services
@@ -424,7 +424,7 @@
/**
* See {@link GroovyScript2RestLoaderPlugin}.
*/
- private List<GroovyScript2RestLoaderPlugin> loadPlugins;
+ protected List<GroovyScript2RestLoaderPlugin> loadPlugins;
/**
* @param cp See {@link ComponentPlugin}
@@ -442,7 +442,7 @@
/**
* Add scripts that specified in configuration.
*/
- private void addScripts()
+ protected void addScripts()
{
if (loadPlugins == null || loadPlugins.size() == 0)
return;
@@ -513,7 +513,7 @@
* @return newly created node
* @throws Exception if any errors occurs
*/
- private Node createScript(Node parent, String name, boolean autoload, InputStream stream) throws Exception
+ protected Node createScript(Node parent, String name, boolean autoload, InputStream stream) throws Exception
{
Node scriptFile = parent.addNode(name, "nt:file");
Node script = scriptFile.addNode("jcr:content", getNodeType());
@@ -531,7 +531,7 @@
* @throws RepositoryException
* @throws PathNotFoundException
*/
- private void readParamsFromRegistryService(SessionProvider sessionProvider) throws PathNotFoundException,
+ protected void readParamsFromRegistryService(SessionProvider sessionProvider) throws PathNotFoundException,
RepositoryException
{
@@ -581,7 +581,7 @@
* @throws IOException
* @throws RepositoryException
*/
- private void writeParamsToRegistryService(SessionProvider sessionProvider) throws IOException, SAXException,
+ protected void writeParamsToRegistryService(SessionProvider sessionProvider) throws IOException, SAXException,
ParserConfigurationException, RepositoryException
{
if (LOG.isDebugEnabled())
@@ -621,7 +621,7 @@
* @param attr The attribute name
* @return Value of attribute if present and null in other case
*/
- private String getAttributeSmart(Element element, String attr)
+ protected String getAttributeSmart(Element element, String attr)
{
return element.hasAttribute(attr) ? element.getAttribute(attr) : null;
}
@@ -633,7 +633,7 @@
* @param attr The attribute name
* @param value The value of attribute
*/
- private void setAttributeSmart(Element element, String attr, String value)
+ protected void setAttributeSmart(Element element, String attr, String value)
{
if (value == null)
{
@@ -648,7 +648,7 @@
/**
* Read parameters from file.
*/
- private void readParamsFromFile()
+ protected void readParamsFromFile()
{
if (initParams != null)
{
@@ -1253,7 +1253,7 @@
* @param fullPath full path to node
* @return node's parent path
*/
- private static String getPath(String fullPath)
+ protected static String getPath(String fullPath)
{
int sl = fullPath.lastIndexOf('/');
return sl > 0 ? "/" + fullPath.substring(0, sl) : "/";
@@ -1265,7 +1265,7 @@
* @param fullPath full path to node
* @return node's name
*/
- private static String getName(String fullPath)
+ protected static String getName(String fullPath)
{
int sl = fullPath.lastIndexOf('/');
return sl >= 0 ? fullPath.substring(sl + 1) : fullPath;
16 years, 2 months
exo-jcr SVN: r2358 - jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/registry.
by do-not-reply@jboss.org
Author: yakimenko
Date: 2010-05-11 05:30:45 -0400 (Tue, 11 May 2010)
New Revision: 2358
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/registry/RESTRegistryService.java
Log:
EXOJCR-717 : Add to RestRegistryService methods without repositoryName in PathParam, insted use current repository. Methods with repositoryName in PathParam marks as Deprecated.
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/registry/RESTRegistryService.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/registry/RESTRegistryService.java 2010-05-10 10:33:07 UTC (rev 2357)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/registry/RESTRegistryService.java 2010-05-11 09:30:45 UTC (rev 2358)
@@ -55,7 +55,7 @@
* @author <a href="mailto:andrew00x@gmail.com">Andrey Parfonov</a>
* @version $Id: $
*/
-@Path("/registry/{repository}/")
+@Path("/registry/")
public class RESTRegistryService implements ResourceContainer
{
@@ -91,12 +91,102 @@
@GET
@Produces(MediaType.APPLICATION_XML)
+ @Path("/{repository}/")
+ @Deprecated
public Response getRegistry(@PathParam("repository") String repository, @Context UriInfo uriInfo)
{
+ try
+ {
+ regService.getRepositoryService().setCurrentRepositoryName(repository);
+ return getRegistry(uriInfo);
+ }
+ catch (Exception e)
+ {
+ log.error("Get registry failed", e);
+ throw new WebApplicationException(e);
+ }
+ }
+
+ @GET
+ @Path("/{repository}/{entryPath:.+}/")
+ @Produces(MediaType.APPLICATION_XML)
+ @Deprecated
+ public Response getEntry(@PathParam("repository") String repository, @PathParam("entryPath") String entryPath)
+ {
+ try
+ {
+ regService.getRepositoryService().setCurrentRepositoryName(repository);
+ return getEntry(entryPath);
+ }
+ catch (Exception e)
+ {
+ log.error("Get registry entry failed", e);
+ throw new WebApplicationException(e);
+ }
+ }
+
+ @POST
+ @Path("/{repository}/{groupName:.+}/")
+ @Consumes(MediaType.APPLICATION_XML)
+ @Deprecated
+ public Response createEntry(InputStream entryStream, @PathParam("repository") String repository,
+ @PathParam("groupName") String groupName, @Context UriInfo uriInfo)
+ {
+ try
+ {
+ regService.getRepositoryService().setCurrentRepositoryName(repository);
+ return createEntry(entryStream, groupName, uriInfo);
+ }
+ catch (Exception e)
+ {
+ log.error("Create registry entry failed", e);
+ throw new WebApplicationException(e);
+ }
+ }
+
+ @PUT
+ @Path("/{repository}/{groupName:.+}/")
+ @Consumes(MediaType.APPLICATION_XML)
+ @Deprecated
+ public Response recreateEntry(InputStream entryStream, @PathParam("repository") String repository,
+ @PathParam("groupName") String groupName, @Context UriInfo uriInfo, @QueryParam("createIfNotExist") boolean createIfNotExist)
+ {
+ try
+ {
+ regService.getRepositoryService().setCurrentRepositoryName(repository);
+ return recreateEntry(entryStream, groupName, uriInfo, createIfNotExist);
+ }
+ catch (Exception e)
+ {
+ log.error("Re-create registry entry failed", e);
+ throw new WebApplicationException(e);
+ }
+ }
+
+ @DELETE
+ @Path("/{repository}/{entryPath:.+}/")
+ @Deprecated
+ public Response removeEntry(@PathParam("repository") String repository, @PathParam("entryPath") String entryPath)
+ {
+ try
+ {
+ regService.getRepositoryService().setCurrentRepositoryName(repository);
+ return removeEntry(entryPath);
+ }
+ catch (Exception e)
+ {
+ log.error("Remove registry entry failed", e);
+ throw new WebApplicationException(e);
+ }
+ }
+
+ @GET
+ @Produces(MediaType.APPLICATION_XML)
+ public Response getRegistry(@Context UriInfo uriInfo)
+ {
SessionProvider sessionProvider = sessionProviderService.getSessionProvider(null);
try
{
- regService.getRepositoryService().setCurrentRepositoryName(repository);
RegistryNode registryEntry = regService.getRegistry(sessionProvider);
if (registryEntry != null)
{
@@ -131,15 +221,14 @@
}
@GET
- @Path("/{entryPath:.+}/")
+ @Path("/{entryPath:.+}")
@Produces(MediaType.APPLICATION_XML)
- public Response getEntry(@PathParam("repository") String repository, @PathParam("entryPath") String entryPath)
+ public Response getEntry(@PathParam("entryPath") String entryPath)
{
SessionProvider sessionProvider = sessionProviderService.getSessionProvider(null);
try
{
- regService.getRepositoryService().setCurrentRepositoryName(repository);
RegistryEntry entry;
entry = regService.getEntry(sessionProvider, normalizePath(entryPath));
return Response.ok(new DOMSource(entry.getDocument())).build();
@@ -156,17 +245,15 @@
}
@POST
- @Path("/{groupName:.+}/")
+ @Path("/{groupName:.+}")
@Consumes(MediaType.APPLICATION_XML)
- public Response createEntry(InputStream entryStream, @PathParam("repository") String repository,
- @PathParam("groupName") String groupName, @Context UriInfo uriInfo)
+ public Response createEntry(InputStream entryStream, @PathParam("groupName") String groupName, @Context UriInfo uriInfo)
{
SessionProvider sessionProvider = sessionProviderService.getSessionProvider(null);
try
{
RegistryEntry entry = RegistryEntry.parse(entryStream);
- regService.getRepositoryService().setCurrentRepositoryName(repository);
regService.createEntry(sessionProvider, normalizePath(groupName), entry);
URI location = uriInfo.getRequestUriBuilder().path(entry.getName()).build();
return Response.created(location).build();
@@ -179,16 +266,14 @@
}
@PUT
- @Path("/{groupName:.+}/")
+ @Path("/{groupName:.+}")
@Consumes(MediaType.APPLICATION_XML)
- public Response recreateEntry(InputStream entryStream, @PathParam("repository") String repository,
- @PathParam("groupName") String groupName, @Context UriInfo uriInfo, @QueryParam("createIfNotExist") boolean createIfNotExist)
+ public Response recreateEntry(InputStream entryStream, @PathParam("groupName") String groupName, @Context UriInfo uriInfo, @QueryParam("createIfNotExist") boolean createIfNotExist)
{
SessionProvider sessionProvider = sessionProviderService.getSessionProvider(null);
try
{
- regService.getRepositoryService().setCurrentRepositoryName(repository);
RegistryEntry entry = RegistryEntry.parse(entryStream);
if (createIfNotExist)
regService.updateEntry(sessionProvider, normalizePath(groupName), entry);
@@ -205,14 +290,13 @@
}
@DELETE
- @Path("/{entryPath:.+}/")
- public Response removeEntry(@PathParam("repository") String repository, @PathParam("entryPath") String entryPath)
+ @Path("/{entryPath:.+}")
+ public Response removeEntry(@PathParam("entryPath") String entryPath)
{
SessionProvider sessionProvider = sessionProviderService.getSessionProvider(null);
try
{
- regService.getRepositoryService().setCurrentRepositoryName(repository);
regService.removeEntry(sessionProvider, normalizePath(entryPath));
return null; // minds status 204 'No content'
}
16 years, 2 months
exo-jcr SVN: r2357 - in kernel/trunk/exo.kernel.container/src: test/java/org/exoplatform/container/jmx and 1 other directory.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-05-10 06:33:07 -0400 (Mon, 10 May 2010)
New Revision: 2357
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/ExoContainer.java
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/RootContainer.java
kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/jmx/TestContainerScoping.java
Log:
EXOJCR-714: The methods initContainer, startContainer, stopContainer and destroyContainer are now deprecated since they must not be explicitly called because they are part of the container lifecycle.
The method start(boolean init) has been added to allow to start and initialize if needed the container
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/ExoContainer.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/ExoContainer.java 2010-05-10 10:32:56 UTC (rev 2356)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/ExoContainer.java 2010-05-10 10:33:07 UTC (rev 2357)
@@ -46,6 +46,11 @@
{
/**
+ * Serial Version UID
+ */
+ private static final long serialVersionUID = -8068506531004854036L;
+
+ /**
* Returns an unmodifable set of profiles defined by the value returned by invoking
* {@link PropertyManager#getProperty(String)} with the {@link org.exoplatform.commons.utils.PropertyManager#RUNTIME_PROFILES}
* property.
@@ -126,7 +131,15 @@
return name;
}
+ /**
+ * Explicit calls are not allowed anymore
+ */
+ @Deprecated
public void initContainer() throws Exception
+ {
+ }
+
+ private void initContainerInternal()
{
ConfigurationManager manager = (ConfigurationManager)getComponentInstanceOfType(ConfigurationManager.class);
ContainerUtil.addContainerLifecyclePlugin(this, manager);
@@ -148,25 +161,47 @@
@Override
public void dispose()
{
- destroyContainer();
+ destroyContainerInternal();
super.dispose();
}
+ /**
+ * Starts the container
+ * @param init indicates if the container must be initialized first
+ */
+ public void start(boolean init)
+ {
+ if (init)
+ {
+ // Initialize the container first
+ initContainerInternal();
+ }
+ start();
+ }
+
@Override
public void start()
{
super.start();
- startContainer();
+ startContainerInternal();
}
@Override
public void stop()
{
- stopContainer();
+ stopContainerInternal();
super.stop();
}
- public void startContainer()
+ /**
+ * Explicit calls are not allowed anymore
+ */
+ @Deprecated
+ public void startContainer() throws Exception
+ {
+ }
+
+ private void startContainerInternal()
{
for (ContainerLifecyclePlugin plugin : containerLifecyclePlugin_)
{
@@ -181,7 +216,15 @@
}
}
- public void stopContainer()
+ /**
+ * Explicit calls are not allowed anymore
+ */
+ @Deprecated
+ public void stopContainer() throws Exception
+ {
+ }
+
+ private void stopContainerInternal()
{
for (ContainerLifecyclePlugin plugin : containerLifecyclePlugin_)
{
@@ -196,7 +239,15 @@
}
}
- public void destroyContainer()
+ /**
+ * Explicit calls are not allowed anymore
+ */
+ @Deprecated
+ public void destroyContainer() throws Exception
+ {
+ }
+
+ private void destroyContainerInternal()
{
for (ContainerLifecyclePlugin plugin : containerLifecyclePlugin_)
{
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/RootContainer.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/RootContainer.java 2010-05-10 10:32:56 UTC (rev 2356)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/RootContainer.java 2010-05-10 10:33:07 UTC (rev 2357)
@@ -32,7 +32,6 @@
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.exoplatform.test.mocks.servlet.MockServletContext;
-import org.picocontainer.ComponentAdapter;
import java.io.File;
import java.util.Collection;
@@ -160,9 +159,8 @@
cService.addConfiguration(ContainerUtil.getConfigurationURL("conf/portal/test-configuration.xml"));
cService.processRemoveConfiguration();
pcontainer.registerComponentInstance(ConfigurationManager.class, cService);
- pcontainer.initContainer();
registerComponentInstance(name, pcontainer);
- pcontainer.start();
+ pcontainer.start(true);
}
catch (Exception ex)
{
@@ -326,10 +324,9 @@
}
cService.processRemoveConfiguration();
- ComponentAdapter adapter = pcontainer.registerComponentInstance(ConfigurationManager.class, cService);
- pcontainer.initContainer();
+ pcontainer.registerComponentInstance(ConfigurationManager.class, cService);
registerComponentInstance(portalContainerName, pcontainer);
- pcontainer.start();
+ pcontainer.start(true);
// Register the portal as an mbean
getManagementContext().register(pcontainer);
@@ -397,13 +394,11 @@
}
service.processRemoveConfiguration();
rootContainer.registerComponentInstance(ConfigurationManager.class, service);
- rootContainer.initContainer();
- rootContainer.start();
+ rootContainer.start(true);
return rootContainer;
}
catch (Exception e)
{
- e.printStackTrace();
log.error("Could not build root container", e);
return null;
}
Modified: kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/jmx/TestContainerScoping.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/jmx/TestContainerScoping.java 2010-05-10 10:32:56 UTC (rev 2356)
+++ kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/jmx/TestContainerScoping.java 2010-05-10 10:33:07 UTC (rev 2357)
@@ -35,8 +35,7 @@
//
ManagedContainer child = new ManagedContainer(root);
- child.initContainer();
- child.start();
+ child.start(true);
//
MBeanServer server = root.getMBeanServer();
16 years, 2 months
exo-jcr SVN: r2356 - in jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl: core and 1 other directory.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-05-10 06:32:56 -0400 (Mon, 10 May 2010)
New Revision: 2356
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryServiceImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/WorkspaceContainer.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java
Log:
EXOJCR-714: The methods initContainer, startContainer, stopContainer and destroyContainer are now deprecated since they must not be explicitly called because they are part of the container lifecycle.
The method start(boolean init) has been added to allow to start and initialize if needed the container
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java 2010-05-06 17:32:20 UTC (rev 2355)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java 2010-05-10 10:32:56 UTC (rev 2356)
@@ -407,23 +407,6 @@
}
/**
- * {@inheritDoc}
- */
- @Override
- public void stop()
- {
- try
- {
- stopContainer();
- }
- catch (Exception e)
- {
- log.error(e.getLocalizedMessage(), e);
- }
- super.stop();
- }
-
- /**
* Initialize worspaces (root node and jcr:system for system workspace).
* <p>
* Runs on container start.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryServiceImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryServiceImpl.java 2010-05-06 17:32:20 UTC (rev 2355)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryServiceImpl.java 2010-05-10 10:32:56 UTC (rev 2356)
@@ -234,7 +234,6 @@
}
repconfig.getWorkspaceEntries().clear();
RepositoryContainer repositoryContainer = repositoryContainers.get(name);
- repositoryContainer.stopContainer();
repositoryContainer.stop();
repositoryContainers.remove(name);
config.getRepositoryConfigurations().remove(repconfig);
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/WorkspaceContainer.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/WorkspaceContainer.java 2010-05-06 17:32:20 UTC (rev 2355)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/WorkspaceContainer.java 2010-05-10 10:32:56 UTC (rev 2356)
@@ -83,22 +83,4 @@
return (WorkspaceInitializer)getComponentInstanceOfType(WorkspaceInitializer.class);
}
- /*
- * (non-Javadoc)
- * @see org.picocontainer.defaults.DefaultPicoContainer#stop()
- */
- @Override
- public void stop()
- {
- try
- {
- stopContainer();
- }
- catch (Exception e)
- {
- log.error(e.getLocalizedMessage(), e);
- }
- super.stop();
- }
-
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java 2010-05-06 17:32:20 UTC (rev 2355)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java 2010-05-10 10:32:56 UTC (rev 2356)
@@ -422,7 +422,6 @@
workspaceContainer = repositoryContainer.getWorkspaceContainer(workspaceName);
try
{
- workspaceContainer.stopContainer();
workspaceContainer.stop();
}
catch (Exception e)
16 years, 2 months
exo-jcr SVN: r2355 - in kernel/trunk/exo.kernel.component.common/src: test/java/org/exoplatform/services/scheduler/test and 1 other directories.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-05-06 13:32:20 -0400 (Thu, 06 May 2010)
New Revision: 2355
Modified:
kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/scheduler/impl/QuartzSheduler.java
kernel/trunk/exo.kernel.component.common/src/test/java/org/exoplatform/services/scheduler/test/TestSchedulerService.java
kernel/trunk/exo.kernel.component.common/src/test/resources/conf/portal/test-configuration.xml
Log:
EXOJCR-716: Fix based on an ContainerLifeCyclePlugin that will start the scheduler after all the components Startable
Modified: kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/scheduler/impl/QuartzSheduler.java
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/scheduler/impl/QuartzSheduler.java 2010-05-06 13:57:53 UTC (rev 2354)
+++ kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/scheduler/impl/QuartzSheduler.java 2010-05-06 17:32:20 UTC (rev 2355)
@@ -18,6 +18,11 @@
*/
package org.exoplatform.services.scheduler.impl;
+import org.exoplatform.container.BaseContainerLifecyclePlugin;
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
import org.picocontainer.Startable;
import org.quartz.Scheduler;
import org.quartz.SchedulerFactory;
@@ -31,13 +36,24 @@
*/
public class QuartzSheduler implements Startable
{
- private Scheduler scheduler_;
+ private static final Log log = ExoLogger.getLogger("exo.kernel.component.common.QuartzSheduler");
+
+ private final Scheduler scheduler_;
- public QuartzSheduler() throws Exception
+ public QuartzSheduler(ExoContainerContext ctx) throws Exception
{
SchedulerFactory sf = new StdSchedulerFactory();
scheduler_ = sf.getScheduler();
- scheduler_.start();
+ // This will launch the scheduler when all the components will be started
+ ctx.getContainer().addContainerLifecylePlugin(new BaseContainerLifecyclePlugin()
+ {
+
+ @Override
+ public void startContainer(ExoContainer container) throws Exception
+ {
+ scheduler_.start();
+ }
+ });
}
public Scheduler getQuartzSheduler()
@@ -57,7 +73,7 @@
}
catch (Exception ex)
{
- ex.printStackTrace();
+ log.warn("Could not shutdown the scheduler", ex);
}
}
}
Modified: kernel/trunk/exo.kernel.component.common/src/test/java/org/exoplatform/services/scheduler/test/TestSchedulerService.java
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/test/java/org/exoplatform/services/scheduler/test/TestSchedulerService.java 2010-05-06 13:57:53 UTC (rev 2354)
+++ kernel/trunk/exo.kernel.component.common/src/test/java/org/exoplatform/services/scheduler/test/TestSchedulerService.java 2010-05-06 17:32:20 UTC (rev 2355)
@@ -18,15 +18,22 @@
*/
package org.exoplatform.services.scheduler.test;
+import org.exoplatform.container.BaseContainerLifecyclePlugin;
+import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.PortalContainer;
import org.exoplatform.services.scheduler.JobInfo;
import org.exoplatform.services.scheduler.JobSchedulerService;
import org.exoplatform.services.scheduler.PeriodInfo;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
import org.quartz.JobListener;
import org.quartz.TriggerListener;
import java.util.Date;
import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
/**
* Created by The eXo Platform SAS Author : Hoa Pham hoapham(a)exoplatform.com Oct
@@ -48,6 +55,12 @@
{
}
+ public void testJobWithNonStartedServices() throws Exception
+ {
+ MyComponent component = (MyComponent)PortalContainer.getInstance().getComponentInstanceOfType(MyComponent.class);
+ assertEquals(Boolean.TRUE, component.getResult());
+ }
+
public void testSeviceWithGlobalListener() throws Exception
{
assertTrue("JobScheduler is not deployed correctly", service_ != null);
@@ -258,4 +271,51 @@
assertTrue("now, expect no non global trigger is found", triggerListenerCol.size() == 0);
System.out.println("-------------------End Test Non Global Listener---------");
}
+
+ public static class MyContainerLifecyclePlugin extends BaseContainerLifecyclePlugin
+ {
+
+ @Override
+ public void startContainer(ExoContainer container) throws Exception
+ {
+ MyComponent component = (MyComponent)container.getComponentInstanceOfType(MyComponent.class);
+ component.started = true;
+ }
+ }
+
+ public static class MyComponent
+ {
+ public boolean started;
+ private final CountDownLatch doneSignal = new CountDownLatch(1);
+ public Boolean result;
+
+ public void doSomething()
+ {
+ if (started)
+ {
+ result = Boolean.TRUE;
+ }
+ else
+ {
+ result = Boolean.FALSE;
+ }
+ doneSignal.countDown();
+ }
+
+ public Boolean getResult() throws InterruptedException
+ {
+ doneSignal.await(2, TimeUnit.SECONDS);
+ return result;
+ }
+ }
+
+ public static class MyJobWithNonStartedServices implements Job
+ {
+
+ public void execute(JobExecutionContext context) throws JobExecutionException
+ {
+ MyComponent component = (MyComponent)PortalContainer.getInstance().getComponentInstanceOfType(MyComponent.class);
+ component.doSomething();
+ }
+ }
}
Modified: kernel/trunk/exo.kernel.component.common/src/test/resources/conf/portal/test-configuration.xml
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/test/resources/conf/portal/test-configuration.xml 2010-05-06 13:57:53 UTC (rev 2354)
+++ kernel/trunk/exo.kernel.component.common/src/test/resources/conf/portal/test-configuration.xml 2010-05-06 17:32:20 UTC (rev 2355)
@@ -21,8 +21,14 @@
-->
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
-
+ <container-lifecycle-plugin>
+ <type>org.exoplatform.services.scheduler.test.TestSchedulerService$MyContainerLifecyclePlugin</type>
+ </container-lifecycle-plugin>
<component>
+ <type>org.exoplatform.services.scheduler.test.TestSchedulerService$MyComponent</type>
+ </component>
+
+ <component>
<key>org.exoplatform.services.net.NetService</key>
<type>org.exoplatform.services.net.impl.NetServiceImpl</type>
</component>
@@ -196,5 +202,25 @@
</properties-param>
</init-params>
</component-plugin>
+ <component-plugin>
+ <name>AddJob</name>
+ <set-method>addPeriodJob</set-method>
+ <type>org.exoplatform.services.scheduler.PeriodJob</type>
+ <description>add a job to the JobSchedulerService</description>
+ <init-params>
+ <properties-param>
+ <name>job.info</name>
+ <description>Test QueueTaks</description>
+ <property name="jobName" value="job1" />
+ <property name="groupName" value="group1" />
+ <property name="job" value="org.exoplatform.services.scheduler.test.TestSchedulerService$MyJobWithNonStartedServices" />
+
+ <property name="repeatCount" value="1" />
+ <property name="period" value="1000" />
+ <property name="startTime" value="" />
+ <property name="endTime" value="" />
+ </properties-param>
+ </init-params>
+ </component-plugin>
</external-component-plugins>
</configuration>
16 years, 2 months