exo-jcr SVN: r2057 - in jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules: jcr and 1 other directory.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-03-11 12:30:03 -0500 (Thu, 11 Mar 2010)
New Revision: 2057
Added:
jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/jcr/statistics.xml
Modified:
jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/jcr.xml
Log:
EXOJCR-585: doc
Added: jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/jcr/statistics.xml
===================================================================
--- jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/jcr/statistics.xml (rev 0)
+++ jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/jcr/statistics.xml 2010-03-11 17:30:03 UTC (rev 2057)
@@ -0,0 +1,251 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<chapter>
+ <title>eXo JCR statistics</title>
+
+ <section>
+ <title>Statistics on the Database Access Layer</title>
+
+ <para>In order to have a better idea of the time spent into the database
+ access layer, it cans be interesting to get some statistics on that part
+ of the code, knowing that most of the time spent into eXo JCR is mainly
+ the database access. This statistics will then allow you to identify
+ without using any profiler what is anormally slow in this layer, which
+ could help to fix the problem quickly.</para>
+
+ <para>In case you use
+ <envar>org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer</envar>
+ or
+ <envar>org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer</envar>
+ as <envar>WorkspaceDataContainer</envar>, you can get statistics on the
+ time spent into the database access layer. The database access layer (in
+ eXo JCR) is represented by the methods of the interface
+ <envar>org.exoplatform.services.jcr.storage.WorkspaceStorageConnection</envar>,
+ so for all the methods defined in this interface, we can have the
+ following figures: </para>
+
+ <itemizedlist>
+ <listitem>
+ <para>The minimum time spent into the method.</para>
+ </listitem>
+
+ <listitem>
+ <para>The maximum time spent into the method.</para>
+ </listitem>
+
+ <listitem>
+ <para>The average time spent into the method.</para>
+ </listitem>
+
+ <listitem>
+ <para>The total amount of time spent into the method.</para>
+ </listitem>
+
+ <listitem>
+ <para>The total amount of times the method has been called.</para>
+ </listitem>
+ </itemizedlist>
+
+ <para>Those figures are also available globaly for all the methods which
+ gives us the global behavior of this layer.</para>
+
+ <para>If you want to enable the statistics, you just need to set the JVM
+ parameter called
+ <emphasis>JDBCWorkspaceDataContainer.statistics.enabled</emphasis> to
+ <emphasis>true</emphasis>. This will then create at startup a file called
+ <emphasis>StatisticsJDBCStorageConnection-${creation-timestamp}.csv</emphasis>
+ into the user directory if it is possible otherwise it will create it into
+ the temporary directory. The format of this file is <envar>CSV</envar>
+ (i.e. Comma-Seperated Values), one new line will be added every 5 seconds
+ and one last line will be added at JVM exit. Each line, will be composed
+ of the 5 figures described above for each method and globaly for all the
+ methods.</para>
+
+ <para>The format of each column header is
+ ${method-alias}-${metric-alias}.</para>
+
+ <table>
+ <title>Method Alias</title>
+
+ <tgroup cols="2">
+ <tbody>
+ <row>
+ <entry>global</entry>
+
+ <entry>This is the alias for all the methods.</entry>
+ </row>
+
+ <row>
+ <entry>getItemDataById</entry>
+
+ <entry>This is the alias for the method
+ <emphasis>getItemData(String identifier).</emphasis></entry>
+ </row>
+
+ <row>
+ <entry>getItemDataByNodeDataNQPathEntry</entry>
+
+ <entry>This is the alias for the method
+ <emphasis>getItemData(NodeData parentData, QPathEntry
+ name).</emphasis></entry>
+ </row>
+
+ <row>
+ <entry>getChildNodesData</entry>
+
+ <entry>This is the alias for the method
+ <emphasis>getChildNodesData(NodeData parent).</emphasis></entry>
+ </row>
+
+ <row>
+ <entry>getChildNodesCount</entry>
+
+ <entry>This is the alias for the method
+ <emphasis>getChildNodesCount(NodeData parent).</emphasis></entry>
+ </row>
+
+ <row>
+ <entry>getChildPropertiesData</entry>
+
+ <entry>This is the alias for the method
+ <emphasis>getChildPropertiesData(NodeData
+ parent).</emphasis></entry>
+ </row>
+
+ <row>
+ <entry>listChildPropertiesData</entry>
+
+ <entry>This is the alias for the method
+ <emphasis>listChildPropertiesData(NodeData
+ parent).</emphasis></entry>
+ </row>
+
+ <row>
+ <entry>getReferencesData</entry>
+
+ <entry>This is the alias for the method
+ <emphasis>getReferencesData(String
+ nodeIdentifier).</emphasis></entry>
+ </row>
+
+ <row>
+ <entry>commit</entry>
+
+ <entry>This is the alias for the method
+ <emphasis>commit().</emphasis></entry>
+ </row>
+
+ <row>
+ <entry>addNodeData</entry>
+
+ <entry>This is the alias for the method <emphasis>add(NodeData
+ data).</emphasis></entry>
+ </row>
+
+ <row>
+ <entry>addPropertyData</entry>
+
+ <entry>This is the alias for the method <emphasis>add(PropertyData
+ data).</emphasis></entry>
+ </row>
+
+ <row>
+ <entry>updateNodeData</entry>
+
+ <entry>This is the alias for the method <emphasis>update(NodeData
+ data).</emphasis></entry>
+ </row>
+
+ <row>
+ <entry>updatePropertyData</entry>
+
+ <entry>This is the alias for the method
+ <emphasis>update(PropertyData data).</emphasis></entry>
+ </row>
+
+ <row>
+ <entry>deleteNodeData</entry>
+
+ <entry>This is the alias for the method <emphasis>delete(NodeData
+ data).</emphasis></entry>
+ </row>
+
+ <row>
+ <entry>deletePropertyData</entry>
+
+ <entry>This is the alias for the method
+ <emphasis>delete(PropertyData data).</emphasis></entry>
+ </row>
+
+ <row>
+ <entry>renameNodeData</entry>
+
+ <entry>This is the alias for the method <emphasis>rename(NodeData
+ data).</emphasis></entry>
+ </row>
+
+ <row>
+ <entry>rollback</entry>
+
+ <entry>This is the alias for the method
+ <emphasis>rollback().</emphasis></entry>
+ </row>
+
+ <row>
+ <entry>isOpened</entry>
+
+ <entry>This is the alias for the method
+ <emphasis>isOpened().</emphasis></entry>
+ </row>
+
+ <row>
+ <entry>close</entry>
+
+ <entry>This is the alias for the method
+ <emphasis>close().</emphasis></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <table>
+ <title>Metric Alias</title>
+
+ <tgroup cols="2">
+ <tbody>
+ <row>
+ <entry>Min</entry>
+
+ <entry>The minimum time spent into the method.</entry>
+ </row>
+
+ <row>
+ <entry>Max</entry>
+
+ <entry>The maximum time spent into the method.</entry>
+ </row>
+
+ <row>
+ <entry>Total</entry>
+
+ <entry>The total amount of time spent into the method.</entry>
+ </row>
+
+ <row>
+ <entry>Avg</entry>
+
+ <entry>The average time spent into the method.</entry>
+ </row>
+
+ <row>
+ <entry>Times</entry>
+
+ <entry>The total amount of times the method has been
+ called.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </section>
+</chapter>
Modified: jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/jcr.xml
===================================================================
--- jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/jcr.xml 2010-03-11 16:08:26 UTC (rev 2056)
+++ jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/jcr.xml 2010-03-11 17:30:03 UTC (rev 2057)
@@ -52,4 +52,8 @@
<xi:include href="jcr/transaction-manager-lookup.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <!-- statistics configs -->
+
+ <xi:include href="jcr/statistics.xml"
+ xmlns:xi="http://www.w3.org/2001/XInclude" />
</part>
16 years, 2 months
exo-jcr SVN: r2056 - jcr/trunk/applications.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-03-11 11:08:26 -0500 (Thu, 11 Mar 2010)
New Revision: 2056
Modified:
jcr/trunk/applications/product-exo-jcr-as-tomcat6.xml
Log:
EXOJCR-586: add slf4j dependency
Modified: jcr/trunk/applications/product-exo-jcr-as-tomcat6.xml
===================================================================
--- jcr/trunk/applications/product-exo-jcr-as-tomcat6.xml 2010-03-11 14:23:47 UTC (rev 2055)
+++ jcr/trunk/applications/product-exo-jcr-as-tomcat6.xml 2010-03-11 16:08:26 UTC (rev 2056)
@@ -32,13 +32,35 @@
<name>eXo JCR Product</name>
<url>http://www.exoplatform.org</url>
<description>eXo JCR Product</description>
-
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.5.8</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.5.8</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
<dependencies>
<dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>runtime</scope>
+ </dependency>
</dependencies>
<properties>
16 years, 2 months
exo-jcr SVN: r2055 - in jcr/trunk/exo.jcr.component.core: src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc and 1 other directories.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-03-11 09:23:47 -0500 (Thu, 11 Mar 2010)
New Revision: 2055
Added:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/statistics/
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/statistics/StatisticsJDBCStorageConnection.java
Modified:
jcr/trunk/exo.jcr.component.core/pom.xml
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java
Log:
EXOJCR-585: Allow to get statistics
Modified: jcr/trunk/exo.jcr.component.core/pom.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/pom.xml 2010-03-11 12:15:22 UTC (rev 2054)
+++ jcr/trunk/exo.jcr.component.core/pom.xml 2010-03-11 14:23:47 UTC (rev 2055)
@@ -364,7 +364,12 @@
<property>
<name>emma.coverage.out.file</name>
<value>target/emma/coverage.ec</value>
- </property>
+ </property>
+ <!-- Uncomment the line below if you want to enable the statistics -->
+ <!--property>
+ <name>JDBCWorkspaceDataContainer.statistics.enabled</name>
+ <value>true</value>
+ </property-->
</systemProperties>
<includes>
<include>org/exoplatform/services/jcr/api/**/Test*.java</include>
@@ -546,7 +551,12 @@
org.apache.jackrabbit.test.api.nodetype.PredefinedNodeTypeTest#testVersionable
org.apache.jackrabbit.test.api.nodetype.PredefinedNodeTypeTest#testVersion
org.apache.jackrabbit.test.api.NamespaceRegistryTest#testRegisterNamespace</value>
- </property>
+ </property>
+ <!-- Uncomment the line below if you want to enable the statistics -->
+ <!--property>
+ <name>JDBCWorkspaceDataContainer.statistics.enabled</name>
+ <value>true</value>
+ </property-->
</systemProperties>
<includes>
<include>org/apache/jackrabbit/test/api/*Test.java</include>
@@ -613,7 +623,12 @@
org.apache.jackrabbit.test.api.nodetype.PredefinedNodeTypeTest#testVersionable
org.apache.jackrabbit.test.api.nodetype.PredefinedNodeTypeTest#testVersion
org.apache.jackrabbit.test.api.NamespaceRegistryTest#testRegisterNamespace</value>
- </property>
+ </property>
+ <!-- Uncomment the line below if you want to enable the statistics -->
+ <!--property>
+ <name>JDBCWorkspaceDataContainer.statistics.enabled</name>
+ <value>true</value>
+ </property-->
</systemProperties>
<includes>
<!-- From default tests -->
@@ -684,7 +699,12 @@
<property>
<name>jcr.test.configuration.file</name>
<value>${jcr.test.configuration.file}</value>
- </property>
+ </property>
+ <!-- Uncomment the line below if you want to enable the statistics -->
+ <!--property>
+ <name>JDBCWorkspaceDataContainer.statistics.enabled</name>
+ <value>true</value>
+ </property-->
</systemProperties>
<includes>
<include>**/**/reading_/Test*.java</include>
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java 2010-03-11 12:15:22 UTC (rev 2054)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java 2010-03-11 14:23:47 UTC (rev 2055)
@@ -27,10 +27,11 @@
import org.exoplatform.services.jcr.impl.storage.jdbc.db.MySQLConnectionFactory;
import org.exoplatform.services.jcr.impl.storage.jdbc.db.OracleConnectionFactory;
import org.exoplatform.services.jcr.impl.storage.jdbc.db.WorkspaceStorageConnectionFactory;
-import org.exoplatform.services.jcr.impl.storage.jdbc.init.StorageDBInitializer;
import org.exoplatform.services.jcr.impl.storage.jdbc.init.IngresSQLDBInitializer;
import org.exoplatform.services.jcr.impl.storage.jdbc.init.OracleDBInitializer;
import org.exoplatform.services.jcr.impl.storage.jdbc.init.PgSQLDBInitializer;
+import org.exoplatform.services.jcr.impl.storage.jdbc.init.StorageDBInitializer;
+import org.exoplatform.services.jcr.impl.storage.jdbc.statistics.StatisticsJDBCStorageConnection;
import org.exoplatform.services.jcr.impl.storage.jdbc.update.StorageUpdateManager;
import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializerException;
@@ -64,6 +65,18 @@
protected static final Log LOG = ExoLogger.getLogger("jcr.JDBCWorkspaceDataContainer");
+ /**
+ * Indicates if the statistics has to be enabled.
+ */
+ public static final boolean STATISTICS_ENABLED = Boolean.valueOf(System.getProperty("JDBCWorkspaceDataContainer.statistics.enabled"));
+ static
+ {
+ if (STATISTICS_ENABLED)
+ {
+ LOG.info("The statistics of the component JDBCWorkspaceDataContainer has been enabled");
+ }
+ }
+
//configuration params
public final static String SOURCE_NAME = "source-name";
@@ -724,8 +737,12 @@
*/
public WorkspaceStorageConnection openConnection() throws RepositoryException
{
-
- return connFactory.openConnection();
+ WorkspaceStorageConnection con = connFactory.openConnection();
+ if (STATISTICS_ENABLED)
+ {
+ con = new StatisticsJDBCStorageConnection(con);
+ }
+ return con;
}
/**
@@ -733,8 +750,12 @@
*/
public WorkspaceStorageConnection openConnection(boolean readOnly) throws RepositoryException
{
-
- return connFactory.openConnection(readOnly);
+ WorkspaceStorageConnection con = connFactory.openConnection(readOnly);
+ if (STATISTICS_ENABLED)
+ {
+ con = new StatisticsJDBCStorageConnection(con);
+ }
+ return con;
}
/**
@@ -742,14 +763,18 @@
*/
public WorkspaceStorageConnection reuseConnection(WorkspaceStorageConnection original) throws RepositoryException
{
-
+ if (original instanceof StatisticsJDBCStorageConnection)
+ {
+ original = ((StatisticsJDBCStorageConnection)original).getNestedWorkspaceStorageConnection();
+ }
+
if (original instanceof JDBCStorageConnection)
{
WorkspaceStorageConnectionFactory cFactory =
new SharedConnectionFactory(((JDBCStorageConnection)original).getJdbcConnection(), containerName, multiDb,
valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
- return cFactory.openConnection();
+ return STATISTICS_ENABLED ? new StatisticsJDBCStorageConnection(cFactory.openConnection()) : cFactory.openConnection();
}
else
{
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/statistics/StatisticsJDBCStorageConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/statistics/StatisticsJDBCStorageConnection.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/statistics/StatisticsJDBCStorageConnection.java 2010-03-11 14:23:47 UTC (rev 2055)
@@ -0,0 +1,805 @@
+package org.exoplatform.services.jcr.impl.storage.jdbc.statistics;
+
+import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.datamodel.QPathEntry;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
+import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Queue;
+import java.util.concurrent.atomic.AtomicLong;
+
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.RepositoryException;
+
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * This class is used to give statistics about the time spent in the database access layer. It will
+ * print all the metrics value into a file in csv format. It will provide metrics of type
+ * minimum, maximum, total, times and average for each method of {@link WorkspaceStorageConnection}
+ * and the global values. It will add data into the file every 5 seconds and add the last line at
+ * JVM exit. To activate the statistics, set the JVM parameter called
+ * "JDBCWorkspaceDataContainer.statistics.enabled" to <code>true</code>.
+ *
+ * Created by The eXo Platform SAS
+ * Author : Nicolas Filotto
+ * nicolas.filotto(a)exoplatform.com
+ * 26 f�vr. 2010
+ */
+public class StatisticsJDBCStorageConnection implements WorkspaceStorageConnection
+{
+
+ /**
+ * The logger
+ */
+ private static final Log LOG = ExoLogger.getLogger(StatisticsJDBCStorageConnection.class);
+
+ /**
+ * The description of the statistics corresponding to the method
+ * <code>update(PropertyData data)</code>
+ */
+ private static final String UPDATE_PROPERTY_DATA_DESCR = "updatePropertyData";
+
+ /**
+ * The description of the statistics corresponding to the method
+ * <code>update(NodeData data)</code>
+ */
+ private static final String UPDATE_NODE_DATA_DESCR = "updateNodeData";
+
+ /**
+ * The description of the statistics corresponding to the method
+ * <code>rollback()</code>
+ */
+ private static final String ROLLBACK_DESCR = "rollback";
+
+ /**
+ * The description of the statistics corresponding to the method
+ * <code>rename(NodeData data)</code>
+ */
+ private static final String RENAME_NODE_DATA_DESCR = "renameNodeData";
+
+ /**
+ * The description of the statistics corresponding to the method
+ * <code>listChildPropertiesData(NodeData parent)</code>
+ */
+ private static final String LIST_CHILD_PROPERTIES_DATA_DESCR = "listChildPropertiesData";
+
+ /**
+ * The description of the statistics corresponding to the method
+ * <code>isOpened()</code>
+ */
+ private static final String IS_OPENED_DESCR = "isOpened";
+
+ /**
+ * The description of the statistics corresponding to the method
+ * <code>getReferencesData(String nodeIdentifier)</code>
+ */
+ private static final String GET_REFERENCES_DATA_DESCR = "getReferencesData";
+
+ /**
+ * The description of the statistics corresponding to the method
+ * <code>getItemData(String identifier)</code>
+ */
+ private static final String GET_ITEM_DATA_BY_ID_DESCR = "getItemDataById";
+
+ /**
+ * The description of the statistics corresponding to the method
+ * <code>getItemData(NodeData parentData, QPathEntry name)</code>
+ */
+ private static final String GET_ITEM_DATA_BY_NODE_DATA_NQ_PATH_ENTRY_DESCR = "getItemDataByNodeDataNQPathEntry";
+
+ /**
+ * The description of the statistics corresponding to the method
+ * <code>getChildPropertiesData(NodeData parent)</code>
+ */
+ private static final String GET_CHILD_PROPERTIES_DATA_DESCR = "getChildPropertiesData";
+
+ /**
+ * The description of the statistics corresponding to the method
+ * <code>getChildNodesData(NodeData parent)</code>
+ */
+ private static final String GET_CHILD_NODES_DATA_DESCR = "getChildNodesData";
+
+ /**
+ * The description of the statistics corresponding to the method
+ * <code>getChildNodesCount(NodeData parent)</code>
+ */
+ private static final String GET_CHILD_NODES_COUNT_DESCR = "getChildNodesCount";
+
+ /**
+ * The description of the statistics corresponding to the method
+ * <code>delete(PropertyData data)</code>
+ */
+ private static final String DELETE_PROPERTY_DATA_DESCR = "deletePropertyData";
+
+ /**
+ * The description of the statistics corresponding to the method
+ * <code>delete(NodeData data)</code>
+ */
+ private static final String DELETE_NODE_DATA_DESCR = "deleteNodeData";
+
+ /**
+ * The description of the statistics corresponding to the method
+ * <code>commit()</code>
+ */
+ private static final String COMMIT_DESCR = "commit";
+
+ /**
+ * The description of the statistics corresponding to the method
+ * <code>close()</code>
+ */
+ private static final String CLOSE_DESCR = "close";
+
+ /**
+ * The description of the statistics corresponding to the method
+ * <code>add(PropertyData data)</code>
+ */
+ private static final String ADD_PROPERTY_DATA_DESCR = "addPropertyData";
+
+ /**
+ * The description of the statistics corresponding to the method
+ * <code>add(NodeData data)</code>
+ */
+ private static final String ADD_NODE_DATA_DESCR = "addNodeData";
+
+ /**
+ * The global statistics for all the database accesses
+ */
+ private final static Statistics GLOBAL_STATISTICS = new Statistics("global");
+
+ /**
+ * The list of all the statistics, one per method
+ */
+ private final static Map<String, Statistics> ALL_STATISTICS = new LinkedHashMap<String, Statistics>();
+ static
+ {
+ // Read Methods
+ ALL_STATISTICS.put(GET_ITEM_DATA_BY_ID_DESCR, new Statistics(GET_ITEM_DATA_BY_ID_DESCR));
+ ALL_STATISTICS.put(GET_ITEM_DATA_BY_NODE_DATA_NQ_PATH_ENTRY_DESCR, new Statistics(
+ GET_ITEM_DATA_BY_NODE_DATA_NQ_PATH_ENTRY_DESCR));
+ ALL_STATISTICS.put(GET_CHILD_NODES_DATA_DESCR, new Statistics(GET_CHILD_NODES_DATA_DESCR));
+ ALL_STATISTICS.put(GET_CHILD_NODES_COUNT_DESCR, new Statistics(GET_CHILD_NODES_COUNT_DESCR));
+ ALL_STATISTICS.put(GET_CHILD_PROPERTIES_DATA_DESCR, new Statistics(GET_CHILD_PROPERTIES_DATA_DESCR));
+ ALL_STATISTICS.put(LIST_CHILD_PROPERTIES_DATA_DESCR, new Statistics(LIST_CHILD_PROPERTIES_DATA_DESCR));
+ ALL_STATISTICS.put(GET_REFERENCES_DATA_DESCR, new Statistics(GET_REFERENCES_DATA_DESCR));
+ // Write Methods
+ // Commit
+ ALL_STATISTICS.put(COMMIT_DESCR, new Statistics(COMMIT_DESCR));
+ // Add methods
+ ALL_STATISTICS.put(ADD_NODE_DATA_DESCR, new Statistics(ADD_NODE_DATA_DESCR));
+ ALL_STATISTICS.put(ADD_PROPERTY_DATA_DESCR, new Statistics(ADD_PROPERTY_DATA_DESCR));
+ // Update methods
+ ALL_STATISTICS.put(UPDATE_NODE_DATA_DESCR, new Statistics(UPDATE_NODE_DATA_DESCR));
+ ALL_STATISTICS.put(UPDATE_PROPERTY_DATA_DESCR, new Statistics(UPDATE_PROPERTY_DATA_DESCR));
+ // Delete methods
+ ALL_STATISTICS.put(DELETE_NODE_DATA_DESCR, new Statistics(DELETE_NODE_DATA_DESCR));
+ ALL_STATISTICS.put(DELETE_PROPERTY_DATA_DESCR, new Statistics(DELETE_PROPERTY_DATA_DESCR));
+ // Rename
+ ALL_STATISTICS.put(RENAME_NODE_DATA_DESCR, new Statistics(RENAME_NODE_DATA_DESCR));
+ // Rollback
+ ALL_STATISTICS.put(ROLLBACK_DESCR, new Statistics(ROLLBACK_DESCR));
+ // Others
+ ALL_STATISTICS.put(IS_OPENED_DESCR, new Statistics(IS_OPENED_DESCR));
+ ALL_STATISTICS.put(CLOSE_DESCR, new Statistics(CLOSE_DESCR));
+ }
+
+ /**
+ * The printer used to print the statistics in csv format
+ */
+ private static PrintWriter STATISTICS_WRITER;
+ static
+ {
+ if (JDBCWorkspaceDataContainer.STATISTICS_ENABLED)
+ {
+ initWriter();
+ if (STATISTICS_WRITER != null)
+ {
+ addTriggers();
+ }
+ }
+ }
+
+ /**
+ * Add all the triggers that will keep the file up to date.
+ */
+ private static void addTriggers()
+ {
+ Runtime.getRuntime().addShutdownHook(new Thread("StatisticsJDBCStorageConnection-Hook")
+ {
+ public void run()
+ {
+ printData();
+ }
+ });
+ // Define the file header
+ printHeader();
+ Thread t = new Thread("StatisticsJDBCStorageConnection-Writer")
+ {
+ public void run()
+ {
+ while (true)
+ {
+ try
+ {
+ sleep(5000);
+ }
+ catch (InterruptedException e)
+ {
+ LOG.debug("InterruptedException", e);
+ }
+ printData();
+ }
+ }
+ };
+ t.setDaemon(true);
+ t.start();
+ }
+
+ /**
+ * Initialize the {@link PrintWriter}.
+ * It will first try to create the file in the user directory, if it cannot, it will try
+ * to create it in the temporary folder.
+ */
+ private static void initWriter()
+ {
+ File file = null;
+ try
+ {
+ file =
+ new File(System.getProperty("user.dir"), "StatisticsJDBCStorageConnection-" + System.currentTimeMillis()
+ + ".csv");
+ file.createNewFile();
+ STATISTICS_WRITER = new PrintWriter(file);
+ }
+ catch (IOException e)
+ {
+ LOG
+ .error(
+ "Cannot create the file for the statistics in the user directory, we will try to create it in the temp directory",
+ e);
+ try
+ {
+ file = File.createTempFile("StatisticsJDBCStorageConnection", "-" + System.currentTimeMillis() + ".csv");
+ STATISTICS_WRITER = new PrintWriter(file);
+ }
+ catch (IOException e1)
+ {
+ LOG.error("Cannot create the file for the statistics", e1);
+ }
+ }
+ if (file != null)
+ {
+ LOG.info("The file for the statistics is " + file.getPath());
+ }
+ }
+
+ /**
+ * The nested {@link WorkspaceStorageConnection}
+ */
+ private final WorkspaceStorageConnection wcs;
+
+ /**
+ * The default constructor
+ */
+ public StatisticsJDBCStorageConnection(WorkspaceStorageConnection wcs)
+ {
+ this.wcs = wcs;
+ }
+
+ /**
+ * @return the nested {@link WorkspaceStorageConnection}
+ */
+ public WorkspaceStorageConnection getNestedWorkspaceStorageConnection()
+ {
+ return wcs;
+ }
+
+ /**
+ * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#add(org.exoplatform.services.jcr.datamodel.NodeData)
+ */
+ public void add(NodeData data) throws RepositoryException, UnsupportedOperationException, InvalidItemStateException,
+ IllegalStateException
+ {
+ Statistics s = ALL_STATISTICS.get(ADD_NODE_DATA_DESCR);
+ try
+ {
+ s.begin();
+ wcs.add(data);
+ }
+ finally
+ {
+ s.end();
+ }
+ }
+
+ /**
+ * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#add(org.exoplatform.services.jcr.datamodel.PropertyData)
+ */
+ public void add(PropertyData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ Statistics s = ALL_STATISTICS.get(ADD_PROPERTY_DATA_DESCR);
+ try
+ {
+ s.begin();
+ wcs.add(data);
+ }
+ finally
+ {
+ s.end();
+ }
+ }
+
+ /**
+ * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#close()
+ */
+ public void close() throws IllegalStateException, RepositoryException
+ {
+ Statistics s = ALL_STATISTICS.get(CLOSE_DESCR);
+ try
+ {
+ s.begin();
+ wcs.close();
+ }
+ finally
+ {
+ s.end();
+ }
+ }
+
+ /**
+ * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#commit()
+ */
+ public void commit() throws IllegalStateException, RepositoryException
+ {
+ Statistics s = ALL_STATISTICS.get(COMMIT_DESCR);
+ try
+ {
+ s.begin();
+ wcs.commit();
+ }
+ finally
+ {
+ s.end();
+ }
+ }
+
+ /**
+ * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#delete(org.exoplatform.services.jcr.datamodel.NodeData)
+ */
+ public void delete(NodeData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ Statistics s = ALL_STATISTICS.get(DELETE_NODE_DATA_DESCR);
+ try
+ {
+ s.begin();
+ wcs.delete(data);
+ }
+ finally
+ {
+ s.end();
+ }
+ }
+
+ /**
+ * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#delete(org.exoplatform.services.jcr.datamodel.PropertyData)
+ */
+ public void delete(PropertyData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ Statistics s = ALL_STATISTICS.get(DELETE_PROPERTY_DATA_DESCR);
+ try
+ {
+ s.begin();
+ wcs.delete(data);
+ }
+ finally
+ {
+ s.end();
+ }
+ }
+
+ /**
+ * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#getChildNodesCount(org.exoplatform.services.jcr.datamodel.NodeData)
+ */
+ public int getChildNodesCount(NodeData parent) throws RepositoryException
+ {
+ Statistics s = ALL_STATISTICS.get(GET_CHILD_NODES_COUNT_DESCR);
+ try
+ {
+ s.begin();
+ return wcs.getChildNodesCount(parent);
+ }
+ finally
+ {
+ s.end();
+ }
+ }
+
+ /**
+ * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#getChildNodesData(org.exoplatform.services.jcr.datamodel.NodeData)
+ */
+ public List<NodeData> getChildNodesData(NodeData parent) throws RepositoryException, IllegalStateException
+ {
+ Statistics s = ALL_STATISTICS.get(GET_CHILD_NODES_DATA_DESCR);
+ try
+ {
+ s.begin();
+ return wcs.getChildNodesData(parent);
+ }
+ finally
+ {
+ s.end();
+ }
+ }
+
+ /**
+ * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#getChildPropertiesData(org.exoplatform.services.jcr.datamodel.NodeData)
+ */
+ public List<PropertyData> getChildPropertiesData(NodeData parent) throws RepositoryException, IllegalStateException
+ {
+ Statistics s = ALL_STATISTICS.get(GET_CHILD_PROPERTIES_DATA_DESCR);
+ try
+ {
+ s.begin();
+ return wcs.getChildPropertiesData(parent);
+ }
+ finally
+ {
+ s.end();
+ }
+ }
+
+ /**
+ * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#getItemData(org.exoplatform.services.jcr.datamodel.NodeData, org.exoplatform.services.jcr.datamodel.QPathEntry)
+ */
+ public ItemData getItemData(NodeData parentData, QPathEntry name) throws RepositoryException, IllegalStateException
+ {
+ Statistics s = ALL_STATISTICS.get(GET_ITEM_DATA_BY_NODE_DATA_NQ_PATH_ENTRY_DESCR);
+ try
+ {
+ s.begin();
+ return wcs.getItemData(parentData, name);
+ }
+ finally
+ {
+ s.end();
+ }
+ }
+
+ /**
+ * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#getItemData(java.lang.String)
+ */
+ public ItemData getItemData(String identifier) throws RepositoryException, IllegalStateException
+ {
+ Statistics s = ALL_STATISTICS.get(GET_ITEM_DATA_BY_ID_DESCR);
+ try
+ {
+ s.begin();
+ return wcs.getItemData(identifier);
+ }
+ finally
+ {
+ s.end();
+ }
+ }
+
+ /**
+ * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#getReferencesData(java.lang.String)
+ */
+ public List<PropertyData> getReferencesData(String nodeIdentifier) throws RepositoryException,
+ IllegalStateException, UnsupportedOperationException
+ {
+ Statistics s = ALL_STATISTICS.get(GET_REFERENCES_DATA_DESCR);
+ try
+ {
+ s.begin();
+ return wcs.getReferencesData(nodeIdentifier);
+ }
+ finally
+ {
+ s.end();
+ }
+ }
+
+ /**
+ * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#isOpened()
+ */
+ public boolean isOpened()
+ {
+ Statistics s = ALL_STATISTICS.get(IS_OPENED_DESCR);
+ try
+ {
+ s.begin();
+ return wcs.isOpened();
+ }
+ finally
+ {
+ s.end();
+ }
+ }
+
+ /**
+ * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#listChildPropertiesData(org.exoplatform.services.jcr.datamodel.NodeData)
+ */
+ public List<PropertyData> listChildPropertiesData(NodeData parent) throws RepositoryException, IllegalStateException
+ {
+ Statistics s = ALL_STATISTICS.get(LIST_CHILD_PROPERTIES_DATA_DESCR);
+ try
+ {
+ s.begin();
+ return wcs.listChildPropertiesData(parent);
+ }
+ finally
+ {
+ s.end();
+ }
+ }
+
+ /**
+ * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#rename(org.exoplatform.services.jcr.datamodel.NodeData)
+ */
+ public void rename(NodeData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ Statistics s = ALL_STATISTICS.get(RENAME_NODE_DATA_DESCR);
+ try
+ {
+ s.begin();
+ wcs.rename(data);
+ }
+ finally
+ {
+ s.end();
+ }
+ }
+
+ /**
+ * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#rollback()
+ */
+ public void rollback() throws IllegalStateException, RepositoryException
+ {
+ Statistics s = ALL_STATISTICS.get(ROLLBACK_DESCR);
+ try
+ {
+ s.begin();
+ wcs.rollback();
+ }
+ finally
+ {
+ s.end();
+ }
+ }
+
+ /**
+ * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#update(org.exoplatform.services.jcr.datamodel.NodeData)
+ */
+ public void update(NodeData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ Statistics s = ALL_STATISTICS.get(UPDATE_NODE_DATA_DESCR);
+ try
+ {
+ s.begin();
+ wcs.update(data);
+ }
+ finally
+ {
+ s.end();
+ }
+ }
+
+ /**
+ * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#update(org.exoplatform.services.jcr.datamodel.PropertyData)
+ */
+ public void update(PropertyData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ Statistics s = ALL_STATISTICS.get(UPDATE_PROPERTY_DATA_DESCR);
+ try
+ {
+ s.begin();
+ wcs.update(data);
+ }
+ finally
+ {
+ s.end();
+ }
+ }
+
+ /**
+ * Print the header of the csv file
+ */
+ private static void printHeader()
+ {
+ GLOBAL_STATISTICS.printHeader(STATISTICS_WRITER);
+ for (Statistics s : ALL_STATISTICS.values())
+ {
+ STATISTICS_WRITER.print(',');
+ s.printHeader(STATISTICS_WRITER);
+ }
+ STATISTICS_WRITER.println();
+ STATISTICS_WRITER.flush();
+ }
+
+ /**
+ * Add one line of data
+ */
+ private static void printData()
+ {
+ GLOBAL_STATISTICS.printData(STATISTICS_WRITER);
+ for (Statistics s : ALL_STATISTICS.values())
+ {
+ STATISTICS_WRITER.print(',');
+ s.printData(STATISTICS_WRITER);
+ }
+ STATISTICS_WRITER.println();
+ STATISTICS_WRITER.flush();
+ }
+
+ /**
+ * The class used to manage all the metrics such as minimum, maximum, total, times and average.
+ */
+ private static class Statistics
+ {
+
+ /**
+ * The description of the statistics
+ */
+ private final String description;
+
+ /**
+ * The min value of the time spent for one call
+ */
+ private final AtomicLong min = new AtomicLong(Long.MAX_VALUE);
+
+ /**
+ * The max value of the time spent for one call
+ */
+ private final AtomicLong max = new AtomicLong(-1);
+
+ /**
+ * The total time spent for all the calls
+ */
+ private final AtomicLong total = new AtomicLong();
+
+ /**
+ * The total amount of calls
+ */
+ private final AtomicLong times = new AtomicLong();
+
+ /**
+ * The {@link ThreadLocal} used to keep the initial timestamp
+ */
+ private final ThreadLocal<Queue<Long>> currentTime = new ThreadLocal<Queue<Long>>()
+ {
+ protected Queue<Long> initialValue()
+ {
+ return new LinkedList<Long>();
+ }
+ };
+
+ /**
+ * The default constructor
+ * @param description the description of the statistics
+ */
+ public Statistics(String description)
+ {
+ this.description = description;
+ }
+
+ /**
+ * Start recording
+ */
+ public void begin()
+ {
+ GLOBAL_STATISTICS.onBegin();
+ onBegin();
+ }
+
+ /**
+ * Store the current timestamp in the {@link ThreadLocal}
+ */
+ private void onBegin()
+ {
+ Queue<Long> q = currentTime.get();
+ q.add(System.currentTimeMillis());
+ }
+
+ /**
+ * Stop recording
+ */
+ public void end()
+ {
+ onEnd();
+ GLOBAL_STATISTICS.onEnd();
+ }
+
+ /**
+ * Refresh the values of the metrics (min, max, total and times)
+ */
+ private void onEnd()
+ {
+ long result = System.currentTimeMillis() - currentTime.get().poll();
+ times.incrementAndGet();
+ if (result < min.get())
+ {
+ min.set(result);
+ }
+ if (max.get() < result)
+ {
+ max.set(result);
+ }
+ total.addAndGet(result);
+ }
+
+ /**
+ * Print the description of all the metrics into the given {@link PrintWriter}
+ */
+ public void printHeader(PrintWriter pw)
+ {
+ pw.print(description);
+ pw.print("-Min,");
+ pw.print(description);
+ pw.print("-Max,");
+ pw.print(description);
+ pw.print("-Total,");
+ pw.print(description);
+ pw.print("-Avg,");
+ pw.print(description);
+ pw.print("-Times");
+ }
+
+ /**
+ * Print the current snapshot of the metrics and evaluate the average value
+ */
+ public void printData(PrintWriter pw)
+ {
+ long lmin = min.get();
+ if (lmin == Long.MAX_VALUE)
+ {
+ lmin = -1;
+ }
+ long lmax = max.get();
+ long ltotal = total.get();
+ long ltimes = times.get();
+ float favg = ltimes == 0 ? 0f : (float)ltotal / ltimes;
+ pw.print(lmin);
+ pw.print(',');
+ pw.print(lmax);
+ pw.print(',');
+ pw.print(ltotal);
+ pw.print(',');
+ pw.print(favg);
+ pw.print(',');
+ pw.print(ltimes);
+ }
+ }
+}
16 years, 2 months
exo-jcr SVN: r2054 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-03-11 07:15:22 -0500 (Thu, 11 Mar 2010)
New Revision: 2054
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
Log:
EXOJCR-519: the queries used to retrieve properties (i.e. FIND_PROPERTIES_BY_PARENTID and FIND_PROPERTIES_BY_PARENTID_CQ) change of explain during load due to the order clause which makes the database do a full scan. If we order by Name instead of Id, we don't have such behavior.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java 2010-03-11 11:49:47 UTC (rev 2053)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java 2010-03-11 12:15:22 UTC (rev 2054)
@@ -215,13 +215,13 @@
FIND_NODES_COUNT_BY_PARENTID = "select count(ID) from JCR_MITEM" + " where I_CLASS=1 and PARENT_ID=?";
- FIND_PROPERTIES_BY_PARENTID = "select * from JCR_MITEM" + " where I_CLASS=2 and PARENT_ID=?" + " order by ID";
+ FIND_PROPERTIES_BY_PARENTID = "select * from JCR_MITEM" + " where I_CLASS=2 and PARENT_ID=?" + " order by NAME";
// property may contain no values
FIND_PROPERTIES_BY_PARENTID_CQ =
"select I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_CLASS, I.I_INDEX, I.N_ORDER_NUM, I.P_TYPE, I.P_MULTIVALUED,"
+ " V.ORDER_NUM, V.DATA, V.STORAGE_DESC from JCR_MITEM I LEFT OUTER JOIN JCR_MVALUE V ON (V.PROPERTY_ID=I.ID)"
- + " where I.I_CLASS=2 and I.PARENT_ID=? order by I.ID";
+ + " where I.I_CLASS=2 and I.PARENT_ID=? order by I.NAME";
INSERT_NODE =
"insert into JCR_MITEM(ID, PARENT_ID, NAME, VERSION, I_CLASS, I_INDEX, N_ORDER_NUM) VALUES(?,?,?,?,"
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java 2010-03-11 11:49:47 UTC (rev 2053)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java 2010-03-11 12:15:22 UTC (rev 2054)
@@ -225,12 +225,12 @@
"select count(ID) from JCR_SITEM" + " where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?";
FIND_PROPERTIES_BY_PARENTID =
- "select * from JCR_SITEM" + " where I_CLASS=2 and CONTAINER_NAME=? and PARENT_ID=?" + " order by ID";
+ "select * from JCR_SITEM" + " where I_CLASS=2 and CONTAINER_NAME=? and PARENT_ID=?" + " order by NAME";
FIND_PROPERTIES_BY_PARENTID_CQ =
"select I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_CLASS, I.I_INDEX, I.N_ORDER_NUM, I.P_TYPE, I.P_MULTIVALUED, V.ORDER_NUM,"
+ " V.DATA, V.STORAGE_DESC from JCR_SITEM I LEFT OUTER JOIN JCR_SVALUE V ON (V.PROPERTY_ID=I.ID)"
- + " where I.I_CLASS=2 and CONTAINER_NAME=? and I.PARENT_ID=? order by I.ID";
+ + " where I.I_CLASS=2 and CONTAINER_NAME=? and I.PARENT_ID=? order by I.NAME";
INSERT_NODE =
"insert into JCR_SITEM(ID, PARENT_ID, NAME, CONTAINER_NAME, VERSION, I_CLASS, I_INDEX, N_ORDER_NUM) VALUES(?,?,?,?,?,"
16 years, 2 months
exo-jcr SVN: r2053 - in jcr/tags/1.12.0-GA: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation and 2 other directories.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-03-11 06:49:47 -0500 (Thu, 11 Mar 2010)
New Revision: 2053
Modified:
jcr/tags/1.12.0-GA/docs/reference/en/src/main/docbook/en-US/modules/kernel/cache.xml
jcr/tags/1.12.0-GA/docs/reference/en/src/main/docbook/en-US/modules/kernel/configuration.xml
jcr/tags/1.12.0-GA/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java
jcr/tags/1.12.0-GA/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
jcr/tags/1.12.0-GA/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
jcr/tags/1.12.0-GA/exo.jcr.component.core/src/main/resources/binding-nodetypevalues.xml
jcr/tags/1.12.0-GA/exo.jcr.component.core/src/main/resources/binding.xml
Log:
EXOJCR-483 Changes from EXOJCR-556 EXOJCR-565 EXOJCR-576 EXOJCR-579 ported to JCR 1.12.0-GA Tag
Modified: jcr/tags/1.12.0-GA/docs/reference/en/src/main/docbook/en-US/modules/kernel/cache.xml
===================================================================
--- jcr/tags/1.12.0-GA/docs/reference/en/src/main/docbook/en-US/modules/kernel/cache.xml 2010-03-11 11:49:03 UTC (rev 2052)
+++ jcr/tags/1.12.0-GA/docs/reference/en/src/main/docbook/en-US/modules/kernel/cache.xml 2010-03-11 11:49:47 UTC (rev 2053)
@@ -137,7 +137,7 @@
</tgroup>
</table>
- <para> </para>
+ <para></para>
</section>
<section>
@@ -377,8 +377,8 @@
<name>LRU</name>
<description>The lru cache creator</description>
<object type="org.exoplatform.services.cache.impl.jboss.lru.LRUExoCacheCreator">
- <field name="defaultTimeToLive"><long>${my-value}</long></field>
- <field name="defaultMaxAge"><long>${my-value}</long></field>
+ <field name="defaultTimeToLive"><long>${my-value}</long></field>
+ <field name="defaultMaxAge"><long>${my-value}</long></field>
</object>
</object-param>
...</programlisting>
@@ -394,8 +394,8 @@
<entry>This is the default value of the field
<emphasis>timeToLive</emphasis> described in the section
dedicated to this cache type. This value is only use when we
- defined a cache of this type with the super type
- <envar>ExoCacheConfig</envar>.</entry>
+ define a cache of this type with the old
+ configuration.</entry>
</row>
<row>
@@ -404,8 +404,8 @@
<entry>his is the default value of the field
<emphasis>maxAge</emphasis> described in the section
dedicated to this cache type. This value is only use when we
- defined a cache of this type with the super type
- <envar>ExoCacheConfig</envar>.</entry>
+ define a cache of this type with the old
+ configuration.</entry>
</row>
</tbody>
</tgroup>
@@ -444,7 +444,7 @@
<name>LFU</name>
<description>The lfu cache creator</description>
<object type="org.exoplatform.services.cache.impl.jboss.lfu.LFUExoCacheCreator">
- <field name="defaultMinNodes"><int>${my-value}</int></field>
+ <field name="defaultMinNodes"><int>${my-value}</int></field>
</object>
</object-param>
...</programlisting>
@@ -460,13 +460,45 @@
<entry>This is the default value of the field
<emphasis>minNodes</emphasis> described in the section
dedicated to this cache type. This value is only use when we
- defined a cache of this type with the super type
- <envar>ExoCacheConfig</envar>.</entry>
+ define a cache of this type with the old
+ configuration.</entry>
</row>
</tbody>
</tgroup>
</table>
</section>
+
+ <section>
+ <title>EA Cache Creator - Expiration Algorithm</title>
+
+ <programlisting>...
+<object-param>
+ <name>EA</name>
+ <description>The ea cache creator</description>
+ <object type="org.exoplatform.services.cache.impl.jboss.ea.EAExoCacheCreator">
+ <field name="defaultExpirationTimeout"><long>2000</long></field>
+ </object>
+</object-param>
+...</programlisting>
+
+ <table>
+ <title>Fields description</title>
+
+ <tgroup cols="2">
+ <tbody>
+ <row>
+ <entry>defaultExpirationTimeout</entry>
+
+ <entry>This is the default value of the field
+ <emphasis>minNodes</emphasis> described in the section
+ dedicated to this cache type. This value is only use when we
+ define a cache of this type with the old
+ configuration.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </section>
</section>
</section>
@@ -476,7 +508,7 @@
<section>
<title>How to define a cache?</title>
- <para>You have 2 ways to define a cache which are: </para>
+ <para>You have 2 ways to define a cache which are:</para>
<itemizedlist>
<listitem>
@@ -952,6 +984,105 @@
</listitem>
</itemizedlist>
</section>
+
+ <section>
+ <title>EA Cache - Expiration Algorithm</title>
+
+ <itemizedlist>
+ <listitem>
+ <para>New configuration<programlisting>...
+ <object-param>
+ <name>ea</name>
+ <description>The ea cache configuration</description>
+ <object type="org.exoplatform.services.cache.impl.jboss.ea.EAExoCacheConfig">
+ <field name="name"><string>ea</string></field>
+ <field name="maxNodes"><int>${my-value}</int></field>
+ <field name="minTimeToLive"><long>${my-value}</long></field>
+ <field name="expirationTimeout"><long>${my-value}</long></field>
+ </object>
+ </object-param>
+...</programlisting></para>
+
+ <table>
+ <title>Fields description</title>
+
+ <tgroup cols="2">
+ <tbody>
+ <row>
+ <entry>maxNodes</entry>
+
+ <entry>This is the maximum number of nodes allowed in this
+ region. 0 denotes immediate expiry, -1 denotes no
+ limit.</entry>
+ </row>
+
+ <row>
+ <entry>minTimeToLive</entry>
+
+ <entry>The minimum amount of time (in milliseconds) a node
+ must be allowed to live after being accessed before it is
+ allowed to be considered for eviction. 0 denotes that this
+ feature is disabled, which is the default value.</entry>
+ </row>
+
+ <row>
+ <entry>expirationTimeout</entry>
+
+ <entry>This is the timeout after which the cache entry
+ must be evicted.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </listitem>
+
+ <listitem>
+ <para>Old configuration<programlisting>...
+ <object-param>
+ <name>ea-with-old-config</name>
+ <description>The ea cache configuration</description>
+ <object type="org.exoplatform.services.cache.ExoCacheConfig">
+ <field name="name"><string>lfu-with-old-config</string></field>
+ <field name="maxSize"><int>${my-value}</int></field>
+ <field name="liveTime"><long>${my-value}</long></field>
+ <field name="implementation"><string>EA</string></field>
+ </object>
+ </object-param>
+...</programlisting></para>
+
+ <table>
+ <title>Fields description</title>
+
+ <tgroup cols="2">
+ <tbody>
+ <row>
+ <entry>maxSize</entry>
+
+ <entry>This is the maximum number of nodes allowed in this
+ region. 0 denotes immediate expiry, -1 denotes no
+ limit.</entry>
+ </row>
+
+ <row>
+ <entry>liveTime</entry>
+
+ <entry>The minimum amount of time (in milliseconds) a node
+ must be allowed to live after being accessed before it is
+ allowed to be considered for eviction. 0 denotes that this
+ feature is disabled, which is the default value.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <para><note>
+ <para>For the fields <emphasis>expirationTimeout</emphasis>
+ needed by JBoss cache, we will use the default values provided
+ by the creator.</para>
+ </note></para>
+ </listitem>
+ </itemizedlist>
+ </section>
</section>
</section>
</chapter>
Modified: jcr/tags/1.12.0-GA/docs/reference/en/src/main/docbook/en-US/modules/kernel/configuration.xml
===================================================================
--- jcr/tags/1.12.0-GA/docs/reference/en/src/main/docbook/en-US/modules/kernel/configuration.xml 2010-03-11 11:49:03 UTC (rev 2052)
+++ jcr/tags/1.12.0-GA/docs/reference/en/src/main/docbook/en-US/modules/kernel/configuration.xml 2010-03-11 11:49:47 UTC (rev 2053)
@@ -350,6 +350,60 @@
<name>default.realm.name</name>
<value>my-exo-domain</value>
</value-param>
+ <!-- The default portal container definition -->
+ <!-- It cans be used to avoid duplicating configuration -->
+ <object-param>
+ <name>default.portal.definition</name>
+ <object type="org.exoplatform.container.definition.PortalContainerDefinition">
+ <!-- All the dependencies of the portal container ordered by loading priority -->
+ <field name="dependencies">
+ <collection type="java.util.ArrayList">
+ <value>
+ <string>foo</string>
+ </value>
+ <value>
+ <string>foo2</string>
+ </value>
+ <value>
+ <string>foo3</string>
+ </value>
+ </collection>
+ </field>
+ <!-- A map of settings tied to the default portal container -->
+ <field name="settings">
+ <map type="java.util.HashMap">
+ <entry>
+ <key>
+ <string>foo5</string>
+ </key>
+ <value>
+ <string>value</string>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>string</string>
+ </key>
+ <value>
+ <string>value0</string>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>int</string>
+ </key>
+ <value>
+ <int>100</int>
+ </value>
+ </entry>
+ </map>
+ </field>
+ <!-- The path to the external properties file -->
+ <field name="externalSettingsPath">
+ <string>classpath:/org/exoplatform/container/definition/default-settings.properties</string>
+ </field>
+ </object>
+ </object-param>
</init-params>
</component></programlisting>
@@ -379,6 +433,17 @@
<entry>The name of the default realm. This field is
optional.</entry>
</row>
+
+ <row>
+ <entry>default.portal.definition</entry>
+
+ <entry>The definition of the default portal container. This
+ field is optional. The expected type is
+ <envar>org.exoplatform.container.definition.PortalContainerDefinition</envar>
+ that is described below. Allow the parameters defined in this
+ default <envar>PortalContainerDefinition</envar> will be the
+ default values.</entry>
+ </row>
</tbody>
</tgroup>
</table>
@@ -482,7 +547,8 @@
<table>
<title>Descriptions of the fields of
- <envar>PortalContainerDefinition</envar></title>
+ <envar>PortalContainerDefinition</envar> when it is used to define a
+ new portal container</title>
<tgroup cols="2">
<tbody>
@@ -490,7 +556,7 @@
<entry>name</entry>
<entry>The name of the portal container. This field is
- mandatory.</entry>
+ mandatory .</entry>
</row>
<row>
@@ -499,7 +565,7 @@
<entry>The name of the context name of the rest web
application. This field is optional. The default value will
the value define at the <envar>PortalContainerConfig</envar>
- level if it is not null, "rest" otherwise.</entry>
+ level.</entry>
</row>
<row>
@@ -507,22 +573,24 @@
<entry>The name of the realm. This field is optional. The
default value will the value define at the
- <envar>PortalContainerConfig</envar> level if it is not null,
- "exo-domain" otherwise.</entry>
+ <envar>PortalContainerConfig</envar> level.</entry>
</row>
<row>
<entry>dependencies</entry>
<entry>All the dependencies of the portal container ordered by
- loading priority. The dependencies are in fact the list of the
- context names of the web applications from which the portal
- container depends. This field is optional. The dependency
- order is really crucial since it will be interpreted the same
- way by several components of the platform. All those
- components, will consider the 1st element in the list less
- important than the second element and so on. It is currently
- used to:<itemizedlist>
+ loading priority. This field is optional. The default value
+ will the value define at the
+ <envar>PortalContainerConfig</envar> level. The dependencies
+ are in fact the list of the context names of the web
+ applications from which the portal container depends. This
+ field is optional. The dependency order is really crucial
+ since it will be interpreted the same way by several
+ components of the platform. All those components, will
+ consider the 1st element in the list less important than the
+ second element and so on. It is currently used
+ to:<itemizedlist>
<listitem>
<para>Know the loading order of all the
dependencies.</para>
@@ -571,7 +639,11 @@
<entry>A <envar>java.util.Map</envar> of internal parameters
that we would like to tie the portal container. Those
parameters could have any type of value. This field is
- optional.</entry>
+ optional. If some internal settings are defined at the
+ <envar>PortalContainerConfig</envar> level, the two maps of
+ settings will be merged. If a setting with the same name is
+ defined in both maps, it will keep the value defined at the
+ <envar>PortalContainerDefinition</envar> level.</entry>
</row>
<row>
@@ -579,9 +651,13 @@
<entry>The path of the external properties file to load as
default settings to the portal container. This field is
- optional. The external properties files can be either of type
- "properties" or of type "xml". The path will be interpreted as
- follows:<orderedlist>
+ optional. If some external settings are defined at the
+ <envar>PortalContainerConfig</envar> level, the two maps of
+ settings will be merged. If a setting with the same name is
+ defined in both maps, it will keep the value defined at the
+ <envar>PortalContainerDefinition</envar> level. The external
+ properties files can be either of type "properties" or of type
+ "xml". The path will be interpreted as follows:<orderedlist>
<listitem>
<para>The path doesn't contain any prefix of type
"classpath:", "jar:" or "file:", we assume that the file
@@ -612,6 +688,148 @@
</tgroup>
</table>
+ <table>
+ <title>Descriptions of the fields of
+ <envar>PortalContainerDefinition</envar> when it is used to define
+ the default portal container</title>
+
+ <tgroup cols="2">
+ <tbody>
+ <row>
+ <entry>name</entry>
+
+ <entry>The name of the portal container. This field is
+ optional. The default portal name will be:<orderedlist>
+ <listitem>
+ <para>If this field is not empty, then the default value
+ will be the value of this field.</para>
+ </listitem>
+
+ <listitem>
+ <para>If this field is empty and the value of the
+ parameter <emphasis>default.portal.container</emphasis>
+ is not empty, then the default value will be the value
+ of the parameter.</para>
+ </listitem>
+
+ <listitem>
+ <para>If this field and the parameter
+ <emphasis>default.portal.container</emphasis> are both
+ empty, the default value will be
+ <emphasis>"portal".</emphasis></para>
+ </listitem>
+ </orderedlist></entry>
+ </row>
+
+ <row>
+ <entry>restContextName</entry>
+
+ <entry>The name of the context name of the rest web
+ application. This field is optional. The default value wil
+ be:<orderedlist>
+ <listitem>
+ <para>If this field is not empty, then the default value
+ will be the value of this field.</para>
+ </listitem>
+
+ <listitem>
+ <para>f this field is empty and the value of the
+ parameter <emphasis>default.rest.context</emphasis> is
+ not empty, then the default value will be the value of
+ the parameter.</para>
+ </listitem>
+
+ <listitem>
+ <para>f this field and the parameter
+ <emphasis>default.rest.context</emphasis> are both
+ empty, the default value will be
+ <emphasis>"rest".</emphasis></para>
+ </listitem>
+ </orderedlist></entry>
+ </row>
+
+ <row>
+ <entry>realmName</entry>
+
+ <entry>The name of the realm. This field is optional. The
+ default value wil be:<orderedlist>
+ <listitem>
+ <para>If this field is not empty, then the default value
+ will be the value of this field.</para>
+ </listitem>
+
+ <listitem>
+ <para>f this field is empty and the value of the
+ parameter <emphasis>default.realm.name</emphasis> is not
+ empty, then the default value will be the value of the
+ parameter.</para>
+ </listitem>
+
+ <listitem>
+ <para>f this field and the parameter
+ <emphasis>default.realm.name</emphasis> are both empty,
+ the default value will be
+ <emphasis>"exo-domain".</emphasis></para>
+ </listitem>
+ </orderedlist></entry>
+ </row>
+
+ <row>
+ <entry>dependencies</entry>
+
+ <entry>All the dependencies of the portal container ordered by
+ loading priority. This field is optional. If this field has a
+ non empty value, it will be the default list of
+ dependencies.</entry>
+ </row>
+
+ <row>
+ <entry>settings</entry>
+
+ <entry>A <envar>java.util.Map</envar> of internal parameters
+ that we would like to tie the default portal container. Those
+ parameters could have any type of value. This field is
+ optional.</entry>
+ </row>
+
+ <row>
+ <entry>externalSettingsPath</entry>
+
+ <entry>The path of the external properties file to load as
+ default settings to the default portal container. This field
+ is optional. The external properties files can be either of
+ type "properties" or of type "xml". The path will be
+ interpreted as follows:<orderedlist>
+ <listitem>
+ <para>The path doesn't contain any prefix of type
+ "classpath:", "jar:" or "file:", we assume that the file
+ could be externalized so we apply the following
+ rules:<orderedlist>
+ <listitem>
+ <para>A file exists at
+ <emphasis>${exo-conf-dir}/portal/${externalSettingsPath}</emphasis>,
+ we will load this file.</para>
+ </listitem>
+
+ <listitem>
+ <para>No file exists at the previous path, we then
+ assume that the path cans be interpreted by the
+ <envar>ConfigurationManager</envar>.</para>
+ </listitem>
+ </orderedlist></para>
+ </listitem>
+
+ <listitem>
+ <para>The path contains a prefix, we then assume that
+ the path cans be interpreted by the
+ <envar>ConfigurationManager</envar>.</para>
+ </listitem>
+ </orderedlist></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
<para>Internal and external settings are both optional, but if we give
a non empty value for both the application will merge the settings. If
the same setting name exists in both settings, we apply the following
@@ -739,11 +957,34 @@
</configuration></programlisting></para>
<para>In the properties file corresponding to the external settings,
- you can reuse variables previously defined to create a new variable.
- In this case the prefix "<emphasis>portal.container.</emphasis>" is
- not needed, see an example below:<programlisting>my-var1=value 1
+ you can reuse variables previously defined (in the external settings
+ or in the internal settings) to create a new variable. In this case
+ the prefix "<emphasis>portal.container.</emphasis>" is not needed, see
+ an example below:<programlisting>my-var1=value 1
my-var2=value 2
-complex-value=${my-var1}-${my-var2}</programlisting> </para>
+complex-value=${my-var1}-${my-var2}</programlisting></para>
+
+ <para>In the external and internal settings, you can also use create
+ variables based on value of System paramaters. The System parameters
+ can either be defined at launch time or thanks to the
+ <envar>PropertyConfigurator</envar> (see next section for more
+ details). See an example below:</para>
+
+ <programlisting>temp-dir=${java.io.tmpdir}${file.separator}my-temp</programlisting>
+
+ <para>However, for the internal settings you can use System parameters
+ only to define settings of type
+ <envar>java.lang.String</envar>.</para>
+
+ <para>It cans be also very usefull to define a generic variable in the
+ settings of the default portal container, the value of this variable
+ will change according to the current portal container. See below an
+ example:<programlisting>my-generic-var=value of the portal container "${name}"</programlisting></para>
+
+ <para>If this variable is defined at the default portal container
+ level, the value of this variable for a portal container called
+ <emphasis>"foo"</emphasis> will be <emphasis>value of the portal
+ container "foo"</emphasis>.</para>
</section>
</section>
</section>
Modified: jcr/tags/1.12.0-GA/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java
===================================================================
--- jcr/tags/1.12.0-GA/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java 2010-03-11 11:49:03 UTC (rev 2052)
+++ jcr/tags/1.12.0-GA/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java 2010-03-11 11:49:47 UTC (rev 2053)
@@ -28,7 +28,6 @@
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
-import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.dataflow.persistent.ByteArrayPersistedValueData;
@@ -50,7 +49,6 @@
import java.util.Map;
import java.util.StringTokenizer;
-import javax.jcr.InvalidItemStateException;
import javax.jcr.RepositoryException;
/**
@@ -88,11 +86,6 @@
protected String FIND_REFERENCE_PROPERTIES_CQ;
/**
- * FIND_ITEM_QPATH_BY_ID_CQ.
- */
- protected String FIND_ITEM_QPATH_BY_ID_CQ;
-
- /**
* Class needed to store node details (property also) since result set is not sorted in valid way.
*/
private static class TempNodeData
@@ -691,84 +684,6 @@
}
}
- /**
- * {@inheritDoc}
- */
- @Override
- protected QPath traverseQPath(String cpid) throws SQLException, InvalidItemStateException, IllegalNameException
- {
- String id = getIdentifier(cpid);
- if (id.equals(Constants.ROOT_UUID))
- {
- return Constants.ROOT_PATH;
- }
- // get item by Identifier usecase
- List<QPathEntry> qrpath = new ArrayList<QPathEntry>(); // reverted path
- String caid = cpid; // container ancestor id
- boolean isRoot = false;
- do
- {
- ResultSet result = null;
- try
- {
- result = findItemQPathByIdentifierCQ(caid);
- if (!result.next())
- throw new InvalidItemStateException("Parent not found, uuid: " + getIdentifier(caid));
-
- QPathEntry qpe1 =
- new QPathEntry(InternalQName.parse(result.getString(COLUMN_NAME)), result.getInt(COLUMN_INDEX));
- boolean isChild = caid.equals(result.getString(COLUMN_ID));
- caid = result.getString(COLUMN_PARENTID);
- if (result.next())
- {
- QPathEntry qpe2 =
- new QPathEntry(InternalQName.parse(result.getString(COLUMN_NAME)), result.getInt(COLUMN_INDEX));
- if (isChild)
- {
- // The child is the first result then we have the parent
- qrpath.add(qpe1);
- qrpath.add(qpe2);
- // We need to take the value of the parent node
- caid = result.getString(COLUMN_PARENTID);
- }
- else
- {
- // The parent is the first result then we have the child
- qrpath.add(qpe2);
- qrpath.add(qpe1);
- }
- }
- else
- {
- qrpath.add(qpe1);
- }
- }
- finally
- {
- result.close();
- }
- if (caid.equals(Constants.ROOT_PARENT_UUID) || (id = getIdentifier(caid)).equals(Constants.ROOT_UUID))
- {
- if (id.equals(Constants.ROOT_UUID))
- {
- qrpath.add(Constants.ROOT_PATH.getEntries()[0]);
- }
- isRoot = true;
- }
- }
- while (!isRoot);
-
- QPathEntry[] qentries = new QPathEntry[qrpath.size()];
- int qi = 0;
- for (int i = qrpath.size() - 1; i >= 0; i--)
- {
- qentries[qi++] = qrpath.get(i);
- }
- return new QPath(qentries);
- }
-
- protected abstract ResultSet findItemQPathByIdentifierCQ(String identifier) throws SQLException;
-
protected abstract ResultSet findChildNodesByParentIdentifierCQ(String parentIdentifier) throws SQLException;
protected abstract ResultSet findChildPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException;
Modified: jcr/tags/1.12.0-GA/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
===================================================================
--- jcr/tags/1.12.0-GA/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java 2010-03-11 11:49:03 UTC (rev 2052)
+++ jcr/tags/1.12.0-GA/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java 2010-03-11 11:49:47 UTC (rev 2053)
@@ -213,11 +213,6 @@
+ " from JCR_MITEM I, JCR_MVALUE V"
+ " where I.I_CLASS=2 and I.PARENT_ID=? and (I.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or I.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions') and I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
- FIND_ITEM_QPATH_BY_ID_CQ =
- "select I.ID, I.PARENT_ID, I.NAME, I.I_INDEX"
- + " from JCR_MITEM I, (SELECT ID, PARENT_ID from JCR_MITEM where ID=?) J"
- + " where I.ID = J.ID or I.ID = J.PARENT_ID";
-
FIND_NODES_COUNT_BY_PARENTID = "select count(ID) from JCR_MITEM" + " where I_CLASS=1 and PARENT_ID=?";
FIND_PROPERTIES_BY_PARENTID = "select * from JCR_MITEM" + " where I_CLASS=2 and PARENT_ID=?" + " order by ID";
@@ -655,21 +650,6 @@
* {@inheritDoc}
*/
@Override
- protected ResultSet findItemQPathByIdentifierCQ(String identifier) throws SQLException
- {
- if (findItemQPathByIdentifierCQ == null)
- findItemQPathByIdentifierCQ = dbConnection.prepareStatement(FIND_ITEM_QPATH_BY_ID_CQ);
- else
- findItemQPathByIdentifierCQ.clearParameters();
-
- findItemQPathByIdentifierCQ.setString(1, identifier);
- return findItemQPathByIdentifierCQ.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
protected ResultSet findReferencePropertiesCQ(String nodeIdentifier) throws SQLException
{
if (findReferencePropertiesCQ == null)
Modified: jcr/tags/1.12.0-GA/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
===================================================================
--- jcr/tags/1.12.0-GA/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java 2010-03-11 11:49:03 UTC (rev 2052)
+++ jcr/tags/1.12.0-GA/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java 2010-03-11 11:49:47 UTC (rev 2053)
@@ -221,11 +221,6 @@
+ " from JCR_SITEM I, JCR_SVALUE V"
+ " where I.I_CLASS=2 and I.CONTAINER_NAME=? and I.PARENT_ID=? and (I.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or I.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions') and I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
- FIND_ITEM_QPATH_BY_ID_CQ =
- "select I.ID, I.PARENT_ID, I.NAME, I.I_INDEX"
- + " from JCR_SITEM I, (SELECT ID, PARENT_ID from JCR_SITEM where ID=?) J"
- + " where I.ID = J.ID or I.ID = J.PARENT_ID";
-
FIND_NODES_COUNT_BY_PARENTID =
"select count(ID) from JCR_SITEM" + " where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?";
@@ -679,21 +674,6 @@
* {@inheritDoc}
*/
@Override
- protected ResultSet findItemQPathByIdentifierCQ(String identifier) throws SQLException
- {
- if (findItemQPathByIdentifierCQ == null)
- findItemQPathByIdentifierCQ = dbConnection.prepareStatement(FIND_ITEM_QPATH_BY_ID_CQ);
- else
- findItemQPathByIdentifierCQ.clearParameters();
-
- findItemQPathByIdentifierCQ.setString(1, identifier);
- return findItemQPathByIdentifierCQ.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
protected ResultSet findReferencePropertiesCQ(String nodeIdentifier) throws SQLException
{
if (findReferencePropertiesCQ == null)
Modified: jcr/tags/1.12.0-GA/exo.jcr.component.core/src/main/resources/binding-nodetypevalues.xml
===================================================================
--- jcr/tags/1.12.0-GA/exo.jcr.component.core/src/main/resources/binding-nodetypevalues.xml 2010-03-11 11:49:03 UTC (rev 2052)
+++ jcr/tags/1.12.0-GA/exo.jcr.component.core/src/main/resources/binding-nodetypevalues.xml 2010-03-11 11:49:47 UTC (rev 2053)
@@ -1,4 +1,6 @@
<binding>
+ <!-- the default deserializer to use for String -->
+ <format type="java.lang.String" deserializer="org.exoplatform.container.xml.Deserializer.cleanString"/>
<mapping name="nodeTypes" class="org.exoplatform.services.jcr.core.nodetype.NodeTypeValuesList">
<collection field="nodeTypeValuesList" item-type="org.exoplatform.services.jcr.core.nodetype.NodeTypeValue" type="java.util.ArrayList" />
Modified: jcr/tags/1.12.0-GA/exo.jcr.component.core/src/main/resources/binding.xml
===================================================================
--- jcr/tags/1.12.0-GA/exo.jcr.component.core/src/main/resources/binding.xml 2010-03-11 11:49:03 UTC (rev 2052)
+++ jcr/tags/1.12.0-GA/exo.jcr.component.core/src/main/resources/binding.xml 2010-03-11 11:49:47 UTC (rev 2053)
@@ -1,4 +1,6 @@
<binding>
+ <!-- the default deserializer to use for String -->
+ <format type="java.lang.String" deserializer="org.exoplatform.container.xml.Deserializer.cleanString"/>
<mapping name="repository-service" class="org.exoplatform.services.jcr.config.RepositoryServiceConfiguration">
<value name="default-repository" field="defaultRepositoryName" style="attribute" />
16 years, 2 months
exo-jcr SVN: r2052 - in kernel/tags/2.2.0-GA: exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ea and 13 other directories.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-03-11 06:49:03 -0500 (Thu, 11 Mar 2010)
New Revision: 2052
Added:
kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ea/
kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ea/EAExoCacheConfig.java
kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ea/EAExoCacheCreator.java
kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestEACache.java
kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/default-settings.properties
kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-both-settings-with-default-portal-def.xml
kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-default-portal-def.xml
kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-empty-default-portal-def.xml
kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-external-settings-with-default-portal-def.xml
kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-external-settings-with-default-portal-def2.xml
kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def.xml
kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def2.xml
kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-settings-with-default-portal-def.xml
kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal/default-settings.properties
kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/sample-gtn-configuration.properties
kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/sample-gtn-configuration.xml
kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/test-trim-value.xml
Removed:
kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ea/EAExoCacheConfig.java
kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ea/EAExoCacheCreator.java
Modified:
kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java
kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheCreator.java
kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/test-configuration.xml
kernel/tags/2.2.0-GA/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java
kernel/tags/2.2.0-GA/exo.kernel.container/src/main/java/org/exoplatform/container/util/ContainerUtil.java
kernel/tags/2.2.0-GA/exo.kernel.container/src/main/java/org/exoplatform/container/xml/Deserializer.java
kernel/tags/2.2.0-GA/exo.kernel.container/src/main/java/org/exoplatform/management/rest/annotations/RESTEndpoint.java
kernel/tags/2.2.0-GA/exo.kernel.container/src/main/resources/binding.xml
kernel/tags/2.2.0-GA/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java
kernel/tags/2.2.0-GA/exo.kernel.container/src/test/java/org/exoplatform/xml/test/TestConfigurationXML.java
kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/settings.properties
Log:
EXOJCR-483: Changes from EXOJCR-556 EXOJCR-565 EXOJCR-566 EXOJCR-576 EXOJCR-580 ported to Kernel 2.2.0-GA Tag
Modified: kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java
===================================================================
--- kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java 2010-03-11 09:32:07 UTC (rev 2051)
+++ kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java 2010-03-11 11:49:03 UTC (rev 2052)
@@ -245,7 +245,7 @@
/**
* Only puts the data into the cache nothing more
*/
- private V putOnly(K key, V value)
+ protected V putOnly(K key, V value)
{
return cache.put(getFqn(key), key, value);
}
@@ -428,7 +428,7 @@
/**
* Returns the Fqn related to the given name
*/
- private Fqn<Serializable> getFqn(Serializable name)
+ protected Fqn<Serializable> getFqn(Serializable name)
{
return Fqn.fromElements(name);
}
Copied: kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ea (from rev 2039, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ea)
Deleted: kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ea/EAExoCacheConfig.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ea/EAExoCacheConfig.java 2010-03-08 11:16:32 UTC (rev 2039)
+++ kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ea/EAExoCacheConfig.java 2010-03-11 11:49:03 UTC (rev 2052)
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2003-2010 eXo Platform SAS.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see<http://www.gnu.org/licenses/>.
- */
-package org.exoplatform.services.cache.impl.jboss.ea;
-
-import org.exoplatform.services.cache.ExoCacheConfig;
-import org.jboss.cache.eviction.ExpirationAlgorithm;
-
-
-/**
- * The {@link org.exoplatform.services.cache.ExoCacheConfig} for the {@link ExpirationAlgorithm}
- * implementation
- *
- * Created by The eXo Platform SAS
- * Author : Nicolas Filotto
- * nicolas.filotto(a)exoplatform.com
- * 8 mars 2010
- */
-public class EAExoCacheConfig extends ExoCacheConfig
-{
-
- private int maxNodes;
-
- private long minTimeToLive;
-
- private long expirationTimeout;
-
- public int getMaxNodes()
- {
- return maxNodes;
- }
-
- public void setMaxNodes(int maxNodes)
- {
- this.maxNodes = maxNodes;
- }
-
- public long getMinTimeToLive()
- {
- return minTimeToLive;
- }
-
- public void setMinTimeToLive(long minTimeToLive)
- {
- this.minTimeToLive = minTimeToLive;
- }
-
- public long getExpirationTimeout()
- {
- return expirationTimeout;
- }
-
- public void setExpirationTimeout(long expirationTimeout)
- {
- this.expirationTimeout = expirationTimeout;
- }
-}
Copied: kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ea/EAExoCacheConfig.java (from rev 2039, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ea/EAExoCacheConfig.java)
===================================================================
--- kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ea/EAExoCacheConfig.java (rev 0)
+++ kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ea/EAExoCacheConfig.java 2010-03-11 11:49:03 UTC (rev 2052)
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.cache.impl.jboss.ea;
+
+import org.exoplatform.services.cache.ExoCacheConfig;
+import org.jboss.cache.eviction.ExpirationAlgorithm;
+
+
+/**
+ * The {@link org.exoplatform.services.cache.ExoCacheConfig} for the {@link ExpirationAlgorithm}
+ * implementation
+ *
+ * Created by The eXo Platform SAS
+ * Author : Nicolas Filotto
+ * nicolas.filotto(a)exoplatform.com
+ * 8 mars 2010
+ */
+public class EAExoCacheConfig extends ExoCacheConfig
+{
+
+ private int maxNodes;
+
+ private long minTimeToLive;
+
+ private long expirationTimeout;
+
+ public int getMaxNodes()
+ {
+ return maxNodes;
+ }
+
+ public void setMaxNodes(int maxNodes)
+ {
+ this.maxNodes = maxNodes;
+ }
+
+ public long getMinTimeToLive()
+ {
+ return minTimeToLive;
+ }
+
+ public void setMinTimeToLive(long minTimeToLive)
+ {
+ this.minTimeToLive = minTimeToLive;
+ }
+
+ public long getExpirationTimeout()
+ {
+ return expirationTimeout;
+ }
+
+ public void setExpirationTimeout(long expirationTimeout)
+ {
+ this.expirationTimeout = expirationTimeout;
+ }
+}
Deleted: kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ea/EAExoCacheCreator.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ea/EAExoCacheCreator.java 2010-03-08 11:16:32 UTC (rev 2039)
+++ kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ea/EAExoCacheCreator.java 2010-03-11 11:49:03 UTC (rev 2052)
@@ -1,180 +0,0 @@
-/*
- * Copyright (C) 2003-2010 eXo Platform SAS.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see<http://www.gnu.org/licenses/>.
- */
-package org.exoplatform.services.cache.impl.jboss.ea;
-
-import org.exoplatform.management.annotations.Managed;
-import org.exoplatform.management.annotations.ManagedDescription;
-import org.exoplatform.management.annotations.ManagedName;
-import org.exoplatform.services.cache.ExoCache;
-import org.exoplatform.services.cache.ExoCacheConfig;
-import org.exoplatform.services.cache.ExoCacheInitException;
-import org.exoplatform.services.cache.impl.jboss.AbstractExoCache;
-import org.exoplatform.services.cache.impl.jboss.ExoCacheCreator;
-import org.jboss.cache.Cache;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.EvictionConfig;
-import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.eviction.ExpirationAlgorithm;
-import org.jboss.cache.eviction.ExpirationAlgorithmConfig;
-
-import java.io.Serializable;
-
-/**
- * The {@link ExpirationAlgorithm} Implementation of an {@link org.exoplatform.services.cache.impl.jboss.ExoCacheCreator}
- * Created by The eXo Platform SAS
- * Author : Nicolas Filotto
- * nicolas.filotto(a)exoplatform.com
- * 8 mars 2010
- */
-public class EAExoCacheCreator implements ExoCacheCreator
-{
-
- /**
- * The expected implementation name
- */
- public static final String EXPECTED_IMPL = "EA";
-
- /**
- * The default value for the parameter expirationTimeout
- */
- protected long defaultExpirationTimeout;
-
- /**
- * {@inheritDoc}
- */
- public String getExpectedImplementation()
- {
- return EXPECTED_IMPL;
- }
-
- /**
- * {@inheritDoc}
- */
- public Class<? extends ExoCacheConfig> getExpectedConfigType()
- {
- return EAExoCacheConfig.class;
- }
-
- /**
- * @see org.exoplatform.services.cache.impl.jboss.ExoCacheCreator#create(org.exoplatform.services.cache.ExoCacheConfig, org.jboss.cache.Cache)
- */
- public ExoCache<Serializable, Object> create(ExoCacheConfig config, Cache<Serializable, Object> cache)
- throws ExoCacheInitException
- {
- if (config instanceof EAExoCacheConfig)
- {
- final EAExoCacheConfig eaConfig = (EAExoCacheConfig)config;
- return create(config, cache, eaConfig.getMaxNodes(), eaConfig.getMinTimeToLive(), eaConfig
- .getExpirationTimeout());
- }
- else
- {
- final long period = config.getLiveTime();
- return create(config, cache, config.getMaxSize(), period > 0 ? period * 1000 : 0, defaultExpirationTimeout);
- }
- }
-
- /**
- * Creates a new ExoCache instance with the relevant parameters
- */
- private ExoCache<Serializable, Object> create(ExoCacheConfig config, Cache<Serializable, Object> cache,
- int maxNodes, long minTimeToLive, long expirationTimeout) throws ExoCacheInitException
- {
- final Configuration configuration = cache.getConfiguration();
- final ExpirationAlgorithmConfig ea = new ExpirationAlgorithmConfig();
- ea.setMaxNodes(maxNodes);
- ea.setMinTimeToLive(minTimeToLive);
- ea.setExpirationKeyName(ExpirationAlgorithmConfig.EXPIRATION_KEY);
- // Create an eviction region config
- final EvictionRegionConfig erc = new EvictionRegionConfig(Fqn.ROOT, ea);
-
- final EvictionConfig evictionConfig = configuration.getEvictionConfig();
- evictionConfig.setDefaultEvictionRegionConfig(erc);
-
- return new EAExoCache(config, cache, ea, expirationTimeout);
- }
-
- /**
- * The {@link ExpirationAlgorithm} implementation of an ExoCache
- */
- public static class EAExoCache extends AbstractExoCache<Serializable, Object>
- {
- private long expirationTimeout;
-
- private final ExpirationAlgorithmConfig ea;
-
- public EAExoCache(ExoCacheConfig config, Cache<Serializable, Object> cache, ExpirationAlgorithmConfig ea,
- long expirationTimeout)
- {
- super(config, cache);
- this.ea = ea;
- this.expirationTimeout = expirationTimeout;
- }
-
- /**
- * We set the <code>ExpirationAlgorithmConfig.EXPIRATION_KEY</code> based on the <code>expirationTimeout</code>
- * @see org.exoplatform.services.cache.impl.jboss.AbstractExoCache#putOnly(java.io.Serializable, java.lang.Object)
- */
- @Override
- protected Object putOnly(Serializable key, Object value)
- {
- Fqn<Serializable> fqn = getFqn(key);
- Long future = new Long(System.currentTimeMillis() + expirationTimeout);
- cache.put(fqn, ExpirationAlgorithmConfig.EXPIRATION_KEY, future);
- return cache.put(fqn, key, value);
- }
-
- public void setMaxSize(int max)
- {
- ea.setMaxNodes(max);
- }
-
- public void setLiveTime(long period)
- {
- ea.setMinTimeToLive(period);
- }
-
- @ManagedName("MaxNodes")
- @ManagedDescription("This is the maximum number of nodes allowed in this region. 0 denotes immediate expiry, -1 denotes no limit.")
- public int getMaxSize()
- {
- return ea.getMaxNodes();
- }
-
- @ManagedName("MinTimeToLive")
- @ManagedDescription("the minimum amount of time a node must be allowed to live after being accessed before it is allowed to be considered for eviction. 0 denotes that this feature is disabled, which is the default value.")
- public long getLiveTime()
- {
- return ea.getMinTimeToLive();
- }
-
- @Managed
- @ManagedName("ExpirationTimeout")
- @ManagedDescription("This is the timeout after which the cache entry must be evicted.")
- public long getExpirationTimeout()
- {
- return expirationTimeout;
- }
-
- @Managed
- public void setExpirationTimeout(long expirationTimeout)
- {
- this.expirationTimeout = expirationTimeout;
- }
- }
-}
Copied: kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ea/EAExoCacheCreator.java (from rev 2039, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ea/EAExoCacheCreator.java)
===================================================================
--- kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ea/EAExoCacheCreator.java (rev 0)
+++ kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/ea/EAExoCacheCreator.java 2010-03-11 11:49:03 UTC (rev 2052)
@@ -0,0 +1,180 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.cache.impl.jboss.ea;
+
+import org.exoplatform.management.annotations.Managed;
+import org.exoplatform.management.annotations.ManagedDescription;
+import org.exoplatform.management.annotations.ManagedName;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ExoCacheConfig;
+import org.exoplatform.services.cache.ExoCacheInitException;
+import org.exoplatform.services.cache.impl.jboss.AbstractExoCache;
+import org.exoplatform.services.cache.impl.jboss.ExoCacheCreator;
+import org.jboss.cache.Cache;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.EvictionConfig;
+import org.jboss.cache.config.EvictionRegionConfig;
+import org.jboss.cache.eviction.ExpirationAlgorithm;
+import org.jboss.cache.eviction.ExpirationAlgorithmConfig;
+
+import java.io.Serializable;
+
+/**
+ * The {@link ExpirationAlgorithm} Implementation of an {@link org.exoplatform.services.cache.impl.jboss.ExoCacheCreator}
+ * Created by The eXo Platform SAS
+ * Author : Nicolas Filotto
+ * nicolas.filotto(a)exoplatform.com
+ * 8 mars 2010
+ */
+public class EAExoCacheCreator implements ExoCacheCreator
+{
+
+ /**
+ * The expected implementation name
+ */
+ public static final String EXPECTED_IMPL = "EA";
+
+ /**
+ * The default value for the parameter expirationTimeout
+ */
+ protected long defaultExpirationTimeout;
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getExpectedImplementation()
+ {
+ return EXPECTED_IMPL;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Class<? extends ExoCacheConfig> getExpectedConfigType()
+ {
+ return EAExoCacheConfig.class;
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.impl.jboss.ExoCacheCreator#create(org.exoplatform.services.cache.ExoCacheConfig, org.jboss.cache.Cache)
+ */
+ public ExoCache<Serializable, Object> create(ExoCacheConfig config, Cache<Serializable, Object> cache)
+ throws ExoCacheInitException
+ {
+ if (config instanceof EAExoCacheConfig)
+ {
+ final EAExoCacheConfig eaConfig = (EAExoCacheConfig)config;
+ return create(config, cache, eaConfig.getMaxNodes(), eaConfig.getMinTimeToLive(), eaConfig
+ .getExpirationTimeout());
+ }
+ else
+ {
+ final long period = config.getLiveTime();
+ return create(config, cache, config.getMaxSize(), period > 0 ? period * 1000 : 0, defaultExpirationTimeout);
+ }
+ }
+
+ /**
+ * Creates a new ExoCache instance with the relevant parameters
+ */
+ private ExoCache<Serializable, Object> create(ExoCacheConfig config, Cache<Serializable, Object> cache,
+ int maxNodes, long minTimeToLive, long expirationTimeout) throws ExoCacheInitException
+ {
+ final Configuration configuration = cache.getConfiguration();
+ final ExpirationAlgorithmConfig ea = new ExpirationAlgorithmConfig();
+ ea.setMaxNodes(maxNodes);
+ ea.setMinTimeToLive(minTimeToLive);
+ ea.setExpirationKeyName(ExpirationAlgorithmConfig.EXPIRATION_KEY);
+ // Create an eviction region config
+ final EvictionRegionConfig erc = new EvictionRegionConfig(Fqn.ROOT, ea);
+
+ final EvictionConfig evictionConfig = configuration.getEvictionConfig();
+ evictionConfig.setDefaultEvictionRegionConfig(erc);
+
+ return new EAExoCache(config, cache, ea, expirationTimeout);
+ }
+
+ /**
+ * The {@link ExpirationAlgorithm} implementation of an ExoCache
+ */
+ public static class EAExoCache extends AbstractExoCache<Serializable, Object>
+ {
+ private long expirationTimeout;
+
+ private final ExpirationAlgorithmConfig ea;
+
+ public EAExoCache(ExoCacheConfig config, Cache<Serializable, Object> cache, ExpirationAlgorithmConfig ea,
+ long expirationTimeout)
+ {
+ super(config, cache);
+ this.ea = ea;
+ this.expirationTimeout = expirationTimeout;
+ }
+
+ /**
+ * We set the <code>ExpirationAlgorithmConfig.EXPIRATION_KEY</code> based on the <code>expirationTimeout</code>
+ * @see org.exoplatform.services.cache.impl.jboss.AbstractExoCache#putOnly(java.io.Serializable, java.lang.Object)
+ */
+ @Override
+ protected Object putOnly(Serializable key, Object value)
+ {
+ Fqn<Serializable> fqn = getFqn(key);
+ Long future = new Long(System.currentTimeMillis() + expirationTimeout);
+ cache.put(fqn, ExpirationAlgorithmConfig.EXPIRATION_KEY, future);
+ return cache.put(fqn, key, value);
+ }
+
+ public void setMaxSize(int max)
+ {
+ ea.setMaxNodes(max);
+ }
+
+ public void setLiveTime(long period)
+ {
+ ea.setMinTimeToLive(period);
+ }
+
+ @ManagedName("MaxNodes")
+ @ManagedDescription("This is the maximum number of nodes allowed in this region. 0 denotes immediate expiry, -1 denotes no limit.")
+ public int getMaxSize()
+ {
+ return ea.getMaxNodes();
+ }
+
+ @ManagedName("MinTimeToLive")
+ @ManagedDescription("the minimum amount of time a node must be allowed to live after being accessed before it is allowed to be considered for eviction. 0 denotes that this feature is disabled, which is the default value.")
+ public long getLiveTime()
+ {
+ return ea.getMinTimeToLive();
+ }
+
+ @Managed
+ @ManagedName("ExpirationTimeout")
+ @ManagedDescription("This is the timeout after which the cache entry must be evicted.")
+ public long getExpirationTimeout()
+ {
+ return expirationTimeout;
+ }
+
+ @Managed
+ public void setExpirationTimeout(long expirationTimeout)
+ {
+ this.expirationTimeout = expirationTimeout;
+ }
+ }
+}
Modified: kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheCreator.java
===================================================================
--- kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheCreator.java 2010-03-11 09:32:07 UTC (rev 2051)
+++ kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheCreator.java 2010-03-11 11:49:03 UTC (rev 2052)
@@ -51,7 +51,7 @@
public static final String EXPECTED_IMPL = "LFU";
/**
- * The default value for the parameter maxAge
+ * The default value for the parameter minNodes
*/
protected int defaultMinNodes;
Copied: kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestEACache.java (from rev 2039, kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestEACache.java)
===================================================================
--- kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestEACache.java (rev 0)
+++ kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestEACache.java 2010-03-11 11:49:03 UTC (rev 2052)
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss;
+
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.services.cache.CacheService;
+import org.exoplatform.services.cache.impl.jboss.ea.EAExoCacheCreator.EAExoCache;
+import org.exoplatform.test.BasicTestCase;
+
+/**
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 21 juil. 2009
+ */
+public class TestEACache extends BasicTestCase
+{
+
+ CacheService service_;
+
+ public TestEACache(String name)
+ {
+ super(name);
+ }
+
+ public void setUp() throws Exception
+ {
+ service_ = (CacheService)PortalContainer.getInstance().getComponentInstanceOfType(CacheService.class);
+ }
+
+ public void testPolicy() throws Exception
+ {
+ testPolicy("test-ea");
+ testPolicy("test-ea-with-old-config");
+ }
+
+ private void testPolicy(String cacheName) throws Exception
+ {
+ EAExoCache cache = (EAExoCache)service_.getCacheInstance(cacheName);
+ cache.put("a", "a");
+ cache.put("b", "a");
+ cache.put("c", "a");
+ cache.put("d", "a");
+ Thread.sleep(1000);
+ assertEquals(4, cache.getCacheSize());
+ cache.put("e", "a");
+ assertEquals(5, cache.getCacheSize());
+ cache.put("f", "a");
+ assertEquals(6, cache.getCacheSize());
+ Thread.sleep(1100);
+ assertEquals(2, cache.getCacheSize());
+ Thread.sleep(1000);
+ assertEquals(0, cache.getCacheSize());
+ cache.setMaxSize(3);
+ cache.setLiveTime(400);
+ cache.setExpirationTimeout(500);
+ cache.put("a", "a");
+ cache.put("b", "a");
+ cache.put("c", "a");
+ cache.put("d", "a");
+ assertEquals(4, cache.getCacheSize());
+ cache.put("e", "a");
+ assertEquals(5, cache.getCacheSize());
+ cache.put("f", "a");
+ Thread.sleep(600);
+ assertEquals(0, cache.getCacheSize());
+ }
+}
Modified: kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/test-configuration.xml
===================================================================
--- kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/test-configuration.xml 2010-03-11 09:32:07 UTC (rev 2051)
+++ kernel/tags/2.2.0-GA/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/resources/conf/portal/test-configuration.xml 2010-03-11 11:49:03 UTC (rev 2052)
@@ -122,7 +122,27 @@
<field name="maxAge"><long>2000</long></field>
<field name="timeToLive"><long>1500</long></field>
</object>
- </object-param>
+ </object-param>
+ <object-param>
+ <name>test-ea-with-old-config</name>
+ <description>The default cache configuration</description>
+ <object type="org.exoplatform.services.cache.ExoCacheConfig">
+ <field name="name"><string>test-ea-with-old-config</string></field>
+ <field name="maxSize"><int>5</int></field>
+ <field name="liveTime"><long>1</long></field>
+ <field name="implementation"><string>EA</string></field>
+ </object>
+ </object-param>
+ <object-param>
+ <name>test-ea</name>
+ <description>The default cache configuration</description>
+ <object type="org.exoplatform.services.cache.impl.jboss.ea.EAExoCacheConfig">
+ <field name="name"><string>test-ea</string></field>
+ <field name="maxNodes"><int>5</int></field>
+ <field name="minTimeToLive"><long>1000</long></field>
+ <field name="expirationTimeout"><long>2000</long></field>
+ </object>
+ </object-param>
</init-params>
</component>
@@ -174,7 +194,14 @@
<field name="defaultTimeToLive"><long>1500</long></field>
<field name="defaultMaxAge"><long>2000</long></field>
</object>
- </object-param>
+ </object-param>
+ <object-param>
+ <name>EA</name>
+ <description>The ea cache creator</description>
+ <object type="org.exoplatform.services.cache.impl.jboss.ea.EAExoCacheCreator">
+ <field name="defaultExpirationTimeout"><long>2000</long></field>
+ </object>
+ </object-param>
</init-params>
</component-plugin>
</external-component-plugins>
Modified: kernel/tags/2.2.0-GA/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java
===================================================================
--- kernel/tags/2.2.0-GA/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java 2010-03-11 09:32:07 UTC (rev 2051)
+++ kernel/tags/2.2.0-GA/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java 2010-03-11 11:49:03 UTC (rev 2052)
@@ -19,12 +19,14 @@
package org.exoplatform.container.definition;
import org.exoplatform.container.PortalContainer;
+import org.exoplatform.container.PropertyConfigurator;
import org.exoplatform.container.RootContainer;
import org.exoplatform.container.configuration.ConfigurationManager;
import org.exoplatform.container.monitor.jvm.J2EEServerInfo;
import org.exoplatform.container.util.ContainerUtil;
import org.exoplatform.container.xml.Deserializer;
import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.container.xml.ObjectParameter;
import org.exoplatform.container.xml.ValueParam;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -36,6 +38,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -76,34 +79,27 @@
/**
* The default name of a portal container
*/
- public static final String DEFAULT_PORTAL_CONTAINER_NAME = "portal";
+ // We use new String to create a new object in order to use the operator ==
+ public static final String DEFAULT_PORTAL_CONTAINER_NAME = new String("portal");
/**
* The default name of a the {@link ServletContext} of the rest web application
*/
- public static final String DEFAULT_REST_CONTEXT_NAME = "rest";
+ // We use new String to create a new object in order to use the operator ==
+ public static final String DEFAULT_REST_CONTEXT_NAME = new String("rest");
/**
* The default realm name
*/
- public static final String DEFAULT_REALM_NAME = "exo-domain";
+ // We use new String to create a new object in order to use the operator ==
+ public static final String DEFAULT_REALM_NAME = new String("exo-domain");
/**
- * The name of the default portal container
+ * The default {@link PortalContainerDefinition}
*/
- private String defaultPortalContainerName;
+ private final PortalContainerDefinition defaultDefinition;
/**
- * The name of the default rest {@link ServletContext}
- */
- private String defaultRestContextName;
-
- /**
- * The name of the default realm
- */
- private String defaultRealmName;
-
- /**
* Indicates if the component has already been initialized
*/
private volatile boolean initialized;
@@ -134,47 +130,189 @@
*/
private final J2EEServerInfo serverInfo;
+ /**
+ * Indicates if new system properties have been added
+ */
+ private final PropertyConfigurator pc;
+
public PortalContainerConfig(ConfigurationManager cm)
{
- this(null, cm, new J2EEServerInfo());
+ this(null, cm, new J2EEServerInfo(), null);
}
+ public PortalContainerConfig(ConfigurationManager cm, PropertyConfigurator pc)
+ {
+ this(null, cm, new J2EEServerInfo(), pc);
+ }
+
public PortalContainerConfig(ConfigurationManager cm, J2EEServerInfo serverInfo)
{
- this(null, cm, serverInfo);
+ this(null, cm, serverInfo, null);
}
+ public PortalContainerConfig(ConfigurationManager cm, J2EEServerInfo serverInfo, PropertyConfigurator pc)
+ {
+ this(null, cm, serverInfo, pc);
+ }
+
+ public PortalContainerConfig(InitParams params, ConfigurationManager cm)
+ {
+ this(params, cm, new J2EEServerInfo(), null);
+ }
+
+ public PortalContainerConfig(InitParams params, ConfigurationManager cm, PropertyConfigurator pc)
+ {
+ this(params, cm, new J2EEServerInfo(), pc);
+ }
+
public PortalContainerConfig(InitParams params, ConfigurationManager cm, J2EEServerInfo serverInfo)
{
+ this(params, cm, serverInfo, null);
+ }
+
+ /**
+ * We add the {@link PropertyConfigurator} in the constructor, in order to make sure that it is
+ * created before since it could define some JVM parameters that could be used internally by the
+ * {@link PortalContainerConfig}
+ */
+ public PortalContainerConfig(InitParams params, ConfigurationManager cm, J2EEServerInfo serverInfo,
+ PropertyConfigurator pc)
+ {
+ this.pc = pc;
this.cm = cm;
this.serverInfo = serverInfo;
- if (params == null)
+ this.defaultDefinition = create(params);
+ }
+
+ /**
+ * Create the default {@link PortalContainerDefinition} corresponding to the given parameters
+ * @param params the parameter to initialize
+ */
+ private PortalContainerDefinition create(InitParams params)
+ {
+ ObjectParameter oDpd = null;
+ if (params != null)
{
- return;
+ oDpd = params.getObjectParam("default.portal.definition");
}
- final ValueParam vDpc = params.getValueParam("default.portal.container");
- if (vDpc != null && vDpc.getValue().trim().length() > 0)
+ PortalContainerDefinition def = null;
+ if (oDpd != null)
{
- this.defaultPortalContainerName = vDpc.getValue().trim();
+ // A default portal definition has been found
+ final Object o = oDpd.getObject();
+ if (o instanceof PortalContainerDefinition)
+ {
+ // The nested object is of the right type
+ def = (PortalContainerDefinition)o;
+ }
+ else
+ {
+ // The nested object is not of the right type, thus it will be ignored
+ log.warn("The object parameter 'default.portal.definition' should be of type "
+ + PortalContainerDefinition.class);
+ }
}
- final ValueParam vRc = params.getValueParam("default.rest.context");
- if (vRc != null && vRc.getValue().trim().length() > 0)
+ if (def == null)
{
- this.defaultRestContextName = vRc.getValue().trim();
+ def = new PortalContainerDefinition();
}
- final ValueParam vRn = params.getValueParam("default.realm.name");
- if (vRn != null && vRn.getValue().trim().length() > 0)
+ initName(params, def);
+ initRestContextName(params, def);
+ initRealmName(params, def);
+ initializeSettings(def, false);
+ return def;
+ }
+
+ /**
+ * Initialize the value of the realm name
+ */
+ private void initRealmName(InitParams params, PortalContainerDefinition def)
+ {
+ if (def.getRealmName() == null || def.getRealmName().trim().length() == 0)
{
- this.defaultRealmName = vRn.getValue().trim();
+ // The realm name is empty
+ // We first set the default value
+ def.setRealmName(DEFAULT_REALM_NAME);
+ if (params == null)
+ {
+ return;
+ }
+ final ValueParam vp = params.getValueParam("default.realm.name");
+ if (vp != null && vp.getValue().trim().length() > 0)
+ {
+ // A realm name has been defined in the value parameter, thus we use it
+ def.setRealmName(vp.getValue().trim());
+ }
}
+ else
+ {
+ // We ensure that the realm name doesn't contain any useless characters
+ def.setRealmName(def.getRealmName().trim());
+ }
}
/**
+ * Initialize the value of the rest context name
+ */
+ private void initRestContextName(InitParams params, PortalContainerDefinition def)
+ {
+ if (def.getRestContextName() == null || def.getRestContextName().trim().length() == 0)
+ {
+ // The rest context name is empty
+ // We first set the default value
+ def.setRestContextName(DEFAULT_REST_CONTEXT_NAME);
+ if (params == null)
+ {
+ return;
+ }
+ final ValueParam vp = params.getValueParam("default.rest.context");
+ if (vp != null && vp.getValue().trim().length() > 0)
+ {
+ // A rest context name has been defined in the value parameter, thus we use it
+ def.setRestContextName(vp.getValue().trim());
+ }
+ }
+ else
+ {
+ // We ensure that the rest context name doesn't contain any useless characters
+ def.setRestContextName(def.getRestContextName().trim());
+ }
+ }
+
+ /**
+ * Initialize the value of the portal container name
+ */
+ private void initName(InitParams params, PortalContainerDefinition def)
+ {
+ if (def.getName() == null || def.getName().trim().length() == 0)
+ {
+ // The name is empty
+ // We first set the default value
+ def.setName(DEFAULT_PORTAL_CONTAINER_NAME);
+ if (params == null)
+ {
+ return;
+ }
+ final ValueParam vp = params.getValueParam("default.portal.container");
+ if (vp != null && vp.getValue().trim().length() > 0)
+ {
+ // A name has been defined in the value parameter, thus we use it
+ def.setName(vp.getValue().trim());
+ }
+ }
+ else
+ {
+ // We ensure that the name doesn't contain any useless characters
+ def.setName(def.getName().trim());
+ }
+ }
+
+ /**
* @return the default name of the portal container
*/
public String getDefaultPortalContainer()
{
- return defaultPortalContainerName;
+ return defaultDefinition.getName();
}
/**
@@ -182,7 +320,7 @@
*/
public String getDefaultRestContext()
{
- return defaultRestContextName;
+ return defaultDefinition.getRestContextName();
}
/**
@@ -190,7 +328,7 @@
*/
public String getDefaultRealmName()
{
- return defaultRealmName;
+ return defaultDefinition.getRealmName();
}
/**
@@ -259,7 +397,7 @@
{
// we assume the old behavior is expected
final String portalContainerName =
- portalContainerNames.contains(contextName) ? contextName : defaultPortalContainerName;
+ portalContainerNames.contains(contextName) ? contextName : defaultDefinition.getName();
return Collections.singletonList(portalContainerName);
}
return result;
@@ -286,7 +424,7 @@
if (result == null || result.isEmpty())
{
// we assume the old behavior is expected
- return defaultPortalContainerName;
+ return defaultDefinition.getName();
}
return result.get(0);
}
@@ -299,7 +437,12 @@
public List<String> getDependencies(String portalContainerName)
{
final PortalContainerDefinition definition = definitions.get(portalContainerName);
- return definition == null ? null : definition.getDependencies();
+ List<String> result = null;
+ if (definition != null)
+ {
+ result = definition.getDependencies();
+ }
+ return result == null ? defaultDefinition.getDependencies() : result;
}
/**
@@ -316,31 +459,35 @@
throw new IllegalArgumentException("The setting name cannot be null");
}
final PortalContainerDefinition definition = definitions.get(portalContainerName);
- if (definition == null)
+ if (definition != null)
{
- return null;
+ final Map<String, Object> settings = definition.getSettings();
+ if (settings != null)
+ {
+ return settings.get(settingName);
+ }
}
- final Map<String, Object> settings = definition.getSettings();
- return settings == null ? null : settings.get(settingName);
+ final Map<String, Object> defaultSettings = defaultDefinition.getSettings();
+ return defaultSettings == null ? null : defaultSettings.get(settingName);
}
/**
* Gives the name of the rest {@link ServletContext} related to the given portal container
* @param portalContainerName the name of the portal container for which we want the rest context name
* @return the name of the related rest context name. It tries to get it from the {@link PortalContainerDefinition}
- * if it has not been set it will return <code>defaultRestContextName</code>
+ * if it has not been set it will return <code>defaultDefinition.getRestContextName()</code>
*/
public String getRestContextName(String portalContainerName)
{
final PortalContainerDefinition definition = definitions.get(portalContainerName);
if (definition == null)
{
- return defaultRestContextName;
+ return defaultDefinition.getRestContextName();
}
else
{
String contextName = definition.getRestContextName();
- return contextName == null ? defaultRestContextName : contextName;
+ return contextName == null ? defaultDefinition.getRestContextName() : contextName;
}
}
@@ -348,19 +495,19 @@
* Gives the name of the realm related to the given portal container
* @param portalContainerName the name of the portal container for which we want the realm name
* @return the name of the related realm name. It tries to get it from the {@link PortalContainerDefinition}
- * if it has not been set it will return <code>defaultRealmName</code>
+ * if it has not been set it will return <code>defaultDefinition.getRealmName()</code>
*/
public String getRealmName(String portalContainerName)
{
final PortalContainerDefinition definition = definitions.get(portalContainerName);
if (definition == null)
{
- return defaultRealmName;
+ return defaultDefinition.getRealmName();
}
else
{
String realmName = definition.getRealmName();
- return realmName == null ? defaultRealmName : realmName;
+ return realmName == null ? defaultDefinition.getRealmName() : realmName;
}
}
@@ -406,7 +553,7 @@
String name = def.getName();
if (name == null || (name = name.trim()).length() == 0)
{
- log.warn("A PortalContainerDefinition cannot have empty name");
+ log.warn("A PortalContainerDefinition cannot have an empty name");
continue;
}
else
@@ -429,10 +576,15 @@
*/
private void registerDependencies(PortalContainerDefinition definition, Map<String, List<String>> scopes)
{
- final List<String> dependencies = definition.getDependencies();
+ List<String> dependencies = definition.getDependencies();
if (dependencies == null || dependencies.isEmpty())
{
- return;
+ // Try to get the default dependencies
+ dependencies = defaultDefinition.getDependencies();
+ if (dependencies == null || dependencies.isEmpty())
+ {
+ return;
+ }
}
for (String context : dependencies)
{
@@ -467,25 +619,38 @@
* portal container name, the realm name and the rest context name.
* @param def the {@link PortalContainerDefinition} from which we have the extract the
* settings and in which we have to re-inject the final settings
+ * @param addDefaultSettings indicates whether the settings of the default portal
+ * container definition has to be loaded first
*/
- private void initializeSettings(PortalContainerDefinition def)
+ private void initializeSettings(PortalContainerDefinition def, boolean addDefaultSettings)
{
+ // The list of portal container definition for which we want to load the settings
+ final PortalContainerDefinition[] defs;
+ if (addDefaultSettings)
+ {
+ // We need to load the default settings then the settings of the current portal
+ // container definition
+ defs = new PortalContainerDefinition[]{defaultDefinition, def};
+ }
+ else
+ {
+ // We only need to load the settings of the current portal container definition
+ defs = new PortalContainerDefinition[]{def};
+ }
final Map<String, Object> settings = new HashMap<String, Object>();
- // We first load the settings of the PortalContainerDefinition if they exist
- final Map<String, Object> tmpSettings = def.getSettings();
- if (tmpSettings != null && !tmpSettings.isEmpty())
+ loadInternalSettings(defs, settings);
+ if (pc != null)
{
- settings.putAll(tmpSettings);
+ resolveInternalSettings(settings);
}
- // We then load the external settings, if they exists
- String path = def.getExternalSettingsPath();
- if (path != null && (path = path.trim()).length() > 0)
+
+ final Map<String, String> externalSettings = new LinkedHashMap<String, String>();
+ loadExternalSettings(def, defs, externalSettings);
+ if (!externalSettings.isEmpty())
{
- final Map<String, String> props = loadExternalSettings(path, def);
- if (props != null && !props.isEmpty())
- {
- mergeSettings(settings, props);
- }
+ resolveExternalSettings(def, settings, externalSettings);
+ // Merge the settings
+ mergeSettings(settings, externalSettings);
}
// We then add the main settings
settings.putAll(getMainSettings(def));
@@ -494,6 +659,87 @@
}
/**
+ * Creates a context from the internal settings, external settings and the main settings and
+ * try to resolve variables defined in the external settings
+ */
+ private void resolveExternalSettings(PortalContainerDefinition def, final Map<String, Object> settings,
+ final Map<String, String> externalSettings)
+ {
+ // Create the context for variable resolution
+ final Map<String, Object> ctx = new LinkedHashMap<String, Object>();
+ ctx.putAll(settings);
+ ctx.putAll(externalSettings);
+ ctx.putAll(getMainSettings(def));
+ // Resolve variables
+ for (Map.Entry<String, String> entry : externalSettings.entrySet())
+ {
+ String propertyName = entry.getKey();
+ String propertyValue = entry.getValue();
+ propertyValue = Deserializer.resolveVariables(propertyValue, ctx);
+ externalSettings.put(propertyName, propertyValue);
+ ctx.put(propertyName, propertyValue);
+ }
+ }
+
+ /**
+ * Loads the external settings of all the given {@link PortalContainerDefinition}
+ */
+ private void loadExternalSettings(PortalContainerDefinition def, final PortalContainerDefinition[] defs,
+ final Map<String, String> externalSettings)
+ {
+ for (PortalContainerDefinition pcd : defs)
+ {
+ // We then load the external settings, if they exists
+ String path = pcd.getExternalSettingsPath();
+ if (path != null && (path = path.trim()).length() > 0)
+ {
+ final Map<String, String> props =
+ loadExternalSettings(path, defaultDefinition == null || pcd == defaultDefinition, def);
+ if (props != null && !props.isEmpty())
+ {
+ externalSettings.putAll(props);
+ }
+ }
+ }
+ }
+
+ /**
+ * Try to resolve all the String values to ensure that there is no variables unresolved
+ * The {@link PropertyConfigurator} cans create new system property so it could be
+ * necessary to resolve the {@link String} settings one more time
+ */
+ private void resolveInternalSettings(final Map<String, Object> settings)
+ {
+ // New System properties have been added so we will try to re-resolve the String variables
+ for (Map.Entry<String, Object> entry : settings.entrySet())
+ {
+ String propertyName = entry.getKey();
+ Object propertyValue = entry.getValue();
+ if (propertyValue instanceof String)
+ {
+ propertyValue = Deserializer.resolveVariables((String)propertyValue);
+ settings.put(propertyName, propertyValue);
+ }
+ }
+ }
+
+ /**
+ * Loads all the internal settings related to the given array of {@link PortalContainerDefinition}
+ */
+ private void loadInternalSettings(final PortalContainerDefinition[] defs, final Map<String, Object> settings)
+ {
+ for (PortalContainerDefinition pcd : defs)
+ {
+ // We first load the internal settings if they exists
+ final Map<String, Object> tmpSettings = pcd.getSettings();
+ if (tmpSettings != null && !tmpSettings.isEmpty())
+ {
+ settings.putAll(tmpSettings);
+ }
+ }
+ }
+
+ /**
* This method gives the main settings such as the portal container name, the rest context name
* and the realm name into a {@link Map}
* @param def the {@link PortalContainerDefinition} from which we extract the value of the main
@@ -506,10 +752,11 @@
// We add the portal container name
settings.put(PORTAL_CONTAINER_SETTING_NAME, def.getName());
// We add the rest context name
- settings.put(REST_CONTEXT_SETTING_NAME, def.getRestContextName() == null ? defaultRestContextName : def
- .getRestContextName());
+ settings.put(REST_CONTEXT_SETTING_NAME, def.getRestContextName() == null ? defaultDefinition.getRestContextName()
+ : def.getRestContextName());
// We add the realm name
- settings.put(REALM_SETTING_NAME, def.getRealmName() == null ? defaultRealmName : def.getRealmName());
+ settings.put(REALM_SETTING_NAME, def.getRealmName() == null ? defaultDefinition.getRealmName() : def
+ .getRealmName());
return settings;
}
@@ -520,8 +767,12 @@
* <li>The path doesn't contain any prefix of type "classpath:", "jar:" or "file:", we
* assume that the file could be externalized so we apply the following rules:
* <ol>
- * <li>A file exists at ${exo-conf-dir}/portal/${portalContainerName}/${path}, we
- * will load this file</li>
+ * <li>The value of the parameter <code>isPath4DefaultPCD</code> is <code>true</code> which
+ * means that the given url comes from the default portal container definition and a file
+ * exists at ${exo-conf-dir}/portal/${path}, we will load this file</li>
+ * <li>The value of the parameter <code>isPath4DefaultPCD</code> is <code>false</code> which
+ * means that the given url doesn't come from the default portal container definition and a file
+ * exists at ${exo-conf-dir}/portal/${portalContainerName}/${path}, we will load this file</li>
* <li>No file exists at the previous path, we then assume that the path cans be
* interpreted by the {@link ConfigurationManager}</li>
* </ol>
@@ -530,10 +781,13 @@
* by the {@link ConfigurationManager}</li>
* </ol>
* @param path the path of the external settings to load
+ * @param isPath4DefaultPCD indicates if the given path comes from the default portal
+ * container definition
* @param def the {@link PortalContainerDefinition} for which we load the external settings
* @return A {@link Map} of settings if the file could be loaded, <code>null</code> otherwise
*/
- private Map<String, String> loadExternalSettings(String path, PortalContainerDefinition def)
+ private Map<String, String> loadExternalSettings(String path, boolean isPath4DefaultPCD,
+ PortalContainerDefinition def)
{
try
{
@@ -541,7 +795,9 @@
if (path.indexOf(':') == -1)
{
// We first check if the file is not in eXo configuration directory
- String fullPath = serverInfo.getExoConfigurationDirectory() + "/portal/" + def.getName() + "/" + path;
+ String fullPath =
+ serverInfo.getExoConfigurationDirectory() + "/portal/" + (isPath4DefaultPCD ? "" : def.getName() + "/")
+ + path;
File file = new File(fullPath);
if (file.exists())
{
@@ -555,7 +811,7 @@
url = cm.getURL(path);
}
// We load the properties from the url found
- return ContainerUtil.loadProperties(url, getMainSettings(def));
+ return ContainerUtil.loadProperties(url, false);
}
catch (Exception e)
{
@@ -667,54 +923,45 @@
*/
private void initialize(Map<String, PortalContainerDefinition> mDefinitions)
{
- if (mDefinitions.isEmpty())
- {
- // No definitions have been found, the default values will be set
- if (defaultPortalContainerName == null)
- {
- this.defaultPortalContainerName = DEFAULT_PORTAL_CONTAINER_NAME;
- }
- }
final List<String> lPortalContainerNames = new ArrayList<String>(mDefinitions.size() + 1);
// Add the default portal container name
- if (defaultPortalContainerName != null)
- {
- lPortalContainerNames.add(defaultPortalContainerName);
- }
+ lPortalContainerNames.add(defaultDefinition.getName());
final Map<String, List<String>> mScopes = new HashMap<String, List<String>>();
for (Map.Entry<String, PortalContainerDefinition> entry : mDefinitions.entrySet())
{
PortalContainerDefinition definition = entry.getValue();
String name = definition.getName();
- if (!name.equals(defaultPortalContainerName))
+ boolean hasChanged = false;
+ if (!name.equals(defaultDefinition.getName()))
{
- if (defaultPortalContainerName == null)
+ if (defaultDefinition.getName() == DEFAULT_PORTAL_CONTAINER_NAME)
{
- this.defaultPortalContainerName = name;
+ defaultDefinition.setName(name);
+ hasChanged = true;
}
lPortalContainerNames.add(name);
}
- if (defaultRestContextName == null)
+ if (defaultDefinition.getRestContextName() == DEFAULT_REST_CONTEXT_NAME
+ && definition.getRestContextName() != null && definition.getRestContextName().trim().length() > 0)
{
- this.defaultRestContextName = definition.getRestContextName();
+ defaultDefinition.setRestContextName(definition.getRestContextName().trim());
+ hasChanged = true;
}
- if (defaultRealmName == null)
+ if (defaultDefinition.getRealmName() == DEFAULT_REALM_NAME && definition.getRealmName() != null
+ && definition.getRealmName().trim().length() > 0)
{
- this.defaultRealmName = definition.getRealmName();
+ defaultDefinition.setRealmName(definition.getRealmName().trim());
+ hasChanged = true;
}
registerDependencies(definition, mScopes);
- initializeSettings(definition);
+ if (hasChanged)
+ {
+ initializeSettings(defaultDefinition, false);
+ }
+ initializeSettings(definition, true);
}
this.portalContainerNames = Collections.unmodifiableList(lPortalContainerNames);
this.scopes = Collections.unmodifiableMap(mScopes);
- if (defaultRestContextName == null)
- {
- this.defaultRestContextName = DEFAULT_REST_CONTEXT_NAME;
- }
- if (defaultRealmName == null)
- {
- this.defaultRealmName = DEFAULT_REALM_NAME;
- }
}
/**
Modified: kernel/tags/2.2.0-GA/exo.kernel.container/src/main/java/org/exoplatform/container/util/ContainerUtil.java
===================================================================
--- kernel/tags/2.2.0-GA/exo.kernel.container/src/main/java/org/exoplatform/container/util/ContainerUtil.java 2010-03-11 09:32:07 UTC (rev 2051)
+++ kernel/tags/2.2.0-GA/exo.kernel.container/src/main/java/org/exoplatform/container/util/ContainerUtil.java 2010-03-11 11:49:03 UTC (rev 2052)
@@ -208,16 +208,16 @@
*/
public static Map<String, String> loadProperties(URL url)
{
- return loadProperties(url, null);
+ return loadProperties(url, true);
}
/**
* Loads the properties file corresponding to the given url
* @param url the url of the properties file
- * @param initEnv the initial environment that is composed of a set of initial variables
+ * @param resolveVariables indicates if the variables must be resolved
* @return a {@link Map} of properties
*/
- public static Map<String, String> loadProperties(URL url, Map<String, String> initEnv)
+ public static Map<String, String> loadProperties(URL url, boolean resolveVariables)
{
LinkedHashMap<String, String> props = null;
String path = null;
@@ -251,15 +251,10 @@
{
log.debug("Will not load property file" + path + " because its format is not recognized");
}
- if (props != null)
+ if (props != null && resolveVariables)
{
// Those properties are used for variables resolution
- final Map<String, String> currentProps = new HashMap<String,String>();
- if (initEnv != null && !initEnv.isEmpty())
- {
- // There are a set of initial variables to load into the environment
- currentProps.putAll(initEnv);
- }
+ final Map<String, Object> currentProps = new HashMap<String, Object>();
for (Map.Entry<String, String> entry : props.entrySet())
{
String propertyName = entry.getKey();
Modified: kernel/tags/2.2.0-GA/exo.kernel.container/src/main/java/org/exoplatform/container/xml/Deserializer.java
===================================================================
--- kernel/tags/2.2.0-GA/exo.kernel.container/src/main/java/org/exoplatform/container/xml/Deserializer.java 2010-03-11 09:32:07 UTC (rev 2051)
+++ kernel/tags/2.2.0-GA/exo.kernel.container/src/main/java/org/exoplatform/container/xml/Deserializer.java 2010-03-11 11:49:03 UTC (rev 2052)
@@ -54,7 +54,7 @@
*/
public static String resolveString(String s)
{
- return Deserializer.resolveVariables(s);
+ return Deserializer.resolveNClean(s);
}
/**
@@ -77,7 +77,7 @@
{
return null;
}
- s = Deserializer.resolveVariables(s);
+ s = Deserializer.resolveNClean(s);
if (s.equalsIgnoreCase("true"))
{
return true;
@@ -107,7 +107,7 @@
{
return null;
}
- s = Deserializer.resolveVariables(s);
+ s = Deserializer.resolveNClean(s);
try
{
return Integer.parseInt(s);
@@ -136,7 +136,7 @@
{
return null;
}
- s = Deserializer.resolveVariables(s);
+ s = Deserializer.resolveNClean(s);
try
{
return Long.parseLong(s);
@@ -165,7 +165,7 @@
{
return null;
}
- s = Deserializer.resolveVariables(s);
+ s = Deserializer.resolveNClean(s);
try
{
return Double.parseDouble(s);
@@ -178,7 +178,7 @@
/**
* Resolve the variables of type ${my.var} for the current context which is composed
- * of the system properties and the portal container properties
+ * of the system properties and the portal container settings
* @param input the input value
* @return the resolve value
*/
@@ -189,12 +189,12 @@
/**
* Resolve the variables of type ${my.var} for the current context which is composed
- * of the system properties, the portal container properties and the given properties
+ * of the system properties, the portal container settings and the given settings
* @param input the input value
- * @param props a set of properties to add for the variable resolution
+ * @param props a set of parameters to add for the variable resolution
* @return the resolve value
*/
- public static String resolveVariables(String input, Map<String, String> props)
+ public static String resolveVariables(String input, Map<String, Object> props)
{
final int NORMAL = 0;
final int SEEN_DOLLAR = 1;
@@ -257,8 +257,9 @@
{
if (props != null)
{
- // Some properties have been given thus we need to check inside first
- value = props.get(key);
+ // Some parameters have been given thus we need to check inside first
+ Object oValue = props.get(key);
+ value = oValue == null ? null : oValue.toString();
}
if (value == null)
{
@@ -284,4 +285,25 @@
return buffer.toString();
}
+
+ /**
+ * This methods will remove useless characters from the given {@link String} and return the result
+ * @param s the input value
+ * @return <code>null</code> if the input value is <code>null</code>, <code>s.trim()</code>
+ * otherwise
+ */
+ public static String cleanString(String s)
+ {
+ return s == null ? null : s.trim();
+ }
+
+ /**
+ * This method will first resolves the variables then it will clean the results
+ * @param s the input value
+ * @return the resolve and clean value
+ */
+ public static String resolveNClean(String s)
+ {
+ return cleanString(resolveVariables(s));
+ }
}
Modified: kernel/tags/2.2.0-GA/exo.kernel.container/src/main/java/org/exoplatform/management/rest/annotations/RESTEndpoint.java
===================================================================
--- kernel/tags/2.2.0-GA/exo.kernel.container/src/main/java/org/exoplatform/management/rest/annotations/RESTEndpoint.java 2010-03-11 09:32:07 UTC (rev 2051)
+++ kernel/tags/2.2.0-GA/exo.kernel.container/src/main/java/org/exoplatform/management/rest/annotations/RESTEndpoint.java 2010-03-11 11:49:03 UTC (rev 2052)
@@ -17,7 +17,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.exoplatform.management.management.annotations;
+package org.exoplatform.management.rest.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Modified: kernel/tags/2.2.0-GA/exo.kernel.container/src/main/resources/binding.xml
===================================================================
--- kernel/tags/2.2.0-GA/exo.kernel.container/src/main/resources/binding.xml 2010-03-11 09:32:07 UTC (rev 2051)
+++ kernel/tags/2.2.0-GA/exo.kernel.container/src/main/resources/binding.xml 2010-03-11 11:49:03 UTC (rev 2052)
@@ -19,6 +19,9 @@
-->
<binding>
+ <!-- the default deserializer to use for String -->
+ <format type="java.lang.String" deserializer="org.exoplatform.container.xml.Deserializer.cleanString"/>
+
<!-- xml object mapping -->
<mapping class="org.exoplatform.xml.object.XMLBaseObject" abstract="true" label="base-object">
<value name="string" usage="optional" get-method="getString" set-method="setString" deserializer="org.exoplatform.container.xml.Deserializer.resolveString"/>
Modified: kernel/tags/2.2.0-GA/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java
===================================================================
--- kernel/tags/2.2.0-GA/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java 2010-03-11 09:32:07 UTC (rev 2051)
+++ kernel/tags/2.2.0-GA/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java 2010-03-11 11:49:03 UTC (rev 2052)
@@ -54,6 +54,15 @@
assertEquals("my-exo-domain", config.getDefaultRealmName());
assertFalse(config.hasDefinition());
+ rootContainer =
+ createRootContainer("portal-container-config-with-default-values-and-with-default-portal-def.xml");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+
+ assertEquals("myPortal-dpcdef", config.getDefaultPortalContainer());
+ assertEquals("myRest-dpcdef", config.getDefaultRestContext());
+ assertEquals("my-exo-domain-dpcdef", config.getDefaultRealmName());
+ assertFalse(config.hasDefinition());
+
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def.xml");
config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
@@ -62,6 +71,15 @@
assertEquals("my-exo-domain", config.getDefaultRealmName());
assertTrue(config.hasDefinition());
+ rootContainer =
+ createRootContainer("portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def.xml");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+
+ assertEquals("myPortal-dpcdef", config.getDefaultPortalContainer());
+ assertEquals("myRest-dpcdef", config.getDefaultRestContext());
+ assertEquals("my-exo-domain-dpcdef", config.getDefaultRealmName());
+ assertTrue(config.hasDefinition());
+
rootContainer = createRootContainer("portal-container-config-with-no-default-values-but-with-portal-def.xml");
config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
@@ -107,7 +125,7 @@
assertTrue(config.isScopeValid("myPortal", "foo"));
assertTrue(config.isScopeValid("myPortal-pcdef", "foo"));
assertTrue(config.hasDefinition());
-
+
// Without dependencies and with no portal container name
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-empty-portal-def.xml");
config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
@@ -135,7 +153,7 @@
assertFalse(config.isPortalContainerName("foo"));
assertTrue(config.isPortalContainerName("myPortal"));
assertFalse(config.isPortalContainerName("myPortal-pcdef"));
-
+
// Without dependencies and with no rest context name an realm name
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-empty-portal-def2.xml");
config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
@@ -168,13 +186,48 @@
assertTrue(config.isScopeValid("myPortal", "foo"));
assertTrue(config.isScopeValid("myPortal-pcdef", "foo"));
assertTrue(config.hasDefinition());
-
+
+ // Without dependencies and with default portal container definition
+ rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def.xml");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ List<String> deps = config.getDependencies("foo");
+ assertTrue(deps != null && deps.size() == 1 && deps.contains("fooX"));
+ deps = config.getDependencies("myPortal");
+ assertTrue(deps != null && deps.size() == 1 && deps.contains("fooX"));
+ deps = config.getDependencies("myPortal-pcdef");
+ assertTrue(deps != null && deps.size() == 1 && deps.contains("fooX"));
+ names = config.getPortalContainerNames("foo");
+ assertTrue(names != null && !names.isEmpty());
+ assertEquals("myPortal-dpcdef", names.get(0));
+ names = config.getPortalContainerNames("myPortal");
+ assertTrue(names != null && !names.isEmpty());
+ assertEquals("myPortal-dpcdef", names.get(0));
+ names = config.getPortalContainerNames("myPortal-pcdef");
+ assertTrue(names != null && !names.isEmpty());
+ assertEquals("myPortal-pcdef", names.get(0));
+ assertEquals("myPortal-dpcdef", config.getPortalContainerName("foo"));
+ assertEquals("myPortal-dpcdef", config.getPortalContainerName("myPortal"));
+ assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal-pcdef"));
+ assertEquals("myRest-dpcdef", config.getRestContextName("foo"));
+ assertEquals("myRest-dpcdef", config.getRestContextName("myPortal"));
+ assertEquals("myRest-pcdef", config.getRestContextName("myPortal-pcdef"));
+ assertEquals("my-exo-domain-dpcdef", config.getRealmName("foo"));
+ assertEquals("my-exo-domain-dpcdef", config.getRealmName("myPortal"));
+ assertEquals("my-exo-domain-pcdef", config.getRealmName("myPortal-pcdef"));
+ assertFalse(config.isPortalContainerName("foo"));
+ assertFalse(config.isPortalContainerName("myPortal"));
+ assertTrue(config.isPortalContainerName("myPortal-pcdef"));
+ assertFalse(config.isScopeValid("foo", "fooX"));
+ assertFalse(config.isScopeValid("myPortal", "fooX"));
+ assertTrue(config.isScopeValid("myPortal-pcdef", "fooX"));
+ assertTrue(config.hasDefinition());
+
// With dependencies
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def2.xml");
config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
assertNull(config.getDependencies("foo"));
assertNull(config.getDependencies("myPortal"));
- List<String> deps = config.getDependencies("myPortal-pcdef");
+ deps = config.getDependencies("myPortal-pcdef");
assertTrue(deps != null && deps.size() == 3);
names = config.getPortalContainerNames("foo");
assertTrue(names != null && !names.isEmpty());
@@ -201,44 +254,176 @@
assertFalse(config.isScopeValid("myPortal", "foo"));
assertTrue(config.isScopeValid("myPortal-pcdef", "foo"));
assertTrue(config.hasDefinition());
+
+ // With dependencies and with default portal container definition
+ rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def2.xml");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ deps = config.getDependencies("foo");
+ assertTrue(deps != null && deps.size() == 1 && deps.contains("fooX"));
+ deps = config.getDependencies("myPortal");
+ assertTrue(deps != null && deps.size() == 1 && deps.contains("fooX"));
+ deps = config.getDependencies("myPortal-pcdef");
+ assertTrue(deps != null && deps.size() == 3);
+ names = config.getPortalContainerNames("foo");
+ assertTrue(names != null && !names.isEmpty());
+ assertEquals("myPortal-pcdef", names.get(0));
+ names = config.getPortalContainerNames("myPortal");
+ assertTrue(names != null && !names.isEmpty());
+ assertEquals("myPortal", names.get(0));
+ names = config.getPortalContainerNames("myPortal-pcdef");
+ assertTrue(names != null && !names.isEmpty());
+ assertEquals("myPortal-pcdef", names.get(0));
+ assertEquals("myPortal-pcdef", config.getPortalContainerName("foo"));
+ assertEquals("myPortal", config.getPortalContainerName("myPortal"));
+ assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal-pcdef"));
+ assertEquals("myRest", config.getRestContextName("foo"));
+ assertEquals("myRest", config.getRestContextName("myPortal"));
+ assertEquals("myRest-pcdef", config.getRestContextName("myPortal-pcdef"));
+ assertEquals("my-exo-domain", config.getRealmName("foo"));
+ assertEquals("my-exo-domain", config.getRealmName("myPortal"));
+ assertEquals("my-exo-domain-pcdef", config.getRealmName("myPortal-pcdef"));
+ assertFalse(config.isPortalContainerName("foo"));
+ assertTrue(config.isPortalContainerName("myPortal"));
+ assertTrue(config.isPortalContainerName("myPortal-pcdef"));
+ assertFalse(config.isScopeValid("foo", "foo"));
+ assertFalse(config.isScopeValid("myPortal", "foo"));
+ assertTrue(config.isScopeValid("myPortal-pcdef", "foo"));
+ assertTrue(config.hasDefinition());
}
public void testSettings()
{
- // Without settings and without portal definition
- RootContainer rootContainer = createRootContainer("portal-container-config-with-default-values.xml");
+ // Without settings, without portal definition and without default values
+ RootContainer rootContainer = createRootContainer("portal-container-config-with-no-default-values.xml");
PortalContainerConfig config =
(PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
assertNull(config.getSetting("foo", "foo"));
assertNull(config.getSetting("myPortal", "foo"));
assertNull(config.getSetting("myPortal-pcdef", "foo"));
- assertNull(config.getSetting("foo", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
- assertNull(config.getSetting("myPortal", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
- assertNull(config.getSetting("myPortal-pcdef", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
- assertNull(config.getSetting("foo", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
- assertNull(config.getSetting("myPortal", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
- assertNull(config.getSetting("myPortal-pcdef", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
- assertNull(config.getSetting("foo", PortalContainerConfig.REALM_SETTING_NAME));
- assertNull(config.getSetting("myPortal", PortalContainerConfig.REALM_SETTING_NAME));
- assertNull(config.getSetting("myPortal-pcdef", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getSetting("foo",
+ PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getSetting("myPortal",
+ PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getSetting("myPortal-pcdef",
+ PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals(PortalContainerConfig.DEFAULT_REST_CONTEXT_NAME, config.getSetting("foo",
+ PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals(PortalContainerConfig.DEFAULT_REST_CONTEXT_NAME, config.getSetting("myPortal",
+ PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals(PortalContainerConfig.DEFAULT_REST_CONTEXT_NAME, config.getSetting("myPortal-pcdef",
+ PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals(PortalContainerConfig.DEFAULT_REALM_NAME, config.getSetting("foo",
+ PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals(PortalContainerConfig.DEFAULT_REALM_NAME, config.getSetting("myPortal",
+ PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals(PortalContainerConfig.DEFAULT_REALM_NAME, config.getSetting("myPortal-pcdef",
+ PortalContainerConfig.REALM_SETTING_NAME));
+ // Without settings and without portal definition
+ rootContainer = createRootContainer("portal-container-config-with-default-values.xml");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertNull(config.getSetting("foo", "foo"));
+ assertNull(config.getSetting("myPortal", "foo"));
+ assertNull(config.getSetting("myPortal-pcdef", "foo"));
+ assertEquals("myPortal", config.getSetting("foo", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myPortal", config.getSetting("myPortal", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myPortal", config.getSetting("myPortal-pcdef", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myRest", config.getSetting("foo", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("myRest", config.getSetting("myPortal", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("myRest", config.getSetting("myPortal-pcdef", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("my-exo-domain", config.getSetting("foo", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("my-exo-domain", config.getSetting("myPortal", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("my-exo-domain", config.getSetting("myPortal-pcdef", PortalContainerConfig.REALM_SETTING_NAME));
+
+ // Without settings, without portal definition and with empty default portal container definition
+ rootContainer =
+ createRootContainer("portal-container-config-with-default-values-and-with-empty-default-portal-def.xml");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertNull(config.getSetting("foo", "foo"));
+ assertNull(config.getSetting("myPortal", "foo"));
+ assertNull(config.getSetting("myPortal-pcdef", "foo"));
+ assertEquals("myPortal", config.getSetting("foo", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myPortal", config.getSetting("myPortal", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myPortal", config.getSetting("myPortal-pcdef", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myRest", config.getSetting("foo", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("myRest", config.getSetting("myPortal", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("myRest", config.getSetting("myPortal-pcdef", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("my-exo-domain", config.getSetting("foo", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("my-exo-domain", config.getSetting("myPortal", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("my-exo-domain", config.getSetting("myPortal-pcdef", PortalContainerConfig.REALM_SETTING_NAME));
+
+ // Without settings, without portal definition and with default portal container definition
+ rootContainer =
+ createRootContainer("portal-container-config-with-default-values-and-with-default-portal-def.xml");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertNull(config.getSetting("foo", "foo"));
+ assertNull(config.getSetting("myPortal", "foo"));
+ assertNull(config.getSetting("myPortal-pcdef", "foo"));
+ assertEquals("myPortal-dpcdef", config.getSetting("foo", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myPortal-dpcdef", config
+ .getSetting("myPortal", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myPortal-dpcdef", config.getSetting("myPortal-pcdef",
+ PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myRest-dpcdef", config.getSetting("foo", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("myRest-dpcdef", config.getSetting("myPortal", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("myRest-dpcdef", config
+ .getSetting("myPortal-pcdef", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("my-exo-domain-dpcdef", config.getSetting("foo", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("my-exo-domain-dpcdef", config.getSetting("myPortal", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("my-exo-domain-dpcdef", config
+ .getSetting("myPortal-pcdef", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("value0", config.getSetting("foo", "string"));
+ assertEquals(new Integer(100), config.getSetting("foo", "int"));
+ assertEquals(new Long(100), config.getSetting("foo", "long"));
+ assertEquals(new Double(100), config.getSetting("foo", "double"));
+ assertEquals(new Boolean(false), config.getSetting("foo", "boolean"));
+ assertEquals("value0", config.getSetting("myPortal", "string"));
+ assertEquals(new Integer(100), config.getSetting("myPortal", "int"));
+ assertEquals(new Long(100), config.getSetting("myPortal", "long"));
+ assertEquals(new Double(100), config.getSetting("myPortal", "double"));
+ assertEquals(new Boolean(false), config.getSetting("myPortal", "boolean"));
+ assertEquals("value0", config.getSetting("myPortal-pcdef", "string"));
+ assertEquals(new Integer(100), config.getSetting("myPortal-pcdef", "int"));
+ assertEquals(new Long(100), config.getSetting("myPortal-pcdef", "long"));
+ assertEquals(new Double(100), config.getSetting("myPortal-pcdef", "double"));
+ assertEquals(new Boolean(false), config.getSetting("myPortal-pcdef", "boolean"));
+
// Without settings and with portal definition
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def.xml");
config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
assertNull(config.getSetting("foo", "foo"));
assertNull(config.getSetting("myPortal", "foo"));
assertNull(config.getSetting("myPortal-pcdef", "foo"));
- assertNull(config.getSetting("foo", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
- assertNull(config.getSetting("myPortal", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myPortal", config.getSetting("foo", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myPortal", config.getSetting("myPortal", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
assertEquals("myPortal-pcdef", config.getSetting("myPortal-pcdef",
PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
- assertNull(config.getSetting("foo", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
- assertNull(config.getSetting("myPortal", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("myRest", config.getSetting("foo", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("myRest", config.getSetting("myPortal", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
assertEquals("myRest-pcdef", config.getSetting("myPortal-pcdef", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
- assertNull(config.getSetting("foo", PortalContainerConfig.REALM_SETTING_NAME));
- assertNull(config.getSetting("myPortal", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("my-exo-domain", config.getSetting("foo", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("my-exo-domain", config.getSetting("myPortal", PortalContainerConfig.REALM_SETTING_NAME));
assertEquals("my-exo-domain-pcdef", config.getSetting("myPortal-pcdef", PortalContainerConfig.REALM_SETTING_NAME));
+ // Without settings, with portal definition and with default portal definition
+ rootContainer =
+ createRootContainer("portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def.xml");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertNull(config.getSetting("foo", "foo"));
+ assertNull(config.getSetting("myPortal", "foo"));
+ assertNull(config.getSetting("myPortal-pcdef", "foo"));
+ assertEquals("myPortal-dpcdef", config.getSetting("foo", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myPortal-dpcdef", config
+ .getSetting("myPortal", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myPortal-pcdef", config.getSetting("myPortal-pcdef",
+ PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myRest-dpcdef", config.getSetting("foo", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("myRest-dpcdef", config.getSetting("myPortal", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("myRest-pcdef", config.getSetting("myPortal-pcdef", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("my-exo-domain-dpcdef", config.getSetting("foo", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("my-exo-domain-dpcdef", config.getSetting("myPortal", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("my-exo-domain-pcdef", config.getSetting("myPortal-pcdef", PortalContainerConfig.REALM_SETTING_NAME));
+
// With internal settings
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-settings.xml");
config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
@@ -253,17 +438,57 @@
assertEquals(new Long(10), config.getSetting("myPortal-pcdef", "long"));
assertEquals(new Double(10), config.getSetting("myPortal-pcdef", "double"));
assertEquals(new Boolean(true), config.getSetting("myPortal-pcdef", "boolean"));
- assertNull(config.getSetting("foo", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
- assertNull(config.getSetting("myPortal", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myPortal", config.getSetting("foo", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myPortal", config.getSetting("myPortal", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
assertEquals("myPortal-pcdef", config.getSetting("myPortal-pcdef",
PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
- assertNull(config.getSetting("foo", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
- assertNull(config.getSetting("myPortal", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("myRest", config.getSetting("foo", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("myRest", config.getSetting("myPortal", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
assertEquals("myRest-pcdef", config.getSetting("myPortal-pcdef", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
- assertNull(config.getSetting("foo", PortalContainerConfig.REALM_SETTING_NAME));
- assertNull(config.getSetting("myPortal", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("my-exo-domain", config.getSetting("foo", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("my-exo-domain", config.getSetting("myPortal", PortalContainerConfig.REALM_SETTING_NAME));
assertEquals("my-exo-domain-pcdef", config.getSetting("myPortal-pcdef", PortalContainerConfig.REALM_SETTING_NAME));
+ // With internal settings and default portal definition
+ rootContainer =
+ createRootContainer("portal-container-config-with-default-values-and-with-settings-with-default-portal-def.xml");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertNull(config.getSetting("foo", "foo"));
+ assertNull(config.getSetting("myPortal", "foo"));
+ assertEquals("value", config.getSetting("myPortal-pcdef", "foo"));
+ assertEquals("value", config.getSetting("foo", "foo2"));
+ assertEquals("value", config.getSetting("myPortal", "foo2"));
+ assertEquals("value", config.getSetting("myPortal-pcdef", "foo2"));
+ assertNull(config.getSetting("foo", "foo3"));
+ assertNull(config.getSetting("myPortal", "foo3"));
+ assertNull(config.getSetting("myPortal-pcdef", "foo3"));
+ assertEquals("myPortal-dpcdef", config.getSetting("foo", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myPortal-dpcdef", config
+ .getSetting("myPortal", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myPortal-pcdef", config.getSetting("myPortal-pcdef",
+ PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myRest-dpcdef", config.getSetting("foo", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("myRest-dpcdef", config.getSetting("myPortal", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("myRest-pcdef", config.getSetting("myPortal-pcdef", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("my-exo-domain-dpcdef", config.getSetting("foo", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("my-exo-domain-dpcdef", config.getSetting("myPortal", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("my-exo-domain-pcdef", config.getSetting("myPortal-pcdef", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("value0", config.getSetting("foo", "string"));
+ assertEquals(new Integer(100), config.getSetting("foo", "int"));
+ assertEquals(new Long(100), config.getSetting("foo", "long"));
+ assertEquals(new Double(100), config.getSetting("foo", "double"));
+ assertEquals(new Boolean(false), config.getSetting("foo", "boolean"));
+ assertEquals("value0", config.getSetting("myPortal", "string"));
+ assertEquals(new Integer(100), config.getSetting("myPortal", "int"));
+ assertEquals(new Long(100), config.getSetting("myPortal", "long"));
+ assertEquals(new Double(100), config.getSetting("myPortal", "double"));
+ assertEquals(new Boolean(false), config.getSetting("myPortal", "boolean"));
+ assertEquals("value", config.getSetting("myPortal-pcdef", "string"));
+ assertEquals(new Integer(10), config.getSetting("myPortal-pcdef", "int"));
+ assertEquals(new Long(10), config.getSetting("myPortal-pcdef", "long"));
+ assertEquals(new Double(10), config.getSetting("myPortal-pcdef", "double"));
+ assertEquals(new Boolean(true), config.getSetting("myPortal-pcdef", "boolean"));
+
// With external settings
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-external-settings.xml");
config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
@@ -278,27 +503,99 @@
assertEquals("20", config.getSetting("myPortal-pcdef", "long"));
assertEquals("20", config.getSetting("myPortal-pcdef", "double"));
assertEquals("false", config.getSetting("myPortal-pcdef", "boolean"));
- assertEquals("myPortal-pcdef-myRest-pcdef-my-exo-domain-pcdef-value-new value", config.getSetting("myPortal-pcdef", "complex-value"));
- assertNull(config.getSetting("foo", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
- assertNull(config.getSetting("myPortal", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myPortal-pcdef-myRest-pcdef-my-exo-domain-pcdef-value-new value", config.getSetting(
+ "myPortal-pcdef", "complex-value"));
+ assertEquals("myPortal", config.getSetting("foo", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myPortal", config.getSetting("myPortal", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
assertEquals("myPortal-pcdef", config.getSetting("myPortal-pcdef",
PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
- assertNull(config.getSetting("foo", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
- assertNull(config.getSetting("myPortal", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("myRest", config.getSetting("foo", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("myRest", config.getSetting("myPortal", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
assertEquals("myRest-pcdef", config.getSetting("myPortal-pcdef", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
- assertNull(config.getSetting("foo", PortalContainerConfig.REALM_SETTING_NAME));
- assertNull(config.getSetting("myPortal", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("my-exo-domain", config.getSetting("foo", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("my-exo-domain", config.getSetting("myPortal", PortalContainerConfig.REALM_SETTING_NAME));
assertEquals("my-exo-domain-pcdef", config.getSetting("myPortal-pcdef", PortalContainerConfig.REALM_SETTING_NAME));
- // With external settings in exo-conf directory
- String path = TestPortalContainerConfig.class.getResource("portal-container-config-with-default-values-and-with-external-settings2.xml").getPath();
+ // Simple usecase from gatein
+ rootContainer = createRootContainer("sample-gtn-configuration.xml");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertEquals("../gatein/data", config.getSetting("portal", "gatein.data.dir"));
+ assertEquals("../gatein/data/db", config.getSetting("portal", "gatein.db.data.dir"));
+ assertEquals("jdbc:hsqldb:file:../gatein/data/db/data/jdbcjcr_portal", config.getSetting("portal", "gatein.jcr.datasource.url"));
+
+ // With external settings, with several portal container definitions and with
+ // default portal container definition
+ rootContainer =
+ createRootContainer("portal-container-config-with-default-values-and-with-external-settings-with-default-portal-def.xml");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertEquals("value0", config.getSetting("foo", "foo"));
+ assertEquals("value0", config.getSetting("myPortal", "foo"));
+ assertEquals("value0", config.getSetting("myPortal0", "foo"));
+ assertEquals("value0", config.getSetting("myPortal-pcdef", "foo"));
+ assertEquals("value0", config.getSetting("myPortal2", "foo"));
+ assertNull(config.getSetting("foo", "foo2"));
+ assertNull(config.getSetting("myPortal", "foo2"));
+ assertNull(config.getSetting("myPortal0", "foo2"));
+ assertEquals("value", config.getSetting("myPortal-pcdef", "foo2"));
+ assertNull(config.getSetting("myPortal2", "foo2"));
+ assertEquals("new value0", config.getSetting("foo", "string"));
+ assertEquals("200", config.getSetting("foo", "int"));
+ assertEquals("200", config.getSetting("foo", "long"));
+ assertEquals("200", config.getSetting("foo", "double"));
+ assertEquals("true", config.getSetting("foo", "boolean"));
+ assertEquals("myPortal-myRest-my-exo-domain-value0-new value0", config.getSetting("foo", "complex-value2"));
+ assertEquals("new value0", config.getSetting("myPortal", "string"));
+ assertEquals("200", config.getSetting("myPortal", "int"));
+ assertEquals("200", config.getSetting("myPortal", "long"));
+ assertEquals("200", config.getSetting("myPortal", "double"));
+ assertEquals("true", config.getSetting("myPortal", "boolean"));
+ assertEquals("myPortal-myRest-my-exo-domain-value0-new value0", config.getSetting("myPortal", "complex-value2"));
+ assertEquals("new value0", config.getSetting("myPortal0", "string"));
+ assertEquals("200", config.getSetting("myPortal0", "int"));
+ assertEquals("200", config.getSetting("myPortal0", "long"));
+ assertEquals("200", config.getSetting("myPortal0", "double"));
+ assertEquals("true", config.getSetting("myPortal0", "boolean"));
+ assertEquals("myPortal0-myRest0-my-exo-domain0-value0-new value0", config.getSetting("myPortal0",
+ "complex-value2"));
+ assertEquals("new value", config.getSetting("myPortal-pcdef", "string"));
+ assertEquals("20", config.getSetting("myPortal-pcdef", "int"));
+ assertEquals("20", config.getSetting("myPortal-pcdef", "long"));
+ assertEquals("20", config.getSetting("myPortal-pcdef", "double"));
+ assertEquals("false", config.getSetting("myPortal-pcdef", "boolean"));
+ assertEquals("myPortal-pcdef-myRest-pcdef-my-exo-domain-pcdef-value-new value", config.getSetting(
+ "myPortal-pcdef", "complex-value"));
+ assertEquals("myPortal-pcdef-myRest-pcdef-my-exo-domain-pcdef-value0-new value", config.getSetting(
+ "myPortal-pcdef", "complex-value2"));
+ assertEquals("new value0", config.getSetting("myPortal2", "string"));
+ assertEquals("200", config.getSetting("myPortal2", "int"));
+ assertEquals("200", config.getSetting("myPortal2", "long"));
+ assertEquals("200", config.getSetting("myPortal2", "double"));
+ assertEquals("true", config.getSetting("myPortal2", "boolean"));
+ assertEquals("myPortal2-myRest2-my-exo-domain2-value0-new value0", config.getSetting("myPortal2",
+ "complex-value2"));
+ assertEquals("myPortal", config.getSetting("foo", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myPortal", config.getSetting("myPortal", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myPortal-pcdef", config.getSetting("myPortal-pcdef",
+ PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myRest", config.getSetting("foo", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("myRest", config.getSetting("myPortal", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("myRest-pcdef", config.getSetting("myPortal-pcdef", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("my-exo-domain", config.getSetting("foo", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("my-exo-domain", config.getSetting("myPortal", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("my-exo-domain-pcdef", config.getSetting("myPortal-pcdef", PortalContainerConfig.REALM_SETTING_NAME));
+
+ String path =
+ TestPortalContainerConfig.class.getResource(
+ "portal-container-config-with-default-values-and-with-external-settings2.xml").getPath();
path = path.substring(0, path.lastIndexOf('/'));
String oldPath = System.getProperty(J2EEServerInfo.EXO_CONF_PARAM);
-
+
try
{
System.setProperty(J2EEServerInfo.EXO_CONF_PARAM, path);
- rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-external-settings2.xml");
+ // With external settings in exo-conf directory
+ rootContainer =
+ createRootContainer("portal-container-config-with-default-values-and-with-external-settings2.xml");
config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
assertNull(config.getSetting("foo", "foo"));
assertNull(config.getSetting("myPortal", "foo"));
@@ -311,17 +608,82 @@
assertEquals("22", config.getSetting("myPortal-pcdef", "long"));
assertEquals("22", config.getSetting("myPortal-pcdef", "double"));
assertEquals("true", config.getSetting("myPortal-pcdef", "boolean"));
- assertEquals("myPortal-pcdef-myRest-pcdef-my-exo-domain-pcdef-value 2-new value 2", config.getSetting("myPortal-pcdef", "complex-value"));
- assertNull(config.getSetting("foo", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
- assertNull(config.getSetting("myPortal", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myPortal-pcdef-myRest-pcdef-my-exo-domain-pcdef-value 2-new value 2", config.getSetting(
+ "myPortal-pcdef", "complex-value"));
+ assertEquals("myPortal", config.getSetting("foo", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myPortal", config.getSetting("myPortal", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
assertEquals("myPortal-pcdef", config.getSetting("myPortal-pcdef",
PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
- assertNull(config.getSetting("foo", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
- assertNull(config.getSetting("myPortal", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("myRest", config.getSetting("foo", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("myRest", config.getSetting("myPortal", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("myRest-pcdef", config.getSetting("myPortal-pcdef",
+ PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("my-exo-domain", config.getSetting("foo", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("my-exo-domain", config.getSetting("myPortal", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("my-exo-domain-pcdef", config.getSetting("myPortal-pcdef",
+ PortalContainerConfig.REALM_SETTING_NAME));
+
+ // With external settings in exo-conf directory, with several portal container definitions
+ // and with default portal container definition
+ rootContainer =
+ createRootContainer("portal-container-config-with-default-values-and-with-external-settings-with-default-portal-def2.xml");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertEquals("value01", config.getSetting("foo", "foo"));
+ assertEquals("value01", config.getSetting("myPortal", "foo"));
+ assertEquals("value01", config.getSetting("myPortal0", "foo"));
+ assertEquals("value01", config.getSetting("myPortal-pcdef", "foo"));
+ assertEquals("value01", config.getSetting("myPortal2", "foo"));
+ assertNull(config.getSetting("foo", "foo2"));
+ assertNull(config.getSetting("myPortal", "foo2"));
+ assertNull(config.getSetting("myPortal0", "foo2"));
+ assertEquals("value 2", config.getSetting("myPortal-pcdef", "foo2"));
+ assertNull(config.getSetting("myPortal2", "foo2"));
+ assertEquals("new value01", config.getSetting("foo", "string"));
+ assertEquals("2001", config.getSetting("foo", "int"));
+ assertEquals("2001", config.getSetting("foo", "long"));
+ assertEquals("2001", config.getSetting("foo", "double"));
+ assertEquals("false", config.getSetting("foo", "boolean"));
+ assertEquals("myPortal-myRest-my-exo-domain-value01-new value01", config.getSetting("foo", "complex-value2"));
+ assertEquals("new value01", config.getSetting("myPortal", "string"));
+ assertEquals("2001", config.getSetting("myPortal", "int"));
+ assertEquals("2001", config.getSetting("myPortal", "long"));
+ assertEquals("2001", config.getSetting("myPortal", "double"));
+ assertEquals("false", config.getSetting("myPortal", "boolean"));
+ assertEquals("myPortal-myRest-my-exo-domain-value01-new value01", config.getSetting("myPortal", "complex-value2"));
+ assertEquals("new value01", config.getSetting("myPortal0", "string"));
+ assertEquals("2001", config.getSetting("myPortal0", "int"));
+ assertEquals("2001", config.getSetting("myPortal0", "long"));
+ assertEquals("2001", config.getSetting("myPortal0", "double"));
+ assertEquals("false", config.getSetting("myPortal0", "boolean"));
+ assertEquals("myPortal0-myRest0-my-exo-domain0-value01-new value01", config.getSetting("myPortal0",
+ "complex-value2"));
+ assertEquals("new value 2", config.getSetting("myPortal-pcdef", "string"));
+ assertEquals("22", config.getSetting("myPortal-pcdef", "int"));
+ assertEquals("22", config.getSetting("myPortal-pcdef", "long"));
+ assertEquals("22", config.getSetting("myPortal-pcdef", "double"));
+ assertEquals("true", config.getSetting("myPortal-pcdef", "boolean"));
+ assertEquals("myPortal-pcdef-myRest-pcdef-my-exo-domain-pcdef-value 2-new value 2", config.getSetting(
+ "myPortal-pcdef", "complex-value"));
+ assertEquals("myPortal-pcdef-myRest-pcdef-my-exo-domain-pcdef-value01-new value 2", config.getSetting(
+ "myPortal-pcdef", "complex-value2"));
+ assertEquals("new value01", config.getSetting("myPortal2", "string"));
+ assertEquals("2001", config.getSetting("myPortal2", "int"));
+ assertEquals("2001", config.getSetting("myPortal2", "long"));
+ assertEquals("2001", config.getSetting("myPortal2", "double"));
+ assertEquals("false", config.getSetting("myPortal2", "boolean"));
+ assertEquals("myPortal2-myRest2-my-exo-domain2-value01-new value01", config.getSetting("myPortal2",
+ "complex-value2"));
+ assertEquals("myPortal", config.getSetting("foo", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myPortal", config.getSetting("myPortal", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myPortal-pcdef", config.getSetting("myPortal-pcdef",
+ PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myRest", config.getSetting("foo", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("myRest", config.getSetting("myPortal", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
assertEquals("myRest-pcdef", config.getSetting("myPortal-pcdef", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
- assertNull(config.getSetting("foo", PortalContainerConfig.REALM_SETTING_NAME));
- assertNull(config.getSetting("myPortal", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("my-exo-domain", config.getSetting("foo", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("my-exo-domain", config.getSetting("myPortal", PortalContainerConfig.REALM_SETTING_NAME));
assertEquals("my-exo-domain-pcdef", config.getSetting("myPortal-pcdef", PortalContainerConfig.REALM_SETTING_NAME));
+
}
finally
{
@@ -334,7 +696,7 @@
System.setProperty(J2EEServerInfo.EXO_CONF_PARAM, oldPath);
}
}
-
+
// With both settings internal and external
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-both-settings.xml");
config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
@@ -349,17 +711,98 @@
assertEquals(new Long(20), config.getSetting("myPortal-pcdef", "long"));
assertEquals(new Double(20), config.getSetting("myPortal-pcdef", "double"));
assertEquals(new Boolean(false), config.getSetting("myPortal-pcdef", "boolean"));
- assertNull(config.getSetting("foo", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
- assertNull(config.getSetting("myPortal", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myPortal", config.getSetting("foo", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myPortal", config.getSetting("myPortal", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
assertEquals("myPortal-pcdef", config.getSetting("myPortal-pcdef",
PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
- assertNull(config.getSetting("foo", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
- assertNull(config.getSetting("myPortal", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("myRest", config.getSetting("foo", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("myRest", config.getSetting("myPortal", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
assertEquals("myRest-pcdef", config.getSetting("myPortal-pcdef", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
- assertNull(config.getSetting("foo", PortalContainerConfig.REALM_SETTING_NAME));
- assertNull(config.getSetting("myPortal", PortalContainerConfig.REALM_SETTING_NAME));
- assertEquals("my-exo-domain-pcdef", config.getSetting("myPortal-pcdef", PortalContainerConfig.REALM_SETTING_NAME));
-
+ assertEquals("my-exo-domain", config.getSetting("foo", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("my-exo-domain", config.getSetting("myPortal", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("my-exo-domain-pcdef", config.getSetting("myPortal-pcdef", PortalContainerConfig.REALM_SETTING_NAME));
+
+ try
+ {
+ System.setProperty("TestPortalContainerConfig-string", "system value");
+ System.setProperty("TestPortalContainerConfig-int", "50");
+ // With both settings internal and external and default portal container definition
+ rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-both-settings-with-default-portal-def.xml");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertEquals("value0", config.getSetting("foo", "foo"));
+ assertEquals("value0", config.getSetting("myPortal", "foo"));
+ assertEquals("value0", config.getSetting("myPortal-pcdef", "foo"));
+ assertEquals("value", config.getSetting("foo", "foo2"));
+ assertEquals("value", config.getSetting("myPortal", "foo2"));
+ assertEquals("value", config.getSetting("myPortal-pcdef", "foo2"));
+ assertNull(config.getSetting("foo", "foo3"));
+ assertNull(config.getSetting("myPortal", "foo3"));
+ assertEquals("value", config.getSetting("myPortal-pcdef", "foo3"));
+ assertEquals("-${foo3}-", config.getSetting("foo", "complex-value3"));
+ assertEquals("-${foo3}-", config.getSetting("myPortal", "complex-value3"));
+ assertEquals("-value-", config.getSetting("myPortal-pcdef", "complex-value3"));
+ assertNull(config.getSetting("foo", "complex-value4"));
+ assertNull(config.getSetting("myPortal", "complex-value4"));
+ assertEquals("-value-", config.getSetting("myPortal-pcdef", "complex-value4"));
+ assertEquals("-value-", config.getSetting("foo", "complex-value5"));
+ assertEquals("-value-", config.getSetting("myPortal", "complex-value5"));
+ assertEquals("-value-", config.getSetting("myPortal-pcdef", "complex-value5"));
+ assertNull(config.getSetting("foo", "complex-value6"));
+ assertNull(config.getSetting("myPortal", "complex-value6"));
+ assertEquals("-value-", config.getSetting("myPortal-pcdef", "complex-value6"));
+ assertNull(config.getSetting("foo", "complex-value7"));
+ assertNull(config.getSetting("myPortal", "complex-value7"));
+ assertEquals("-value-", config.getSetting("myPortal-pcdef", "complex-value7"));
+ assertEquals("-${foo6}-", config.getSetting("foo", "complex-value8"));
+ assertEquals("-${foo6}-", config.getSetting("myPortal", "complex-value8"));
+ assertEquals("-value-", config.getSetting("myPortal-pcdef", "complex-value8"));
+ assertEquals("-property_value_1-", config.getSetting("foo", "complex-value9"));
+ assertEquals("-property_value_1-", config.getSetting("myPortal", "complex-value9"));
+ assertEquals("-property_value_1-", config.getSetting("myPortal-pcdef", "complex-value9"));
+ assertEquals("-system value-", config.getSetting("foo", "cpv1"));
+ assertEquals("-system value-", config.getSetting("myPortal", "cpv1"));
+ assertEquals("-system value-", config.getSetting("myPortal-pcdef", "cpv1"));
+ assertEquals(new Integer(50), config.getSetting("foo", "cpv2"));
+ assertEquals(new Integer(50), config.getSetting("myPortal", "cpv2"));
+ assertEquals(new Integer(50), config.getSetting("myPortal-pcdef", "cpv2"));
+ assertEquals("-property_value_1-", config.getSetting("foo", "cpv3"));
+ assertEquals("-property_value_1-", config.getSetting("myPortal", "cpv3"));
+ assertEquals("-property_value_1-", config.getSetting("myPortal-pcdef", "cpv3"));
+ assertEquals("new value0", config.getSetting("foo", "string"));
+ assertEquals(new Integer(200), config.getSetting("foo", "int"));
+ assertEquals(new Integer(60), config.getSetting("foo", "int2"));
+ assertEquals(new Long(200), config.getSetting("foo", "long"));
+ assertEquals(new Double(200), config.getSetting("foo", "double"));
+ assertEquals(new Boolean(true), config.getSetting("foo", "boolean"));
+ assertEquals("new value0", config.getSetting("myPortal", "string"));
+ assertEquals(new Integer(200), config.getSetting("myPortal", "int"));
+ assertEquals(new Integer(60), config.getSetting("myPortal", "int2"));
+ assertEquals(new Long(200), config.getSetting("myPortal", "long"));
+ assertEquals(new Double(200), config.getSetting("myPortal", "double"));
+ assertEquals(new Boolean(true), config.getSetting("myPortal", "boolean"));
+ assertEquals("new value", config.getSetting("myPortal-pcdef", "string"));
+ assertEquals(new Integer(20), config.getSetting("myPortal-pcdef", "int"));
+ assertEquals(new Integer(60), config.getSetting("myPortal-pcdef", "int2"));
+ assertEquals(new Long(20), config.getSetting("myPortal-pcdef", "long"));
+ assertEquals(new Double(20), config.getSetting("myPortal-pcdef", "double"));
+ assertEquals(new Boolean(false), config.getSetting("myPortal-pcdef", "boolean"));
+ assertEquals("myPortal", config.getSetting("foo", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myPortal", config.getSetting("myPortal", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myPortal-pcdef", config.getSetting("myPortal-pcdef",
+ PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myRest", config.getSetting("foo", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("myRest", config.getSetting("myPortal", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("myRest-pcdef", config.getSetting("myPortal-pcdef", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("my-exo-domain", config.getSetting("foo", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("my-exo-domain", config.getSetting("myPortal", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("my-exo-domain-pcdef", config.getSetting("myPortal-pcdef", PortalContainerConfig.REALM_SETTING_NAME));
+ }
+ finally
+ {
+ System.getProperties().remove("TestPortalContainerConfig-string");
+ System.getProperties().remove("TestPortalContainerConfig-int");
+ }
+
// With both settings internal and external, and with invalid values
rootContainer = createRootContainer("portal-container-config-with-invalid-values.xml");
config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
@@ -368,15 +811,15 @@
assertEquals("", config.getSetting("myPortal-pcdef", "fake-value-4-string"));
assertEquals(new Integer(10), config.getSetting("myPortal-pcdef", "fake-value-4-int"));
assertEquals(new Integer(10), config.getSetting("myPortal-pcdef", "invalid-value-4-int"));
- assertNull(config.getSetting("foo", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
- assertNull(config.getSetting("myPortal", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myPortal", config.getSetting("foo", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
+ assertEquals("myPortal", config.getSetting("myPortal", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
assertEquals("myPortal-pcdef", config.getSetting("myPortal-pcdef",
PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
- assertNull(config.getSetting("foo", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
- assertNull(config.getSetting("myPortal", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("myRest", config.getSetting("foo", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
+ assertEquals("myRest", config.getSetting("myPortal", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
assertEquals("myRest", config.getSetting("myPortal-pcdef", PortalContainerConfig.REST_CONTEXT_SETTING_NAME));
- assertNull(config.getSetting("foo", PortalContainerConfig.REALM_SETTING_NAME));
- assertNull(config.getSetting("myPortal", PortalContainerConfig.REALM_SETTING_NAME));
- assertEquals("my-exo-domain", config.getSetting("myPortal-pcdef", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("my-exo-domain", config.getSetting("foo", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("my-exo-domain", config.getSetting("myPortal", PortalContainerConfig.REALM_SETTING_NAME));
+ assertEquals("my-exo-domain", config.getSetting("myPortal-pcdef", PortalContainerConfig.REALM_SETTING_NAME));
}
}
Modified: kernel/tags/2.2.0-GA/exo.kernel.container/src/test/java/org/exoplatform/xml/test/TestConfigurationXML.java
===================================================================
--- kernel/tags/2.2.0-GA/exo.kernel.container/src/test/java/org/exoplatform/xml/test/TestConfigurationXML.java 2010-03-11 09:32:07 UTC (rev 2051)
+++ kernel/tags/2.2.0-GA/exo.kernel.container/src/test/java/org/exoplatform/xml/test/TestConfigurationXML.java 2010-03-11 11:49:03 UTC (rev 2052)
@@ -21,24 +21,134 @@
import junit.framework.TestCase;
import org.exoplatform.container.xml.Component;
+import org.exoplatform.container.xml.ComponentLifecyclePlugin;
+import org.exoplatform.container.xml.ComponentPlugin;
import org.exoplatform.container.xml.Configuration;
+import org.exoplatform.container.xml.ContainerLifecyclePlugin;
+import org.exoplatform.container.xml.ExternalComponentPlugins;
import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.container.xml.ManageableComponents;
import org.exoplatform.container.xml.ObjectParameter;
import org.exoplatform.container.xml.PropertiesParam;
import org.exoplatform.container.xml.ValueParam;
+import org.exoplatform.container.xml.ValuesParam;
import org.exoplatform.xml.object.XMLObject;
import org.jibx.runtime.BindingDirectory;
import org.jibx.runtime.IBindingFactory;
import org.jibx.runtime.IUnmarshallingContext;
import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
*/
public class TestConfigurationXML extends TestCase
{
+
+ @SuppressWarnings("unchecked")
+ public void testTrimValue() throws Exception
+ {
+ InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("test-trim-value.xml");
+ assertNotNull(is);
+ try
+ {
+ IBindingFactory bfact = BindingDirectory.getFactory(XMLObject.class);
+ IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
+ Configuration conf =
+ (Configuration)uctx.unmarshalDocument(is, null);
+ assertNotNull(conf);
+ Iterator it = conf.getContainerLifecyclePluginIterator();
+ assertNotNull(it);
+ assertTrue(it.hasNext());
+ ContainerLifecyclePlugin conlp = (ContainerLifecyclePlugin)it.next();
+ assertEquals("container-lifecycle-plugin-type", conlp.getType());
+ assertNotNull(conlp.getInitParams());
+ assertEquals("container-lifecycle-plugin-value-param-value", (conlp.getInitParams().getValueParam("container-lifecycle-plugin-value-param-name")).getValue());
+ it = conf.getComponentLifecyclePluginIterator();
+ assertNotNull(it);
+ assertTrue(it.hasNext());
+ ComponentLifecyclePlugin comlp = (ComponentLifecyclePlugin)it.next();
+ assertEquals("component-lifecycle-plugin", comlp.getType());
+ ManageableComponents mc = comlp.getManageableComponents();
+ assertNotNull(mc);
+ assertEquals("manageable-components-component-type", mc.getComponentsType().get(0));
+ ValuesParam valuesParam = comlp.getInitParams().getValuesParam("component-lifecycle-plugin-values-param-name");
+ assertNotNull(valuesParam);
+ assertNotNull(valuesParam.getValues());
+ assertTrue(valuesParam.getValues().contains("component-lifecycle-plugin-values-param-value1"));
+ assertTrue(valuesParam.getValues().contains("component-lifecycle-plugin-values-param-value2"));
+ Component c = conf.getComponent("component-key1");
+ assertNotNull(c);
+ assertEquals("component-type1", c.getType());
+ PropertiesParam propertiesParam = c.getInitParams().getPropertiesParam("component-key1-properties-param-name");
+ assertNotNull(propertiesParam);
+ assertEquals("component-key1-properties-param-prop-value", propertiesParam.getProperty("component-key1-properties-param-prop-name"));
+ c = conf.getComponent("component-type2");
+ assertNotNull(c);
+ ObjectParameter objectParameter = c.getInitParams().getObjectParam("component-key2-object-param-name");
+ assertNotNull(objectParameter);
+ MyObject o = (MyObject)objectParameter.getObject();
+ assertNotNull(o);
+ assertEquals("string-value", o.field1);
+ assertEquals(1, o.field2);
+ assertEquals(1l, o.field3);
+ assertEquals(1d, o.field4);
+ assertEquals(true, o.field5);
+ assertNotNull(o.field6);
+ assertEquals("entry-value", o.field6.get("entry-name"));
+ assertNotNull(o.field7);
+ assertTrue(o.field7.contains("string-value"));
+ assertNotNull(o.field8);
+ assertEquals(1, o.field8[0]);
+ List list = c.getComponentPlugins();
+ assertNotNull(list);
+ assertFalse(list.isEmpty());
+ ComponentPlugin cp = (ComponentPlugin)list.get(0);
+ assertEquals("component-plugins-name", cp.getName());
+ assertEquals("set-method-name", cp.getSetMethod());
+ assertEquals("component-plugins-type", cp.getType());
+ assertEquals("1", cp.getPriority());
+ it = conf.getExternalComponentPluginsIterator();
+ assertNotNull(it);
+ assertTrue(it.hasNext());
+ ExternalComponentPlugins ecps = (ExternalComponentPlugins)it.next();
+ assertEquals("target-component-name", ecps.getTargetComponent());
+ list = ecps.getComponentPlugins();
+ assertNotNull(list);
+ assertFalse(list.isEmpty());
+ cp = (ComponentPlugin)list.get(0);
+ assertEquals("component-plugins-name", cp.getName());
+ assertEquals("set-method-name", cp.getSetMethod());
+ assertEquals("component-plugins-type", cp.getType());
+ assertEquals("1", cp.getPriority());
+ list = conf.getImports();
+ assertNotNull(list);
+ assertFalse(list.isEmpty());
+ assertEquals("import-value", list.get(0));
+ list = conf.getRemoveConfiguration();
+ assertNotNull(list);
+ assertFalse(list.isEmpty());
+ assertEquals("remove-configuration-value", list.get(0));
+ }
+ finally
+ {
+ try
+ {
+ is.close();
+ }
+ catch (Exception e)
+ {
+ // ignore me
+ }
+ }
+ }
+
public void testSystemPropertyResolving() throws Exception
{
@@ -118,5 +228,17 @@
assertNotNull(paramName);
assertEquals(expectedValue, valueParam.getValue());
}
+
+ public static class MyObject
+ {
+ public String field1;
+ public int field2;
+ public long field3;
+ public double field4;
+ public boolean field5;
+ public Map field6;
+ public Collection field7;
+ public int[] field8;
+ }
}
\ No newline at end of file
Copied: kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/default-settings.properties (from rev 2010, kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/default-settings.properties)
===================================================================
--- kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/default-settings.properties (rev 0)
+++ kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/default-settings.properties 2010-03-11 11:49:03 UTC (rev 2052)
@@ -0,0 +1,13 @@
+foo=value0
+foo4=value
+string=new value0
+int=200
+int2=${property_Int}
+long=200
+double=200
+boolean=true
+complex-value2=${name}-${rest}-${realm}-${foo}-${string}
+complex-value3=-${foo3}-
+complex-value5=-${foo5}-
+complex-value8=-${foo6}-
+complex-value9=-${property_String}-
\ No newline at end of file
Copied: kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal/default-settings.properties (from rev 2010, kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal/default-settings.properties)
===================================================================
--- kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal/default-settings.properties (rev 0)
+++ kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal/default-settings.properties 2010-03-11 11:49:03 UTC (rev 2052)
@@ -0,0 +1,7 @@
+foo=value01
+string=new value01
+int=2001
+long=2001
+double=2001
+boolean=false
+complex-value2=${name}-${rest}-${realm}-${foo}-${string}
\ No newline at end of file
Copied: kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-both-settings-with-default-portal-def.xml (from rev 2010, kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-both-settings-with-default-portal-def.xml)
===================================================================
--- kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-both-settings-with-default-portal-def.xml (rev 0)
+++ kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-both-settings-with-default-portal-def.xml 2010-03-11 11:49:03 UTC (rev 2052)
@@ -0,0 +1,244 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+ <!--
+
+ Copyright (C) 2009 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.
+ -->
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"
+ xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd">
+ <component>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <type>org.exoplatform.container.definition.PortalContainerConfig</type>
+ <init-params>
+ <!-- The name of the default portal container -->
+ <value-param>
+ <name>default.portal.container</name>
+ <value>myPortal</value>
+ </value-param>
+ <!-- The name of the default rest ServletContext -->
+ <value-param>
+ <name>default.rest.context</name>
+ <value>myRest</value>
+ </value-param>
+ <!-- The name of the default realm -->
+ <value-param>
+ <name>default.realm.name</name>
+ <value>my-exo-domain</value>
+ </value-param>
+ <!-- The default portal container definition -->
+ <!-- It cans be used to avoid duplicating configuration -->
+ <object-param>
+ <name>default.portal.definition</name>
+ <object type="org.exoplatform.container.definition.PortalContainerDefinition">
+ <!-- A map of settings tied to the default portal container -->
+ <field name="settings">
+ <map type="java.util.HashMap">
+ <entry>
+ <key>
+ <string>cpv1</string>
+ </key>
+ <value>
+ <string>-${TestPortalContainerConfig-string}-</string>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>cpv2</string>
+ </key>
+ <value>
+ <int>${TestPortalContainerConfig-int}</int>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>cpv3</string>
+ </key>
+ <value>
+ <string>-${property_String}-</string>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>foo2</string>
+ </key>
+ <value>
+ <string>value</string>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>foo5</string>
+ </key>
+ <value>
+ <string>value</string>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>string</string>
+ </key>
+ <value>
+ <string>value0</string>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>int</string>
+ </key>
+ <value>
+ <int>100</int>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>int2</string>
+ </key>
+ <value>
+ <int>100</int>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>long</string>
+ </key>
+ <value>
+ <long>100</long>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>double</string>
+ </key>
+ <value>
+ <double>100</double>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>boolean</string>
+ </key>
+ <value>
+ <boolean>false</boolean>
+ </value>
+ </entry>
+ </map>
+ </field>
+ <!-- The path to the external properties file -->
+ <field name="externalSettingsPath">
+ <string>classpath:/org/exoplatform/container/definition/default-settings.properties</string>
+ </field>
+ </object>
+ </object-param>
+ </init-params>
+ </component>
+ <component>
+ <key>PropertyManagerConfigurator</key>
+ <type>org.exoplatform.container.PropertyConfigurator</type>
+ <init-params>
+ <properties-param>
+ <name>properties</name>
+ <property name="property_String" value="property_value_1" />
+ <property name="property_Int" value="60" />
+ </properties-param>
+ </init-params>
+ </component>
+ <external-component-plugins>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
+ <component-plugin>
+ <!-- The name of the plugin -->
+ <name>Add PortalContainer Definitions</name>
+ <!-- The name of the method to call on the PortalContainerConfig in order to register the PortalContainerDefinitions -->
+ <set-method>registerPlugin</set-method>
+ <!-- The full qualified name of the PortalContainerDefinitionPlugin -->
+ <type>org.exoplatform.container.definition.PortalContainerDefinitionPlugin</type>
+ <init-params>
+ <object-param>
+ <name>portal</name>
+ <object type="org.exoplatform.container.definition.PortalContainerDefinition">
+ <!-- The name of the portal container -->
+ <field name="name">
+ <string>myPortal-pcdef</string>
+ </field>
+ <!-- The name of the context name of the rest web application -->
+ <field name="restContextName">
+ <string>myRest-pcdef</string>
+ </field>
+ <!-- The name of the realm -->
+ <field name="realmName">
+ <string>my-exo-domain-pcdef</string>
+ </field>
+ <!-- A map of settings tied to the portal container -->
+ <field name="settings">
+ <map type="java.util.HashMap">
+ <entry>
+ <key>
+ <string>foo</string>
+ </key>
+ <value>
+ <string>value</string>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>foo6</string>
+ </key>
+ <value>
+ <string>value</string>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>string</string>
+ </key>
+ <value>
+ <string>value</string>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>int</string>
+ </key>
+ <value>
+ <int>10</int>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>long</string>
+ </key>
+ <value>
+ <long>10</long>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>double</string>
+ </key>
+ <value>
+ <double>10</double>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>boolean</string>
+ </key>
+ <value>
+ <boolean>true</boolean>
+ </value>
+ </entry>
+ </map>
+ </field>
+ <!-- The path to the external properties file -->
+ <field name="externalSettingsPath">
+ <string>classpath:/org/exoplatform/container/definition/settings.properties</string>
+ </field>
+ </object>
+ </object-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+</configuration>
\ No newline at end of file
Copied: kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-default-portal-def.xml (from rev 2010, kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-default-portal-def.xml)
===================================================================
--- kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-default-portal-def.xml (rev 0)
+++ kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-default-portal-def.xml 2010-03-11 11:49:03 UTC (rev 2052)
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+ <!--
+
+ Copyright (C) 2009 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.
+ -->
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"
+ xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd">
+ <component>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <type>org.exoplatform.container.definition.PortalContainerConfig</type>
+ <init-params>
+ <!-- The name of the default portal container -->
+ <value-param>
+ <name>default.portal.container</name>
+ <value>myPortal</value>
+ </value-param>
+ <!-- The name of the default rest ServletContext -->
+ <value-param>
+ <name>default.rest.context</name>
+ <value>myRest</value>
+ </value-param>
+ <!-- The name of the default realm -->
+ <value-param>
+ <name>default.realm.name</name>
+ <value>my-exo-domain</value>
+ </value-param>
+ <!-- The default portal container definition -->
+ <!-- It cans be used to avoid duplicating configuration -->
+ <object-param>
+ <name>default.portal.definition</name>
+ <object type="org.exoplatform.container.definition.PortalContainerDefinition">
+ <!-- The name of the portal container -->
+ <!-- If this value is not null, it will replace the value defined
+ by the value-param "default.portal.container" -->
+ <field name="name">
+ <string>myPortal-dpcdef</string>
+ </field>
+ <!-- The name of the context name of the rest web application -->
+ <!-- If this value is not null, it will replace the value defined
+ by the value-param "default.rest.context" -->
+ <field name="restContextName">
+ <string>myRest-dpcdef</string>
+ </field>
+ <!-- The name of the realm -->
+ <!-- If this value is not null, it will replace the value defined
+ by the value-param "default.realm.name" -->
+ <field name="realmName">
+ <string>my-exo-domain-dpcdef</string>
+ </field>
+ <!-- A map of settings tied to the default portal container -->
+ <field name="settings">
+ <map type="java.util.HashMap">
+ <entry>
+ <key>
+ <string>string</string>
+ </key>
+ <value>
+ <string>value0</string>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>int</string>
+ </key>
+ <value>
+ <int>100</int>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>long</string>
+ </key>
+ <value>
+ <long>100</long>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>double</string>
+ </key>
+ <value>
+ <double>100</double>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>boolean</string>
+ </key>
+ <value>
+ <boolean>false</boolean>
+ </value>
+ </entry>
+ </map>
+ </field>
+ </object>
+ </object-param>
+ </init-params>
+ </component>
+</configuration>
\ No newline at end of file
Copied: kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-empty-default-portal-def.xml (from rev 2010, kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-empty-default-portal-def.xml)
===================================================================
--- kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-empty-default-portal-def.xml (rev 0)
+++ kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-empty-default-portal-def.xml 2010-03-11 11:49:03 UTC (rev 2052)
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+ <!--
+
+ Copyright (C) 2009 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.
+ -->
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"
+ xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd">
+ <component>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <type>org.exoplatform.container.definition.PortalContainerConfig</type>
+ <init-params>
+ <!-- The name of the default portal container -->
+ <value-param>
+ <name>default.portal.container</name>
+ <value>myPortal</value>
+ </value-param>
+ <!-- The name of the default rest ServletContext -->
+ <value-param>
+ <name>default.rest.context</name>
+ <value>myRest</value>
+ </value-param>
+ <!-- The name of the default realm -->
+ <value-param>
+ <name>default.realm.name</name>
+ <value>my-exo-domain</value>
+ </value-param>
+ <!-- The default portal container definition -->
+ <!-- It cans be used to avoid duplicating configuration -->
+ <object-param>
+ <name>default.portal.definition</name>
+ <object type="org.exoplatform.container.definition.PortalContainerDefinition">
+ </object>
+ </object-param>
+ </init-params>
+ </component>
+</configuration>
\ No newline at end of file
Copied: kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-external-settings-with-default-portal-def.xml (from rev 2010, kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-external-settings-with-default-portal-def.xml)
===================================================================
--- kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-external-settings-with-default-portal-def.xml (rev 0)
+++ kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-external-settings-with-default-portal-def.xml 2010-03-11 11:49:03 UTC (rev 2052)
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+ <!--
+
+ Copyright (C) 2009 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.
+ -->
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"
+ xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd">
+ <component>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <type>org.exoplatform.container.definition.PortalContainerConfig</type>
+ <init-params>
+ <!-- The name of the default portal container -->
+ <value-param>
+ <name>default.portal.container</name>
+ <value>myPortal</value>
+ </value-param>
+ <!-- The name of the default rest ServletContext -->
+ <value-param>
+ <name>default.rest.context</name>
+ <value>myRest</value>
+ </value-param>
+ <!-- The name of the default realm -->
+ <value-param>
+ <name>default.realm.name</name>
+ <value>my-exo-domain</value>
+ </value-param>
+ <!-- The default portal container definition -->
+ <!-- It cans be used to avoid duplicating configuration -->
+ <object-param>
+ <name>default.portal.definition</name>
+ <object type="org.exoplatform.container.definition.PortalContainerDefinition">
+ <!-- The path to the external properties file -->
+ <field name="externalSettingsPath">
+ <string>classpath:/org/exoplatform/container/definition/default-settings.properties</string>
+ </field>
+ </object>
+ </object-param>
+ </init-params>
+ </component>
+ <external-component-plugins>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
+ <component-plugin>
+ <!-- The name of the plugin -->
+ <name>Add PortalContainer Definitions</name>
+ <!-- The name of the method to call on the PortalContainerConfig in order to register the PortalContainerDefinitions -->
+ <set-method>registerPlugin</set-method>
+ <!-- The full qualified name of the PortalContainerDefinitionPlugin -->
+ <type>org.exoplatform.container.definition.PortalContainerDefinitionPlugin</type>
+ <init-params>
+ <object-param>
+ <name>portal0</name>
+ <object type="org.exoplatform.container.definition.PortalContainerDefinition">
+ <!-- The name of the portal container -->
+ <field name="name">
+ <string>myPortal0</string>
+ </field>
+ <!-- The name of the context name of the rest web application -->
+ <field name="restContextName">
+ <string>myRest0</string>
+ </field>
+ <!-- The name of the realm -->
+ <field name="realmName">
+ <string>my-exo-domain0</string>
+ </field>
+ </object>
+ </object-param>
+ <object-param>
+ <name>portal</name>
+ <object type="org.exoplatform.container.definition.PortalContainerDefinition">
+ <!-- The name of the portal container -->
+ <field name="name">
+ <string>myPortal-pcdef</string>
+ </field>
+ <!-- The name of the context name of the rest web application -->
+ <field name="restContextName">
+ <string>myRest-pcdef</string>
+ </field>
+ <!-- The name of the realm -->
+ <field name="realmName">
+ <string>my-exo-domain-pcdef</string>
+ </field>
+ <!-- The path to the external properties file -->
+ <field name="externalSettingsPath">
+ <string>classpath:/org/exoplatform/container/definition/settings.properties</string>
+ </field>
+ </object>
+ </object-param>
+ <object-param>
+ <name>portal2</name>
+ <object type="org.exoplatform.container.definition.PortalContainerDefinition">
+ <!-- The name of the portal container -->
+ <field name="name">
+ <string>myPortal2</string>
+ </field>
+ <!-- The name of the context name of the rest web application -->
+ <field name="restContextName">
+ <string>myRest2</string>
+ </field>
+ <!-- The name of the realm -->
+ <field name="realmName">
+ <string>my-exo-domain2</string>
+ </field>
+ </object>
+ </object-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+</configuration>
\ No newline at end of file
Copied: kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-external-settings-with-default-portal-def2.xml (from rev 2010, kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-external-settings-with-default-portal-def2.xml)
===================================================================
--- kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-external-settings-with-default-portal-def2.xml (rev 0)
+++ kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-external-settings-with-default-portal-def2.xml 2010-03-11 11:49:03 UTC (rev 2052)
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+ <!--
+
+ Copyright (C) 2009 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.
+ -->
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"
+ xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd">
+ <component>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <type>org.exoplatform.container.definition.PortalContainerConfig</type>
+ <init-params>
+ <!-- The name of the default portal container -->
+ <value-param>
+ <name>default.portal.container</name>
+ <value>myPortal</value>
+ </value-param>
+ <!-- The name of the default rest ServletContext -->
+ <value-param>
+ <name>default.rest.context</name>
+ <value>myRest</value>
+ </value-param>
+ <!-- The name of the default realm -->
+ <value-param>
+ <name>default.realm.name</name>
+ <value>my-exo-domain</value>
+ </value-param>
+ <!-- The default portal container definition -->
+ <!-- It cans be used to avoid duplicating configuration -->
+ <object-param>
+ <name>default.portal.definition</name>
+ <object type="org.exoplatform.container.definition.PortalContainerDefinition">
+ <!-- The path to the external properties file -->
+ <field name="externalSettingsPath">
+ <string>default-settings.properties</string>
+ </field>
+ </object>
+ </object-param>
+ </init-params>
+ </component>
+ <external-component-plugins>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
+ <component-plugin>
+ <!-- The name of the plugin -->
+ <name>Add PortalContainer Definitions</name>
+ <!-- The name of the method to call on the PortalContainerConfig in order to register the PortalContainerDefinitions -->
+ <set-method>registerPlugin</set-method>
+ <!-- The full qualified name of the PortalContainerDefinitionPlugin -->
+ <type>org.exoplatform.container.definition.PortalContainerDefinitionPlugin</type>
+ <init-params>
+ <object-param>
+ <name>portal0</name>
+ <object type="org.exoplatform.container.definition.PortalContainerDefinition">
+ <!-- The name of the portal container -->
+ <field name="name">
+ <string>myPortal0</string>
+ </field>
+ <!-- The name of the context name of the rest web application -->
+ <field name="restContextName">
+ <string>myRest0</string>
+ </field>
+ <!-- The name of the realm -->
+ <field name="realmName">
+ <string>my-exo-domain0</string>
+ </field>
+ </object>
+ </object-param>
+ <object-param>
+ <name>portal</name>
+ <object type="org.exoplatform.container.definition.PortalContainerDefinition">
+ <!-- The name of the portal container -->
+ <field name="name">
+ <string>myPortal-pcdef</string>
+ </field>
+ <!-- The name of the context name of the rest web application -->
+ <field name="restContextName">
+ <string>myRest-pcdef</string>
+ </field>
+ <!-- The name of the realm -->
+ <field name="realmName">
+ <string>my-exo-domain-pcdef</string>
+ </field>
+ <!-- The path to the external properties file -->
+ <field name="externalSettingsPath">
+ <string>settings.properties</string>
+ </field>
+ </object>
+ </object-param>
+ <object-param>
+ <name>portal2</name>
+ <object type="org.exoplatform.container.definition.PortalContainerDefinition">
+ <!-- The name of the portal container -->
+ <field name="name">
+ <string>myPortal2</string>
+ </field>
+ <!-- The name of the context name of the rest web application -->
+ <field name="restContextName">
+ <string>myRest2</string>
+ </field>
+ <!-- The name of the realm -->
+ <field name="realmName">
+ <string>my-exo-domain2</string>
+ </field>
+ </object>
+ </object-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+</configuration>
\ No newline at end of file
Copied: kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def.xml (from rev 2010, kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def.xml)
===================================================================
--- kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def.xml (rev 0)
+++ kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def.xml 2010-03-11 11:49:03 UTC (rev 2052)
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+ <!--
+
+ Copyright (C) 2009 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.
+ -->
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"
+ xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd">
+ <component>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <type>org.exoplatform.container.definition.PortalContainerConfig</type>
+ <init-params>
+ <!-- The name of the default portal container -->
+ <value-param>
+ <name>default.portal.container</name>
+ <value>myPortal</value>
+ </value-param>
+ <!-- The name of the default rest ServletContext -->
+ <value-param>
+ <name>default.rest.context</name>
+ <value>myRest</value>
+ </value-param>
+ <!-- The name of the default realm -->
+ <value-param>
+ <name>default.realm.name</name>
+ <value>my-exo-domain</value>
+ </value-param>
+ <!-- The default portal container definition -->
+ <!-- It cans be used to avoid duplicating configuration -->
+ <object-param>
+ <name>default.portal.definition</name>
+ <object type="org.exoplatform.container.definition.PortalContainerDefinition">
+ <!-- The name of the portal container -->
+ <!-- If this value is not null, it will replace the value defined
+ by the value-param "default.portal.container" -->
+ <field name="name">
+ <string>myPortal-dpcdef</string>
+ </field>
+ <!-- The name of the context name of the rest web application -->
+ <!-- If this value is not null, it will replace the value defined
+ by the value-param "default.rest.context" -->
+ <field name="restContextName">
+ <string>myRest-dpcdef</string>
+ </field>
+ <!-- The name of the realm -->
+ <!-- If this value is not null, it will replace the value defined
+ by the value-param "default.realm.name" -->
+ <field name="realmName">
+ <string>my-exo-domain-dpcdef</string>
+ </field>
+ <field name="dependencies">
+ <collection type="java.util.ArrayList">
+ <value>
+ <string>fooX</string>
+ </value>
+ </collection>
+ </field>
+ </object>
+ </object-param>
+ </init-params>
+ </component>
+ <external-component-plugins>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
+ <component-plugin>
+ <!-- The name of the plugin -->
+ <name>Add PortalContainer Definitions</name>
+ <!-- The name of the method to call on the PortalContainerConfig in order to register the PortalContainerDefinitions -->
+ <set-method>registerPlugin</set-method>
+ <!-- The full qualified name of the PortalContainerDefinitionPlugin -->
+ <type>org.exoplatform.container.definition.PortalContainerDefinitionPlugin</type>
+ <init-params>
+ <object-param>
+ <name>portal</name>
+ <object type="org.exoplatform.container.definition.PortalContainerDefinition">
+ <!-- The name of the portal container -->
+ <field name="name">
+ <string>myPortal-pcdef</string>
+ </field>
+ <!-- The name of the context name of the rest web application -->
+ <field name="restContextName">
+ <string>myRest-pcdef</string>
+ </field>
+ <!-- The name of the realm -->
+ <field name="realmName">
+ <string>my-exo-domain-pcdef</string>
+ </field>
+ </object>
+ </object-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+</configuration>
\ No newline at end of file
Copied: kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def2.xml (from rev 2010, kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def2.xml)
===================================================================
--- kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def2.xml (rev 0)
+++ kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def2.xml 2010-03-11 11:49:03 UTC (rev 2052)
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+ <!--
+
+ Copyright (C) 2009 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.
+ -->
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"
+ xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd">
+ <component>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <type>org.exoplatform.container.definition.PortalContainerConfig</type>
+ <init-params>
+ <!-- The name of the default portal container -->
+ <value-param>
+ <name>default.portal.container</name>
+ <value>myPortal</value>
+ </value-param>
+ <!-- The name of the default rest ServletContext -->
+ <value-param>
+ <name>default.rest.context</name>
+ <value>myRest</value>
+ </value-param>
+ <!-- The name of the default realm -->
+ <value-param>
+ <name>default.realm.name</name>
+ <value>my-exo-domain</value>
+ </value-param>
+ <!-- The default portal container definition -->
+ <!-- It cans be used to avoid duplicating configuration -->
+ <object-param>
+ <name>default.portal.definition</name>
+ <object type="org.exoplatform.container.definition.PortalContainerDefinition">
+ <field name="dependencies">
+ <collection type="java.util.ArrayList">
+ <value>
+ <string>fooX</string>
+ </value>
+ </collection>
+ </field>
+ </object>
+ </object-param>
+ </init-params>
+ </component>
+ <external-component-plugins>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
+ <component-plugin>
+ <!-- The name of the plugin -->
+ <name>Add PortalContainer Definitions</name>
+ <!-- The name of the method to call on the PortalContainerConfig in order to register the PortalContainerDefinitions -->
+ <set-method>registerPlugin</set-method>
+ <!-- The full qualified name of the PortalContainerDefinitionPlugin -->
+ <type>org.exoplatform.container.definition.PortalContainerDefinitionPlugin</type>
+ <init-params>
+ <object-param>
+ <name>portal</name>
+ <object type="org.exoplatform.container.definition.PortalContainerDefinition">
+ <!-- The name of the portal container -->
+ <field name="name">
+ <string>myPortal-pcdef</string>
+ </field>
+ <!-- The name of the context name of the rest web application -->
+ <field name="restContextName">
+ <string>myRest-pcdef</string>
+ </field>
+ <!-- The name of the realm -->
+ <field name="realmName">
+ <string>my-exo-domain-pcdef</string>
+ </field>
+ <!-- All the dependencies of the portal container ordered by loading priority -->
+ <field name="dependencies">
+ <collection type="java.util.ArrayList">
+ <value>
+ <string>foo</string>
+ </value>
+ <value>
+ <string>foo2</string>
+ </value>
+ <value>
+ <string>foo3</string>
+ </value>
+ </collection>
+ </field>
+ </object>
+ </object-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+</configuration>
\ No newline at end of file
Copied: kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-settings-with-default-portal-def.xml (from rev 2010, kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-settings-with-default-portal-def.xml)
===================================================================
--- kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-settings-with-default-portal-def.xml (rev 0)
+++ kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-settings-with-default-portal-def.xml 2010-03-11 11:49:03 UTC (rev 2052)
@@ -0,0 +1,195 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+ <!--
+
+ Copyright (C) 2009 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.
+ -->
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"
+ xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd">
+ <component>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <type>org.exoplatform.container.definition.PortalContainerConfig</type>
+ <init-params>
+ <!-- The name of the default portal container -->
+ <value-param>
+ <name>default.portal.container</name>
+ <value>myPortal</value>
+ </value-param>
+ <!-- The name of the default rest ServletContext -->
+ <value-param>
+ <name>default.rest.context</name>
+ <value>myRest</value>
+ </value-param>
+ <!-- The name of the default realm -->
+ <value-param>
+ <name>default.realm.name</name>
+ <value>my-exo-domain</value>
+ </value-param>
+ <!-- The default portal container definition -->
+ <!-- It cans be used to avoid duplicating configuration -->
+ <object-param>
+ <name>default.portal.definition</name>
+ <object type="org.exoplatform.container.definition.PortalContainerDefinition">
+ <!-- The name of the portal container -->
+ <!-- If this value is not null, it will replace the value defined
+ by the value-param "default.portal.container" -->
+ <field name="name">
+ <string>myPortal-dpcdef</string>
+ </field>
+ <!-- The name of the context name of the rest web application -->
+ <!-- If this value is not null, it will replace the value defined
+ by the value-param "default.rest.context" -->
+ <field name="restContextName">
+ <string>myRest-dpcdef</string>
+ </field>
+ <!-- The name of the realm -->
+ <!-- If this value is not null, it will replace the value defined
+ by the value-param "default.realm.name" -->
+ <field name="realmName">
+ <string>my-exo-domain-dpcdef</string>
+ </field>
+ <!-- A map of settings tied to the default portal container -->
+ <field name="settings">
+ <map type="java.util.HashMap">
+ <entry>
+ <key>
+ <string>foo2</string>
+ </key>
+ <value>
+ <string>value</string>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>string</string>
+ </key>
+ <value>
+ <string>value0</string>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>int</string>
+ </key>
+ <value>
+ <int>100</int>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>long</string>
+ </key>
+ <value>
+ <long>100</long>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>double</string>
+ </key>
+ <value>
+ <double>100</double>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>boolean</string>
+ </key>
+ <value>
+ <boolean>false</boolean>
+ </value>
+ </entry>
+ </map>
+ </field>
+ </object>
+ </object-param>
+ </init-params>
+ </component>
+ <external-component-plugins>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
+ <component-plugin>
+ <!-- The name of the plugin -->
+ <name>Add PortalContainer Definitions</name>
+ <!-- The name of the method to call on the PortalContainerConfig in order to register the PortalContainerDefinitions -->
+ <set-method>registerPlugin</set-method>
+ <!-- The full qualified name of the PortalContainerDefinitionPlugin -->
+ <type>org.exoplatform.container.definition.PortalContainerDefinitionPlugin</type>
+ <init-params>
+ <object-param>
+ <name>portal</name>
+ <object type="org.exoplatform.container.definition.PortalContainerDefinition">
+ <!-- The name of the portal container -->
+ <field name="name">
+ <string>myPortal-pcdef</string>
+ </field>
+ <!-- The name of the context name of the rest web application -->
+ <field name="restContextName">
+ <string>myRest-pcdef</string>
+ </field>
+ <!-- The name of the realm -->
+ <field name="realmName">
+ <string>my-exo-domain-pcdef</string>
+ </field>
+ <!-- A map of settings tied to the portal container -->
+ <field name="settings">
+ <map type="java.util.HashMap">
+ <entry>
+ <key>
+ <string>foo</string>
+ </key>
+ <value>
+ <string>value</string>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>string</string>
+ </key>
+ <value>
+ <string>value</string>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>int</string>
+ </key>
+ <value>
+ <int>10</int>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>long</string>
+ </key>
+ <value>
+ <long>10</long>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>double</string>
+ </key>
+ <value>
+ <double>10</double>
+ </value>
+ </entry>
+ <entry>
+ <key>
+ <string>boolean</string>
+ </key>
+ <value>
+ <boolean>true</boolean>
+ </value>
+ </entry>
+ </map>
+ </field>
+ </object>
+ </object-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+</configuration>
\ No newline at end of file
Copied: kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/sample-gtn-configuration.properties (from rev 2048, kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/sample-gtn-configuration.properties)
===================================================================
--- kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/sample-gtn-configuration.properties (rev 0)
+++ kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/sample-gtn-configuration.properties 2010-03-11 11:49:03 UTC (rev 2052)
@@ -0,0 +1,3 @@
+gatein.data.dir=../gatein/data
+gatein.db.data.dir=${gatein.data.dir}/db
+gatein.jcr.datasource.url=jdbc:hsqldb:file:${gatein.db.data.dir}/data/jdbcjcr_${name}
\ No newline at end of file
Copied: kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/sample-gtn-configuration.xml (from rev 2048, kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/sample-gtn-configuration.xml)
===================================================================
--- kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/sample-gtn-configuration.xml (rev 0)
+++ kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/sample-gtn-configuration.xml 2010-03-11 11:49:03 UTC (rev 2052)
@@ -0,0 +1,21 @@
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"
+ xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd">
+
+ <component>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <type>org.exoplatform.container.definition.PortalContainerConfig</type>
+ <init-params>
+ <!-- It cans be used to avoid duplicating configuration -->
+ <object-param>
+ <name>default.portal.definition</name>
+ <object type="org.exoplatform.container.definition.PortalContainerDefinition">
+ <!-- The path to the external properties file -->
+ <field name="externalSettingsPath">
+ <string>sample-gtn-configuration.properties</string>
+ </field>
+ </object>
+ </object-param>
+ </init-params>
+ </component>
+</configuration>
Modified: kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/settings.properties
===================================================================
--- kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/settings.properties 2010-03-11 09:32:07 UTC (rev 2051)
+++ kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/settings.properties 2010-03-11 11:49:03 UTC (rev 2052)
@@ -1,7 +1,11 @@
foo2=value
+foo3=value
string=new value
int=20
long=20
double=20
boolean=false
-complex-value=${name}-${rest}-${realm}-${foo2}-${string}
\ No newline at end of file
+complex-value=${name}-${rest}-${realm}-${foo2}-${string}
+complex-value4=-${foo4}-
+complex-value6=-${foo6}-
+complex-value7=-${foo5}-
\ No newline at end of file
Copied: kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/test-trim-value.xml (from rev 1983, kernel/trunk/exo.kernel.container/src/test/resources/test-trim-value.xml)
===================================================================
--- kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/test-trim-value.xml (rev 0)
+++ kernel/tags/2.2.0-GA/exo.kernel.container/src/test/resources/test-trim-value.xml 2010-03-11 11:49:03 UTC (rev 2052)
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+ <!--
+
+ Copyright (C) 2009 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.
+ -->
+<configuration>
+
+ <container-lifecycle-plugin>
+ <type> container-lifecycle-plugin-type
+ </type>
+ <init-params>
+ <value-param>
+ <name> container-lifecycle-plugin-value-param-name </name>
+ <value> container-lifecycle-plugin-value-param-value </value>
+ </value-param>
+ </init-params>
+ </container-lifecycle-plugin>
+ <component-lifecycle-plugin>
+ <type> component-lifecycle-plugin
+ </type>
+ <manageable-components>
+ <component-type> manageable-components-component-type</component-type>
+ </manageable-components>
+ <init-params>
+ <values-param>
+ <name> component-lifecycle-plugin-values-param-name </name>
+ <value> component-lifecycle-plugin-values-param-value1 </value>
+ <value> component-lifecycle-plugin-values-param-value2
+ </value>
+ </values-param>
+ </init-params>
+ </component-lifecycle-plugin>
+ <component>
+ <key> component-key1
+ </key>
+ <type> component-type1
+ </type>
+ <init-params>
+ <properties-param>
+ <name> component-key1-properties-param-name </name>
+ <property name=" component-key1-properties-param-prop-name " value=" component-key1-properties-param-prop-value
+ " />
+ </properties-param>
+ </init-params>
+ </component>
+ <component>
+ <type> component-type2
+ </type>
+ <component-plugins>
+ <component-plugin>
+ <name> component-plugins-name </name>
+ <set-method> set-method-name</set-method>
+ <type> component-plugins-type </type>
+ <priority> 1 </priority>
+ </component-plugin>
+ </component-plugins>
+ <init-params>
+ <object-param>
+ <name> component-key2-object-param-name </name>
+ <object type=" org.exoplatform.xml.test.TestConfigurationXML$MyObject ">
+ <field name=" field1 ">
+ <string> string-value </string>
+ </field>
+ <field name=" field2 ">
+ <int> 1 </int>
+ </field>
+ <field name=" field3 ">
+ <long> 1 </long>
+ </field>
+ <field name=" field4 ">
+ <double> 1 </double>
+ </field>
+ <field name=" field5 ">
+ <boolean> true </boolean>
+ </field>
+ <field name=" field6 ">
+ <map type=" java.util.HashMap ">
+ <entry>
+ <key><string> entry-name </string></key>
+ <value><string> entry-value </string></value>
+ </entry>
+ </map>
+ </field>
+ <field name=" field7 ">
+ <collection type=" java.util.HashSet ">
+ <value>
+ <string> string-value </string>
+ </value>
+ </collection>
+ </field>
+ <field name=" field8 ">
+ <native-array type=" int ">
+ <array> 1 </array>
+ </native-array>
+ </field>
+ </object>
+ </object-param>
+ </init-params>
+ </component>
+ <external-component-plugins>
+ <target-component> target-component-name
+ </target-component>
+ <component-plugin>
+ <name> component-plugins-name </name>
+ <set-method> set-method-name</set-method>
+ <type> component-plugins-type </type>
+ <priority> 1 </priority>
+ </component-plugin>
+ </external-component-plugins>
+ <import> import-value
+ </import>
+ <remove-configuration> remove-configuration-value </remove-configuration>
+</configuration>
16 years, 2 months
exo-jcr SVN: r2051 - in core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization: jdbc and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-03-11 04:32:07 -0500 (Thu, 11 Mar 2010)
New Revision: 2051
Modified:
core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/hibernate/UserDAOImpl.java
core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/jdbc/UserDAOImpl.java
Log:
EXOJCR-584: not case-sensitive user's search
Modified: core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/hibernate/UserDAOImpl.java
===================================================================
--- core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/hibernate/UserDAOImpl.java 2010-03-10 15:39:06 UTC (rev 2050)
+++ core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/hibernate/UserDAOImpl.java 2010-03-11 09:32:07 UTC (rev 2051)
@@ -178,9 +178,18 @@
public ListAccess<User> findUsersByQuery(Query q) throws Exception
{
ObjectQuery oq = new ObjectQuery(UserImpl.class);
- oq.addLIKE("userName", q.getUserName());
- oq.addLIKE("firstName", q.getFirstName());
- oq.addLIKE("lastName", q.getLastName());
+ if (q.getUserName() != null)
+ {
+ oq.addLIKE("UPPER(userName)", q.getUserName().toUpperCase());
+ }
+ if (q.getFirstName() != null)
+ {
+ oq.addLIKE("UPPER(firstName)", q.getFirstName().toUpperCase());
+ }
+ if (q.getLastName() != null)
+ {
+ oq.addLIKE("UPPER(lastName)", q.getLastName().toUpperCase());
+ }
oq.addLIKE("email", q.getEmail());
oq.addGT("lastLoginTime", q.getFromLoginDate());
oq.addLT("lastLoginTime", q.getToLoginDate());
Modified: core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/jdbc/UserDAOImpl.java
===================================================================
--- core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/jdbc/UserDAOImpl.java 2010-03-10 15:39:06 UTC (rev 2050)
+++ core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/jdbc/UserDAOImpl.java 2010-03-11 09:32:07 UTC (rev 2051)
@@ -110,9 +110,18 @@
public ListAccess<User> findUsersByQuery(Query orgQuery) throws Exception
{
DBObjectQuery dbQuery = new DBObjectQuery<UserImpl>(UserImpl.class);
- dbQuery.addLIKE("USER_NAME", orgQuery.getUserName());
- dbQuery.addLIKE("FIRST_NAME", orgQuery.getFirstName());
- dbQuery.addLIKE("LAST_NAME", orgQuery.getLastName());
+ if (orgQuery.getUserName() != null)
+ {
+ dbQuery.addLIKE("UPPER(USER_NAME)", orgQuery.getUserName().toUpperCase());
+ }
+ if (orgQuery.getFirstName() != null)
+ {
+ dbQuery.addLIKE("UPPER(FIRST_NAME)", orgQuery.getFirstName().toUpperCase());
+ }
+ if (orgQuery.getLastName() != null)
+ {
+ dbQuery.addLIKE("UPPER(LAST_NAME)", orgQuery.getLastName().toUpperCase());
+ }
dbQuery.addLIKE("EMAIL", orgQuery.getEmail());
dbQuery.addGT("LAST_LOGIN_TIME", orgQuery.getFromLoginDate());
dbQuery.addLT("LAST_LOGIN_TIME", orgQuery.getToLoginDate());
16 years, 2 months
exo-jcr SVN: r2050 - in jcr/trunk/exo.jcr.component.core/src: test/java/org/exoplatform/services/jcr/api/importing and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-03-10 10:39:06 -0500 (Wed, 10 Mar 2010)
New Revision: 2050
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/util/VersionHistoryImporter.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestImport.java
Log:
EXOJCR-548: remove VersionHistory node before importing
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/util/VersionHistoryImporter.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/util/VersionHistoryImporter.java 2010-03-10 15:04:14 UTC (rev 2049)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/util/VersionHistoryImporter.java 2010-03-10 15:39:06 UTC (rev 2050)
@@ -132,12 +132,6 @@
{
String path = versionableNode.getVersionHistory().getParent().getPath();
- if (versionableNode.getVersionHistory().getParent().hasNode(versionHistory))
- {
- throw new RepositoryException("Can't import version history for node with identifier '" + versionHistory
- + "', because it already exists in version storage.");
- }
-
NodeData versionable = (NodeData)versionableNode.getData();
// ----- VERSIONABLE properties -----
// jcr:versionHistory
@@ -177,9 +171,9 @@
changesLogDeltete.add(ItemState
.createDeletedState(((PropertyImpl)versionableNode.getProperty("jcr:predecessors")).getData()));
dataKeeper.save(changesLogDeltete);
- userSession.save();
// remove version history
dataKeeper.save(changesLog);
+ userSession.save();
// import new version history
userSession.getWorkspace().importXML(path, versionHistoryStream, 0);
userSession.save();
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestImport.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestImport.java 2010-03-10 15:04:14 UTC (rev 2049)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestImport.java 2010-03-10 15:39:06 UTC (rev 2050)
@@ -34,21 +34,29 @@
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
+import java.io.IOException;
import java.io.InputStream;
+import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Random;
import javax.jcr.ImportUUIDBehavior;
import javax.jcr.Node;
+import javax.jcr.NodeIterator;
import javax.jcr.Property;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.Value;
import javax.jcr.ValueFormatException;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.QueryResult;
import javax.jcr.util.TraversingItemVisitor;
+import javax.jcr.version.Version;
/**
* Created by The eXo Platform SAS.
@@ -65,6 +73,8 @@
private final Random random;
+ private List<String> versionList = new ArrayList<String>();
+
// private List<String> versionList = new ArrayList<String>();
public TestImport()
@@ -738,6 +748,106 @@
session1.save();
}
+ public void testImportAndExport() throws Exception
+ {
+ Node aaa = root.addNode("AAA");
+ Node bbb = root.addNode("BBB");
+ Node ccc = root.addNode("CCC");
+ session.save();
+
+ // Export Action
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ aaa.getSession().exportDocumentView(aaa.getPath(), bos, false, false);
+ ByteArrayInputStream is = new ByteArrayInputStream(bos.toByteArray());
+ bbb.getSession().importXML(bbb.getPath(), is, 1);
+ session.save();
+
+ String[] paths = new String[]{"AAA", "BBB", "BBB/AAA"};
+ for (String path : paths)
+ {
+ if (bbb.hasNode(path))
+ {
+ }
+ }
+
+ Node hello = aaa.addNode("hello", "exo:article");
+ hello.setProperty("exo:title", "hello");
+ hello.addMixin("mix:versionable");
+ session.save();
+
+ Version version = hello.checkin();
+ hello.checkout();
+
+ session.save();
+
+ /**
+ * Before import this node has one version
+ */
+ Version rootVersion = hello.getVersionHistory().getRootVersion();
+ getListVersion(rootVersion);
+ assertEquals(1, versionList.size());
+
+ // Export VersionHistory
+ InputStream inputVersion = null;
+ if (hello.isNodeType("mix:versionable"))
+ {
+ ByteArrayOutputStream bosVersion = new ByteArrayOutputStream();
+ hello.getSession().exportDocumentView(hello.getVersionHistory().getPath(), bosVersion, false, false);
+ inputVersion = new ByteArrayInputStream(bosVersion.toByteArray());
+ }
+ String versionHistory = hello.getProperty("jcr:versionHistory").getValue().getString();
+ String baseVersion = hello.getProperty("jcr:baseVersion").getValue().getString();
+ Value[] jcrPredecessors = hello.getProperty("jcr:predecessors").getValues();
+ String[] predecessorsHistory;
+ StringBuilder jcrPredecessorsBuilder = new StringBuilder();
+ for (Value value : jcrPredecessors)
+ {
+ if (jcrPredecessorsBuilder.length() > 0)
+ jcrPredecessorsBuilder.append(",");
+ jcrPredecessorsBuilder.append(value.getString());
+ }
+ if (jcrPredecessorsBuilder.toString().indexOf(",") > -1)
+ {
+ predecessorsHistory = jcrPredecessorsBuilder.toString().split(",");
+ }
+ else
+ {
+ predecessorsHistory = new String[]{jcrPredecessorsBuilder.toString()};
+ }
+
+ // Export Action
+ ByteArrayOutputStream bosHello = new ByteArrayOutputStream();
+ hello.getSession().exportDocumentView(hello.getPath(), bosHello, false, false);
+ ByteArrayInputStream isHello = new ByteArrayInputStream(bosHello.toByteArray());
+ // Remove node "/aaa/hello" and it's version history, before importing it
+ // again!
+ // hello.remove();
+ session.save();
+ ccc.getSession().importXML(ccc.getPath(), isHello, 1);
+ session.save();
+
+ /**
+ * Import VersionHistory After import version history, the node has no
+ * version Errors: Lose version when import version history
+ */
+ Node helloImport = (Node)session.getItem("/CCC/hello");
+ importHistory((NodeImpl)helloImport, inputVersion, baseVersion, predecessorsHistory, versionHistory);
+ // versionList.clear();
+ // Version rootVersionImport =
+ // helloImport.getVersionHistory().getRootVersion();
+ // getListVersion(rootVersionImport);
+ // assertEquals(1, versionList.size());
+
+ aaa = root.getNode("AAA");
+ bbb = root.getNode("BBB");
+ ccc = root.getNode("CCC");
+
+ aaa.remove();
+ bbb.remove();
+ ccc.remove();
+ session.save();
+ }
+
private String dumpVersionable(Node versionableNode) throws RepositoryException
{
String result;
@@ -859,4 +969,35 @@
}
}
+
+ private void importHistory(NodeImpl versionableNode, InputStream versionHistoryStream, String baseVersionUuid,
+ String[] predecessors, String versionHistory) throws RepositoryException, IOException
+ {
+ VersionHistoryImporter versionHistoryImporter =
+ new VersionHistoryImporter(versionableNode, versionHistoryStream, baseVersionUuid, predecessors,
+ versionHistory);
+ versionHistoryImporter.doImport();
+ }
+
+ public void getListVersion(Version version)
+ {
+ try
+ {
+ String uuid = version.getUUID();
+ QueryManager queryManager = session.getWorkspace().getQueryManager();
+ Query query =
+ queryManager.createQuery("//element(*, nt:version)[@jcr:predecessors='" + uuid + "']", Query.XPATH);
+ QueryResult queryResult = query.execute();
+ NodeIterator iterate = queryResult.getNodes();
+ while (iterate.hasNext())
+ {
+ Version version1 = (Version)iterate.nextNode();
+ versionList.add(version1.getUUID());
+ getListVersion(version1);
+ }
+ }
+ catch (Exception e)
+ {
+ }
+ }
}
16 years, 2 months
exo-jcr SVN: r2049 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2010-03-10 10:04:14 -0500 (Wed, 10 Mar 2010)
New Revision: 2049
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFile.java
Log:
EXOJCR-581: Check on null in TreeFile class added.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFile.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFile.java 2010-03-10 12:10:39 UTC (rev 2048)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFile.java 2010-03-10 15:04:14 UTC (rev 2049)
@@ -70,7 +70,7 @@
if (fp.isDirectory())
{
String[] ls = fp.list();
- if (ls.length <= 0)
+ if (ls != null && ls.length <= 0)
{
if (res = fp.delete())
{
16 years, 2 months
exo-jcr SVN: r2048 - in kernel/trunk/exo.kernel.container/src: test/java/org/exoplatform/container/definition and 1 other directories.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-03-10 07:10:39 -0500 (Wed, 10 Mar 2010)
New Revision: 2048
Added:
kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/sample-gtn-configuration.properties
kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/sample-gtn-configuration.xml
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java
kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java
Log:
EXOJCR-580: The context used to resolve variables was not updated
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java 2010-03-10 10:15:57 UTC (rev 2047)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java 2010-03-10 12:10:39 UTC (rev 2048)
@@ -677,6 +677,7 @@
String propertyValue = entry.getValue();
propertyValue = Deserializer.resolveVariables(propertyValue, ctx);
externalSettings.put(propertyName, propertyValue);
+ ctx.put(propertyName, propertyValue);
}
}
Modified: kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java 2010-03-10 10:15:57 UTC (rev 2047)
+++ kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java 2010-03-10 12:10:39 UTC (rev 2048)
@@ -516,6 +516,13 @@
assertEquals("my-exo-domain", config.getSetting("myPortal", PortalContainerConfig.REALM_SETTING_NAME));
assertEquals("my-exo-domain-pcdef", config.getSetting("myPortal-pcdef", PortalContainerConfig.REALM_SETTING_NAME));
+ // Simple usecase from gatein
+ rootContainer = createRootContainer("sample-gtn-configuration.xml");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertEquals("../gatein/data", config.getSetting("portal", "gatein.data.dir"));
+ assertEquals("../gatein/data/db", config.getSetting("portal", "gatein.db.data.dir"));
+ assertEquals("jdbc:hsqldb:file:../gatein/data/db/data/jdbcjcr_portal", config.getSetting("portal", "gatein.jcr.datasource.url"));
+
// With external settings, with several portal container definitions and with
// default portal container definition
rootContainer =
Added: kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/sample-gtn-configuration.properties
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/sample-gtn-configuration.properties (rev 0)
+++ kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/sample-gtn-configuration.properties 2010-03-10 12:10:39 UTC (rev 2048)
@@ -0,0 +1,3 @@
+gatein.data.dir=../gatein/data
+gatein.db.data.dir=${gatein.data.dir}/db
+gatein.jcr.datasource.url=jdbc:hsqldb:file:${gatein.db.data.dir}/data/jdbcjcr_${name}
\ No newline at end of file
Added: kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/sample-gtn-configuration.xml
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/sample-gtn-configuration.xml (rev 0)
+++ kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/sample-gtn-configuration.xml 2010-03-10 12:10:39 UTC (rev 2048)
@@ -0,0 +1,21 @@
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"
+ xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd">
+
+ <component>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <type>org.exoplatform.container.definition.PortalContainerConfig</type>
+ <init-params>
+ <!-- It cans be used to avoid duplicating configuration -->
+ <object-param>
+ <name>default.portal.definition</name>
+ <object type="org.exoplatform.container.definition.PortalContainerDefinition">
+ <!-- The path to the external properties file -->
+ <field name="externalSettingsPath">
+ <string>sample-gtn-configuration.properties</string>
+ </field>
+ </object>
+ </object-param>
+ </init-params>
+ </component>
+</configuration>
16 years, 2 months