exo-jcr SVN: r2097 - in jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache: jdbc and 1 other directory.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2010-03-23 03:23:36 -0400 (Tue, 23 Mar 2010)
New Revision: 2097
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManagerImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableSessionLockManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/jdbc/CacheableJDBCLockManagerImpl.java
Log:
EXOJCR-600: HashMap sessionLockManagers HashMap changed to ConcurrentHashMap
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManagerImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManagerImpl.java 2010-03-22 13:58:36 UTC (rev 2096)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManagerImpl.java 2010-03-23 07:23:36 UTC (rev 2097)
@@ -74,11 +74,11 @@
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import javax.jcr.RepositoryException;
import javax.jcr.lock.LockException;
@@ -236,7 +236,7 @@
lockTimeOut = DEFAULT_LOCK_TIMEOUT;
}
- sessionLockManagers = new HashMap<String, CacheableSessionLockManager>();
+ sessionLockManagers = new ConcurrentHashMap<String, CacheableSessionLockManager>();
dataManager.addItemPersistenceListener(this);
@@ -566,7 +566,7 @@
nodeIdentifier = currChangesLog.getAllStates().get(0).getData().getParentIdentifier();
CacheableSessionLockManager session = sessionLockManagers.get(sessionId);
- if (session != null && session.cotainsPendingLock(nodeIdentifier))
+ if (session != null && session.containsPendingLock(nodeIdentifier))
{
containers.add(new LockOperationContainer(nodeIdentifier, currChangesLog.getSessionId(),
ExtendedEvent.LOCK));
@@ -790,7 +790,7 @@
private synchronized void internalLock(String sessionId, String nodeIdentifier) throws LockException
{
CacheableSessionLockManager session = sessionLockManagers.get(sessionId);
- if (session != null && session.cotainsPendingLock(nodeIdentifier))
+ if (session != null && session.containsPendingLock(nodeIdentifier))
{
LockData lockData = session.getPendingLock(nodeIdentifier);
Fqn<String> lockPath = makeLockFqn(lockData.getNodeIdentifier());
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableSessionLockManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableSessionLockManager.java 2010-03-22 13:58:36 UTC (rev 2096)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableSessionLockManager.java 2010-03-23 07:23:36 UTC (rev 2097)
@@ -290,7 +290,7 @@
* @param nodeId - node ID string
* @return boolean
*/
- public boolean cotainsPendingLock(String nodeId)
+ public boolean containsPendingLock(String nodeId)
{
return pendingLocks.contains(nodeId);
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/jdbc/CacheableJDBCLockManagerImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/jdbc/CacheableJDBCLockManagerImpl.java 2010-03-22 13:58:36 UTC (rev 2096)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/jdbc/CacheableJDBCLockManagerImpl.java 2010-03-23 07:23:36 UTC (rev 2097)
@@ -383,7 +383,7 @@
nodeIdentifier = currChangesLog.getAllStates().get(0).getData().getParentIdentifier();
CacheableSessionLockManager session = sessionLockManagers.get(sessionId);
- if (session != null && session.cotainsPendingLock(nodeIdentifier))
+ if (session != null && session.containsPendingLock(nodeIdentifier))
{
containers.add(new LockOperationContainer(nodeIdentifier, currChangesLog.getSessionId(),
ExtendedEvent.LOCK));
@@ -642,7 +642,7 @@
private synchronized void internalLock(String sessionId, String nodeIdentifier) throws RepositoryException
{
CacheableSessionLockManager sessionLockManager = sessionLockManagers.get(sessionId);
- if (sessionLockManager != null && sessionLockManager.cotainsPendingLock(nodeIdentifier))
+ if (sessionLockManager != null && sessionLockManager.containsPendingLock(nodeIdentifier))
{
LockData lockData = sessionLockManager.getPendingLock(nodeIdentifier);
16 years, 1 month
exo-jcr SVN: r2096 - in kernel/trunk: docs and 8 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-03-22 09:58:36 -0400 (Mon, 22 Mar 2010)
New Revision: 2096
Added:
kernel/trunk/docs/
kernel/trunk/docs/pom.xml
kernel/trunk/docs/reference/
kernel/trunk/docs/reference/en/
kernel/trunk/docs/reference/en/build.cmd
kernel/trunk/docs/reference/en/pom.xml
kernel/trunk/docs/reference/en/src/
kernel/trunk/docs/reference/en/src/main/
kernel/trunk/docs/reference/en/src/main/docbook/
kernel/trunk/docs/reference/en/src/main/docbook/en-US/
kernel/trunk/docs/reference/en/src/main/docbook/en-US/master.xml
kernel/trunk/docs/reference/en/src/main/docbook/en-US/modules/
kernel/trunk/docs/reference/en/src/main/docbook/en-US/modules/services.xml
kernel/trunk/docs/reference/en/src/main/docbook/en-US/modules/services/
kernel/trunk/docs/reference/en/src/main/docbook/en-US/modules/services/initial-context-binder-service.xml
kernel/trunk/docs/reference/en/src/main/resources/
kernel/trunk/docs/reference/pom.xml
Modified:
kernel/trunk/pom.xml
Log:
EXOJCR-573: add InitialContextBinder docbook
Added: kernel/trunk/docs/pom.xml
===================================================================
--- kernel/trunk/docs/pom.xml (rev 0)
+++ kernel/trunk/docs/pom.xml 2010-03-22 13:58:36 UTC (rev 2096)
@@ -0,0 +1,38 @@
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>kernel-parent</artifactId>
+ <version>2.2.1-GA-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>docs</artifactId>
+
+ <name>Kernel project documentation</name>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>reference</module>
+ </modules>
+</project>
Added: kernel/trunk/docs/reference/en/build.cmd
===================================================================
--- kernel/trunk/docs/reference/en/build.cmd (rev 0)
+++ kernel/trunk/docs/reference/en/build.cmd 2010-03-22 13:58:36 UTC (rev 2096)
@@ -0,0 +1 @@
+@start mvn clean install jdocbook:resources jdocbook:generate
\ No newline at end of file
Added: kernel/trunk/docs/reference/en/pom.xml
===================================================================
--- kernel/trunk/docs/reference/en/pom.xml (rev 0)
+++ kernel/trunk/docs/reference/en/pom.xml 2010-03-22 13:58:36 UTC (rev 2096)
@@ -0,0 +1,128 @@
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>reference-docs</artifactId>
+ <version>2.2.1-GA-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>reference-docs-${translation}</artifactId>
+
+ <name>Kernel reference documentation (${translation})</name>
+ <packaging>jdocbook</packaging>
+
+ <properties>
+ <translation>en</translation>
+ <enforcer.skip>true</enforcer.skip>
+ </properties>
+
+ <build>
+ <finalName>${project.parent.artifactId}_${translation}-${version}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>xml-maven-plugin</artifactId>
+ <!-- version>1.0-beta-2</version -->
+ </plugin>
+
+ <plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-jdocbook-plugin</artifactId>
+ <version>2.1.1</version>
+ <extensions>true</extensions>
+ <dependencies>
+ <dependency>
+ <groupId>org.exoplatform.doc</groupId>
+ <artifactId>exo-docbook-xslt</artifactId>
+ <version>${org.exoplatform.doc-style.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.doc</groupId>
+ <artifactId>exo-jdocbook-style</artifactId>
+ <version>${org.exoplatform.doc-style.version}</version>
+ <type>jdocbook-style</type>
+ </dependency>
+ <!-- dependency>
+ <groupId>xalan</groupId>
+ <artifactId>xalan</artifactId>
+ <version>2.7.1</version>
+ </dependency -->
+ <!-- dependency>
+ <groupId>net.sf.saxon</groupId>
+ <artifactId>saxon</artifactId>
+ <version>9.1.0.8</version>
+ </dependency -->
+ </dependencies>
+ <configuration>
+ <sourceDocumentName>master.xml</sourceDocumentName>
+
+ <!--sourceDocumentName>modules/lock-manager-config.xml</sourceDocumentName-->
+ <imageResource>
+ <directory>${pom.basedir}/src/main/resources</directory>
+ <includes>
+ <include>images/**/*</include>
+ </includes>
+ </imageResource>
+
+ <formats>
+ <format>
+ <formatName>html</formatName>
+ <stylesheetResource>classpath:/xslt/org/exojcr/xhtml.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
+ <format>
+ <formatName>html_single</formatName>
+ <stylesheetResource>classpath:/xslt/org/exojcr/xhtml-single.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
+ <!-- format>
+ <formatName>pdf</formatName>
+ <stylesheetResource>classpath://xslt/org/exojcr/pdf.xsl</stylesheetResource>
+ <finalName>${pom.name}.pdf</finalName>
+ </format -->
+ <!-- format>
+ <formatName>eclipse</formatName>
+ <stylesheetResource>classpath:/xslt/org/exojcr/eclipse.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format -->
+ </formats>
+
+ <options>
+ <xincludeSupported>true</xincludeSupported>
+ <xmlTransformerType>saxon</xmlTransformerType>
+ <!-- needed for uri-resolvers; can be ommitted if using 'current' uri scheme -->
+ <!-- could also locate the docbook dependency and inspect its version... -->
+ <docbookVersion>1.74.0</docbookVersion>
+ </options>
+
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Added: kernel/trunk/docs/reference/en/src/main/docbook/en-US/master.xml
===================================================================
--- kernel/trunk/docs/reference/en/src/main/docbook/en-US/master.xml (rev 0)
+++ kernel/trunk/docs/reference/en/src/main/docbook/en-US/master.xml 2010-03-22 13:58:36 UTC (rev 2096)
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<book lang="en">
+ <bookinfo>
+ <title>Kernle Reference Manual</title>
+
+ <subtitle>Kernel</subtitle>
+
+ <copyright>
+ <year>2009, 2010</year>
+ <holder>eXoPlatform</holder>
+ </copyright>
+ </bookinfo>
+
+ <toc></toc>
+
+ <xi:include href="modules/services.xml"
+ xmlns:xi="http://www.w3.org/2001/XInclude" />
+
+</book>
Added: kernel/trunk/docs/reference/en/src/main/docbook/en-US/modules/services/initial-context-binder-service.xml
===================================================================
--- kernel/trunk/docs/reference/en/src/main/docbook/en-US/modules/services/initial-context-binder-service.xml (rev 0)
+++ kernel/trunk/docs/reference/en/src/main/docbook/en-US/modules/services/initial-context-binder-service.xml 2010-03-22 13:58:36 UTC (rev 2096)
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<chapter>
+ <?dbhtml filename="ch-initial-context-binder-service.html"?>
+
+ <title>Initial Context Binder</title>
+
+ <section>
+ <title>About</title>
+
+ <para>Initial Context Binder is responsible for binding references at
+ runtime, persisting in file and automatically rebinding after restart.
+ Java temp directory is used to persist references in bind-references.xml
+ file.</para>
+ </section>
+
+ <section>
+ <title>API</title>
+
+ <para>Service provide methods for binding reference.</para>
+
+ <programlisting>public void bind(String bindName, String className, String factory, String factoryLocation, Map<String, String> refAddr) throws NamingException, FileNotFoundException, XMLStreamException;</programlisting>
+
+ <itemizedlist>
+ <listitem>
+ <para>bindName - name of binding</para>
+ </listitem>
+
+ <listitem>
+ <para>className - the fully-qualified name of the class of the object
+ to which this Reference refers</para>
+ </listitem>
+
+ <listitem>
+ <para>factory - the name of the factory class for creating an instance
+ of the object to which this Reference refers</para>
+ </listitem>
+
+ <listitem>
+ <para>factoryLocation - the location of the factory class</para>
+ </listitem>
+
+ <listitem>
+ <para>refAddr - object's properties map</para>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title>A configuration examples</title>
+
+ <para>Service's configuration.</para>
+
+ <programlisting><component>
+ <key>org.exoplatform.services.naming.InitialContextBinder</key>
+ <type>org.exoplatform.services.naming.InitialContextBinder</type>
+</component></programlisting>
+ </section>
+</chapter>
Added: kernel/trunk/docs/reference/en/src/main/docbook/en-US/modules/services.xml
===================================================================
--- kernel/trunk/docs/reference/en/src/main/docbook/en-US/modules/services.xml (rev 0)
+++ kernel/trunk/docs/reference/en/src/main/docbook/en-US/modules/services.xml 2010-03-22 13:58:36 UTC (rev 2096)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<part>
+ <?dbhtml filename="part-services.html"?>
+
+ <title>Kernel</title>
+
+ <xi:include href="services/initial-context-binder-service.xml"
+ xmlns:xi="http://www.w3.org/2001/XInclude" />
+
+</part>
Added: kernel/trunk/docs/reference/pom.xml
===================================================================
--- kernel/trunk/docs/reference/pom.xml (rev 0)
+++ kernel/trunk/docs/reference/pom.xml 2010-03-22 13:58:36 UTC (rev 2096)
@@ -0,0 +1,38 @@
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>docs</artifactId>
+ <version>2.2.1-GA-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>reference-docs</artifactId>
+
+ <name>Kernel reference documentation</name>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>en</module>
+ </modules>
+</project>
Modified: kernel/trunk/pom.xml
===================================================================
--- kernel/trunk/pom.xml 2010-03-22 13:34:06 UTC (rev 2095)
+++ kernel/trunk/pom.xml 2010-03-22 13:58:36 UTC (rev 2096)
@@ -38,7 +38,8 @@
<properties>
<exo.product.name>exo-kernel</exo.product.name>
<exo.product.specification>2.2</exo.product.specification>
- <org.exoplatform.framework.junit.version>1.2.2-GA-SNAPSHOT</org.exoplatform.framework.junit.version>
+ <org.exoplatform.framework.junit.version>1.2.2-GA-SNAPSHOT</org.exoplatform.framework.junit.version>
+ <org.exoplatform.doc-style.version>2-SNAPSHOT</org.exoplatform.doc-style.version>
<forkMode>always</forkMode>
</properties>
16 years, 1 month
exo-jcr SVN: r2095 - in core/trunk: docs and 8 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-03-22 09:34:06 -0400 (Mon, 22 Mar 2010)
New Revision: 2095
Added:
core/trunk/docs/
core/trunk/docs/pom.xml
core/trunk/docs/reference/
core/trunk/docs/reference/en/
core/trunk/docs/reference/en/build.cmd
core/trunk/docs/reference/en/pom.xml
core/trunk/docs/reference/en/src/
core/trunk/docs/reference/en/src/main/
core/trunk/docs/reference/en/src/main/docbook/
core/trunk/docs/reference/en/src/main/docbook/en-US/
core/trunk/docs/reference/en/src/main/docbook/en-US/master.xml
core/trunk/docs/reference/en/src/main/docbook/en-US/modules/
core/trunk/docs/reference/en/src/main/docbook/en-US/modules/services.xml
core/trunk/docs/reference/en/src/main/docbook/en-US/modules/services/
core/trunk/docs/reference/en/src/main/docbook/en-US/modules/services/db-creator-service.xml
core/trunk/docs/reference/en/src/main/resources/
core/trunk/docs/reference/pom.xml
Log:
EXOJCR-573: add DBCreator docbook
Added: core/trunk/docs/pom.xml
===================================================================
--- core/trunk/docs/pom.xml (rev 0)
+++ core/trunk/docs/pom.xml 2010-03-22 13:34:06 UTC (rev 2095)
@@ -0,0 +1,38 @@
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.exoplatform.core</groupId>
+ <artifactId>core-parent</artifactId>
+ <version>2.3.1-GA-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>docs</artifactId>
+
+ <name>Core project documentation</name>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>reference</module>
+ </modules>
+</project>
Added: core/trunk/docs/reference/en/build.cmd
===================================================================
--- core/trunk/docs/reference/en/build.cmd (rev 0)
+++ core/trunk/docs/reference/en/build.cmd 2010-03-22 13:34:06 UTC (rev 2095)
@@ -0,0 +1 @@
+@start mvn clean install jdocbook:resources jdocbook:generate
\ No newline at end of file
Added: core/trunk/docs/reference/en/pom.xml
===================================================================
--- core/trunk/docs/reference/en/pom.xml (rev 0)
+++ core/trunk/docs/reference/en/pom.xml 2010-03-22 13:34:06 UTC (rev 2095)
@@ -0,0 +1,128 @@
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.exoplatform.core</groupId>
+ <artifactId>reference-docs</artifactId>
+ <version>2.3.1-GA-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>reference-docs-${translation}</artifactId>
+
+ <name>Core reference documentation (${translation})</name>
+ <packaging>jdocbook</packaging>
+
+ <properties>
+ <translation>en</translation>
+ <enforcer.skip>true</enforcer.skip>
+ </properties>
+
+ <build>
+ <finalName>${project.parent.artifactId}_${translation}-${version}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>xml-maven-plugin</artifactId>
+ <!-- version>1.0-beta-2</version -->
+ </plugin>
+
+ <plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-jdocbook-plugin</artifactId>
+ <version>2.1.1</version>
+ <extensions>true</extensions>
+ <dependencies>
+ <dependency>
+ <groupId>org.exoplatform.doc</groupId>
+ <artifactId>exo-docbook-xslt</artifactId>
+ <version>${org.exoplatform.doc-style.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.doc</groupId>
+ <artifactId>exo-jdocbook-style</artifactId>
+ <version>${org.exoplatform.doc-style.version}</version>
+ <type>jdocbook-style</type>
+ </dependency>
+ <!-- dependency>
+ <groupId>xalan</groupId>
+ <artifactId>xalan</artifactId>
+ <version>2.7.1</version>
+ </dependency -->
+ <!-- dependency>
+ <groupId>net.sf.saxon</groupId>
+ <artifactId>saxon</artifactId>
+ <version>9.1.0.8</version>
+ </dependency -->
+ </dependencies>
+ <configuration>
+ <sourceDocumentName>master.xml</sourceDocumentName>
+
+ <!--sourceDocumentName>modules/lock-manager-config.xml</sourceDocumentName-->
+ <imageResource>
+ <directory>${pom.basedir}/src/main/resources</directory>
+ <includes>
+ <include>images/**/*</include>
+ </includes>
+ </imageResource>
+
+ <formats>
+ <format>
+ <formatName>html</formatName>
+ <stylesheetResource>classpath:/xslt/org/exojcr/xhtml.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
+ <format>
+ <formatName>html_single</formatName>
+ <stylesheetResource>classpath:/xslt/org/exojcr/xhtml-single.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
+ <!-- format>
+ <formatName>pdf</formatName>
+ <stylesheetResource>classpath://xslt/org/exojcr/pdf.xsl</stylesheetResource>
+ <finalName>${pom.name}.pdf</finalName>
+ </format -->
+ <!-- format>
+ <formatName>eclipse</formatName>
+ <stylesheetResource>classpath:/xslt/org/exojcr/eclipse.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format -->
+ </formats>
+
+ <options>
+ <xincludeSupported>true</xincludeSupported>
+ <xmlTransformerType>saxon</xmlTransformerType>
+ <!-- needed for uri-resolvers; can be ommitted if using 'current' uri scheme -->
+ <!-- could also locate the docbook dependency and inspect its version... -->
+ <docbookVersion>1.74.0</docbookVersion>
+ </options>
+
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Added: core/trunk/docs/reference/en/src/main/docbook/en-US/master.xml
===================================================================
--- core/trunk/docs/reference/en/src/main/docbook/en-US/master.xml (rev 0)
+++ core/trunk/docs/reference/en/src/main/docbook/en-US/master.xml 2010-03-22 13:34:06 UTC (rev 2095)
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<book lang="en">
+ <bookinfo>
+ <title>Core Reference Manual</title>
+
+ <subtitle>Core</subtitle>
+
+ <copyright>
+ <year>2009, 2010</year>
+ <holder>eXoPlatform</holder>
+ </copyright>
+ </bookinfo>
+
+ <toc></toc>
+
+ <xi:include href="modules/services.xml"
+ xmlns:xi="http://www.w3.org/2001/XInclude" />
+
+</book>
Added: core/trunk/docs/reference/en/src/main/docbook/en-US/modules/services/db-creator-service.xml
===================================================================
--- core/trunk/docs/reference/en/src/main/docbook/en-US/modules/services/db-creator-service.xml (rev 0)
+++ core/trunk/docs/reference/en/src/main/docbook/en-US/modules/services/db-creator-service.xml 2010-03-22 13:34:06 UTC (rev 2095)
@@ -0,0 +1,181 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<chapter>
+ <?dbhtml filename="ch-db-creator-service.html"?>
+
+ <title>Database Creator</title>
+
+ <section>
+ <title>About</title>
+
+ <para>Database Creator is responsible for execution DDL script at runtime.
+ A DDL script may contain templates for database name, user name and
+ password which will be replaced by real values at execution time.</para>
+
+ <para>Supports 3 templates:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>${database} for database name;</para>
+ </listitem>
+
+ <listitem>
+ <para>${username} for user name;</para>
+ </listitem>
+
+ <listitem>
+ <para>${password} for user's password;</para>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title>API</title>
+
+ <para>Service provide method for execute script for new database creation.
+ Database name which are passed as parameter will be substituted in DDL
+ script instead of ${database} template. Returns DBConnectionInfo object
+ (with all neccesary information of new database's connection) or throws
+ DBScriptExecutorException exception if any errors occurs in other
+ case.</para>
+
+ <programlisting>public DBConnectionInfo createDatabase(String dbName) throws DBCreatorException;</programlisting>
+
+ <para>For MSSQL and Sybase servers uses autocommit mode set true for
+ connection. It's due to after execution "create database" command newly
+ created database not available for "use" command and therefore you can't
+ create new user inside database per one script.</para>
+ </section>
+
+ <section>
+ <title>A configuration examples</title>
+
+ <para>Service's configuration.</para>
+
+ <programlisting><component>
+ <key>org.exoplatform.services.database.creator.DBCreator</key>
+ <type>org.exoplatform.services.database.creator.DBCreator</type>
+ <init-params>
+ <properties-param>
+ <name>db-connection</name>
+ <description>database connection properties</description>
+ <property name="driverClassName" value="com.mysql.jdbc.Driver" />
+ <property name="url" value="jdbc:mysql://localhost/" />
+ <property name="username" value="root" />
+ <property name="password" value="admin" />
+ </properties-param>
+ <properties-param>
+ <name>db-creation</name>.
+ <description>database creation properties</description>.
+ <property name="scriptPath" value="script.sql" />
+ <property name="username" value="testuser" />
+ <property name="password" value="testpwd" />
+ </properties-param>
+ </init-params>
+ </component></programlisting>
+
+ <para>db-connection properties section contains parameters needed for
+ connection to database server</para>
+
+ <para>db-creation properties section contains paramaters for database
+ creation using DDL script:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>scriptPath: absolute path to DDL script file;</para>
+ </listitem>
+
+ <listitem>
+ <para>username: user name for substitution ${username} template in DDL
+ script;</para>
+ </listitem>
+
+ <listitem>
+ <para>password: user's password for substitution ${password} template
+ in DDL script;</para>
+ </listitem>
+ </itemizedlist>
+
+ <para>Specific db-connection properties section for different
+ databases.</para>
+
+ <para>MySQL:</para>
+
+ <programlisting><property name="driverClassName" value="com.mysql.jdbc.Driver" />
+<property name="url" value="jdbc:mysql://localhost/" />
+<property name="username" value="root" />
+<property name="password" value="admin" /></programlisting>
+
+ <para>PostgreSQL:</para>
+
+ <programlisting><property name="driverClassName" value="org.postgresql.Driver" />
+<property name="url" value="jdbc:postgresql://localhost/" />
+<property name="username" value="root" />
+<property name="password" value="admin" /></programlisting>
+
+ <para>MSSQL:</para>
+
+ <programlisting><property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
+<property name="url" value="jdbc:sqlserver://localhost:1433;"/>
+<property name="username" value="root"/>
+<property name="password" value="admin"/></programlisting>
+
+ <para>Sybase:</para>
+
+ <programlisting><property name="driverClassName" value="com.sybase.jdbc3.jdbc.SybDriver" />
+<property name="url" value="jdbc:sybase:Tds:localhost:5000/"/>
+<property name="username" value="root"/>
+<property name="password" value="admin"/></programlisting>
+
+ <para>Oracle:</para>
+
+ <programlisting><property name="driverClassName" value="oracle.jdbc.OracleDriver" />
+<property name="url" value="jdbc:oracle:thin:@db2.exoua-int:1521:orclvm" />
+<property name="username" value="root" />
+<property name="password" value="admin" /></programlisting>
+ </section>
+
+ <section>
+ <title>An examples of a DDL script</title>
+
+ <para>MySQL:</para>
+
+ <programlisting>CREATE DATABASE ${database};
+USE ${database};
+CREATE USER '${username}' IDENTIFIED BY '${password}';
+GRANT SELECT,INSERT,UPDATE,DELETE ON ${database}.* TO '${username}';</programlisting>
+
+ <para>PostgreSQL:</para>
+
+ <programlisting>CREATE USER ${username} WITH PASSWORD '${password}';
+CREATE DATABASE ${database} WITH OWNER ${username};</programlisting>
+
+ <para>MSSQL:</para>
+
+ <programlisting>USE MASTER;
+CREATE DATABASE ${database};
+USE ${database};
+CREATE LOGIN ${username} WITH PASSWORD = '${password}';
+CREATE USER ${username} FOR LOGIN ${username};</programlisting>
+
+ <para>Sybase:</para>
+
+ <programlisting>sp_addlogin ${username}, ${password};
+CREATE DATABASE ${database};
+USE ${database};
+sp_adduser ${username};</programlisting>
+
+ <para>Oracle:</para>
+
+ <programlisting>CREATE TABLESPACE "${database}" DATAFILE '/var/oracle_db/orclvm/${database}' SIZE 10M AUTOEXTEND ON NEXT 6M MAXSIZE UNLIMITED LOGGING EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;
+CREATE TEMPORARY TABLESPACE "${database}.TEMP" TEMPFILE '/var/oracle_db/orclvm/${database}.temp' SIZE 5M AUTOEXTEND ON NEXT 5M MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M;
+CREATE USER "${username}" PROFILE "DEFAULT" IDENTIFIED BY "${password}" DEFAULT TABLESPACE "${database}" TEMPORARY TABLESPACE "${database}.TEMP" ACCOUNT UNLOCK;
+GRANT CREATE SEQUENCE TO "${username}";
+GRANT CREATE TABLE TO "${username}";
+GRANT CREATE TRIGGER TO "${username}";
+GRANT UNLIMITED TABLESPACE TO "${username}";
+GRANT "CONNECT" TO "${username}";
+GRANT "RESOURCE" TO "${username}";</programlisting>
+ </section>
+</chapter>
Added: core/trunk/docs/reference/en/src/main/docbook/en-US/modules/services.xml
===================================================================
--- core/trunk/docs/reference/en/src/main/docbook/en-US/modules/services.xml (rev 0)
+++ core/trunk/docs/reference/en/src/main/docbook/en-US/modules/services.xml 2010-03-22 13:34:06 UTC (rev 2095)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<part>
+ <?dbhtml filename="part-services.html"?>
+
+ <title>Core</title>
+
+ <xi:include href="services/db-creator-service.xml"
+ xmlns:xi="http://www.w3.org/2001/XInclude" />
+
+</part>
Added: core/trunk/docs/reference/pom.xml
===================================================================
--- core/trunk/docs/reference/pom.xml (rev 0)
+++ core/trunk/docs/reference/pom.xml 2010-03-22 13:34:06 UTC (rev 2095)
@@ -0,0 +1,38 @@
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.exoplatform.core</groupId>
+ <artifactId>docs</artifactId>
+ <version>2.3.1-GA-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>reference-docs</artifactId>
+
+ <name>Core reference documentation</name>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>en</module>
+ </modules>
+</project>
16 years, 1 month
exo-jcr SVN: r2094 - core/trunk.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-03-22 09:31:51 -0400 (Mon, 22 Mar 2010)
New Revision: 2094
Modified:
core/trunk/pom.xml
Log:
EXOJCR-573: add DBCreator docbook
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2010-03-22 12:53:09 UTC (rev 2093)
+++ core/trunk/pom.xml 2010-03-22 13:31:51 UTC (rev 2094)
@@ -40,6 +40,7 @@
<org.exoplatform.framework.junit.version>1.2.2-GA-SNAPSHOT</org.exoplatform.framework.junit.version>
<org.exoplatform.kernel.version>2.2.1-GA-SNAPSHOT</org.exoplatform.kernel.version>
+ <org.exoplatform.doc-style.version>2-SNAPSHOT</org.exoplatform.doc-style.version>
</properties>
<scm>
16 years, 1 month
exo-jcr SVN: r2093 - jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/jcr.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2010-03-22 08:53:09 -0400 (Mon, 22 Mar 2010)
New Revision: 2093
Modified:
jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/jcr/jdbc-data-container-config.xml
Log:
EXOJCR-598: documentation about Query hints parameter added
Modified: jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/jcr/jdbc-data-container-config.xml
===================================================================
--- jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/jcr/jdbc-data-container-config.xml 2010-03-22 12:17:37 UTC (rev 2092)
+++ jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/jcr/jdbc-data-container-config.xml 2010-03-22 12:53:09 UTC (rev 2093)
@@ -1,533 +1,592 @@
-<?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 id="ch_jdbc_data_container">
- <?dbhtml filename="ch-jdbc-data-container-config.html"?>
-
- <title>JDBC Data Container Config</title>
-
- <section>
- <title>Introduction</title>
-
- <para>eXo JCR persistent data container can work in two configuration
- modes:<itemizedlist>
- <listitem>
- <para><phrase>Multi-database</phrase>: one database for each
- workspace (used in standalone eXo JCR service mode)</para>
- </listitem>
-
- <listitem>
- <para><phrase>Single-database</phrase>: all workspaces persisted in
- one database (used in embedded eXo JCR service mode, e.g. in eXo
- portal)</para>
- </listitem>
- </itemizedlist></para>
-
- <para>The data container uses the JDBC driver to communicate with the
- actual database software, i.e. any JDBC-enabled data storage can be used
- with eXo JCR implementation.</para>
-
- <para>Currently the data container is tested with the following
- RDBMS:<itemizedlist>
- <listitem>
- <para>MySQL (5.x including UTF8 support)</para>
- </listitem>
-
- <listitem>
- <para>PostgreSQL (8.x)</para>
- </listitem>
-
- <listitem>
- <para>Oracle Database (9i, 10g)</para>
- </listitem>
-
- <listitem>
- <para>Microsoft SQL Server (2005)</para>
- </listitem>
-
- <listitem>
- <para>Sybase ASE (15.0)</para>
- </listitem>
-
- <listitem>
- <para>Apache Derby/Java DB (10.1.x, 10.2.x)</para>
- </listitem>
-
- <listitem>
- <para>IBM DB2 (8.x, 9.x)</para>
- </listitem>
-
- <listitem>
- <para>HSQLDB (1.8.0.7)</para>
- </listitem>
- </itemizedlist></para>
-
- <para>Each database software supports ANSI SQL standards but has its own
- specifics too. So, each database has its own configuration in eXo JCR as a
- database dialect parameter. If you need a more detailed configuration of
- the database it's possible to do that by editing the metadata SQL-script
- files.</para>
-
- <para>In case the non-ANSI node name is used it's necessary to use a
- database with MultiLanguage support[TODO link to MultiLanguage]. Some JDBC
- drivers need additional parameters for establishing a Unicode friendly
- connection. E.g. under mysql it's necessary to add an additional parameter
- for the JDBC driver at the end of JDBC URL. For instance:
- <code>jdbc:mysql://exoua.dnsalias.net/portal?characterEncoding=utf8</code></para>
-
- <para>There are preconfigured configuration files for HSQLDB. Look for
- these files in /conf/portal and /conf/standalone folders of the jar-file
- <package>exo.jcr.component.core-XXX.XXX.jar</package> or
- source-distribution of eXo JCR implementation.</para>
-
- <para>By default the configuration files are located in service jars
- <filename>/conf/portal/configuration.xml</filename> (eXo services
- including JCR Repository Service) and
- <filename>exo-jcr-config.xml</filename> (repositories configuration). In
- eXo portal product JCR is configured in portal web application
- <filename>portal/WEB-INF/conf/jcr/jcr-configuration.xml</filename> (JCR
- Repository Service and related serivces) and repository-configuration.xml
- (repositories configuration).</para>
-
- <para>Read more about <link linkend="ch_configuration">Repository
- configuration</link>.</para>
- </section>
-
- <section>
- <title>Multi-database Configuration</title>
-
- <para>You need to configure each workspace in a repository. You may have
- each one on different remote servers as far as you need.</para>
-
- <para>First of all configure the data containers in the
- <classname>org.exoplatform.services.naming.InitialContextInitializer</classname>
- service. It's the JNDI context initializer which registers (binds) naming
- resources (DataSources) for data containers.</para>
-
- <para>Example (standalone mode, two data containers
- <parameter>jdbcjcr</parameter> - local HSQLDB,
- <parameter>jdbcjcr1</parameter> - remote MySQL):<programlisting><component>
- <key>org.exoplatform.services.naming.InitialContextInitializer</key>
- <type>org.exoplatform.services.naming.InitialContextInitializer</type>
- <component-plugins>
- <component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcr</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
- <property name="url" value="jdbc:hsqldb:file:target/temp/data/portal"/>
- <property name="username" value="sa"/>
- <property name="password" value=""/>
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcr1</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
- <property name="url" value="jdbc:mysql://exoua.dnsalias.net/jcr"/>
- <property name="username" value="exoadmin"/>
- <property name="password" value="exo12321"/>
- <property name="maxActive" value="50"/>
- <property name="maxIdle" value="5"/>
- <property name="initialSize" value="5"/>
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugins>
- <init-params>
- <value-param>
- <name>default-context-factory</name>
- <value>org.exoplatform.services.naming.SimpleContextFactory</value>
- </value-param>
- </init-params>
- </component></programlisting></para>
-
- <para>We configure the database connection parameters:<itemizedlist>
- <listitem>
- <para><parameter>driverClassName</parameter>, e.g.
- "org.hsqldb.jdbcDriver", "com.mysql.jdbc.Driver",
- "org.postgresql.Driver"</para>
- </listitem>
-
- <listitem>
- <para><parameter>url</parameter>, e.g.
- "jdbc:hsqldb:file:target/temp/data/portal",
- "jdbc:mysql://exoua.dnsalias.net/jcr"</para>
- </listitem>
-
- <listitem>
- <para><parameter>username</parameter>, e.g. "sa", "exoadmin"</para>
- </listitem>
-
- <listitem>
- <para><parameter>password</parameter>, e.g. "", "exo12321"</para>
- </listitem>
- </itemizedlist></para>
-
- <para>There can be connection pool configuration parameters
- (org.apache.commons.dbcp.BasicDataSourceFactory):<itemizedlist>
- <listitem>
- <para><parameter>maxActive</parameter>, e.g. 50</para>
- </listitem>
-
- <listitem>
- <para><parameter>maxIdle</parameter>, e.g. 5</para>
- </listitem>
-
- <listitem>
- <para><parameter>initialSize</parameter>, e.g. 5</para>
- </listitem>
-
- <listitem>
- <para>and other according to <ulink
- url="http://jakarta.apache.org/commons/dbcp/configuration.html">Apache
- DBCP configuration</ulink></para>
- </listitem>
- </itemizedlist></para>
-
- <para>When the data container configuration is done we can configure the
- repository service. Each workspace will be configured for its own data
- container.</para>
-
- <para>Example (two workspaces <parameter>ws</parameter> - jdbcjcr,
- <parameter>ws1</parameter> - jdbcjcr1):<programlisting><workspaces>
- <workspace name="ws" auto-init-root-nodetype="nt:unstructured">
- <container class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
- <properties>
- <property name="source-name" value="jdbcjcr"/>
- <property name="dialect" value="hsqldb"/>
- <property name="multi-db" value="true"/>
- <property name="max-buffer-size" value="200K"/>
- <property name="swap-directory" value="target/temp/swap/ws"/>
- </properties>
- </container>
- <cache enabled="true">
- <properties>
- <property name="max-size" value="10K"/><!-- 10Kbytes -->
- <property name="live-time" value="30m"/><!-- 30 min -->
- </properties>
- </cache>
- <query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
- <properties>
- <property name="index-dir" value="target/temp/index"/>
- </properties>
- </query-handler>
- <lock-manager>
- <time-out>15m</time-out><!-- 15 min -->
- <persister class="org.exoplatform.services.jcr.impl.core.lock.FileSystemLockPersister">
- <properties>
- <property name="path" value="target/temp/lock/ws"/>
- </properties>
- </persister>
- </lock-manager>
- </workspace>
- <workspace name="ws1" auto-init-root-nodetype="nt:unstructured">
- <container class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
- <properties>
- <property name="source-name" value="jdbcjcr1"/>
- <property name="dialect" value="mysql"/>
- <property name="multi-db" value="true"/>
- <property name="max-buffer-size" value="200K"/>
- <property name="swap-directory" value="target/temp/swap/ws1"/>
- </properties>
- </container>
- <cache enabled="true">
- <properties>
- <property name="max-size" value="10K"/>
- <property name="live-time" value="5m"/>
- </properties>
- </cache>
- <query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
- <properties>
- <property name="index-dir" value="target/temp/index"/>
- </properties>
- </query-handler>
- <lock-manager>
- <time-out>15m</time-out><!-- 15 min -->
- <persister class="org.exoplatform.services.jcr.impl.core.lock.FileSystemLockPersister">
- <properties>
- <property name="path" value="target/temp/lock/ws1"/>
- </properties>
- </persister>
- </lock-manager>
- </workspace>
-</workspaces></programlisting><itemizedlist>
- <listitem>
- <para><parameter>source-name</parameter> - a javax.sql.DataSource
- name configured in InitialContextInitializer component (was
- <parameter>sourceName</parameter> prior JCR 1.9);</para>
- </listitem>
-
- <listitem>
- <para><parameter>dialect</parameter> - a database dialect, one of
- "hsqldb", "mysql", "mysql-utf8", "pgsql", "oracle", "oracle-oci",
- "mssql", "sybase", "derby", "db2", "db2v8".</para>
- </listitem>
-
- <listitem>
- <para><parameter>multi-db</parameter> - enable multi-database
- container with this parameter (set value "true");</para>
- </listitem>
-
- <listitem>
- <para><parameter>max-buffer-size</parameter> - a threshold (in
- bytes) after which a javax.jcr.Value content will be swapped to a
- file in a temporary storage. I.e. swap for pending changes.</para>
- </listitem>
-
- <listitem>
- <para><parameter>swap-directory</parameter> - a path in the file
- system used to swap the pending changes.</para>
- </listitem>
- </itemizedlist></para>
-
- <para>In this way we have configured two workspace which will be persisted
- in two different databases (ws in HSQLDB, ws1 in MySQL).</para>
-
- <note>
- <para> Starting from v.1.9 <link linkend="ch_configuration">repository
- configuration</link> parameters supports human-readable formats of
- values (e.g. 200K - 200 Kbytes, 30m - 30 minutes etc)</para>
- </note>
- </section>
-
- <section>
- <title>Single-database configuration</title>
-
- <para>It's more simple to configure a single-database data container. We
- have to configure one naming resource.</para>
-
- <para>Example (embedded mode for <parameter>jdbcjcr</parameter> data
- container):<programlisting><external-component-plugins>
- <target-component>org.exoplatform.services.naming.InitialContextInitializer</target-component>
- <component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcr</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="driverClassName" value="org.postgresql.Driver"/>
- <property name="url" value="jdbc:postgresql://exoua.dnsalias.net/portal"/>
- <property name="username" value="exoadmin"/>
- <property name="password" value="exo12321"/>
- <property name="maxActive" value="50"/>
- <property name="maxIdle" value="5"/>
- <property name="initialSize" value="5"/>
- </properties-param>
- </init-params>
- </component-plugin>
- </external-component-plugins></programlisting></para>
-
- <para>And configure repository workspaces in repositories configuration
- with this one database. Parameter "multi-db" must be switched off (set
- value "false").</para>
-
- <para>Example (two workspaces <parameter>ws</parameter> - jdbcjcr,
- <parameter>ws1</parameter> - jdbcjcr):<programlisting><workspaces>
- <workspace name="ws" auto-init-root-nodetype="nt:unstructured">
- <container class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
- <properties>
- <property name="source-name" value="jdbcjcr"/>
- <property name="dialect" value="pgsql"/>
- <property name="multi-db" value="false"/>
- <property name="max-buffer-size" value="200K"/>
- <property name="swap-directory" value="target/temp/swap/ws"/>
- </properties>
- </container>
- <cache enabled="true">
- <properties>
- <property name="max-size" value="10K"/>
- <property name="live-time" value="30m"/>
- </properties>
- </cache>
- <query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
- <properties>
- <property name="index-dir" value="../temp/index"/>
- </properties>
- </query-handler>
- <lock-manager>
- <time-out>15m</time-out>
- <persister class="org.exoplatform.services.jcr.impl.core.lock.FileSystemLockPersister">
- <properties>
- <property name="path" value="target/temp/lock/ws"/>
- </properties>
- </persister>
- </lock-manager>
- </workspace>
- <workspace name="ws1" auto-init-root-nodetype="nt:unstructured">
- <container class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
- <properties>
- <property name="source-name" value="jdbcjcr"/>
- <property name="dialect" value="pgsql"/>
- <property name="multi-db" value="false"/>
- <property name="max-buffer-size" value="200K"/>
- <property name="swap-directory" value="target/temp/swap/ws1"/>
- </properties>
- </container>
- <cache enabled="true">
- <properties>
- <property name="max-size" value="10K"/>
- <property name="live-time" value="5m"/>
- </properties>
- </cache>
- <lock-manager>
- <time-out>15m</time-out>
- <persister class="org.exoplatform.services.jcr.impl.core.lock.FileSystemLockPersister">
- <properties>
- <property name="path" value="target/temp/lock/ws1"/>
- </properties>
- </persister>
- </lock-manager>
- </workspace>
-</workspaces></programlisting></para>
-
- <para>In this way we have configured two workspaces which will be
- persisted in one database (PostgreSQL).</para>
-
- <section>
- <title>Configuration without DataSource</title>
-
- <para>Repository configuration without using of the
- <classname>javax.sql.DataSource</classname> bounded in JNDI.</para>
-
- <para>This case may be usable if you have a dedicated JDBC driver
- implementation with special features like XA transactions,
- statements/connections pooling etc:<itemizedlist>
- <listitem>
- <para>You have to remove the configuration in
- <classname>InitialContextInitializer</classname> for your database
- and configure a new one directly in the workspace
- container.</para>
- </listitem>
-
- <listitem>
- <para>Remove parameter "source-name" and add next lines instead.
- Describe your values for a JDBC driver, database url and
- username.</para>
- </listitem>
- </itemizedlist></para>
-
- <note>
- <para>But be careful in this case JDBC driver should implement and
- provide connection pooling. Connection pooling is very recommended for
- use with JCR to prevent a database overload.</para>
- </note>
-
- <programlisting><workspace name="ws" auto-init-root-nodetype="nt:unstructured">
- <container class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
- <properties>
- <property name="dialect" value="hsqldb"/>
- <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
- <property name="url" value="jdbc:hsqldb:file:target/temp/data/portal"/>
- <property name="username" value="su"/>
- <property name="password" value=""/>
- ......</programlisting>
- </section>
-
- <section>
- <title>Dynamic Workspace Creation</title>
-
- <para>Workspaces can be added dynamically during runtime.</para>
-
- <para>This can be performed in two steps:<itemizedlist>
- <listitem>
- <para>Firstly,
- <classname>ManageableRepository.configWorkspace(WorkspaceEntry
- wsConfig)</classname> - register a new configuration in
- RepositoryContainer and create a WorkspaceContainer.</para>
- </listitem>
-
- <listitem>
- <para>Secondly, the main step,
- <classname>ManageableRepository.createWorkspace(String
- workspaceName)</classname> - creation of a new workspace.</para>
- </listitem>
- </itemizedlist></para>
- </section>
- </section>
-
- <section>
- <title>Notes for Microsoft Windows users</title>
-
- <para>The current configuration of eXo JCR uses Apache DBCP connection
- pool
- (<classname>org.apache.commons.dbcp.BasicDataSourceFactory</classname>).
- It's possible to set a big value for maxActive parameter in
- <filename>configuration.xml</filename>. That means usage of lots of TCP/IP
- ports from a client machine inside the pool (i.e. JDBC driver). As a
- result the data container can throw exceptions like "Address already in
- use". To solve this problem you have to configure the client's machine
- networking software for the usage of shorter timeouts for opened TCP/IP
- ports.</para>
-
- <para>Microsoft Windows has <parameter>MaxUserPort</parameter>,
- <parameter>TcpTimedWaitDelay</parameter> registry keys in the node
- <parameter>HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParameters</parameter>,
- by default these keys are unset, set each one with values like
- these:<itemizedlist>
- <listitem>
- <para>"TcpTimedWaitDelay"=dword:0000001e, sets TIME_WAIT parameter
- to 30 seconds, default is 240.</para>
- </listitem>
-
- <listitem>
- <para>"MaxUserPort"=dword:00001b58, sets the maximum of open ports
- to 7000 or higher, default is 5000.</para>
- </listitem>
- </itemizedlist></para>
-
- <para>A sample registry file is below:<programlisting>Windows Registry Editor Version 5.00
-
-[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]
-"MaxUserPort"=dword:00001b58
-"TcpTimedWaitDelay"=dword:0000001e</programlisting></para>
- </section>
-</chapter>
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<chapter id="ch_jdbc_data_container">
+ <?dbhtml filename="ch-jdbc-data-container-config.html"?>
+
+ <title>JDBC Data Container Config</title>
+
+ <section>
+ <title>Introduction</title>
+
+ <para>eXo JCR persistent data container can work in two configuration
+ modes:<itemizedlist>
+ <listitem>
+ <para><phrase>Multi-database</phrase>: one database for each
+ workspace (used in standalone eXo JCR service mode)</para>
+ </listitem>
+
+ <listitem>
+ <para><phrase>Single-database</phrase>: all workspaces persisted in
+ one database (used in embedded eXo JCR service mode, e.g. in eXo
+ portal)</para>
+ </listitem>
+ </itemizedlist></para>
+
+ <para>The data container uses the JDBC driver to communicate with the
+ actual database software, i.e. any JDBC-enabled data storage can be used
+ with eXo JCR implementation.</para>
+
+ <para>Currently the data container is tested with the following
+ RDBMS:<itemizedlist>
+ <listitem>
+ <para>MySQL (5.x including UTF8 support)</para>
+ </listitem>
+
+ <listitem>
+ <para>PostgreSQL (8.x)</para>
+ </listitem>
+
+ <listitem>
+ <para>Oracle Database (9i, 10g)</para>
+ </listitem>
+
+ <listitem>
+ <para>Microsoft SQL Server (2005)</para>
+ </listitem>
+
+ <listitem>
+ <para>Sybase ASE (15.0)</para>
+ </listitem>
+
+ <listitem>
+ <para>Apache Derby/Java DB (10.1.x, 10.2.x)</para>
+ </listitem>
+
+ <listitem>
+ <para>IBM DB2 (8.x, 9.x)</para>
+ </listitem>
+
+ <listitem>
+ <para>HSQLDB (1.8.0.7)</para>
+ </listitem>
+ </itemizedlist></para>
+
+ <para>Each database software supports ANSI SQL standards but has its own
+ specifics too. So, each database has its own configuration in eXo JCR as a
+ database dialect parameter. If you need a more detailed configuration of
+ the database it's possible to do that by editing the metadata SQL-script
+ files.</para>
+
+ <para>In case the non-ANSI node name is used it's necessary to use a
+ database with MultiLanguage support[TODO link to MultiLanguage]. Some JDBC
+ drivers need additional parameters for establishing a Unicode friendly
+ connection. E.g. under mysql it's necessary to add an additional parameter
+ for the JDBC driver at the end of JDBC URL. For instance:
+ <code>jdbc:mysql://exoua.dnsalias.net/portal?characterEncoding=utf8</code></para>
+
+ <para>There are preconfigured configuration files for HSQLDB. Look for
+ these files in /conf/portal and /conf/standalone folders of the jar-file
+ <package>exo.jcr.component.core-XXX.XXX.jar</package> or
+ source-distribution of eXo JCR implementation.</para>
+
+ <para>By default the configuration files are located in service jars
+ <filename>/conf/portal/configuration.xml</filename> (eXo services
+ including JCR Repository Service) and
+ <filename>exo-jcr-config.xml</filename> (repositories configuration). In
+ eXo portal product JCR is configured in portal web application
+ <filename>portal/WEB-INF/conf/jcr/jcr-configuration.xml</filename> (JCR
+ Repository Service and related serivces) and repository-configuration.xml
+ (repositories configuration).</para>
+
+ <para>Read more about <link linkend="ch_configuration">Repository
+ configuration</link>.</para>
+ </section>
+
+ <section>
+ <title>Multi-database Configuration</title>
+
+ <para>You need to configure each workspace in a repository. You may have
+ each one on different remote servers as far as you need.</para>
+
+ <para>First of all configure the data containers in the
+ <classname>org.exoplatform.services.naming.InitialContextInitializer</classname>
+ service. It's the JNDI context initializer which registers (binds) naming
+ resources (DataSources) for data containers.</para>
+
+ <para>Example (standalone mode, two data containers
+ <parameter>jdbcjcr</parameter> - local HSQLDB,
+ <parameter>jdbcjcr1</parameter> - remote MySQL):<programlisting><component>
+ <key>org.exoplatform.services.naming.InitialContextInitializer</key>
+ <type>org.exoplatform.services.naming.InitialContextInitializer</type>
+ <component-plugins>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
+ <property name="url" value="jdbc:hsqldb:file:target/temp/data/portal"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr1</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
+ <property name="url" value="jdbc:mysql://exoua.dnsalias.net/jcr"/>
+ <property name="username" value="exoadmin"/>
+ <property name="password" value="exo12321"/>
+ <property name="maxActive" value="50"/>
+ <property name="maxIdle" value="5"/>
+ <property name="initialSize" value="5"/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugins>
+ <init-params>
+ <value-param>
+ <name>default-context-factory</name>
+ <value>org.exoplatform.services.naming.SimpleContextFactory</value>
+ </value-param>
+ </init-params>
+ </component></programlisting></para>
+
+ <para>We configure the database connection parameters:<itemizedlist>
+ <listitem>
+ <para><parameter>driverClassName</parameter>, e.g.
+ "org.hsqldb.jdbcDriver", "com.mysql.jdbc.Driver",
+ "org.postgresql.Driver"</para>
+ </listitem>
+
+ <listitem>
+ <para><parameter>url</parameter>, e.g.
+ "jdbc:hsqldb:file:target/temp/data/portal",
+ "jdbc:mysql://exoua.dnsalias.net/jcr"</para>
+ </listitem>
+
+ <listitem>
+ <para><parameter>username</parameter>, e.g. "sa", "exoadmin"</para>
+ </listitem>
+
+ <listitem>
+ <para><parameter>password</parameter>, e.g. "", "exo12321"</para>
+ </listitem>
+ </itemizedlist></para>
+
+ <para>There can be connection pool configuration parameters
+ (org.apache.commons.dbcp.BasicDataSourceFactory):<itemizedlist>
+ <listitem>
+ <para><parameter>maxActive</parameter>, e.g. 50</para>
+ </listitem>
+
+ <listitem>
+ <para><parameter>maxIdle</parameter>, e.g. 5</para>
+ </listitem>
+
+ <listitem>
+ <para><parameter>initialSize</parameter>, e.g. 5</para>
+ </listitem>
+
+ <listitem>
+ <para>and other according to <ulink
+ url="http://jakarta.apache.org/commons/dbcp/configuration.html">Apache
+ DBCP configuration</ulink></para>
+ </listitem>
+ </itemizedlist></para>
+
+ <para>When the data container configuration is done we can configure the
+ repository service. Each workspace will be configured for its own data
+ container.</para>
+
+ <para>Example (two workspaces <parameter>ws</parameter> - jdbcjcr,
+ <parameter>ws1</parameter> - jdbcjcr1):<programlisting><workspaces>
+ <workspace name="ws" auto-init-root-nodetype="nt:unstructured">
+ <container class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
+ <properties>
+ <property name="source-name" value="jdbcjcr"/>
+ <property name="dialect" value="hsqldb"/>
+ <property name="multi-db" value="true"/>
+ <property name="max-buffer-size" value="200K"/>
+ <property name="swap-directory" value="target/temp/swap/ws"/>
+ </properties>
+ </container>
+ <cache enabled="true">
+ <properties>
+ <property name="max-size" value="10K"/><!-- 10Kbytes -->
+ <property name="live-time" value="30m"/><!-- 30 min -->
+ </properties>
+ </cache>
+ <query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="index-dir" value="target/temp/index"/>
+ </properties>
+ </query-handler>
+ <lock-manager>
+ <time-out>15m</time-out><!-- 15 min -->
+ <persister class="org.exoplatform.services.jcr.impl.core.lock.FileSystemLockPersister">
+ <properties>
+ <property name="path" value="target/temp/lock/ws"/>
+ </properties>
+ </persister>
+ </lock-manager>
+ </workspace>
+ <workspace name="ws1" auto-init-root-nodetype="nt:unstructured">
+ <container class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
+ <properties>
+ <property name="source-name" value="jdbcjcr1"/>
+ <property name="dialect" value="mysql"/>
+ <property name="multi-db" value="true"/>
+ <property name="max-buffer-size" value="200K"/>
+ <property name="swap-directory" value="target/temp/swap/ws1"/>
+ </properties>
+ </container>
+ <cache enabled="true">
+ <properties>
+ <property name="max-size" value="10K"/>
+ <property name="live-time" value="5m"/>
+ </properties>
+ </cache>
+ <query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="index-dir" value="target/temp/index"/>
+ </properties>
+ </query-handler>
+ <lock-manager>
+ <time-out>15m</time-out><!-- 15 min -->
+ <persister class="org.exoplatform.services.jcr.impl.core.lock.FileSystemLockPersister">
+ <properties>
+ <property name="path" value="target/temp/lock/ws1"/>
+ </properties>
+ </persister>
+ </lock-manager>
+ </workspace>
+</workspaces></programlisting><itemizedlist>
+ <listitem>
+ <para><parameter>source-name</parameter> - a javax.sql.DataSource
+ name configured in InitialContextInitializer component (was
+ <parameter>sourceName</parameter> prior JCR 1.9);</para>
+ </listitem>
+
+ <listitem>
+ <para><parameter>dialect</parameter> - a database dialect, one of
+ "hsqldb", "mysql", "mysql-utf8", "pgsql", "oracle", "oracle-oci",
+ "mssql", "sybase", "derby", "db2", "db2v8" or "auto" for dialect
+ autodetection;</para>
+ </listitem>
+
+ <listitem>
+ <para><parameter>multi-db</parameter> - enable multi-database
+ container with this parameter (set value "true");</para>
+ </listitem>
+
+ <listitem>
+ <para><parameter>max-buffer-size</parameter> - a threshold (in
+ bytes) after which a javax.jcr.Value content will be swapped to a
+ file in a temporary storage. I.e. swap for pending changes.</para>
+ </listitem>
+
+ <listitem>
+ <para><parameter>swap-directory</parameter> - a path in the file
+ system used to swap the pending changes.</para>
+ </listitem>
+ </itemizedlist></para>
+
+ <para>In this way we have configured two workspace which will be persisted
+ in two different databases (ws in HSQLDB, ws1 in MySQL).</para>
+
+ <note>
+ <para>Starting from v.1.9 <link linkend="ch_configuration">repository
+ configuration</link> parameters supports human-readable formats of
+ values (e.g. 200K - 200 Kbytes, 30m - 30 minutes etc)</para>
+ </note>
+ </section>
+
+ <section>
+ <title>Single-database configuration</title>
+
+ <para>It's more simple to configure a single-database data container. We
+ have to configure one naming resource.</para>
+
+ <para>Example (embedded mode for <parameter>jdbcjcr</parameter> data
+ container):<programlisting><external-component-plugins>
+ <target-component>org.exoplatform.services.naming.InitialContextInitializer</target-component>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName" value="org.postgresql.Driver"/>
+ <property name="url" value="jdbc:postgresql://exoua.dnsalias.net/portal"/>
+ <property name="username" value="exoadmin"/>
+ <property name="password" value="exo12321"/>
+ <property name="maxActive" value="50"/>
+ <property name="maxIdle" value="5"/>
+ <property name="initialSize" value="5"/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins></programlisting></para>
+
+ <para>And configure repository workspaces in repositories configuration
+ with this one database. Parameter "multi-db" must be switched off (set
+ value "false").</para>
+
+ <para>Example (two workspaces <parameter>ws</parameter> - jdbcjcr,
+ <parameter>ws1</parameter> - jdbcjcr):<programlisting><workspaces>
+ <workspace name="ws" auto-init-root-nodetype="nt:unstructured">
+ <container class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
+ <properties>
+ <property name="source-name" value="jdbcjcr"/>
+ <property name="dialect" value="pgsql"/>
+ <property name="multi-db" value="false"/>
+ <property name="max-buffer-size" value="200K"/>
+ <property name="swap-directory" value="target/temp/swap/ws"/>
+ </properties>
+ </container>
+ <cache enabled="true">
+ <properties>
+ <property name="max-size" value="10K"/>
+ <property name="live-time" value="30m"/>
+ </properties>
+ </cache>
+ <query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="index-dir" value="../temp/index"/>
+ </properties>
+ </query-handler>
+ <lock-manager>
+ <time-out>15m</time-out>
+ <persister class="org.exoplatform.services.jcr.impl.core.lock.FileSystemLockPersister">
+ <properties>
+ <property name="path" value="target/temp/lock/ws"/>
+ </properties>
+ </persister>
+ </lock-manager>
+ </workspace>
+ <workspace name="ws1" auto-init-root-nodetype="nt:unstructured">
+ <container class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
+ <properties>
+ <property name="source-name" value="jdbcjcr"/>
+ <property name="dialect" value="pgsql"/>
+ <property name="multi-db" value="false"/>
+ <property name="max-buffer-size" value="200K"/>
+ <property name="swap-directory" value="target/temp/swap/ws1"/>
+ </properties>
+ </container>
+ <cache enabled="true">
+ <properties>
+ <property name="max-size" value="10K"/>
+ <property name="live-time" value="5m"/>
+ </properties>
+ </cache>
+ <lock-manager>
+ <time-out>15m</time-out>
+ <persister class="org.exoplatform.services.jcr.impl.core.lock.FileSystemLockPersister">
+ <properties>
+ <property name="path" value="target/temp/lock/ws1"/>
+ </properties>
+ </persister>
+ </lock-manager>
+ </workspace>
+</workspaces></programlisting></para>
+
+ <para>In this way we have configured two workspaces which will be
+ persisted in one database (PostgreSQL).</para>
+
+ <section>
+ <title>Configuration without DataSource</title>
+
+ <para>Repository configuration without using of the
+ <classname>javax.sql.DataSource</classname> bounded in JNDI.</para>
+
+ <para>This case may be usable if you have a dedicated JDBC driver
+ implementation with special features like XA transactions,
+ statements/connections pooling etc:<itemizedlist>
+ <listitem>
+ <para>You have to remove the configuration in
+ <classname>InitialContextInitializer</classname> for your database
+ and configure a new one directly in the workspace
+ container.</para>
+ </listitem>
+
+ <listitem>
+ <para>Remove parameter "source-name" and add next lines instead.
+ Describe your values for a JDBC driver, database url and
+ username.</para>
+ </listitem>
+ </itemizedlist></para>
+
+ <note>
+ <para>But be careful in this case JDBC driver should implement and
+ provide connection pooling. Connection pooling is very recommended for
+ use with JCR to prevent a database overload.</para>
+ </note>
+
+ <programlisting><workspace name="ws" auto-init-root-nodetype="nt:unstructured">
+ <container class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
+ <properties>
+ <property name="dialect" value="hsqldb"/>
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
+ <property name="url" value="jdbc:hsqldb:file:target/temp/data/portal"/>
+ <property name="username" value="su"/>
+ <property name="password" value=""/>
+ ......</programlisting>
+ </section>
+
+ <section>
+ <title>Dynamic Workspace Creation</title>
+
+ <para>Workspaces can be added dynamically during runtime.</para>
+
+ <para>This can be performed in two steps:<itemizedlist>
+ <listitem>
+ <para>Firstly,
+ <classname>ManageableRepository.configWorkspace(WorkspaceEntry
+ wsConfig)</classname> - register a new configuration in
+ RepositoryContainer and create a WorkspaceContainer.</para>
+ </listitem>
+
+ <listitem>
+ <para>Secondly, the main step,
+ <classname>ManageableRepository.createWorkspace(String
+ workspaceName)</classname> - creation of a new workspace.</para>
+ </listitem>
+ </itemizedlist></para>
+ </section>
+ </section>
+
+ <section>
+ <title>Simple and Complex queries</title>
+
+ <para>eXo JCR provides two ways for interact with Database -
+ <classname>JDBCStorageConnection</classname> that uses simple queries and
+ <classname>CQJDBCStorageConection</classname> that uses complex queries
+ for reducing amount of database callings.</para>
+
+ <para>Simple queries will be used if you chose
+ <classname>org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer</classname>:<programlisting><workspaces>
+ <workspace name="ws" auto-init-root-nodetype="nt:unstructured">
+ <container class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
+ ...
+ </workspace>
+</worksapces></programlisting></para>
+
+ <para>Complex queries will be used if you chose
+ <classname>org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer</classname>:<programlisting><workspaces>
+ <workspace name="ws" auto-init-root-nodetype="nt:unstructured">
+ <container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
+ ...
+ </workspace>
+</worksapces></programlisting></para>
+
+ <para>Why we should use a Complex Queries?<simplelist>
+ <member>They are optimised to reduce amount of requests to
+ database.</member>
+ </simplelist>Why we should use a Simple Queries?<simplelist>
+ <member>Simple queries implemented in way to support as many database
+ dialects as possible.</member>
+
+ <member>Simple queries do not use sub queries, left or right
+ joins.</member>
+ </simplelist></para>
+ </section>
+
+ <section>
+ <title>Forse Query Hints</title>
+
+ <para>Some databases supports hints to increase query performance (like
+ Oracle, MySQL, etc). eXo JCR have separate Complex Query implementation
+ for Orcale dialect, that uses query hints to increase performance for few
+ important queries. </para>
+
+ <para>To enable this option put next configuration
+ property:<programlisting><workspace name="ws" auto-init-root-nodetype="nt:unstructured">
+ <container class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
+ <properties>
+ <property name="dialect" value="oracle"/>
+ <property name="force.query.hints" value="true" />
+ ......</programlisting></para>
+
+ <para>Query hints enabled by default. </para>
+
+ <para>eXo JCR uses query hints only for Complex Query Oracle dialect. For
+ all other dialects this parameter is ignored.</para>
+ </section>
+
+ <section>
+ <title>Notes for Microsoft Windows users</title>
+
+ <para>The current configuration of eXo JCR uses Apache DBCP connection
+ pool
+ (<classname>org.apache.commons.dbcp.BasicDataSourceFactory</classname>).
+ It's possible to set a big value for maxActive parameter in
+ <filename>configuration.xml</filename>. That means usage of lots of TCP/IP
+ ports from a client machine inside the pool (i.e. JDBC driver). As a
+ result the data container can throw exceptions like "Address already in
+ use". To solve this problem you have to configure the client's machine
+ networking software for the usage of shorter timeouts for opened TCP/IP
+ ports.</para>
+
+ <para>Microsoft Windows has <parameter>MaxUserPort</parameter>,
+ <parameter>TcpTimedWaitDelay</parameter> registry keys in the node
+ <parameter>HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParameters</parameter>,
+ by default these keys are unset, set each one with values like
+ these:<itemizedlist>
+ <listitem>
+ <para>"TcpTimedWaitDelay"=dword:0000001e, sets TIME_WAIT parameter
+ to 30 seconds, default is 240.</para>
+ </listitem>
+
+ <listitem>
+ <para>"MaxUserPort"=dword:00001b58, sets the maximum of open ports
+ to 7000 or higher, default is 5000.</para>
+ </listitem>
+ </itemizedlist></para>
+
+ <para>A sample registry file is below:<programlisting>Windows Registry Editor Version 5.00
+
+[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]
+"MaxUserPort"=dword:00001b58
+"TcpTimedWaitDelay"=dword:0000001e</programlisting></para>
+ </section>
+</chapter>
16 years, 1 month
exo-jcr SVN: r2092 - in jcr/trunk/exo.jcr.component.core: src/test/resources/conf/standalone and 1 other directory.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2010-03-22 08:17:37 -0400 (Mon, 22 Mar 2010)
New Revision: 2092
Modified:
jcr/trunk/exo.jcr.component.core/pom.xml
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration-sjdbc.xml
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config-sjdbc.xml
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml
Log:
EXOJCR-598: xmls reverted
Modified: jcr/trunk/exo.jcr.component.core/pom.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/pom.xml 2010-03-22 12:11:01 UTC (rev 2091)
+++ jcr/trunk/exo.jcr.component.core/pom.xml 2010-03-22 12:17:37 UTC (rev 2092)
@@ -31,8 +31,7 @@
<name>eXo JCR :: Component :: Core Service</name>
<description>eXo JCR Service core component</description>
<properties>
- <!--jcr.test.configuration.file>/conf/standalone/test-configuration.xml</jcr.test.configuration.file-->
- <jcr.test.configuration.file>/conf/standalone/test-configuration-sjdbc.xml</jcr.test.configuration.file>
+ <jcr.test.configuration.file>/conf/standalone/test-configuration.xml</jcr.test.configuration.file>
</properties>
<dependencies>
<dependency>
@@ -215,7 +214,7 @@
<scope>test</scope>
</dependency>
<!-- For Oracle 10g support (local-jcr repository) -->
- <dependency>
+ <!-- dependency>
<groupId>ojdbc</groupId>
<artifactId>ojdbc</artifactId>
<version>14</version>
@@ -226,7 +225,7 @@
<artifactId>orai18n</artifactId>
<version>14</version>
<scope>test</scope>
- </dependency>
+ </dependency -->
<!-- For IBM DB2 support (local-jcr repository) -->
<!-- dependency>
<groupId>com.ibm.db2</groupId>
@@ -359,11 +358,11 @@
<property>
<name>emma.coverage.out.file</name>
<value>target/emma/coverage.ec</value>
- </property>
- <!-- Uncomment the line below if you want to enable the statistics -->
- <!--property>
- <name>JDBCWorkspaceDataContainer.statistics.enabled</name>
- <value>true</value>
+ </property>
+ <!-- Uncomment the line below if you want to enable the statistics -->
+ <!--property>
+ <name>JDBCWorkspaceDataContainer.statistics.enabled</name>
+ <value>true</value>
</property-->
</systemProperties>
<includes>
@@ -549,11 +548,11 @@
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>
- <!-- Uncomment the line below if you want to enable the statistics -->
- <!--property>
- <name>JDBCWorkspaceDataContainer.statistics.enabled</name>
- <value>true</value>
+ </property>
+ <!-- Uncomment the line below if you want to enable the statistics -->
+ <!--property>
+ <name>JDBCWorkspaceDataContainer.statistics.enabled</name>
+ <value>true</value>
</property-->
</systemProperties>
<includes>
@@ -621,11 +620,11 @@
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>
- <!-- Uncomment the line below if you want to enable the statistics -->
- <!--property>
- <name>JDBCWorkspaceDataContainer.statistics.enabled</name>
- <value>true</value>
+ </property>
+ <!-- Uncomment the line below if you want to enable the statistics -->
+ <!--property>
+ <name>JDBCWorkspaceDataContainer.statistics.enabled</name>
+ <value>true</value>
</property-->
</systemProperties>
<includes>
@@ -699,11 +698,11 @@
<property>
<name>jcr.test.configuration.file</name>
<value>${jcr.test.configuration.file}</value>
- </property>
- <!-- Uncomment the line below if you want to enable the statistics -->
- <!--property>
- <name>JDBCWorkspaceDataContainer.statistics.enabled</name>
- <value>true</value>
+ </property>
+ <!-- Uncomment the line below if you want to enable the statistics -->
+ <!--property>
+ <name>JDBCWorkspaceDataContainer.statistics.enabled</name>
+ <value>true</value>
</property-->
</systemProperties>
<includes>
Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration-sjdbc.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration-sjdbc.xml 2010-03-22 12:11:01 UTC (rev 2091)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration-sjdbc.xml 2010-03-22 12:17:37 UTC (rev 2092)
@@ -244,13 +244,10 @@
<properties-param>
<name>ref-addresses</name>
<description>ref-addresses</description>
- <property name="driverClassName" value="oracle.jdbc.OracleDriver" />
- <property name="url" value="jdbc:oracle:thin:@db2.exoua-int:1521:orclvm" />
- <property name="username" value="exoperf" />
- <property name="password" value="exo12321" />
- <property name="maxActive" value="600" />
- <property name="maxIdle" value="50" />
- <property name="initialSize" value="5" />
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
+ <property name="url" value="jdbc:hsqldb:file:target/temp/data/portal"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
</properties-param>
</init-params>
</component-plugin>
Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config-sjdbc.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config-sjdbc.xml 2010-03-22 12:11:01 UTC (rev 2091)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config-sjdbc.xml 2010-03-22 12:17:37 UTC (rev 2092)
@@ -38,7 +38,6 @@
<property name="update-storage" value="false" />
<property name="max-buffer-size" value="200k" />
<property name="swap-directory" value="target/temp/swap/ws" />
- <property name="force.query.hints" value="true" />
</properties>
<value-storages>
<value-storage id="ws" class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml 2010-03-22 12:11:01 UTC (rev 2091)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml 2010-03-22 12:17:37 UTC (rev 2092)
@@ -36,7 +36,6 @@
<property name="dialect" value="auto" />
<property name="multi-db" value="true" />
<property name="update-storage" value="false" />
-
<property name="max-buffer-size" value="200k" />
<property name="swap-directory" value="target/temp/swap/ws" />
</properties>
16 years, 1 month
exo-jcr SVN: r2091 - in jcr/trunk/exo.jcr.component.core: src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc and 3 other directories.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2010-03-22 08:11:01 -0400 (Mon, 22 Mar 2010)
New Revision: 2091
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
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DefaultOracleConnectionFactory.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleConnectionFactory.java
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration-sjdbc.xml
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config-sjdbc.xml
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml
Log:
EXOJCR-598: force.query.hints config parameter added
Modified: jcr/trunk/exo.jcr.component.core/pom.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/pom.xml 2010-03-22 09:54:46 UTC (rev 2090)
+++ jcr/trunk/exo.jcr.component.core/pom.xml 2010-03-22 12:11:01 UTC (rev 2091)
@@ -31,7 +31,8 @@
<name>eXo JCR :: Component :: Core Service</name>
<description>eXo JCR Service core component</description>
<properties>
- <jcr.test.configuration.file>/conf/standalone/test-configuration.xml</jcr.test.configuration.file>
+ <!--jcr.test.configuration.file>/conf/standalone/test-configuration.xml</jcr.test.configuration.file-->
+ <jcr.test.configuration.file>/conf/standalone/test-configuration-sjdbc.xml</jcr.test.configuration.file>
</properties>
<dependencies>
<dependency>
@@ -214,7 +215,7 @@
<scope>test</scope>
</dependency>
<!-- For Oracle 10g support (local-jcr repository) -->
- <!-- dependency>
+ <dependency>
<groupId>ojdbc</groupId>
<artifactId>ojdbc</artifactId>
<version>14</version>
@@ -225,7 +226,7 @@
<artifactId>orai18n</artifactId>
<version>14</version>
<scope>test</scope>
- </dependency -->
+ </dependency>
<!-- For IBM DB2 support (local-jcr repository) -->
<!-- dependency>
<groupId>com.ibm.db2</groupId>
@@ -358,11 +359,11 @@
<property>
<name>emma.coverage.out.file</name>
<value>target/emma/coverage.ec</value>
- </property>
- <!-- Uncomment the line below if you want to enable the statistics -->
- <!--property>
- <name>JDBCWorkspaceDataContainer.statistics.enabled</name>
- <value>true</value>
+ </property>
+ <!-- Uncomment the line below if you want to enable the statistics -->
+ <!--property>
+ <name>JDBCWorkspaceDataContainer.statistics.enabled</name>
+ <value>true</value>
</property-->
</systemProperties>
<includes>
@@ -548,11 +549,11 @@
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>
- <!-- Uncomment the line below if you want to enable the statistics -->
- <!--property>
- <name>JDBCWorkspaceDataContainer.statistics.enabled</name>
- <value>true</value>
+ </property>
+ <!-- Uncomment the line below if you want to enable the statistics -->
+ <!--property>
+ <name>JDBCWorkspaceDataContainer.statistics.enabled</name>
+ <value>true</value>
</property-->
</systemProperties>
<includes>
@@ -620,11 +621,11 @@
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>
- <!-- Uncomment the line below if you want to enable the statistics -->
- <!--property>
- <name>JDBCWorkspaceDataContainer.statistics.enabled</name>
- <value>true</value>
+ </property>
+ <!-- Uncomment the line below if you want to enable the statistics -->
+ <!--property>
+ <name>JDBCWorkspaceDataContainer.statistics.enabled</name>
+ <value>true</value>
</property-->
</systemProperties>
<includes>
@@ -698,11 +699,11 @@
<property>
<name>jcr.test.configuration.file</name>
<value>${jcr.test.configuration.file}</value>
- </property>
- <!-- Uncomment the line below if you want to enable the statistics -->
- <!--property>
- <name>JDBCWorkspaceDataContainer.statistics.enabled</name>
- <value>true</value>
+ </property>
+ <!-- Uncomment the line below if you want to enable the statistics -->
+ <!--property>
+ <name>JDBCWorkspaceDataContainer.statistics.enabled</name>
+ <value>true</value>
</property-->
</systemProperties>
<includes>
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-22 09:54:46 UTC (rev 2090)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java 2010-03-22 12:11:01 UTC (rev 2091)
@@ -68,7 +68,8 @@
/**
* Indicates if the statistics has to be enabled.
*/
- public static final boolean STATISTICS_ENABLED = Boolean.valueOf(System.getProperty("JDBCWorkspaceDataContainer.statistics.enabled"));
+ public static final boolean STATISTICS_ENABLED =
+ Boolean.valueOf(System.getProperty("JDBCWorkspaceDataContainer.statistics.enabled"));
static
{
if (STATISTICS_ENABLED)
@@ -76,7 +77,7 @@
LOG.info("The statistics of the component JDBCWorkspaceDataContainer has been enabled");
}
}
-
+
//configuration params
public final static String SOURCE_NAME = "source-name";
@@ -98,6 +99,8 @@
public final static String DB_PASSWORD = "password";
+ public final static String DB_FORCE_QUERY_HINTS = "force.query.hints";
+
protected final String containerName;
protected final String dbSourceName;
@@ -129,6 +132,12 @@
protected GenericConnectionFactory connFactory;
/**
+ * Some DataBases supports query hints, that may improve query performance.
+ * For default hints are enabled.
+ */
+ protected boolean useQueryHints;
+
+ /**
* Shared connection factory.
*
* Issued to share JDBC connection between system and regular workspace in case of same database
@@ -346,6 +355,9 @@
}
LOG.info("Using a dialect '" + this.dbDialect + "'");
+ // check is there DB_FORCE_QUERY_HINTS parameter - by default its enabled
+ useQueryHints = wsConfig.getContainer().getParameterBoolean(DB_FORCE_QUERY_HINTS, true);
+
try
{
this.checkSNSNewConnection = wsConfig.getContainer().getParameterBoolean(CHECK_SNS_NEW_CONNECTION);
@@ -767,14 +779,15 @@
{
original = ((StatisticsJDBCStorageConnection)original).getNestedWorkspaceStorageConnection();
}
-
+
if (original instanceof JDBCStorageConnection)
{
WorkspaceStorageConnectionFactory cFactory =
new SharedConnectionFactory(((JDBCStorageConnection)original).getJdbcConnection(), containerName, multiDb,
valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
- return STATISTICS_ENABLED ? new StatisticsJDBCStorageConnection(cFactory.openConnection()) : cFactory.openConnection();
+ return STATISTICS_ENABLED ? new StatisticsJDBCStorageConnection(cFactory.openConnection()) : cFactory
+ .openConnection();
}
else
{
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java 2010-03-22 09:54:46 UTC (rev 2090)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java 2010-03-22 12:11:01 UTC (rev 2091)
@@ -28,10 +28,10 @@
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.optimisation.db.DefaultOracleConnectionFactory;
import org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.GenericCQConnectionFactory;
import org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.HSQLDBConnectionFactory;
import org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.MySQLConnectionFactory;
-import org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.DefaultOracleConnectionFactory;
import org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.OracleConnectionFactory;
import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializerException;
import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
@@ -93,19 +93,19 @@
LOG.warn(DBConstants.DB_DIALECT_ORACLEOCI + " dialect is experimental!");
// sample of connection factory customization
if (dbSourceName != null)
- {
+ {
DataSource ds = (DataSource)new InitialContext().lookup(dbSourceName);
if (ds != null)
this.connFactory =
new DefaultOracleConnectionFactory(ds, containerName, multiDb, valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ swapDirectory, swapCleaner, useQueryHints);
else
throw new RepositoryException("Datasource '" + dbSourceName + "' is not bound in this context.");
- }
+ }
else
this.connFactory =
new OracleConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner, useQueryHints);
sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.ora.sql";
@@ -121,14 +121,14 @@
if (ds != null)
this.connFactory =
new DefaultOracleConnectionFactory(ds, containerName, multiDb, valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ swapDirectory, swapCleaner, useQueryHints);
else
throw new RepositoryException("Datasource '" + dbSourceName + "' is not bound in this context.");
}
else
this.connFactory =
new DefaultOracleConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner, useQueryHints);
sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.ora.sql";
dbInitilizer = new OracleDBInitializer(containerName, this.connFactory.getJdbcConnection(), sqlPath, multiDb);
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DefaultOracleConnectionFactory.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DefaultOracleConnectionFactory.java 2010-03-22 09:54:46 UTC (rev 2090)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DefaultOracleConnectionFactory.java 2010-03-22 12:11:01 UTC (rev 2091)
@@ -34,6 +34,9 @@
*/
public class DefaultOracleConnectionFactory extends GenericCQConnectionFactory
{
+
+ protected boolean forceQueryHints;
+
/**
* DefaultOracleConnectionFactory constructor.
*
@@ -51,12 +54,15 @@
* - Swap directory (see configuration)
* @param swapCleaner
* - Swap cleaner (internal FileCleaner).
+ * @param forceQueryHints
+ * - use Oracle queries with query hints
*/
public DefaultOracleConnectionFactory(DataSource dataSource, String containerName, boolean multiDb,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File swapDirectory, FileCleaner swapCleaner)
+ ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File swapDirectory, FileCleaner swapCleaner,
+ boolean forceQueryHints)
{
-
super(dataSource, containerName, multiDb, valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ this.forceQueryHints = forceQueryHints;
}
/**
@@ -84,18 +90,21 @@
* - Swap directory (see configuration)
* @param swapCleaner
* - Swap cleaner (internal FileCleaner).
+ * @param forceQueryHints
+ * - use Oracle queries with query hints
* @throws RepositoryException
* if error eccurs
*/
public DefaultOracleConnectionFactory(String dbDriver, String dbUrl, String dbUserName, String dbPassword,
String containerName, boolean multiDb, ValueStoragePluginProvider valueStorageProvider, int maxBufferSize,
- File swapDirectory, FileCleaner swapCleaner) throws RepositoryException
+ File swapDirectory, FileCleaner swapCleaner, boolean forceQueryHints) throws RepositoryException
{
super(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ this.forceQueryHints = forceQueryHints;
}
-
+
/**
* {@inheritDoc}
*/
@@ -104,20 +113,27 @@
{
try
{
+ if (forceQueryHints)
+ {
+ if (multiDb)
+ {
+ return new OracleMultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly, containerName,
+ valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ }
- if (multiDb)
- {
- return new OracleMultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly, containerName,
+ return new OracleSingleDbJDBCConnection(getJdbcConnection(readOnly), readOnly, containerName,
valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
}
+ else
+ {
+ // use common CQ queries, since Oracle[Multi/Single]DbJDBCConnection contains only queries with hints
+ return super.openConnection(readOnly);
+ }
- return new OracleSingleDbJDBCConnection(getJdbcConnection(readOnly), readOnly, containerName,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
-
}
catch (SQLException e)
{
throw new RepositoryException(e);
}
- }
+ }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleConnectionFactory.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleConnectionFactory.java 2010-03-22 09:54:46 UTC (rev 2090)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleConnectionFactory.java 2010-03-22 12:11:01 UTC (rev 2091)
@@ -77,12 +77,14 @@
* - Swap directory (see configuration)
* @param swapCleaner
* - Swap cleaner (internal FileCleaner).
+ * @param forceQueryHints
+ * - use Oracle queries with query hints
* @throws RepositoryException
* if error occurs
*/
public OracleConnectionFactory(String dbDriver, String dbUrl, String dbUserName, String dbPassword,
String containerName, boolean multiDb, ValueStoragePluginProvider valueStorageProvider, int maxBufferSize,
- File swapDirectory, FileCleaner swapCleaner) throws RepositoryException
+ File swapDirectory, FileCleaner swapCleaner, boolean forceQueryHints) throws RepositoryException
{
// ;D:\Devel\oracle_instantclient_10_2\;C:\oracle\ora92\bin;
@@ -111,7 +113,7 @@
*/
super(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb, valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ swapDirectory, swapCleaner, forceQueryHints);
Object cds = null;
try
Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration-sjdbc.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration-sjdbc.xml 2010-03-22 09:54:46 UTC (rev 2090)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration-sjdbc.xml 2010-03-22 12:11:01 UTC (rev 2091)
@@ -244,10 +244,13 @@
<properties-param>
<name>ref-addresses</name>
<description>ref-addresses</description>
- <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
- <property name="url" value="jdbc:hsqldb:file:target/temp/data/portal"/>
- <property name="username" value="sa"/>
- <property name="password" value=""/>
+ <property name="driverClassName" value="oracle.jdbc.OracleDriver" />
+ <property name="url" value="jdbc:oracle:thin:@db2.exoua-int:1521:orclvm" />
+ <property name="username" value="exoperf" />
+ <property name="password" value="exo12321" />
+ <property name="maxActive" value="600" />
+ <property name="maxIdle" value="50" />
+ <property name="initialSize" value="5" />
</properties-param>
</init-params>
</component-plugin>
Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config-sjdbc.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config-sjdbc.xml 2010-03-22 09:54:46 UTC (rev 2090)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config-sjdbc.xml 2010-03-22 12:11:01 UTC (rev 2091)
@@ -38,6 +38,7 @@
<property name="update-storage" value="false" />
<property name="max-buffer-size" value="200k" />
<property name="swap-directory" value="target/temp/swap/ws" />
+ <property name="force.query.hints" value="true" />
</properties>
<value-storages>
<value-storage id="ws" class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml 2010-03-22 09:54:46 UTC (rev 2090)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml 2010-03-22 12:11:01 UTC (rev 2091)
@@ -36,6 +36,7 @@
<property name="dialect" value="auto" />
<property name="multi-db" value="true" />
<property name="update-storage" value="false" />
+
<property name="max-buffer-size" value="200k" />
<property name="swap-directory" value="target/temp/swap/ws" />
</properties>
16 years, 1 month
exo-jcr SVN: r2090 - in core/trunk/exo.core.component.database: src/main/java/org/exoplatform/services/database/creator and 2 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-03-22 05:54:46 -0400 (Mon, 22 Mar 2010)
New Revision: 2090
Added:
core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java
core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreatorException.java
core/trunk/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDBCreator.java
Removed:
core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBScriptExecutor.java
core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBScriptExecutorException.java
core/trunk/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDBScriptExecutor.java
Modified:
core/trunk/exo.core.component.database/pom.xml
core/trunk/exo.core.component.database/src/test/resources/conf/standalone/test-configuration.xml
Log:
EXOJCR-573: rename DBScriptExecutor to DBCreator
Modified: core/trunk/exo.core.component.database/pom.xml
===================================================================
--- core/trunk/exo.core.component.database/pom.xml 2010-03-22 09:35:46 UTC (rev 2089)
+++ core/trunk/exo.core.component.database/pom.xml 2010-03-22 09:54:46 UTC (rev 2090)
@@ -102,7 +102,7 @@
</exclusion>
</exclusions>
</dependency>
- </dependencies>
+ </dependencies>
<build>
<pluginManagement>
@@ -113,7 +113,7 @@
<configuration>
<excludes>
<exclude>**/DBCreatorTest.java</exclude>
- <exclude>**/TestDBScriptExecutor.java</exclude>
+ <exclude>**/TestDBCreator.java</exclude>
</excludes>
</configuration>
</plugin>
Added: core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java
===================================================================
--- core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java (rev 0)
+++ core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java 2010-03-22 09:54:46 UTC (rev 2090)
@@ -0,0 +1,376 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.database.creator;
+
+import org.exoplatform.container.configuration.ConfigurationException;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.container.xml.PropertiesParam;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+/**
+ * @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy Bazko</a>
+ * @version $Id: DBCreator.java 111 2010-11-11 11:11:11Z tolusha $
+ */
+public class DBCreator
+{
+
+ /**
+ * Database template.
+ */
+ public static final String DATABASE_TEMPLATE = "${database}";
+
+ /**
+ * User name template.
+ */
+ public static final String USERNAME_TEMPLATE = "${username}";
+
+ /**
+ * Password template.
+ */
+ public static final String PASSWORD_TEMPLATE = "${password}";
+
+ /**
+ * Driver class name.
+ */
+ protected final String driver;
+
+ /**
+ * Server url.
+ */
+ protected final String serverUrl;
+
+ /**
+ * User name with administrative rights for connection to server.
+ */
+ protected final String adminName;
+
+ /**
+ * User's password.
+ */
+ protected final String adminPwd;
+
+ /**
+ * Internal login connection property needed for Oracle.
+ */
+ protected final String internal_logon;
+
+ /**
+ * DDL script database creation.
+ */
+ protected final String dbScript;
+
+ /**
+ * User name for new database.
+ */
+ protected final String dbUserName;
+
+ /**
+ * User's password.
+ */
+ protected final String dbPassword;
+
+ /**
+ * DBCreator constructor.
+ *
+ * @param params
+ * Initializations parameters
+ */
+ public DBCreator(InitParams params) throws ConfigurationException
+ {
+ if (params == null)
+ {
+ throw new ConfigurationException("Initializations parameters expected");
+ }
+
+ PropertiesParam prop = params.getPropertiesParam("db-connection");
+
+ if (prop != null)
+ {
+ this.driver = prop.getProperty("driverClassName");
+ if (driver == null)
+ {
+ throw new ConfigurationException("driverClassName expected in db-connection properties section");
+ }
+
+ this.serverUrl = prop.getProperty("url");
+ if (serverUrl == null)
+ {
+ throw new ConfigurationException("url expected in db-connection properties section");
+ }
+
+ this.adminName = prop.getProperty("username");
+ if (adminName == null)
+ {
+ throw new ConfigurationException("username expected in db-connection properties section");
+ }
+
+ this.adminPwd = prop.getProperty("password");
+ if (adminPwd == null)
+ {
+ throw new ConfigurationException("password expected in db-connection properties section");
+ }
+
+ this.internal_logon = prop.getProperty("internal_logon");
+ }
+ else
+ {
+ throw new ConfigurationException("db-connection properties expected in initializations parameters");
+ }
+
+ prop = params.getPropertiesParam("db-creation");
+ if (prop != null)
+ {
+ String scriptPath = prop.getProperty("scriptPath");
+ if (scriptPath != null)
+ {
+ try
+ {
+ dbScript = readScriptResource(scriptPath);
+ }
+ catch (IOException e)
+ {
+ throw new ConfigurationException("Can't read script resource " + scriptPath, e);
+ }
+ }
+ else
+ {
+ throw new ConfigurationException("scriptPath expected in db-creation properties section");
+ }
+
+ this.dbUserName = prop.getProperty("username");
+ if (dbUserName == null)
+ {
+ throw new ConfigurationException("username expected in db-creation properties section");
+ }
+
+ this.dbPassword = prop.getProperty("password");
+ if (dbPassword == null)
+ {
+ throw new ConfigurationException("password expected in db-creation properties section");
+ }
+ }
+ else
+ {
+ throw new ConfigurationException("db-creation properties expected in initializations parameters");
+ }
+ }
+
+ /**
+ * Execute DDL script for new database creation. Database name are passed as parameter,
+ * user name and password are passed via configuration. In script database name, user name
+ * and password defined via templates as ${database}, ${username} and ${password} respectively.
+ * At execution time method replaces templates by real values.
+ *
+ * @param dbName
+ * new database name
+ * @throws DBCreatorException
+ * if any error occurs
+ */
+ public DBConnectionInfo createDatabase(String dbName) throws DBCreatorException
+ {
+ Connection conn = null;
+ try
+ {
+ Class.forName(driver);
+
+ // Properties props = new java.util.Properties();
+ // props.put("user", adminName);
+ // props.put("password", adminPwd);
+ // if (internal_logon != null)
+ // {
+ // props.put("internal_logon", internal_logon);
+ // }
+ // conn = DriverManager.getConnection(serverUrl, props);
+ conn = DriverManager.getConnection(serverUrl, adminName, adminPwd);
+ }
+ catch (SQLException e)
+ {
+ throw new DBCreatorException("Can't establish the JDBC connection to database " + serverUrl, e);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new DBCreatorException("Can't load the JDBC driver " + driver, e);
+ }
+
+ String dbProductName;
+ try
+ {
+ dbProductName = conn.getMetaData().getDatabaseProductName();
+
+ if (dbProductName.startsWith("Microsoft SQL Server") || dbProductName.startsWith("Adaptive Server Anywhere")
+ || dbProductName.equals("Sybase SQL Server") || dbProductName.equals("Adaptive Server Enterprise"))
+ {
+ executeAutoCommitMode(conn, dbName);
+ }
+ else
+ {
+ executeBatchMode(conn, dbName);
+ }
+ }
+ catch (SQLException e)
+ {
+ String errorTrace = "";
+ while (e != null)
+ {
+ errorTrace += e.getMessage() + "; ";
+ e = e.getNextException();
+ }
+
+ throw new DBCreatorException("Can't execute SQL script " + errorTrace);
+ }
+ finally
+ {
+ try
+ {
+ conn.close();
+ }
+ catch (SQLException e)
+ {
+ throw new DBCreatorException("Can't close connection", e);
+ }
+ }
+
+ // try to solve database url connection depending on specific database
+ String dbUrl = serverUrl;
+ if (dbProductName.startsWith("Microsoft SQL Server"))
+ {
+ dbUrl = dbUrl + (dbUrl.endsWith(";") ? "" : ";") + "databaseName=" + dbName + ";";
+ }
+ else if (dbProductName.equals("Oracle"))
+ {
+ // do nothing
+ }
+ else
+ {
+ dbUrl = dbUrl + (dbUrl.endsWith("/") ? "" : "/") + dbName;
+ }
+
+ return new DBConnectionInfo(driver, dbUrl, dbUserName, dbPassword);
+ }
+
+ /**
+ * Executes DDL script in generic batch mode.
+ *
+ * @param conn
+ * connection to server
+ * @param dbName
+ * database name
+ * @throws SQLException
+ * if any errors occurs
+ */
+ private void executeBatchMode(Connection conn, String dbName) throws SQLException
+ {
+ Statement statement = conn.createStatement();
+ for (String scr : dbScript.split(";"))
+ {
+ scr = scr.replace(DATABASE_TEMPLATE, dbName);
+ scr = scr.replace(USERNAME_TEMPLATE, dbUserName);
+ scr = scr.replace(PASSWORD_TEMPLATE, dbPassword);
+
+ String s = cleanWhitespaces(scr.trim());
+ if (s.length() > 0)
+ {
+ statement.addBatch(s);
+ }
+ }
+ statement.executeBatch();
+ }
+
+ /**
+ * Executes DDL script with autocommit mode set true. Actually need for MSSQL and Sybase database servers.
+ * After execution "create database" command newly created database not available for "use" command and
+ * therefore you can't create user inside.
+ *
+ * @param conn
+ * connection to server
+ * @param dbName
+ * database name
+ * @throws SQLException
+ * if any errors occurs
+ */
+ private void executeAutoCommitMode(Connection conn, String dbName) throws SQLException
+ {
+ conn.setAutoCommit(true);
+ for (String scr : dbScript.split(";"))
+ {
+ scr = scr.replace(DATABASE_TEMPLATE, dbName);
+ scr = scr.replace(USERNAME_TEMPLATE, dbUserName);
+ scr = scr.replace(PASSWORD_TEMPLATE, dbPassword);
+
+ String s = cleanWhitespaces(scr.trim());
+ if (s.length() > 0)
+ {
+ conn.createStatement().executeUpdate(s);
+ }
+ }
+ }
+
+ /**
+ * Read SQL script from file resource.
+ */
+ protected String readScriptResource(String path) throws IOException
+ {
+ InputStream is = new FileInputStream(path);
+ InputStreamReader isr = new InputStreamReader(is);
+ try
+ {
+ StringBuilder sbuff = new StringBuilder();
+ char[] buff = new char[is.available()];
+ int r = 0;
+ while ((r = isr.read(buff)) > 0)
+ {
+ sbuff.append(buff, 0, r);
+ }
+
+ return sbuff.toString();
+ }
+ finally
+ {
+ is.close();
+ }
+ }
+
+ /**
+ * Clean whitespace.
+ */
+ private String cleanWhitespaces(String string)
+ {
+ if (string != null)
+ {
+ char[] cc = string.toCharArray();
+ for (int ci = cc.length - 1; ci > 0; ci--)
+ {
+ if (Character.isWhitespace(cc[ci]))
+ {
+ cc[ci] = ' ';
+ }
+ }
+ return new String(cc);
+ }
+ return string;
+ }
+}
Added: core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreatorException.java
===================================================================
--- core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreatorException.java (rev 0)
+++ core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreatorException.java 2010-03-22 09:54:46 UTC (rev 2090)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.database.creator;
+
+/**
+ * @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy Bazko</a>
+ * @version $Id: DBCreatorException.java 111 2010-11-11 11:11:11Z tolusha $
+ */
+public class DBCreatorException extends Exception
+{
+
+ /**
+ * DBCreationException constructor.
+ */
+ public DBCreatorException(Throwable e)
+ {
+ super(e);
+ }
+
+ /**
+ * DBCreationException constructor.
+ */
+ public DBCreatorException(String message, Throwable e)
+ {
+ super(message, e);
+ }
+
+ /**
+ * DBCreationException constructor.
+ */
+ public DBCreatorException(String message)
+ {
+ super(message);
+ }
+}
Deleted: core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBScriptExecutor.java
===================================================================
--- core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBScriptExecutor.java 2010-03-22 09:35:46 UTC (rev 2089)
+++ core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBScriptExecutor.java 2010-03-22 09:54:46 UTC (rev 2090)
@@ -1,376 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.database.creator;
-
-import org.exoplatform.container.configuration.ConfigurationException;
-import org.exoplatform.container.xml.InitParams;
-import org.exoplatform.container.xml.PropertiesParam;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Properties;
-
-/**
- * @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy Bazko</a>
- * @version $Id: DBCreator.java 111 2010-11-11 11:11:11Z tolusha $
- */
-public class DBScriptExecutor
-{
-
- /**
- * Database template.
- */
- public static final String DATABASE_TEMPLATE = "${database}";
-
- /**
- * User name template.
- */
- public static final String USERNAME_TEMPLATE = "${username}";
-
- /**
- * Password template.
- */
- public static final String PASSWORD_TEMPLATE = "${password}";
-
- /**
- * Driver class name.
- */
- protected final String driver;
-
- /**
- * Server url.
- */
- protected final String serverUrl;
-
- /**
- * User name with administrative rights for connection to server.
- */
- protected final String adminName;
-
- /**
- * User's password.
- */
- protected final String adminPwd;
-
- /**
- * Internal login connection property needed for Oracle.
- */
- protected final String internal_logon;
-
- /**
- * DDL script database creation.
- */
- protected final String dbScript;
-
- /**
- * User name for new database.
- */
- protected final String dbUserName;
-
- /**
- * User's password.
- */
- protected final String dbPassword;
-
- /**
- * DBScriptExecutor constructor.
- *
- * @param params
- * Initializations parameters
- */
- public DBScriptExecutor(InitParams params) throws ConfigurationException
- {
- if (params == null)
- {
- throw new ConfigurationException("Initializations parameters expected");
- }
-
- PropertiesParam prop = params.getPropertiesParam("db-connection");
-
- if (prop != null)
- {
- this.driver = prop.getProperty("driverClassName");
- if (driver == null)
- {
- throw new ConfigurationException("driverClassName expected in db-connection properties section");
- }
-
- this.serverUrl = prop.getProperty("url");
- if (serverUrl == null)
- {
- throw new ConfigurationException("url expected in db-connection properties section");
- }
-
- this.adminName = prop.getProperty("username");
- if (adminName == null)
- {
- throw new ConfigurationException("username expected in db-connection properties section");
- }
-
- this.adminPwd = prop.getProperty("password");
- if (adminPwd == null)
- {
- throw new ConfigurationException("password expected in db-connection properties section");
- }
-
- this.internal_logon = prop.getProperty("internal_logon");
- }
- else
- {
- throw new ConfigurationException("db-connection properties expected in initializations parameters");
- }
-
- prop = params.getPropertiesParam("db-creation");
- if (prop != null)
- {
- String scriptPath = prop.getProperty("scriptPath");
- if (scriptPath != null)
- {
- try
- {
- dbScript = readScriptResource(scriptPath);
- }
- catch (IOException e)
- {
- throw new ConfigurationException("Can't read script resource " + scriptPath, e);
- }
- }
- else
- {
- throw new ConfigurationException("scriptPath expected in db-creation properties section");
- }
-
- this.dbUserName = prop.getProperty("username");
- if (dbUserName == null)
- {
- throw new ConfigurationException("username expected in db-creation properties section");
- }
-
- this.dbPassword = prop.getProperty("password");
- if (dbPassword == null)
- {
- throw new ConfigurationException("password expected in db-creation properties section");
- }
- }
- else
- {
- throw new ConfigurationException("db-creation properties expected in initializations parameters");
- }
- }
-
- /**
- * Execute DDL script for new database creation. Database name are passed as parameter,
- * user name and password are passed via configuration. In script database name, user name
- * and password defined via templates as ${database}, ${username} and ${password} respectively.
- * At execution time method replaces templates by real values.
- *
- * @param dbName
- * new database name
- * @throws DBScriptExecutorException
- * if any error occurs
- */
- public DBConnectionInfo createDatabase(String dbName) throws DBScriptExecutorException
- {
- Connection conn = null;
- try
- {
- Class.forName(driver);
-
- Properties props = new java.util.Properties();
- props.put("user", adminName);
- props.put("password", adminPwd);
- if (internal_logon != null)
- {
- props.put("internal_logon", internal_logon);
- }
- conn = DriverManager.getConnection(serverUrl, props);
- }
- catch (SQLException e)
- {
- throw new DBScriptExecutorException("Can't establish the JDBC connection to database " + serverUrl, e);
- }
- catch (ClassNotFoundException e)
- {
- throw new DBScriptExecutorException("Can't load the JDBC driver " + driver, e);
- }
-
- String dbProductName;
- try
- {
- dbProductName = conn.getMetaData().getDatabaseProductName();
-
- if (dbProductName.startsWith("Microsoft SQL Server") || dbProductName.startsWith("Adaptive Server Anywhere")
- || dbProductName.equals("Sybase SQL Server") || dbProductName.equals("Adaptive Server Enterprise"))
- {
- executeAutoCommitMode(conn, dbName);
- }
- else
- {
- executeBatchMode(conn, dbName);
- }
- }
- catch (SQLException e)
- {
- String errorTrace = "";
- while (e != null)
- {
- errorTrace += e.getMessage() + "; ";
- e = e.getNextException();
- }
-
- throw new DBScriptExecutorException("Can't execute SQL script " + errorTrace);
- }
- finally
- {
- try
- {
- conn.close();
- }
- catch (SQLException e)
- {
- throw new DBScriptExecutorException("Can't close connection", e);
- }
- }
-
- // try to solve database url connection depending on specific database
- String dbUrl = serverUrl;
- if (dbProductName.startsWith("Microsoft SQL Server"))
- {
- dbUrl = dbUrl + (dbUrl.endsWith(";") ? "" : ";") + "databaseName=" + dbName + ";";
- }
- else if (dbProductName.equals("Oracle"))
- {
- // do nothing
- }
- else
- {
- dbUrl = dbUrl + (dbUrl.endsWith("/") ? "" : "/") + dbName;
- }
-
- return new DBConnectionInfo(driver, dbUrl, dbUserName, dbPassword);
- }
-
- /**
- * Executes DDL script in generic batch mode.
- *
- * @param conn
- * connection to server
- * @param dbName
- * database name
- * @throws SQLException
- * if any errors occurs
- */
- private void executeBatchMode(Connection conn, String dbName) throws SQLException
- {
- Statement statement = conn.createStatement();
- for (String scr : dbScript.split(";"))
- {
- scr = scr.replace(DATABASE_TEMPLATE, dbName);
- scr = scr.replace(USERNAME_TEMPLATE, dbUserName);
- scr = scr.replace(PASSWORD_TEMPLATE, dbPassword);
-
- String s = cleanWhitespaces(scr.trim());
- if (s.length() > 0)
- {
- statement.addBatch(s);
- }
- }
- statement.executeBatch();
- }
-
- /**
- * Executes DDL script with autocommit mode set true. Actually need for MSSQL and Sybase database servers.
- * After execution "create database" command newly created database not available for "use" command and
- * therefore you can't create user inside.
- *
- * @param conn
- * connection to server
- * @param dbName
- * database name
- * @throws SQLException
- * if any errors occurs
- */
- private void executeAutoCommitMode(Connection conn, String dbName) throws SQLException
- {
- conn.setAutoCommit(true);
- for (String scr : dbScript.split(";"))
- {
- scr = scr.replace(DATABASE_TEMPLATE, dbName);
- scr = scr.replace(USERNAME_TEMPLATE, dbUserName);
- scr = scr.replace(PASSWORD_TEMPLATE, dbPassword);
-
- String s = cleanWhitespaces(scr.trim());
- if (s.length() > 0)
- {
- conn.createStatement().executeUpdate(s);
- }
- }
- }
-
- /**
- * Read SQL script from file resource.
- */
- protected String readScriptResource(String path) throws IOException
- {
- InputStream is = new FileInputStream(path);
- InputStreamReader isr = new InputStreamReader(is);
- try
- {
- StringBuilder sbuff = new StringBuilder();
- char[] buff = new char[is.available()];
- int r = 0;
- while ((r = isr.read(buff)) > 0)
- {
- sbuff.append(buff, 0, r);
- }
-
- return sbuff.toString();
- }
- finally
- {
- is.close();
- }
- }
-
- /**
- * Clean whitespace.
- */
- private String cleanWhitespaces(String string)
- {
- if (string != null)
- {
- char[] cc = string.toCharArray();
- for (int ci = cc.length - 1; ci > 0; ci--)
- {
- if (Character.isWhitespace(cc[ci]))
- {
- cc[ci] = ' ';
- }
- }
- return new String(cc);
- }
- return string;
- }
-}
Deleted: core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBScriptExecutorException.java
===================================================================
--- core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBScriptExecutorException.java 2010-03-22 09:35:46 UTC (rev 2089)
+++ core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBScriptExecutorException.java 2010-03-22 09:54:46 UTC (rev 2090)
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.database.creator;
-
-/**
- * @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy Bazko</a>
- * @version $Id: DBCreatorException.java 111 2010-11-11 11:11:11Z tolusha $
- */
-public class DBScriptExecutorException extends Exception
-{
-
- /**
- * DBCreationException constructor.
- */
- public DBScriptExecutorException(Throwable e)
- {
- super(e);
- }
-
- /**
- * DBCreationException constructor.
- */
- public DBScriptExecutorException(String message, Throwable e)
- {
- super(message, e);
- }
-
- /**
- * DBCreationException constructor.
- */
- public DBScriptExecutorException(String message)
- {
- super(message);
- }
-}
Added: core/trunk/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDBCreator.java
===================================================================
--- core/trunk/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDBCreator.java (rev 0)
+++ core/trunk/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDBCreator.java 2010-03-22 09:54:46 UTC (rev 2090)
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.database;
+
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.services.database.creator.DBConnectionInfo;
+import org.exoplatform.services.database.creator.DBCreator;
+import org.exoplatform.services.naming.InitialContextBinder;
+import org.exoplatform.services.naming.InitialContextInitializer;
+
+import java.sql.Connection;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.sql.DataSource;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy Bazko</a>
+ * @version $Id: TestDBCreator.java 111 2010-11-11 11:11:11Z tolusha $
+ */
+public class TestDBCreator extends TestCase
+{
+
+ protected DBCreator dbCreator;
+
+ private InitialContextBinder initialContextBinder;
+
+ private InitialContextInitializer initContext;
+
+ public void setUp() throws Exception
+ {
+ PortalContainer container = PortalContainer.getInstance();
+
+ dbCreator = (DBCreator)container.getComponentInstanceOfType(DBCreator.class);
+ initContext = (InitialContextInitializer)container.getComponentInstanceOfType(InitialContextInitializer.class);
+ initialContextBinder = (InitialContextBinder)container.getComponentInstanceOfType(InitialContextBinder.class);
+ }
+
+ public void testDBCreate() throws Exception
+ {
+ assertNotNull(dbCreator);
+
+ DBConnectionInfo dbInfo = dbCreator.createDatabase("testdb");
+
+ Map<String, String> refAddr = new HashMap<String, String>();
+ refAddr.put("driverClassName", dbInfo.getDriver());
+ refAddr.put("url", dbInfo.getUrl());
+ refAddr.put("username", dbInfo.getUsername());
+ refAddr.put("password", dbInfo.getPassword());
+
+ initialContextBinder.bind("testjdbcjcr", "javax.sql.DataSource",
+ "org.apache.commons.dbcp.BasicDataSourceFactory", null, refAddr);
+
+ DataSource ds = (DataSource)initContext.getInitialContext().lookup("testjdbcjcr");
+ assertNotNull(ds);
+
+ Connection conn = ds.getConnection();
+ assertNotNull(conn);
+ }
+}
Deleted: core/trunk/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDBScriptExecutor.java
===================================================================
--- core/trunk/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDBScriptExecutor.java 2010-03-22 09:35:46 UTC (rev 2089)
+++ core/trunk/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDBScriptExecutor.java 2010-03-22 09:54:46 UTC (rev 2090)
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.database;
-
-import org.exoplatform.container.PortalContainer;
-import org.exoplatform.services.database.creator.DBConnectionInfo;
-import org.exoplatform.services.database.creator.DBScriptExecutor;
-import org.exoplatform.services.naming.InitialContextBinder;
-import org.exoplatform.services.naming.InitialContextInitializer;
-
-import java.sql.Connection;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.sql.DataSource;
-
-import junit.framework.TestCase;
-
-/**
- * @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy Bazko</a>
- * @version $Id: TestDBCreator.java 111 2010-11-11 11:11:11Z tolusha $
- */
-public class TestDBScriptExecutor extends TestCase
-{
-
- protected DBScriptExecutor dbExecutor;
-
- private InitialContextBinder initialContextBinder;
-
- private InitialContextInitializer initContext;
-
- public void setUp() throws Exception
- {
- PortalContainer container = PortalContainer.getInstance();
-
- dbExecutor = (DBScriptExecutor)container.getComponentInstanceOfType(DBScriptExecutor.class);
- initContext = (InitialContextInitializer)container.getComponentInstanceOfType(InitialContextInitializer.class);
- initialContextBinder = (InitialContextBinder)container.getComponentInstanceOfType(InitialContextBinder.class);
- }
-
- public void testDBCreate() throws Exception
- {
- assertNotNull(dbExecutor);
-
- DBConnectionInfo dbInfo = dbExecutor.createDatabase("testdb");
-
- Map<String, String> refAddr = new HashMap<String, String>();
- refAddr.put("driverClassName", dbInfo.getDriver());
- refAddr.put("url", dbInfo.getUrl());
- refAddr.put("username", dbInfo.getUsername());
- refAddr.put("password", dbInfo.getPassword());
-
- initialContextBinder.bind("testjdbcjcr", "javax.sql.DataSource",
- "org.apache.commons.dbcp.BasicDataSourceFactory", null, refAddr);
-
- DataSource ds = (DataSource)initContext.getInitialContext().lookup("testjdbcjcr");
- assertNotNull(ds);
-
- Connection conn = ds.getConnection();
- assertNotNull(conn);
- }
-}
Modified: core/trunk/exo.core.component.database/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
--- core/trunk/exo.core.component.database/src/test/resources/conf/standalone/test-configuration.xml 2010-03-22 09:35:46 UTC (rev 2089)
+++ core/trunk/exo.core.component.database/src/test/resources/conf/standalone/test-configuration.xml 2010-03-22 09:54:46 UTC (rev 2090)
@@ -51,8 +51,8 @@
</component>
<component>
- <key>org.exoplatform.services.database.creator.DBScriptExecutor</key>
- <type>org.exoplatform.services.database.creator.DBScriptExecutor</type>
+ <key>org.exoplatform.services.database.creator.DBCreator</key>
+ <type>org.exoplatform.services.database.creator.DBCreator</type>
<init-params>
<properties-param>
<name>db-connection</name>
@@ -65,7 +65,7 @@
<properties-param>
<name>db-creation</name>
<description>database creation properties</description>
- <property name="scriptPath" value="script.sql" />
+ <property name="scriptPath" value="test.sql" />
<property name="username" value="testuser" />
<property name="password" value="testpwd" />
</properties-param>
16 years, 1 month
exo-jcr SVN: r2089 - in kernel/trunk/exo.kernel.component.common: src/main/java/org/exoplatform/services/naming and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-03-22 05:35:46 -0400 (Mon, 22 Mar 2010)
New Revision: 2089
Modified:
kernel/trunk/exo.kernel.component.common/pom.xml
kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/naming/InitialContextBinder.java
Log:
EXOJCR-573: add javadocs
Modified: kernel/trunk/exo.kernel.component.common/pom.xml
===================================================================
--- kernel/trunk/exo.kernel.component.common/pom.xml 2010-03-20 07:02:33 UTC (rev 2088)
+++ kernel/trunk/exo.kernel.component.common/pom.xml 2010-03-22 09:35:46 UTC (rev 2089)
@@ -99,7 +99,6 @@
<excludes>
<exclude>**/InitialContextTest.java</exclude>
<exclude>**/TransactionTest.java</exclude>
- <exclude>**/TestInitialContextBinder.java</exclude>
</excludes>
</configuration>
</plugin>
Modified: kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/naming/InitialContextBinder.java
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/naming/InitialContextBinder.java 2010-03-20 07:02:33 UTC (rev 2088)
+++ kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/naming/InitialContextBinder.java 2010-03-22 09:35:46 UTC (rev 2089)
@@ -18,24 +18,20 @@
*/
package org.exoplatform.services.naming;
-import org.exoplatform.container.configuration.ConfigurationException;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.Stack;
-import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.naming.NamingException;
-import javax.naming.RefAddr;
import javax.naming.Reference;
import javax.naming.StringRefAddr;
import javax.xml.stream.XMLEventReader;
@@ -50,7 +46,7 @@
import javax.xml.stream.events.XMLEvent;
/**
- * Class is responsible for binding datasources at runtime, persists on file and automatically rebinds after restart.
+ * Class is responsible for binding references at runtime, persists on file and automatically binds after restart.
*
* @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy Bazko</a>
* @version $Id: InitialContextBinder.java 111 2010-11-11 11:11:11Z tolusha $
@@ -79,8 +75,14 @@
*/
protected final InitialContextInitializer initialContextInitializer;
+ /**
+ * Absolute file path to references's storage.
+ */
protected final String bindReferencesPath;
+ /**
+ * All current binded references.
+ */
protected Map<String, Reference> bindReferences;
/**
@@ -90,24 +92,25 @@
* initial context initializer
* @param initParams
* initialization parameters
- *
- * @throws ConfigurationException
+ * @throws XMLStreamException
+ * @throws FileNotFoundException
* @throws FileNotFoundException
* @throws XMLStreamException
+ * @throws NamingException
* @throws NamingException
*/
- public InitialContextBinder(InitialContextInitializer initialContextInitializer) throws ConfigurationException,
- FileNotFoundException, XMLStreamException, NamingException
+ public InitialContextBinder(InitialContextInitializer initialContextInitializer) throws FileNotFoundException,
+ XMLStreamException, NamingException
{
this.initialContextInitializer = initialContextInitializer;
this.bindReferences = new HashMap<String, Reference>();
- this.bindReferencesPath = System.getProperty("java.io.tmpdir") + File.separator + "datasources.xml";
+ this.bindReferencesPath = System.getProperty("java.io.tmpdir") + File.separator + "bind-references.xml";
if (new File(bindReferencesPath).exists())
{
- this.bindReferences.putAll(doImport());
- for (Entry<String, Reference> entry : bindReferences.entrySet())
+ Map<String, Reference> importedRefs = doImport();
+ for (Entry<String, Reference> entry : importedRefs.entrySet())
{
bind(entry.getKey(), entry.getValue());
}
@@ -115,7 +118,24 @@
}
/**
- * Bind reference.
+ * Constructs references from params, binds in initial contexts and persists list of all binded
+ * references into file.
+ *
+ * @param bindName
+ * bind name
+ * @param className
+ * class name
+ * @param factory
+ * factory name
+ * @param factoryLocation
+ * factory location
+ * @param refAddr
+ * map of references's properties
+ *
+ * @throws NamingException
+ * if error occurs due to binding
+ * @throws XMLStreamException
+ * @throws FileNotFoundException
*/
public void bind(String bindName, String className, String factory, String factoryLocation,
Map<String, String> refAddr) throws NamingException, FileNotFoundException, XMLStreamException
@@ -128,22 +148,24 @@
bind(bindName, reference);
- bindReferences.put(bindName, reference);
doExport();
}
private void bind(String bindName, Reference reference) throws NamingException
{
initialContextInitializer.getInitialContext().bind(bindName, reference);
+ bindReferences.put(bindName, reference);
}
/**
* Export references into xml-file.
*
- * @throws XMLStreamException
+ * @throws XMLStreamException
+ * if any exception occurs during export
* @throws FileNotFoundException
+ * if can't open output stream from file
*/
- protected void doExport() throws XMLStreamException, FileNotFoundException
+ protected void doExport() throws FileNotFoundException, XMLStreamException
{
XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
XMLStreamWriter writer = outputFactory.createXMLStreamWriter(new FileOutputStream(bindReferencesPath), "UTF-8");
@@ -189,15 +211,19 @@
/**
* Import references from xml-file.
*
- * @return list of references
+ * @return map with bind name - references
*
- * @throws XMLStreamException
+ * @throws XMLStreamException
+ * if errors occurs during import
* @throws FileNotFoundException
+ * if can't open input stream from file
*/
protected Map<String, Reference> doImport() throws FileNotFoundException, XMLStreamException
{
- Map<String, Reference> references = new HashMap<String, Reference>();
+ Stack<RefEntity> stack = new Stack<RefEntity>();
+ Map<String, Reference> importedRefs = new HashMap<String, Reference>();
+
XMLInputFactory factory = XMLInputFactory.newInstance();
XMLEventReader reader = factory.createXMLEventReader(new FileInputStream(bindReferencesPath), "UTF-8");
@@ -208,8 +234,16 @@
{
case XMLStreamConstants.START_ELEMENT :
StartElement startElement = event.asStartElement();
- Map<String, String> attr = parseAttributes(startElement);
+ Map<String, String> attr = new HashMap<String, String>();
+
+ Iterator attributes = startElement.getAttributes();
+ while (attributes.hasNext())
+ {
+ Attribute attribute = (Attribute)attributes.next();
+ attr.put(attribute.getName().getLocalPart(), attribute.getValue());
+ }
+
String localName = startElement.getName().getLocalPart();
if (localName.equals(REFERENCE_ELEMENT))
{
@@ -219,54 +253,31 @@
String factoryLocation = attr.get(FACTORY_LOCATION_ATTR);
Reference reference = new Reference(className, factoryName, factoryLocation);
- for (RefAddr refAddr : importRefAddr(reader))
- {
- reference.add(refAddr);
- }
-
- references.put(bindName, reference);
+ stack.push(new RefEntity(bindName, reference));
}
- break;
- case XMLStreamConstants.END_ELEMENT :
- break;
- default :
- break;
- }
- }
+ else if (localName.equals(PROPERTY_ELEMENT))
+ {
+ RefEntity refEntity = stack.pop();
+ Reference reference = refEntity.getValue();
- return references;
- }
-
- private List<RefAddr> importRefAddr(XMLEventReader reader) throws XMLStreamException
- {
- List<RefAddr> refAddrs = new ArrayList<RefAddr>();
-
- outer : while (reader.hasNext())
- {
- XMLEvent event = reader.nextEvent();
- switch (event.getEventType())
- {
- case XMLStreamConstants.START_ELEMENT :
- StartElement startElement = event.asStartElement();
-
- Map<String, String> attr = parseAttributes(startElement);
-
- String localName = startElement.getName().getLocalPart();
- if (localName.equals(PROPERTY_ELEMENT))
- {
for (Entry<String, String> entry : attr.entrySet())
{
- refAddrs.add(new StringRefAddr(entry.getKey(), entry.getValue()));
+ reference.add(new StringRefAddr(entry.getKey(), entry.getValue()));
}
+
+ refEntity.setValue(reference);
+ stack.push(refEntity);
}
+
break;
case XMLStreamConstants.END_ELEMENT :
EndElement endElement = event.asEndElement();
+ localName = endElement.getName().getLocalPart();
- localName = endElement.getName().getLocalPart();
- if (localName.equals(REFADDR_ELEMENT))
+ if (localName.equals(REFERENCE_ELEMENT))
{
- break outer;
+ RefEntity refEntity = stack.pop();
+ importedRefs.put(refEntity.getKey(), refEntity.getValue());
}
break;
default :
@@ -274,20 +285,67 @@
}
}
- return refAddrs;
+ return importedRefs;
}
- private Map<String, String> parseAttributes(StartElement startElement)
+ /**
+ * Class implements Map.Entry interface and used to push/pop entity in stack.
+ */
+ class RefEntity implements Map.Entry
{
- Map<String, String> attr = new HashMap<String, String>();
- Iterator attributes = startElement.getAttributes();
- while (attributes.hasNext())
+ /**
+ * Entry key.
+ */
+ private final String key;
+
+ /**
+ * Entry value.
+ */
+ private Reference value;
+
+ /**
+ * RefEntity constructor.
+ *
+ * @param key
+ * entry key
+ * @param value
+ * entry value
+ */
+ public RefEntity(String key, Reference value)
{
- Attribute attribute = (Attribute)attributes.next();
- attr.put(attribute.getName().getLocalPart(), attribute.getValue());
+ this.key = key;
+ this.value = value;
}
- return attr;
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getKey()
+ {
+ return key;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Reference getValue()
+ {
+ return value;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Reference setValue(Object value)
+ {
+ Reference oldValue = this.value;
+ this.value = (Reference)value;
+
+ return oldValue;
+ }
}
}
16 years, 1 month
exo-jcr SVN: r2088 - 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-20 03:02:33 -0400 (Sat, 20 Mar 2010)
New Revision: 2088
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/OracleMultiDbJDBCConnection.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleSingleDbJDBCConnection.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
Log:
EXOJCR-519: Avoid duplicating the complex queries just to add the hints, now we use replaceFirst to add the hints
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-19 17:45:28 UTC (rev 2087)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java 2010-03-20 07:02:33 UTC (rev 2088)
@@ -51,6 +51,18 @@
public class MultiDbJDBCConnection extends CQJDBCStorageConnection
{
+ protected static final String FIND_NODES_BY_PARENTID_CQ_QUERY =
+ "select I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA"
+ + " from JCR_MITEM I, JCR_MITEM P, JCR_MVALUE V"
+ + " where I.I_CLASS=1 and I.PARENT_ID=? and"
+ + " P.I_CLASS=2 and P.PARENT_ID=I.ID and (P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')"
+ + " and V.PROPERTY_ID=P.ID order by I.N_ORDER_NUM, I.ID";
+
+ protected static final String FIND_PROPERTIES_BY_PARENTID_CQ_QUERY =
+ "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.NAME";
+
protected PreparedStatement findItemById;
protected PreparedStatement findItemByPath;
@@ -196,12 +208,7 @@
FIND_NODES_BY_PARENTID = "select * from JCR_MITEM" + " where I_CLASS=1 and PARENT_ID=?" + " order by N_ORDER_NUM";
- FIND_NODES_BY_PARENTID_CQ =
- "select I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA"
- + " from JCR_MITEM I, JCR_MITEM P, JCR_MVALUE V"
- + " where I.I_CLASS=1 and I.PARENT_ID=? and"
- + " P.I_CLASS=2 and P.PARENT_ID=I.ID and (P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')"
- + " and V.PROPERTY_ID=P.ID order by I.N_ORDER_NUM, I.ID";
+ FIND_NODES_BY_PARENTID_CQ = FIND_NODES_BY_PARENTID_CQ_QUERY;
FIND_NODE_MAIN_PROPERTIES_BY_PARENTID_CQ =
"select I.NAME, V.DATA, V.ORDER_NUM"
@@ -218,10 +225,7 @@
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.NAME";
+ FIND_PROPERTIES_BY_PARENTID_CQ = FIND_PROPERTIES_BY_PARENTID_CQ_QUERY;
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/OracleMultiDbJDBCConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleMultiDbJDBCConnection.java 2010-03-19 17:45:28 UTC (rev 2087)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleMultiDbJDBCConnection.java 2010-03-20 07:02:33 UTC (rev 2088)
@@ -32,6 +32,15 @@
public class OracleMultiDbJDBCConnection extends MultiDbJDBCConnection
{
+ protected static final String FIND_NODES_BY_PARENTID_CQ_QUERY =
+ MultiDbJDBCConnection.FIND_NODES_BY_PARENTID_CQ_QUERY
+ .replaceFirst("select",
+ "select /*+ INDEX(I JCR_IDX_MITEM_PARENT_ID) INDEX(P JCR_IDX_MITEM_PARENT_ID) INDEX(V JCR_IDX_MVALUE_PROPERTY)*/");
+
+ protected static final String FIND_PROPERTIES_BY_PARENTID_CQ_QUERY =
+ MultiDbJDBCConnection.FIND_PROPERTIES_BY_PARENTID_CQ_QUERY.replaceFirst("select",
+ "select /*+ INDEX(I JCR_IDX_MITEM_PARENT_ID) INDEX(V JCR_IDX_MVALUE_PROPERTY)*/");
+
/**
* Oracle Multidatabase JDBC Connection constructor.
*
@@ -69,15 +78,7 @@
{
super.prepareQueries();
- FIND_NODES_BY_PARENTID_CQ =
- "select /*+ INDEX(I JCR_IDX_MITEM_PARENT_ID) INDEX(P JCR_IDX_MITEM_PARENT_ID) INDEX(V JCR_IDX_MVALUE_PROPERTY)*/ I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA"
- + " from JCR_MITEM I, JCR_MITEM P, JCR_MVALUE V"
- + " where I.I_CLASS=1 and I.PARENT_ID=? and"
- + " P.I_CLASS=2 and P.PARENT_ID=I.ID and (P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')"
- + " and V.PROPERTY_ID=P.ID order by I.N_ORDER_NUM, I.ID";
- FIND_PROPERTIES_BY_PARENTID_CQ =
- "select /*+ INDEX(I JCR_IDX_MITEM_PARENT_ID) INDEX(V JCR_IDX_MVALUE_PROPERTY)*/ 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.NAME";
+ FIND_NODES_BY_PARENTID_CQ = FIND_NODES_BY_PARENTID_CQ_QUERY;
+ FIND_PROPERTIES_BY_PARENTID_CQ = FIND_PROPERTIES_BY_PARENTID_CQ_QUERY;
}
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleSingleDbJDBCConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleSingleDbJDBCConnection.java 2010-03-19 17:45:28 UTC (rev 2087)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleSingleDbJDBCConnection.java 2010-03-20 07:02:33 UTC (rev 2088)
@@ -32,6 +32,15 @@
public class OracleSingleDbJDBCConnection extends SingleDbJDBCConnection
{
+ protected static final String FIND_NODES_BY_PARENTID_CQ_QUERY =
+ SingleDbJDBCConnection.FIND_NODES_BY_PARENTID_CQ_QUERY
+ .replaceFirst("select",
+ "select /*+ INDEX(I JCR_IDX_SITEM_PARENT_ID) INDEX(P JCR_IDX_SITEM_PARENT_ID) INDEX(V JCR_IDX_SVALUE_PROPERTY)*/");
+
+ protected static final String FIND_PROPERTIES_BY_PARENTID_CQ_QUERY =
+ SingleDbJDBCConnection.FIND_PROPERTIES_BY_PARENTID_CQ_QUERY.replaceFirst("select",
+ "select /*+ INDEX(I JCR_IDX_SITEM_PARENT_ID) INDEX(V JCR_IDX_SVALUE_PROPERTY)*/");
+
/**
* Oracle Singledatabase JDBC Connection constructor.
*
@@ -52,7 +61,7 @@
* @throws SQLException
*
* @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
- */
+ */
public OracleSingleDbJDBCConnection(Connection dbConnection, boolean readOnly, String containerName,
ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File swapDirectory, FileCleaner swapCleaner)
throws SQLException
@@ -69,15 +78,7 @@
{
super.prepareQueries();
- FIND_NODES_BY_PARENTID_CQ =
- "select /*+ INDEX(I JCR_IDX_SITEM_PARENT_ID) INDEX(P JCR_IDX_SITEM_PARENT_ID) INDEX(V JCR_IDX_SVALUE_PROPERTY)*/ I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA"
- + " from JCR_SITEM I, JCR_SITEM P, JCR_SVALUE V"
- + " where I.I_CLASS=1 and I.CONTAINER_NAME=? and I.PARENT_ID=? and"
- + " P.I_CLASS=2 and P.CONTAINER_NAME=? and P.PARENT_ID=I.ID and (P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')"
- + " and V.PROPERTY_ID=P.ID order by I.N_ORDER_NUM, I.ID";
- FIND_PROPERTIES_BY_PARENTID_CQ =
- "select /*+ INDEX(I JCR_IDX_SITEM_PARENT_ID) INDEX(V JCR_IDX_SVALUE_PROPERTY)*/ 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 I.CONTAINER_NAME=? and I.PARENT_ID=? order by I.NAME";
+ FIND_NODES_BY_PARENTID_CQ = FIND_NODES_BY_PARENTID_CQ_QUERY;
+ FIND_PROPERTIES_BY_PARENTID_CQ = FIND_PROPERTIES_BY_PARENTID_CQ_QUERY;
}
}
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-19 17:45:28 UTC (rev 2087)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java 2010-03-20 07:02:33 UTC (rev 2088)
@@ -49,6 +49,18 @@
public class SingleDbJDBCConnection extends CQJDBCStorageConnection
{
+ protected static final String FIND_NODES_BY_PARENTID_CQ_QUERY =
+ "select I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA"
+ + " from JCR_SITEM I, JCR_SITEM P, JCR_SVALUE V"
+ + " where I.I_CLASS=1 and I.CONTAINER_NAME=? and I.PARENT_ID=? and"
+ + " P.I_CLASS=2 and P.CONTAINER_NAME=? and P.PARENT_ID=I.ID and (P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')"
+ + " and V.PROPERTY_ID=P.ID order by I.N_ORDER_NUM, I.ID";
+
+ protected static final String FIND_PROPERTIES_BY_PARENTID_CQ_QUERY =
+ "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 I.CONTAINER_NAME=? and I.PARENT_ID=? order by I.NAME";
+
protected PreparedStatement findItemById;
protected PreparedStatement findItemByPath;
@@ -204,12 +216,7 @@
FIND_NODES_BY_PARENTID =
"select * from JCR_SITEM" + " where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?" + " order by N_ORDER_NUM";
- FIND_NODES_BY_PARENTID_CQ =
- "select I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA"
- + " from JCR_SITEM I, JCR_SITEM P, JCR_SVALUE V"
- + " where I.I_CLASS=1 and I.CONTAINER_NAME=? and I.PARENT_ID=? and"
- + " P.I_CLASS=2 and P.CONTAINER_NAME=? and P.PARENT_ID=I.ID and (P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')"
- + " and V.PROPERTY_ID=P.ID order by I.N_ORDER_NUM, I.ID";
+ FIND_NODES_BY_PARENTID_CQ = FIND_NODES_BY_PARENTID_CQ_QUERY;
FIND_NODE_MAIN_PROPERTIES_BY_PARENTID_CQ =
"select I.NAME, V.DATA, V.ORDER_NUM"
@@ -227,10 +234,7 @@
FIND_PROPERTIES_BY_PARENTID =
"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 I.CONTAINER_NAME=? and I.PARENT_ID=? order by I.NAME";
+ FIND_PROPERTIES_BY_PARENTID_CQ = FIND_PROPERTIES_BY_PARENTID_CQ_QUERY;
INSERT_NODE =
"insert into JCR_SITEM(ID, PARENT_ID, NAME, CONTAINER_NAME, VERSION, I_CLASS, I_INDEX, N_ORDER_NUM) VALUES(?,?,?,?,?,"
16 years, 1 month