Author: mstruk
Date: 2012-02-24 10:37:53 -0500 (Fri, 24 Feb 2012)
New Revision: 8457
Added:
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/util/TemplateConfigurationHelper.java
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/test/java/org/exoplatform/container/TestStandaloneContainer.java
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/test/java/org/exoplatform/container/util/TestTemplateConfigurationHelper.java
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/test/resources/tsm-excludes.properties
Modified:
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/pom.xml
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/ConcurrentPicoContainer.java
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/PropertyConfigurator.java
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/StandaloneContainer.java
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/component/RequestLifeCycle.java
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/ConfigurationUnmarshaller.java
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/Namespaces.java
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/management/ManageableContainer.java
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/management/ManagementContextImpl.java
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/management/MetaDataBuilder.java
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/monitor/jvm/J2EEServerInfo.java
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/util/ContainerUtil.java
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/util/ExoWurflSource.java
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/xml/Configuration.java
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/xml/ObjectParam.java
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/management/jmx/impl/JMXManagementProvider.java
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/management/spi/ManagedMethodMetaData.java
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/management/spi/ManagedPropertyMetaData.java
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/management/spi/ManagedTypeMetaData.java
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/test/java/org/exoplatform/container/TestPortalContainer.java
Log:
Updated exo.kernel.container to version 2.3.6-GA
Modified: sandbox/as7_support/branches/gatein-as7/exo.kernel.container/pom.xml
===================================================================
--- sandbox/as7_support/branches/gatein-as7/exo.kernel.container/pom.xml 2012-02-24
14:34:41 UTC (rev 8456)
+++ sandbox/as7_support/branches/gatein-as7/exo.kernel.container/pom.xml 2012-02-24
15:37:53 UTC (rev 8457)
@@ -12,15 +12,15 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>kernel-parent</artifactId>
- <version>2.3.2-GA</version>
+ <version>2.3.6-GA</version>
</parent>
<artifactId>exo.kernel.container</artifactId>
- <version>2.3.2-GA-AS7-Beta02</version>
+ <version>2.3.6-GA-AS7-Beta03</version>
<name>eXo Kernel :: Container</name>
<description>eXo Kernel Container</description>
<properties>
- <version.exo.kernel>2.3.0-GA</version.exo.kernel>
+ <version.exo.kernel>2.3.6-GA</version.exo.kernel>
</properties>
<dependencies>
<dependency>
Modified:
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/ConcurrentPicoContainer.java
===================================================================
---
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/ConcurrentPicoContainer.java 2012-02-24
14:34:41 UTC (rev 8456)
+++
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/ConcurrentPicoContainer.java 2012-02-24
15:37:53 UTC (rev 8457)
@@ -111,7 +111,9 @@
public ConcurrentPicoContainer(ComponentAdapterFactory componentAdapterFactory,
PicoContainer parent)
{
if (componentAdapterFactory == null)
- throw new NullPointerException("componentAdapterFactory");
+ {
+ throw new IllegalArgumentException("componentAdapterFactory");
+ }
this.componentAdapterFactory = componentAdapterFactory;
this.parent = parent == null ? null : new ImmutablePicoContainer(parent);
}
Modified:
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/PropertyConfigurator.java
===================================================================
---
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/PropertyConfigurator.java 2012-02-24
14:34:41 UTC (rev 8456)
+++
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/PropertyConfigurator.java 2012-02-24
15:37:53 UTC (rev 8457)
@@ -62,32 +62,38 @@
/** The logger. */
private final Log log = ExoLogger.getExoLogger(PropertyConfigurator.class);
+ public PropertyConfigurator(ConfigurationManager confManager)
+ {
+ this(null, confManager);
+ }
+
public PropertyConfigurator(InitParams params, ConfigurationManager confManager)
{
- PropertiesParam propertiesParam =
params.getPropertiesParam("properties");
- if (propertiesParam != null)
+ String path = null;
+ if (params != null)
{
- log.debug("Going to initialize properties from init param");
- for (Iterator<Property> i =
propertiesParam.getPropertyIterator();i.hasNext();)
+ PropertiesParam propertiesParam =
params.getPropertiesParam("properties");
+ if (propertiesParam != null)
{
- Property property = i.next();
- String name = property.getName();
- String value = property.getValue();
- log.debug("Adding property from init param " + name + " =
" + value);
- PropertyManager.setProperty(name, value);
+ log.debug("Going to initialize properties from init param");
+ for (Iterator<Property> i =
propertiesParam.getPropertyIterator();i.hasNext();)
+ {
+ Property property = i.next();
+ String name = property.getName();
+ String value = property.getValue();
+ log.debug("Adding property from init param " + name + " =
" + value);
+ PropertyManager.setProperty(name, value);
+ }
+ }
+ ValueParam pathParam = params.getValueParam("properties.url");
+ if (pathParam != null)
+ {
+ log.debug("Using file path " + path + " found from
configuration");
+ path = pathParam.getValue();
}
}
//
- String path = null;
- ValueParam pathParam = params.getValueParam("properties.url");
- if (pathParam != null)
- {
- log.debug("Using file path " + path + " found from
configuration");
- path = pathParam.getValue();
- }
-
- //
String systemPath = PropertyManager.getProperty(PropertyManager.PROPERTIES_URL);
if (systemPath != null)
{
Modified:
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/StandaloneContainer.java
===================================================================
---
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/StandaloneContainer.java 2012-02-24
14:34:41 UTC (rev 8456)
+++
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/StandaloneContainer.java 2012-02-24
15:37:53 UTC (rev 8457)
@@ -36,6 +36,7 @@
import org.exoplatform.services.log.Log;
import java.io.File;
+import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.PrivilegedAction;
@@ -96,6 +97,10 @@
{
registerComponentInstance(ConfigurationManager.class, configurationManager);
registerComponentImplementation(SessionManagerImpl.class);
+ // Workaround used to allow to use the PropertyConfigurator with the
StandaloneContainer
+ // If the system property PropertyManager.PROPERTIES_URL has been set
properly, it will load the properties
+ // from the file and load them as system properties
+ new PropertyConfigurator(configurationManager);
return null;
}
});
@@ -329,6 +334,7 @@
{
super.stop();
ExoContainerContext.setTopContainer(null);
+ container = null;
}
// -------------- Helpers ----------
@@ -349,7 +355,7 @@
{
SecurityHelper.doPrivilegedIOExceptionAction(new
PrivilegedExceptionAction<Void>()
{
- public Void run() throws Exception
+ public Void run() throws IOException
{
url.openStream().close();
return null;
@@ -357,7 +363,7 @@
});
return true;
}
- catch (Exception e)
+ catch (IOException e)
{
return false;
}
@@ -419,7 +425,10 @@
}
catch (Exception ex)
{
- // ignore me
+ if (LOG.isTraceEnabled())
+ {
+ LOG.trace("An exception occurred: " + ex.getMessage());
+ }
}
}
Modified:
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/component/RequestLifeCycle.java
===================================================================
---
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/component/RequestLifeCycle.java 2012-02-24
14:34:41 UTC (rev 8456)
+++
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/component/RequestLifeCycle.java 2012-02-24
15:37:53 UTC (rev 8457)
@@ -96,7 +96,7 @@
{
if (container == null)
{
- throw new NullPointerException();
+ throw new IllegalArgumentException("The container cannot be null");
}
RequestLifeCycleStack lf = current.get();
if (lf == null)
@@ -118,7 +118,7 @@
{
if (lifeCycle == null)
{
- throw new NullPointerException();
+ throw new IllegalArgumentException("The lifeCycle cannot be null");
}
RequestLifeCycleStack lf = current.get();
if (lf == null)
Modified:
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/ConfigurationUnmarshaller.java
===================================================================
---
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/ConfigurationUnmarshaller.java 2012-02-24
14:34:41 UTC (rev 8456)
+++
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/ConfigurationUnmarshaller.java 2012-02-24
15:37:53 UTC (rev 8457)
@@ -70,7 +70,7 @@
public class ConfigurationUnmarshaller
{
- private static final Log log =
ExoLogger.getLogger("exo.kernel.container.ConfigurationUnmarshaller");
+ private static final Log LOG =
ExoLogger.getLogger("exo.kernel.container.ConfigurationUnmarshaller");
/**
* A private copy of the list of kernel namespaces
@@ -92,14 +92,14 @@
public void warning(SAXParseException exception) throws SAXException
{
- log.warn(exception.getMessage(), exception);
+ LOG.warn(exception.getMessage(), exception);
}
public void error(SAXParseException exception) throws SAXException
{
if (exception.getMessage().equals("cvc-elt.1: Cannot find the declaration
of element 'configuration'."))
{
- log.info("The document "
+ LOG.info("The document "
+ url
+ " does not contain a schema declaration, it should have an "
+ "XML declaration similar to\n"
@@ -111,7 +111,7 @@
}
else
{
- log.error("In document " + url + " at (" +
exception.getLineNumber() + "," + exception.getColumnNumber()
+ LOG.error("In document " + url + " at (" +
exception.getLineNumber() + "," + exception.getColumnNumber()
+ ") :" + exception.getMessage());
}
valid = false;
@@ -119,7 +119,7 @@
public void fatalError(SAXParseException exception) throws SAXException
{
- log.fatal("In document " + url + " at (" +
exception.getLineNumber() + "," + exception.getColumnNumber()
+ LOG.fatal("In document " + url + " at (" +
exception.getLineNumber() + "," + exception.getColumnNumber()
+ ") :" + exception.getMessage());
valid = false;
}
@@ -172,12 +172,12 @@
}
catch (ParserConfigurationException e)
{
- log.error("Got a parser configuration exception when doing XSD
validation");
+ LOG.error("Got a parser configuration exception when doing XSD
validation");
return false;
}
catch (SAXException e)
{
- log.error("Got a sax exception when doing XSD validation");
+ LOG.error("Got a sax exception when doing XSD validation");
return false;
}
}
@@ -204,7 +204,10 @@
}
catch (Exception e)
{
- // ignore me
+ if (LOG.isTraceEnabled())
+ {
+ LOG.trace("An exception occurred: " + e.getMessage());
+ }
}
}
}
@@ -216,7 +219,7 @@
boolean valid = isValid(url);
if (!valid)
{
- log.info("The configuration file " + url + " was not found
valid according to its XSD");
+ LOG.info("The configuration file " + url + " was not found
valid according to its XSD");
}
}
@@ -239,7 +242,7 @@
if (cause instanceof FactoryConfigurationError)
{
// do nothing and let try to instantiate later
- log.debug("Was not able to find document builder factory class in Java
> 5, will use default", cause);
+ LOG.debug("Was not able to find document builder factory class in Java
> 5, will use default", cause);
}
else
{
@@ -249,7 +252,10 @@
}
catch (NoSuchMethodException e)
{
- // Java < 6
+ if (LOG.isTraceEnabled())
+ {
+ LOG.trace("An exception occurred: " + e.getMessage());
+ }
}
//
@@ -295,8 +301,8 @@
String document = buffer.toString();
// Debug
- if (log.isTraceEnabled())
- log.trace("About to parse configuration file " + document);
+ if (LOG.isTraceEnabled())
+ LOG.trace("About to parse configuration file " + document);
//
IBindingFactory bfact = BindingDirectory.getFactory(Configuration.class);
Modified:
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/Namespaces.java
===================================================================
---
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/Namespaces.java 2012-02-24
14:34:41 UTC (rev 8456)
+++
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/Namespaces.java 2012-02-24
15:37:53 UTC (rev 8457)
@@ -90,7 +90,8 @@
*/
public static String[] getKernelNamespaces()
{
- return new String[]{KERNEL_1_0_URI, KERNEL_1_1_URI, KERNEL_1_2_URI,
KERNEL_1_0_URI_OLD, KERNEL_1_1_URI_OLD, KERNEL_1_2_URI_OLD};
+ return new String[]{KERNEL_1_0_URI, KERNEL_1_1_URI, KERNEL_1_2_URI,
KERNEL_1_0_URI_OLD, KERNEL_1_1_URI_OLD,
+ KERNEL_1_2_URI_OLD};
}
/**
Modified:
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/management/ManageableContainer.java
===================================================================
---
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/management/ManageableContainer.java 2012-02-24
14:34:41 UTC (rev 8456)
+++
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/management/ManageableContainer.java 2012-02-24
15:37:53 UTC (rev 8457)
@@ -46,6 +46,7 @@
import java.util.Set;
import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
/**
@@ -201,7 +202,7 @@
{
this.objectName = JMX.createObjectName("exo", props);
}
- catch (Exception e)
+ catch (MalformedObjectNameException e)
{
LOG.error("Could not create the object name", e);
}
@@ -246,7 +247,10 @@
}
catch (Exception e)
{
- // Ignore, may be caused by lazy initialization mechanism
+ if (LOG.isTraceEnabled())
+ {
+ LOG.trace("An exception occurred: " + e.getMessage());
+ }
}
return super.unregisterComponent(componentKey);
}
Modified:
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/management/ManagementContextImpl.java
===================================================================
---
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/management/ManagementContextImpl.java 2012-02-24
14:34:41 UTC (rev 8456)
+++
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/management/ManagementContextImpl.java 2012-02-24
15:37:53 UTC (rev 8457)
@@ -75,7 +75,7 @@
{
if (container == null)
{
- throw new NullPointerException();
+ throw new IllegalArgumentException("The container cannot be null");
}
//
@@ -102,11 +102,11 @@
{
if (parent == null)
{
- throw new NullPointerException();
+ throw new IllegalArgumentException("The parent cannot be null");
}
if (container == null)
{
- throw new NullPointerException();
+ throw new IllegalArgumentException("The container cannot be null");
}
//
@@ -133,7 +133,7 @@
{
if (parent == null)
{
- throw new NullPointerException();
+ throw new IllegalArgumentException("The parent cannot be null");
}
if ((resource != null && typeMD == null) && (resource == null
&& typeMD != null))
{
Modified:
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/management/MetaDataBuilder.java
===================================================================
---
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/management/MetaDataBuilder.java 2012-02-24
14:34:41 UTC (rev 8456)
+++
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/management/MetaDataBuilder.java 2012-02-24
15:37:53 UTC (rev 8457)
@@ -91,7 +91,7 @@
{
if (clazz == null)
{
- throw new NullPointerException();
+ throw new IllegalArgumentException("The clazz cannot be null");
}
//
Modified:
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/monitor/jvm/J2EEServerInfo.java
===================================================================
---
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/monitor/jvm/J2EEServerInfo.java 2012-02-24
14:34:41 UTC (rev 8456)
+++
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/monitor/jvm/J2EEServerInfo.java 2012-02-24
15:37:53 UTC (rev 8457)
@@ -27,6 +27,7 @@
import java.lang.management.ManagementFactory;
import java.lang.reflect.Method;
import java.net.URI;
+import java.net.URISyntaxException;
import java.security.PrivilegedAction;
import java.security.PrivilegedExceptionAction;
@@ -42,7 +43,7 @@
/**
* The logger
*/
- private static final Log log =
ExoLogger.getLogger("exo.kernel.container.J2EEServerInfo");
+ private static final Log LOG =
ExoLogger.getLogger("exo.kernel.container.J2EEServerInfo");
/**
* The name of the JVM parameter that allows us to change the location of the
@@ -101,10 +102,27 @@
{
exoConfDir_ = new File(new File(new URI(jbossConfigUrl)),
confDirName).getAbsolutePath();
}
- catch (Throwable e)
+ catch (SecurityException e)
{
- // don't care about it
+ if (LOG.isTraceEnabled())
+ {
+ LOG.trace("An exception occurred: " + e.getMessage());
+ }
}
+ catch (URISyntaxException e)
+ {
+ if (LOG.isTraceEnabled())
+ {
+ LOG.trace("An exception occurred: " + e.getMessage());
+ }
+ }
+ catch (IllegalArgumentException e)
+ {
+ if (LOG.isTraceEnabled())
+ {
+ LOG.trace("An exception occurred: " + e.getMessage());
+ }
+ }
}
//
@@ -124,7 +142,7 @@
}
catch (Exception ignore)
{
- log.debug(ignore.getLocalizedMessage(), ignore);
+ LOG.debug(ignore.getLocalizedMessage(), ignore);
}
}
else if (jettyHome != null)
@@ -182,7 +200,7 @@
String exoConfHome = PrivilegedSystemHelper.getProperty(EXO_CONF_PARAM);
if (exoConfHome != null && exoConfHome.length() > 0)
{
- log.info("Override exo-conf directory '" + exoConfDir_ +
"' with location '" + exoConfHome
+ LOG.info("Override exo-conf directory '" + exoConfDir_ +
"' with location '" + exoConfHome
+ "'");
exoConfDir_ = exoConfHome;
}
Modified:
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/util/ContainerUtil.java
===================================================================
---
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/util/ContainerUtil.java 2012-02-24
14:34:41 UTC (rev 8456)
+++
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/util/ContainerUtil.java 2012-02-24
15:37:53 UTC (rev 8457)
@@ -52,7 +52,7 @@
public class ContainerUtil
{
/** The logger. */
- private static final Log log = ExoLogger.getExoLogger(ContainerUtil.class);
+ private static final Log LOG = ExoLogger.getExoLogger(ContainerUtil.class);
static public Constructor<?>[] getSortedConstructors(Class<?> clazz)
throws NoClassDefFoundError
{
@@ -142,7 +142,7 @@
}
catch (Exception ex)
{
- log.error("Failed to instanciate plugin " + plugin.getType() + ":
" + ex.getMessage(), ex);
+ LOG.error("Failed to instanciate plugin " + plugin.getType() + ":
" + ex.getMessage(), ex);
}
}
@@ -163,7 +163,7 @@
}
catch (Exception ex)
{
- log.error("Failed to instanciate plugin " + plugin.getType() +
": " + ex.getMessage(), ex);
+ LOG.error("Failed to instanciate plugin " + plugin.getType() +
": " + ex.getMessage(), ex);
}
}
}
@@ -188,7 +188,7 @@
if (component.isMultiInstance())
{
container.registerComponent(new
ConstructorInjectionComponentAdapter(classType, classType));
- log.debug("===>>> Thread local component " +
classType.getName() + " registered.");
+ LOG.debug("===>>> Thread local component " +
classType.getName() + " registered.");
}
else
{
@@ -203,7 +203,7 @@
if (component.isMultiInstance())
{
container.registerComponent(new
ConstructorInjectionComponentAdapter(keyType, classType));
- log.debug("===>>> Thread local component " +
classType.getName() + " registered.");
+ LOG.debug("===>>> Thread local component " +
classType.getName() + " registered.");
}
else
{
@@ -218,7 +218,7 @@
}
catch (ClassNotFoundException ex)
{
- log.error("Cannot register the component corresponding to key =
'" + key + "' and type = '" + type + "'", ex);
+ LOG.error("Cannot register the component corresponding to key =
'" + key + "' and type = '" + type + "'", ex);
}
}
}
@@ -259,19 +259,19 @@
String fileName = url.getFile();
if (Tools.endsWithIgnoreCase(path, ".properties"))
{
- if (log.isDebugEnabled())
- log.debug("Attempt to load property file " + path);
+ if (LOG.isDebugEnabled())
+ LOG.debug("Attempt to load property file " + path);
props = PropertiesLoader.load(in);
}
else if (Tools.endsWithIgnoreCase(fileName, ".xml"))
{
- if (log.isDebugEnabled())
- log.debug("Attempt to load property file " + path + "
with XML format");
+ if (LOG.isDebugEnabled())
+ LOG.debug("Attempt to load property file " + path + "
with XML format");
props = PropertiesLoader.loadFromXML(in);
}
- else if (log.isDebugEnabled())
+ else if (LOG.isDebugEnabled())
{
- log.debug("Will not load property file" + path + " because
its format is not recognized");
+ LOG.debug("Will not load property file" + path + " because
its format is not recognized");
}
if (props != null && resolveVariables)
{
@@ -289,12 +289,12 @@
}
else
{
- log.error("Could not load property file " + path);
+ LOG.error("Could not load property file " + path);
}
}
catch (Exception e)
{
- log.error("Cannot load property file " + path, e);
+ LOG.error("Cannot load property file " + path, e);
}
finally
{
@@ -306,6 +306,10 @@
}
catch (IOException ignore)
{
+ if (LOG.isTraceEnabled())
+ {
+ LOG.trace("An exception occurred: " + ignore.getMessage());
+ }
}
}
}
Modified:
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/util/ExoWurflSource.java
===================================================================
---
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/util/ExoWurflSource.java 2012-02-24
14:34:41 UTC (rev 8456)
+++
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/util/ExoWurflSource.java 2012-02-24
15:37:53 UTC (rev 8457)
@@ -21,6 +21,7 @@
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
+import java.io.IOException;
import java.io.InputStream;
//import net.sourceforge.wurfl.wurflapi.WurflSource;
@@ -41,7 +42,7 @@
{
return wurflUrl.openStream();
}
- catch (Exception e)
+ catch (IOException e)
{
LOG.error(e.getLocalizedMessage(), e);
return null;
Added:
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/util/TemplateConfigurationHelper.java
===================================================================
---
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/util/TemplateConfigurationHelper.java
(rev 0)
+++
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/util/TemplateConfigurationHelper.java 2012-02-24
15:37:53 UTC (rev 8457)
@@ -0,0 +1,260 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.container.util;
+
+import org.exoplatform.commons.utils.PrivilegedFileHelper;
+import org.exoplatform.container.configuration.ConfigurationManager;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.regex.Pattern;
+
+/**
+ * Builds configuration from template using map of template-variables <--> value.
+ * Class provides extra functionality for filtering parameters by pattern, excluding
+ * unnecessary parameters.
+ *
+ * @author <a href="mailto:nikolazius@gmail.com">Nikolay
Zamosenchuk</a>
+ * @version $Id: TemplateConfigurationHelper.java 34360 2009-07-22 23:58:59Z nzamosenchuk
$
+ *
+ */
+public class TemplateConfigurationHelper
+{
+
+ private static final Log LOG =
ExoLogger.getLogger("exo.kernel.container.TemplateConfigurationHelper");
+
+ // list with include-patterns
+ private List<Pattern> includes = new ArrayList<Pattern>();
+
+ // list with exclude-patterns
+ private List<Pattern> excludes = new ArrayList<Pattern>();
+
+ private ConfigurationManager cfm;
+
+ /**
+ * Creates instance of template configuration helper with given lists of filtering
+ * patterns. Parameter will be included only if it matches any include-pattern and
+ * doesn't match any exclude-pattern. I.e. You can include "extended-*"
and exclude
+ * "extended-type". Please refer to Java regexp documentation. Filtering for
this
+ * example, should be defined as following:
+ * include: "^extended-.*"
+ * exclude: "^extended-type"
+ *
+ * @param includes Array with string representation of include reg-exp patterns
+ * @param excludes Array with string representation of exclude reg-exp patterns
+ * @param ConfigurationManager instance for looking up resources
+ */
+ public TemplateConfigurationHelper(String[] includes, String[] excludes,
ConfigurationManager cfm)
+ {
+ super();
+ this.cfm = cfm;
+ // compile include patterns
+ for (String regex : includes)
+ {
+ this.includes.add(Pattern.compile(regex));
+ }
+ // compile exclude patterns
+ for (String regex : excludes)
+ {
+ this.excludes.add(Pattern.compile(regex));
+ }
+ }
+
+ /**
+ * Reads configuration file from a stream and replaces all the occurrences of
template-variables
+ * (like : "${parameter.name}") with values provided in the map.
+ *
+ * @param inputStream
+ * @param parameters
+ * @return
+ * @throws IOException
+ */
+ public InputStream fillTemplate(InputStream inputStream, Map<String, String>
parameters) throws IOException
+ {
+ if (inputStream == null || parameters == null || parameters.size() == 0)
+ {
+ return inputStream;
+ }
+ // parameters filtering
+ Map<String, String> preparedParams = prepareParameters(parameters);
+ // read stream
+ String configuration = readStream(inputStream);
+ for (Entry<String, String> entry : preparedParams.entrySet())
+ {
+ configuration = configuration.replace(entry.getKey(), entry.getValue());
+ }
+ // create new stream
+ InputStream configurationStream = new
ByteArrayInputStream(configuration.getBytes());
+ return configurationStream;
+ }
+
+ /**
+ * Reads configuration file from a stream and replaces all the occurrences of
template-variables
+ * (like : "${parameter.name}") with values provided in the map.
+ *
+ * @param filename
+ * @param parameters
+ * @return
+ * @throws IOException
+ */
+ public InputStream fillTemplate(String filename, Map<String, String> parameters)
throws IOException
+ {
+ InputStream inputStream = getInputStream(cfm, filename);
+ // inputStream still remains null, so file was not opened
+ if (inputStream == null)
+ {
+ throw new IOException("Can't find or open file:" + filename);
+ }
+ return fillTemplate(inputStream, parameters);
+ }
+
+ /**
+ * Tries first to get the file content using the configuration manager, if it cannot
+ * be found it will then try to get it from the context class loader of the current
thread,
+ * if it cannot be found it will try to get it from the class loader of the current
class and
+ * finally it still cannot be found it will try to use the file name as a file path.
+ * @param cfm the configuration manager from which we want to try to find the file
content
+ * @param filename the name of the file to found
+ * @return the {@link InputStream} corresponding to the file content if it can be
found
+ * <code>null</code> otherwise
+ */
+ public static InputStream getInputStream(ConfigurationManager cfm, String filename)
+ {
+ InputStream inputStream = null;
+ // try to get using configuration manager
+ try
+ {
+ inputStream = cfm.getInputStream(filename);
+ }
+ catch (Exception e)
+ {
+ if (LOG.isTraceEnabled())
+ {
+ LOG.trace("An exception occurred: " + e.getMessage());
+ }
+ }
+
+ // try to get resource by class loader
+ if (inputStream == null)
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ inputStream = cl == null ? null : cl.getResourceAsStream(filename);
+ }
+
+ // check system class loader
+ if (inputStream == null)
+ {
+ inputStream =
TemplateConfigurationHelper.class.getClassLoader().getResourceAsStream(filename);
+ }
+
+ // try to get as file stream
+ if (inputStream == null)
+ {
+ try
+ {
+ inputStream = PrivilegedFileHelper.fileInputStream(filename);
+ }
+ catch (IOException e)
+ {
+ if (LOG.isTraceEnabled())
+ {
+ LOG.trace("An exception occurred: " + e.getMessage());
+ }
+ }
+ }
+ return inputStream;
+ }
+
+ /**
+ * Checks if String mathes to any pattern from the list
+ *
+ * @param patterns
+ * @param parameter
+ * @return
+ */
+ private boolean matches(List<Pattern> patterns, String parameter)
+ {
+ for (Pattern pattern : patterns)
+ {
+ if (pattern.matcher(parameter).matches())
+ {
+ // string matched
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Filters the map of parameters, leaving only those than matches filtering regular
expressions.
+ * Also adds "${}" to the parameter key: <br>
+ * I.e. such map provided on input:
+ *
+ * "jbosscache-cache.loader":"org.exoplatform"
+ * "jbosscache-configuration":"/conf/test.xml"
+ * "max-volatile-size":"100Kb"
+ *
+ * the output will be like:
+ *
+ * "${jbosscache-cache.loader}":"org.exoplatform"
+ *
+ * Other will be ignored (depending on includes/excludes lists provided in
constructor).
+ *
+ * @param parameters
+ * @return
+ */
+ protected Map<String, String> prepareParameters(Map<String, String>
parameters)
+ {
+ Map<String, String> map = new HashMap<String, String>();
+ for (Entry<String, String> entry : parameters.entrySet())
+ {
+ if (matches(includes, entry.getKey()) && !matches(excludes,
entry.getKey()))
+ {
+ map.put("${" + entry.getKey() + "}", entry.getValue());
+ }
+ }
+ return map;
+ }
+
+ /**
+ * Reads bytes from input stream and builds a string from them
+ *
+ * @param inputStream
+ * @return
+ * @throws IOException
+ */
+ protected String readStream(InputStream inputStream) throws IOException
+ {
+ StringBuffer out = new StringBuffer();
+ byte[] b = new byte[4096];
+ for (int n; (n = inputStream.read(b)) != -1;)
+ {
+ out.append(new String(b, 0, n));
+ }
+ return out.toString();
+ }
+}
Modified:
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/xml/Configuration.java
===================================================================
---
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/xml/Configuration.java 2012-02-24
14:34:41 UTC (rev 8456)
+++
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/xml/Configuration.java 2012-02-24
15:37:53 UTC (rev 8457)
@@ -47,7 +47,7 @@
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 static final Log LOG =
ExoLogger.getLogger("exo.kernel.container.Configuration");
private Map<String, ContainerLifecyclePlugin> containerLifecyclePlugin_ =
new HashMap<String, ContainerLifecyclePlugin>();
@@ -257,16 +257,8 @@
}
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;
- }
+ // Initialize with the clone of the first non null configuration
+ result = (Configuration)conf.clone();
}
else
{
@@ -276,6 +268,42 @@
}
return result;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ protected Object clone()
+ {
+ try
+ {
+ Configuration conf = (Configuration)super.clone();
+ conf.component_ = (Map<String, Component>)((HashMap<String,
Component>)component_).clone();
+ conf.componentLifecyclePlugin_ =
+ (Map<String, ComponentLifecyclePlugin>)((HashMap<String,
ComponentLifecyclePlugin>)componentLifecyclePlugin_)
+ .clone();
+ conf.containerLifecyclePlugin_ =
+ (Map<String, ContainerLifecyclePlugin>)((HashMap<String,
ContainerLifecyclePlugin>)containerLifecyclePlugin_)
+ .clone();
+ conf.externalComponentPlugins_ =
+ (Map<String, ExternalComponentPlugins>)((HashMap<String,
ExternalComponentPlugins>)externalComponentPlugins_)
+ .clone();
+ if (imports_ != null)
+ {
+ conf.imports_ = (ArrayList<String>)imports_.clone();
+ }
+ if (removeConfiguration_ != null)
+ {
+ conf.removeConfiguration_ =
(ArrayList<String>)removeConfiguration_.clone();
+ }
+ return conf;
+ }
+ catch (CloneNotSupportedException e)
+ {
+ throw new AssertionError("Could not clone the configuration");
+ }
+ }
/**
* Dumps the configuration in XML format into the given {@link Writer}
@@ -291,7 +319,7 @@
}
catch (Exception e)
{
- log.warn("Couldn't dump the runtime configuration in XML Format",
e);
+ LOG.warn("Couldn't dump the runtime configuration in XML Format",
e);
}
}
@@ -308,7 +336,7 @@
}
catch (Exception e)
{
- log.warn("Cannot convert the configuration to XML format", e);
+ LOG.warn("Cannot convert the configuration to XML format", e);
return null;
}
finally
@@ -319,6 +347,10 @@
}
catch (IOException ignore)
{
+ if (LOG.isTraceEnabled())
+ {
+ LOG.trace("An exception occurred: " + ignore.getMessage());
+ }
}
}
return sw.toString();
Modified:
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/xml/ObjectParam.java
===================================================================
---
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/xml/ObjectParam.java 2012-02-24
14:34:41 UTC (rev 8456)
+++
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/container/xml/ObjectParam.java 2012-02-24
15:37:53 UTC (rev 8457)
@@ -100,7 +100,7 @@
}
}
}
- catch (Throwable ex)
+ catch (Exception ex)
{
// if(prop != null) {
// S ystem.out.println("Exception when try setting the prop.name " +
@@ -149,10 +149,15 @@
{
String[] temp = value.split(" ");
String className = temp[1];
+
if (className.indexOf(".") < 0)
{
- className = package_ + "." + className;
- Class clazz = Class.forName(className);
+ StringBuilder fullName = new StringBuilder();
+ fullName.append(package_);
+ fullName.append(".");
+ fullName.append(className);
+
+ Class clazz = Class.forName(fullName.toString());
return clazz.newInstance();
}
}
Modified:
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/management/jmx/impl/JMXManagementProvider.java
===================================================================
---
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/management/jmx/impl/JMXManagementProvider.java 2012-02-24
14:34:41 UTC (rev 8456)
+++
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/management/jmx/impl/JMXManagementProvider.java 2012-02-24
15:37:53 UTC (rev 8457)
@@ -32,11 +32,14 @@
import java.util.Map;
import javax.management.InstanceNotFoundException;
+import javax.management.MBeanException;
import javax.management.MBeanRegistrationException;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
+import javax.management.RuntimeOperationsException;
+import javax.management.modelmbean.InvalidTargetObjectTypeException;
import javax.management.modelmbean.ModelMBeanInfo;
/**
@@ -73,11 +76,41 @@
ModelMBeanInfo info = infoBuilder.build();
mbean = new ExoModelMBean(context, context.getResource(), info);
}
- catch (Exception e)
+ catch (IllegalArgumentException e)
{
- LOG.warn("Could not create the ExoModelMBean for the class " +
- (context == null ? null : (context.getResource() == null ? null :
context.getResource().getClass())), e);
+ LOG.warn(
+ "Could not create the ExoModelMBean for the class "
+ + (context == null ? null : (context.getResource() == null ? null :
context.getResource().getClass())),
+ e);
}
+ catch (RuntimeOperationsException e)
+ {
+ LOG.warn(
+ "Could not create the ExoModelMBean for the class "
+ + (context == null ? null : (context.getResource() == null ? null :
context.getResource().getClass())),
+ e);
+ }
+ catch (InstanceNotFoundException e)
+ {
+ LOG.warn(
+ "Could not create the ExoModelMBean for the class "
+ + (context == null ? null : (context.getResource() == null ? null :
context.getResource().getClass())),
+ e);
+ }
+ catch (MBeanException e)
+ {
+ LOG.warn(
+ "Could not create the ExoModelMBean for the class "
+ + (context == null ? null : (context.getResource() == null ? null :
context.getResource().getClass())),
+ e);
+ }
+ catch (InvalidTargetObjectTypeException e)
+ {
+ LOG.warn(
+ "Could not create the ExoModelMBean for the class "
+ + (context == null ? null : (context.getResource() == null ? null :
context.getResource().getClass())),
+ e);
+ }
//
if (mbean != null)
@@ -166,7 +199,7 @@
}
});
}
- catch (Exception e)
+ catch (PrivilegedActionException e)
{
throw new RuntimeException("Failed to unregister MBean '" +
name + " due to " + e.getMessage(), e);
}
@@ -182,7 +215,7 @@
}
});
}
- catch (Exception e)
+ catch (PrivilegedActionException e)
{
throw new RuntimeException("Failed to register MBean '" + name
+ " due to " + e.getMessage(), e);
}
Modified:
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/management/spi/ManagedMethodMetaData.java
===================================================================
---
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/management/spi/ManagedMethodMetaData.java 2012-02-24
14:34:41 UTC (rev 8456)
+++
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/management/spi/ManagedMethodMetaData.java 2012-02-24
15:37:53 UTC (rev 8457)
@@ -49,17 +49,17 @@
*
* @param method the method
* @param impactType the access mode
- * @throws NullPointerException if the method is null or the impact is null
+ * @throws IllegalArgumentException if the method is null or the impact is null
*/
- public ManagedMethodMetaData(Method method, ImpactType impactType) throws
NullPointerException
+ public ManagedMethodMetaData(Method method, ImpactType impactType) throws
IllegalArgumentException
{
if (method == null)
{
- throw new NullPointerException();
+ throw new IllegalArgumentException("The method cannot be null");
}
if (impactType == null)
{
- throw new NullPointerException();
+ throw new IllegalArgumentException("The impactType cannot be null");
}
//
@@ -87,7 +87,7 @@
{
if (parameter == null)
{
- throw new NullPointerException("No null parameter accepted");
+ throw new IllegalArgumentException("No null parameter accepted");
}
parameters.put(parameter.getIndex(), parameter);
}
Modified:
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/management/spi/ManagedPropertyMetaData.java
===================================================================
---
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/management/spi/ManagedPropertyMetaData.java 2012-02-24
14:34:41 UTC (rev 8456)
+++
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/management/spi/ManagedPropertyMetaData.java 2012-02-24
15:37:53 UTC (rev 8457)
@@ -48,12 +48,11 @@
private final ManagedParameterMetaData setterParameter;
public ManagedPropertyMetaData(String name, Method getter, String getterDescription,
Method setter,
- String setterDescription, ManagedParameterMetaData setterParameter) throws
NullPointerException,
- IllegalArgumentException
+ String setterDescription, ManagedParameterMetaData setterParameter) throws
IllegalArgumentException
{
if (name == null)
{
- throw new NullPointerException("No null name accepted");
+ throw new IllegalArgumentException("No null name accepted");
}
if (setter != null)
{
Modified:
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/management/spi/ManagedTypeMetaData.java
===================================================================
---
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/management/spi/ManagedTypeMetaData.java 2012-02-24
14:34:41 UTC (rev 8456)
+++
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/main/java/org/exoplatform/management/spi/ManagedTypeMetaData.java 2012-02-24
15:37:53 UTC (rev 8457)
@@ -43,11 +43,11 @@
/** . */
private final Map<MethodKey, ManagedMethodMetaData> methods;
- public ManagedTypeMetaData(Class type) throws NullPointerException
+ public ManagedTypeMetaData(Class type) throws IllegalArgumentException
{
if (type == null)
{
- throw new NullPointerException();
+ throw new IllegalArgumentException("The type cannot be null");
}
//
Modified:
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/test/java/org/exoplatform/container/TestPortalContainer.java
===================================================================
---
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/test/java/org/exoplatform/container/TestPortalContainer.java 2012-02-24
14:34:41 UTC (rev 8456)
+++
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/test/java/org/exoplatform/container/TestPortalContainer.java 2012-02-24
15:37:53 UTC (rev 8457)
@@ -161,6 +161,36 @@
assertNull(PortalContainer.getCurrentSetting("boolean"));
}
+ public void testGetConfigurationXML()
+ {
+ URL rootURL = getClass().getResource("test-exo-container.xml");
+ URL portalURL = getClass().getResource("/conf/test-configuration.xml");
+ assertNotNull(rootURL);
+ assertNotNull(portalURL);
+ //
+ new ContainerBuilder().withRoot(rootURL).withPortal(portalURL).build();
+
+ String configXML = RootContainer.getInstance().getConfigurationXML();
+ assertNotNull(configXML);
+ int size = configXML.length();
+ int hash = configXML.hashCode();
+ configXML = RootContainer.getInstance().getConfigurationXML();
+ assertNotNull(configXML);
+ assertTrue(size > 0);
+ assertEquals(size, configXML.length());
+ assertEquals(hash, configXML.hashCode());
+
+ configXML = PortalContainer.getInstance().getConfigurationXML();
+ assertNotNull(configXML);
+ assertTrue(size > 0);
+ size = configXML.length();
+ hash = configXML.hashCode();
+ configXML = PortalContainer.getInstance().getConfigurationXML();
+ assertNotNull(configXML);
+ assertEquals(size, configXML.length());
+ assertEquals(hash, configXML.hashCode());
+ }
+
public static class MyComponent
{
private final InitParams params;
Added:
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/test/java/org/exoplatform/container/TestStandaloneContainer.java
===================================================================
---
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/test/java/org/exoplatform/container/TestStandaloneContainer.java
(rev 0)
+++
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/test/java/org/exoplatform/container/TestStandaloneContainer.java 2012-02-24
15:37:53 UTC (rev 8457)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.container;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:nfilotto@exoplatform.com">Nicolas
Filotto</a>
+ * @version $Id$
+ *
+ */
+public class TestStandaloneContainer extends TestCase
+{
+
+ public void testHotDeploy() throws Exception
+ {
+ StandaloneContainer.getInstance();
+ ExoContainer container = ExoContainerContext.getTopContainer();
+ assertEquals(container.getClass(), StandaloneContainer.class);
+ container = ExoContainerContext.getCurrentContainer();
+ assertEquals(container.getClass(), StandaloneContainer.class);
+
+ container.stop();
+
+ StandaloneContainer.getInstance();
+ container = ExoContainerContext.getTopContainer();
+ assertEquals(container.getClass(), StandaloneContainer.class);
+ container = ExoContainerContext.getCurrentContainer();
+ assertEquals(container.getClass(), StandaloneContainer.class);
+ }
+}
Added:
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/test/java/org/exoplatform/container/util/TestTemplateConfigurationHelper.java
===================================================================
---
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/test/java/org/exoplatform/container/util/TestTemplateConfigurationHelper.java
(rev 0)
+++
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/test/java/org/exoplatform/container/util/TestTemplateConfigurationHelper.java 2012-02-24
15:37:53 UTC (rev 8457)
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.container.util;
+
+import junit.framework.TestCase;
+
+import org.exoplatform.container.configuration.ConfigurationManagerImpl;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:nikolazius@gmail.com">Nikolay
Zamosenchuk</a>
+ * @version $Id: TestTemplateHelper.java 34360 2009-07-22 23:58:59Z nzamosenchuk $
+ *
+ */
+public class TestTemplateConfigurationHelper extends TestCase
+{
+
+ public void testFilters()
+ {
+ // create helper with predefined include and exclude patterns
+ TemplateConfigurationHelper helper =
+ new TemplateConfigurationHelper(new String[]{"^jbosscache-.*",
"^jgroups-configuration"},
+ new String[]{"^jbosscache-configuration"}, new
ConfigurationManagerImpl());
+ Map<String, String> parameters = new HashMap<String, String>();
+ parameters.put("jbosscache-configuration", "");
+ parameters.put("jbosscache-cache.loader", "");
+ parameters.put("jbosscache-clustername", "");
+ parameters.put("max-volatile-size", "");
+ Map<String, String> preparedParameters =
helper.prepareParameters(parameters);
+ assertEquals(2, preparedParameters.size());
+ // "jbosscache-configuration" and "max-volatile-size" should be
excluded
+
assertFalse(preparedParameters.containsKey("${jbosscache-configuration}"));
+ assertFalse(preparedParameters.containsKey("${max-volatile-size}"));
+
assertTrue(preparedParameters.containsKey("${jbosscache-cache.loader}"));
+ assertTrue(preparedParameters.containsKey("${jbosscache-clustername}"));
+ }
+
+ public void testFilters2()
+ {
+ // create helper with predefined include and exclude patterns
+ TemplateConfigurationHelper helper =
+ new TemplateConfigurationHelper(new String[]{"^jbosscache-.*",
"^jgroups-configuration"},
+ new String[]{"^jbosscache-configuration"}, new
ConfigurationManagerImpl());
+ Map<String, String> parameters = new HashMap<String, String>();
+ parameters.put("jgroups-configuration", "");
+ parameters.put("jbosscache-cache.loader", "");
+ parameters.put("jbosscache-clustername", "");
+ parameters.put("max-volatile-size", "");
+ Map<String, String> preparedParameters =
helper.prepareParameters(parameters);
+ assertEquals(3, preparedParameters.size());
+ // "jbosscache-configuration" and "max-volatile-size" should be
excluded
+ assertFalse(preparedParameters.containsKey("${max-volatile-size}"));
+
assertTrue(preparedParameters.containsKey("${jbosscache-cache.loader}"));
+ assertTrue(preparedParameters.containsKey("${jbosscache-clustername}"));
+ }
+
+ public void testTemplating() throws IOException
+ {
+ TemplateConfigurationHelper helper =
+ new TemplateConfigurationHelper(new String[]{"^jbosscache-.*",
"^jgroups-configuration"},
+ new String[]{"^jbosscache-configuration"}, new
ConfigurationManagerImpl());
+ String template = "configuration in any format, containing
${jbosscache-template-variable} and many others";
+ String expectedConfig = "configuration in any format, containing pretty good
parameter and many others";
+
+ InputStream templateStream = new ByteArrayInputStream(template.getBytes());
+
+ Map<String, String> parameters = new HashMap<String, String>();
+ parameters.put("jbosscache-template-variable", "pretty good
parameter");
+
+ InputStream configStream = helper.fillTemplate(templateStream, parameters);
+ String config = readStream(configStream);
+ assertTrue(expectedConfig.equals(config));
+ }
+
+ private String readStream(InputStream inputStream) throws IOException
+ {
+ StringBuffer out = new StringBuffer();
+ byte[] b = new byte[4096];
+ for (int n; (n = inputStream.read(b)) != -1;)
+ {
+ out.append(new String(b, 0, n));
+ }
+ return out.toString();
+ }
+}
Added:
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/test/resources/tsm-excludes.properties
===================================================================
---
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/test/resources/tsm-excludes.properties
(rev 0)
+++
sandbox/as7_support/branches/gatein-as7/exo.kernel.container/src/test/resources/tsm-excludes.properties 2012-02-24
15:37:53 UTC (rev 8457)
@@ -0,0 +1 @@
+org.exoplatform.container.TestPortalContainer.testGetConfigurationXML=getConfigurationXML
\ No newline at end of file