[exo-jcr-commits] exo-jcr SVN: r4411 - in jcr/trunk: applications/exo.jcr.applications.jboss and 20 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon May 23 09:24:46 EDT 2011


Author: tolusha
Date: 2011-05-23 09:24:45 -0400 (Mon, 23 May 2011)
New Revision: 4411

Added:
   jcr/trunk/applications/exo.jcr.ear/src/main/application/META-INF/jboss-app.xml
   jcr/trunk/applications/product-patches/as/jboss/ds/
   jcr/trunk/applications/product-patches/as/jboss/ds/jcr-ds.xml
   jcr/trunk/exo.jcr.connectors.jca/
   jcr/trunk/exo.jcr.connectors.jca/pom.xml
   jcr/trunk/exo.jcr.connectors.jca/src/
   jcr/trunk/exo.jcr.connectors.jca/src/main/
   jcr/trunk/exo.jcr.connectors.jca/src/main/java/
   jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/
   jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/
   jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/
   jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/
   jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/adapter/
   jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/adapter/SessionFactory.java
   jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/impl/
   jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/impl/adapter/
   jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/impl/adapter/ManagedSessionFactory.java
   jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/impl/adapter/ManagedSessionImpl.java
   jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/impl/adapter/RepositoryResourceAdapter.java
   jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/impl/adapter/SessionFactoryImpl.java
   jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/impl/adapter/SessionRequestInfo.java
   jcr/trunk/exo.jcr.connectors.jca/src/main/rar/
   jcr/trunk/exo.jcr.connectors.jca/src/main/rar/META-INF/
   jcr/trunk/exo.jcr.connectors.jca/src/main/rar/META-INF/ra.xml
   jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/jca.xml
Removed:
   jcr/trunk/exo.jcr.connectors.localadapter/
Modified:
   jcr/trunk/applications/exo.jcr.applications.jboss/pom.xml
   jcr/trunk/applications/exo.jcr.ear/pom.xml
   jcr/trunk/exo.jcr.component.core/pom.xml
   jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr.xml
   jcr/trunk/pom.xml
Log:
EXOJCR-1328: JCA support

Modified: jcr/trunk/applications/exo.jcr.applications.jboss/pom.xml
===================================================================
--- jcr/trunk/applications/exo.jcr.applications.jboss/pom.xml	2011-05-23 13:19:32 UTC (rev 4410)
+++ jcr/trunk/applications/exo.jcr.applications.jboss/pom.xml	2011-05-23 13:24:45 UTC (rev 4411)
@@ -120,6 +120,9 @@
                   <copy todir="${exo.projects.directory.working}/exo-jboss/server/default/conf/" verbose="true" overwrite="true">
                      <fileset dir="${basedir}/../product-patches/as/jboss/exoplatform.sar/META-INF/" includes="login*.xml" />
                   </copy>
+                  <copy todir="${exo.projects.directory.working}/exo-jboss/server/default/deploy/" verbose="true" overwrite="true">
+                     <fileset dir="${basedir}/../product-patches/as/jboss/ds/" includes="*.xml" />
+                  </copy>
                   <copy todir="${exo.projects.directory.working}/exo-jboss/bin/" verbose="true" overwrite="true">
                      <fileset dir="${basedir}/../product-patches/as/jboss/bin/" includes="*.*" />
                   </copy>

Modified: jcr/trunk/applications/exo.jcr.ear/pom.xml
===================================================================
--- jcr/trunk/applications/exo.jcr.ear/pom.xml	2011-05-23 13:19:32 UTC (rev 4410)
+++ jcr/trunk/applications/exo.jcr.ear/pom.xml	2011-05-23 13:24:45 UTC (rev 4411)
@@ -35,17 +35,67 @@
   <dependencies>
     <dependency>
       <groupId>org.exoplatform.jcr</groupId>
-      <artifactId>exo.jcr.connectors.localadapter</artifactId>
+      <artifactId>exo.jcr.connectors.jca</artifactId>
       <scope>runtime</scope>
       <type>rar</type>
     </dependency>
     <dependency>
       <groupId>org.exoplatform.jcr</groupId>
+      <artifactId>exo.jcr.component.core</artifactId>
+      <scope>runtime</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>com.sun.xml.parsers</groupId>
+          <artifactId>jaxp-ri</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>javax.servlet</groupId>
+          <artifactId>servlet-api</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.exoplatform.jcr</groupId>
+      <artifactId>exo.jcr.component.ext</artifactId>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.exoplatform.jcr</groupId>
+      <artifactId>exo.jcr.component.ftp</artifactId>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.exoplatform.jcr</groupId>
+      <artifactId>exo.jcr.framework.command</artifactId>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.exoplatform.jcr</groupId>
+      <artifactId>exo.jcr.framework.ftpclient</artifactId>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.exoplatform.jcr</groupId>
+      <artifactId>exo.jcr.framework.web</artifactId>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.exoplatform.ws</groupId>
+      <artifactId>exo.ws.frameworks.servlet</artifactId>
+      <scope>runtime</scope>
+    </dependency>    
+    <dependency>
+      <groupId>org.exoplatform.jcr</groupId>
       <artifactId>exo.jcr.applications.rest</artifactId>
       <scope>runtime</scope>
       <type>war</type>
     </dependency>
     <dependency>
+      <groupId>com.sun.xml.bind</groupId>
+      <artifactId>jaxb-impl</artifactId>
+      <scope>runtime</scope>
+    </dependency>    
+    <dependency>
       <groupId>org.exoplatform.jcr</groupId>
       <artifactId>exo.jcr.applications.browser</artifactId>
       <scope>runtime</scope>
@@ -79,8 +129,7 @@
               <role-name>administrators</role-name>
             </security-role>
           </security>
-          <!-- all deps jars inside the rar, so copy all jars in-self -->
-          <defaultLibBundleDir>../APP-INF/lib</defaultLibBundleDir>
+          <defaultLibBundleDir>APP-INF/lib</defaultLibBundleDir>
           <archive>
             <manifest>
               <addClasspath>true</addClasspath>
@@ -89,7 +138,7 @@
           <modules>
             <rarModule>
               <groupId>org.exoplatform.jcr</groupId>
-              <artifactId>exo.jcr.connectors.localadapter</artifactId>
+              <artifactId>exo.jcr.connectors.jca</artifactId>
               <bundleFileName>exo-jcr.rar</bundleFileName>
             </rarModule>
             <webModule>

Added: jcr/trunk/applications/exo.jcr.ear/src/main/application/META-INF/jboss-app.xml
===================================================================
--- jcr/trunk/applications/exo.jcr.ear/src/main/application/META-INF/jboss-app.xml	                        (rev 0)
+++ jcr/trunk/applications/exo.jcr.ear/src/main/application/META-INF/jboss-app.xml	2011-05-23 13:24:45 UTC (rev 4411)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+    Copyright (C) 2009 eXo Platform SAS.
+
+    This is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Lesser General Public License as
+    published by the Free Software Foundation; either version 2.1 of
+    the License, or (at your option) any later version.
+
+    This software is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this software; if not, write to the Free
+    Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+    02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+<!DOCTYPE jboss-app PUBLIC "-//JBoss//DTD J2EE Application 4.2//EN" "http://www.jboss.org/j2ee/dtd/jboss-app_4_2.dtd">
+<jboss-app>
+<library-directory>APP-INF/lib</library-directory>
+</jboss-app>
\ No newline at end of file

Added: jcr/trunk/applications/product-patches/as/jboss/ds/jcr-ds.xml
===================================================================
--- jcr/trunk/applications/product-patches/as/jboss/ds/jcr-ds.xml	                        (rev 0)
+++ jcr/trunk/applications/product-patches/as/jboss/ds/jcr-ds.xml	2011-05-23 13:24:45 UTC (rev 4411)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<connection-factories>
+
+  <tx-connection-factory>
+
+    <jndi-name>jcr/repository</jndi-name>
+
+    <xa-transaction/>
+
+    <rar-name>exo.jcr.ear.ear#exo-jcr.rar</rar-name>
+
+    <adapter-display-name>eXo JCR Adapter</adapter-display-name>
+    <connection-definition>org.exoplatform.connectors.jcr.adapter.SessionFactory</connection-definition>
+    <!--
+    <config-property name="PortalContainer" type="java.lang.String">portal</config-property>
+    -->
+    <config-property name="Repository" type="java.lang.String">repository</config-property>
+  </tx-connection-factory>
+
+</connection-factories>

Modified: jcr/trunk/exo.jcr.component.core/pom.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/pom.xml	2011-05-23 13:19:32 UTC (rev 4410)
+++ jcr/trunk/exo.jcr.component.core/pom.xml	2011-05-23 13:24:45 UTC (rev 4411)
@@ -140,10 +140,6 @@
          <artifactId>picocontainer</artifactId>
       </dependency>
       <dependency>
-         <groupId>javax.resource</groupId>
-         <artifactId>connector-api</artifactId>
-      </dependency>
-      <dependency>
          <groupId>javax.transaction</groupId>
          <artifactId>jta</artifactId>
       </dependency>

Added: jcr/trunk/exo.jcr.connectors.jca/pom.xml
===================================================================
--- jcr/trunk/exo.jcr.connectors.jca/pom.xml	                        (rev 0)
+++ jcr/trunk/exo.jcr.connectors.jca/pom.xml	2011-05-23 13:24:45 UTC (rev 4411)
@@ -0,0 +1,88 @@
+<?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.
+
+-->
+<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">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.exoplatform.jcr</groupId>
+    <artifactId>jcr-parent</artifactId>
+    <version>1.14.0-GA-SNAPSHOT</version>
+  </parent>
+  <artifactId>exo.jcr.connectors.jca</artifactId>
+  <packaging>rar</packaging>
+  <name>eXo JCR :: Connector :: JCA</name>
+  <description>JCA resource adapter for eXo JCR</description>
+  <dependencies>
+    <dependency>
+      <groupId>org.exoplatform.jcr</groupId>
+      <artifactId>exo.jcr.component.core</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>javax.resource</groupId>
+      <artifactId>connector-api</artifactId>
+      <scope>provided</scope>
+    </dependency>    
+  </dependencies>
+  <build>
+    <resources>
+      <resource>
+        <directory>src/main/rar</directory>
+        <targetPath>${project.build.directory}</targetPath>
+        <filtering>true</filtering>
+      </resource>
+    </resources>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <configuration>
+          <archive>
+            <manifest>
+              <addClasspath>true</addClasspath>
+            </manifest>
+          </archive>
+        </configuration>
+        <executions>
+          <!-- We manually ask to create the JAR and it is automatically included in the RAR -->
+          <execution>
+            <phase>compile</phase>
+            <goals>
+              <goal>jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-rar-plugin</artifactId>
+        <configuration>
+          <raXmlFile>${project.build.directory}/META-INF/ra.xml</raXmlFile>
+          <archive>
+            <manifest>
+              <addClasspath>true</addClasspath>
+            </manifest>
+          </archive>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/adapter/SessionFactory.java
===================================================================
--- jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/adapter/SessionFactory.java	                        (rev 0)
+++ jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/adapter/SessionFactory.java	2011-05-23 13:24:45 UTC (rev 4411)
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.connectors.jcr.adapter;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.resource.cci.ConnectionFactory;
+
+/**
+ * The equivalent of a {@link ConnectionFactory} for the JCR
+ * 
+ * @author <a href="mailto:nfilotto at exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ *
+ */
+public interface SessionFactory
+{
+   /**
+    * Get a JCR session corresponding to the repository
+    * defined in the configuration and the default workspace.
+    * @return a JCR session corresponding to the criteria
+    * @throws RepositoryException if the session could not be created
+    */
+   Session getSession() throws RepositoryException;
+
+   /**
+    * Get a JCR session corresponding to the repository
+    * defined in the configuration and the default workspace, using
+    * the given user name and password.
+    * @param userName the user name to use for the authentication
+    * @param password the password to use for the authentication
+    * @return a JCR session corresponding to the criteria
+    * @throws RepositoryException if the session could not be created
+    */
+   Session getSession(String userName, String password) throws RepositoryException;
+
+   /**
+    * Get a JCR session corresponding to the repository
+    * defined in the configuration and the given workspace.
+    * @param workspace the name of the expected workspace
+    * @return a JCR session corresponding to the criteria
+    * @throws RepositoryException if the session could not be created
+    */
+   Session getSession(String workspace) throws RepositoryException;
+
+   /**
+    * Get a JCR session corresponding to the repository
+    * defined in the configuration and the given workspace, using
+    * the given user name and password.
+    * @param workspace the name of the expected workspace
+    * @param userName the user name to use for the authentication
+    * @param password the password to use for the authentication
+    * @return a JCR session corresponding to the criteria
+    * @throws RepositoryException if the session could not be created
+    */
+   Session getSession(String workspace, String userName, String password) throws RepositoryException;
+}

Added: jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/impl/adapter/ManagedSessionFactory.java
===================================================================
--- jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/impl/adapter/ManagedSessionFactory.java	                        (rev 0)
+++ jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/impl/adapter/ManagedSessionFactory.java	2011-05-23 13:24:45 UTC (rev 4411)
@@ -0,0 +1,342 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.connectors.jcr.impl.adapter;
+
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.container.RootContainer;
+import org.exoplatform.services.jcr.RepositoryService;
+import org.exoplatform.services.jcr.core.CredentialsImpl;
+import org.exoplatform.services.jcr.core.ManageableRepository;
+import org.exoplatform.services.jcr.impl.core.SessionImpl;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+import java.io.PrintWriter;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.jcr.Credentials;
+import javax.resource.NotSupportedException;
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionManager;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionFactory;
+import javax.resource.spi.security.PasswordCredential;
+import javax.security.auth.Subject;
+
+/**
+ * @author <a href="mailto:nfilotto at exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ *
+ */
+public class ManagedSessionFactory implements ManagedConnectionFactory
+{
+
+   /**
+    * The serial version UID
+    */
+   private static final long serialVersionUID = 2298804451713956342L;
+
+   /**
+    * Logger
+    */
+   private static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.ManagedSessionFactory");
+
+   /**
+    * The default name of the portal container
+    */
+   private String portalContainer;
+
+   /**
+    * The name of the repository
+    */
+   private String repository;
+
+   /**
+    * @see javax.resource.spi.ManagedConnectionFactory#createConnectionFactory()
+    */
+   public Object createConnectionFactory() throws ResourceException
+   {
+      if (LOG.isDebugEnabled())
+      {
+         LOG.debug("createConnectionFactory()");
+      }
+      throw new NotSupportedException("Only managed environments are supported");
+   }
+
+   /**
+    * @see javax.resource.spi.ManagedConnectionFactory#createConnectionFactory(javax.resource.spi.ConnectionManager)
+    */
+   public Object createConnectionFactory(ConnectionManager cxManager) throws ResourceException
+   {
+      if (LOG.isDebugEnabled())
+      {
+         LOG.debug("createConnectionFactory(" + cxManager + ")");
+      }
+      return new SessionFactoryImpl(cxManager, this);
+   }
+
+   /**
+    * @see javax.resource.spi.ManagedConnectionFactory#createManagedConnection(javax.security.auth.Subject, javax.resource.spi.ConnectionRequestInfo)
+    */
+   public ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo cxRequestInfo)
+      throws ResourceException
+   {
+      if (LOG.isDebugEnabled())
+      {
+         LOG.debug("createManagedConnection(" + subject + "," + cxRequestInfo + ")");
+      }
+      if (!(cxRequestInfo instanceof SessionRequestInfo))
+      {
+         throw new ResourceException("The connection request info must be an instance of type SessionRequestInfo");
+      }
+      ExoContainer container = getContainer();
+      if (LOG.isDebugEnabled())
+      {
+         LOG.debug("createManagedConnection: container = " + container.getContext().getName());
+      }
+      RepositoryService rs = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
+      if (rs == null)
+      {
+         throw new ResourceException("No RepositoryService could be found in the container "
+            + container.getContext().getName());
+      }
+      ManageableRepository mRepository = getRepository(rs);
+      SessionRequestInfo sri = (SessionRequestInfo)cxRequestInfo;
+      String workspaceName = sri.getWorkspace();
+      if (LOG.isDebugEnabled())
+      {
+         LOG.debug("createManagedConnection: workspace = " + (workspaceName == null ? "'default'" : workspaceName));
+      }
+      Credentials credentials = getCredentials(subject, sri);
+      SessionImpl session = null;
+      try
+      {
+         session = (SessionImpl)mRepository.login(credentials, workspaceName);
+      }
+      catch (Exception e)
+      {
+         throw new ResourceException("Could not login to the workspace " + (workspaceName == null ? "'default'" : workspaceName), e);
+      }
+      return new ManagedSessionImpl(session);
+   }
+
+   /**
+    * Gets the credentials from the subject, if it cannot be found and the user name
+    * has been set in the {@link SessionRequestInfo}, we will use the credentials
+    * from the {@link SessionRequestInfo}, otherwise we will use the credentials
+    * defined in the configuration of the {@link ManagedSessionFactory}.
+    */
+   private Credentials getCredentials(final Subject subject, SessionRequestInfo sri) throws ResourceException
+   {
+      CredentialsImpl credentials = null;
+      if (subject != null)
+      {
+         credentials = AccessController.doPrivileged(new PrivilegedAction<CredentialsImpl>()
+         {
+            public CredentialsImpl run()
+            {
+               Iterator<Object> i = subject.getPrivateCredentials().iterator();
+               while (i.hasNext())
+               {
+                  Object o = i.next();
+                  if (o instanceof PasswordCredential)
+                  {
+                     PasswordCredential cred = (PasswordCredential)o;
+                     if (cred.getManagedConnectionFactory().equals(ManagedSessionFactory.this))
+                     {
+                        return new CredentialsImpl(cred.getUserName(), cred.getPassword());
+                     }
+                  }
+               }
+               return null;
+            }
+         });
+      }
+      if (credentials == null && sri.getUserName() != null)
+      {
+         credentials =
+            new CredentialsImpl(sri.getUserName(), sri.getPassword() == null ? null : sri.getPassword()
+               .toCharArray());
+      }
+      if (LOG.isDebugEnabled())
+      {
+         LOG.debug("getCredentials: login = " + (credentials == null ? "undefined" : credentials.getUserID()));
+      }
+      return credentials;
+   }
+
+   /**
+    * Gets the repository corresponding to the given context, if a repository name
+    * has been defined in the configuration of the {@link ManagedSessionFactory}
+    * it will try to get it otherwise it will get the current repository
+    */
+   private ManageableRepository getRepository(RepositoryService rs) throws ResourceException
+   {
+      ManageableRepository mRepository = null;
+      try
+      {
+         mRepository = repository == null ? rs.getCurrentRepository() : rs.getRepository(repository);
+      }
+      catch (Exception e)
+      {
+         throw new ResourceException("Could not get the "
+            + (repository == null ? "current repository." : "repository '" + repository + "'"), e);
+      }
+      if (mRepository == null)
+      {
+         throw new ResourceException("Could not find the "
+            + (repository == null ? "current repository." : "repository '" + repository + "'"));
+      }
+      if (LOG.isDebugEnabled())
+      {
+         LOG.debug("getRepository: repository = " + (repository == null ? "current." : repository));
+      }
+
+      return mRepository;
+   }
+
+   /**
+    * Gets the container from the current context
+    */
+   private ExoContainer getContainer() throws ResourceException
+   {
+      ExoContainer container = ExoContainerContext.getCurrentContainer();
+      if (container instanceof RootContainer)
+      {
+         String portalContainerName =
+            portalContainer == null ? PortalContainer.DEFAULT_PORTAL_CONTAINER_NAME : portalContainer;
+         container = RootContainer.getInstance().getPortalContainer(portalContainerName);
+         if (container == null)
+         {
+            throw new ResourceException("The eXo container is null, because the current container is a RootContainer "
+               + "and there is no PortalContainer with the name '" + portalContainerName + "'.");
+         }
+      }
+      else if (container == null)
+      {
+         throw new ResourceException("The eXo container is null, because the current container is null.");
+      }
+      return container;
+   }
+
+   /**
+    * @see javax.resource.spi.ManagedConnectionFactory#getLogWriter()
+    */
+   public PrintWriter getLogWriter() throws ResourceException
+   {
+      return null;
+   }
+
+   /**
+    * @see javax.resource.spi.ManagedConnectionFactory#matchManagedConnections(java.util.Set, javax.security.auth.Subject, javax.resource.spi.ConnectionRequestInfo)
+    */
+   public ManagedConnection matchManagedConnections(@SuppressWarnings("rawtypes") Set connectionSet, Subject subject,
+      ConnectionRequestInfo cxRequestInfo) throws ResourceException
+   {
+      throw new NotSupportedException("The JCR sessions are not shareable");
+   }
+
+   /**
+    * @see javax.resource.spi.ManagedConnectionFactory#setLogWriter(java.io.PrintWriter)
+    */
+   public void setLogWriter(PrintWriter out) throws ResourceException
+   {
+   }
+
+   /**
+    * @return the portalContainer
+    */
+   public String getPortalContainer()
+   {
+      return portalContainer;
+   }
+
+   /**
+    * @param portalContainer the portalContainer to set
+    */
+   public void setPortalContainer(String portalContainer)
+   {
+      this.portalContainer = portalContainer;
+   }
+
+   /**
+    * @return the repository
+    */
+   public String getRepository()
+   {
+      return repository;
+   }
+
+   /**
+    * @param repository the repository to set
+    */
+   public void setRepository(String repository)
+   {
+      this.repository = repository;
+   }
+
+   /**
+    * @see java.lang.Object#hashCode()
+    */
+   @Override
+   public int hashCode()
+   {
+      final int prime = 31;
+      int result = 1;
+      result = prime * result + ((portalContainer == null) ? 0 : portalContainer.hashCode());
+      result = prime * result + ((repository == null) ? 0 : repository.hashCode());
+      return result;
+   }
+
+   /**
+    * @see java.lang.Object#equals(java.lang.Object)
+    */
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (this == obj)
+         return true;
+      if (obj == null)
+         return false;
+      if (getClass() != obj.getClass())
+         return false;
+      ManagedSessionFactory other = (ManagedSessionFactory)obj;
+      if (portalContainer == null)
+      {
+         if (other.portalContainer != null)
+            return false;
+      }
+      else if (!portalContainer.equals(other.portalContainer))
+         return false;
+      if (repository == null)
+      {
+         if (other.repository != null)
+            return false;
+      }
+      else if (!repository.equals(other.repository))
+         return false;
+      return true;
+   }
+}

Added: jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/impl/adapter/ManagedSessionImpl.java
===================================================================
--- jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/impl/adapter/ManagedSessionImpl.java	                        (rev 0)
+++ jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/impl/adapter/ManagedSessionImpl.java	2011-05-23 13:24:45 UTC (rev 4411)
@@ -0,0 +1,205 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.connectors.jcr.impl.adapter;
+
+import org.exoplatform.services.jcr.core.ExtendedSession;
+import org.exoplatform.services.jcr.core.SessionLifecycleListener;
+import org.exoplatform.services.jcr.impl.core.SessionImpl;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+import java.io.PrintWriter;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import javax.resource.NotSupportedException;
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionEvent;
+import javax.resource.spi.ConnectionEventListener;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.LocalTransaction;
+import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionMetaData;
+import javax.security.auth.Subject;
+import javax.transaction.xa.XAResource;
+
+/**
+ * The implementation of a {@link ManagedConnection} for eXo JCR.
+ * 
+ * @author <a href="mailto:nfilotto at exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ *
+ */
+public class ManagedSessionImpl implements ManagedConnection
+{
+
+   /**
+    * Logger
+    */
+   private static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.ManagedSessionImpl");
+
+   /**
+    * The corresponding JCR session
+    */
+   private final SessionImpl session;
+
+   /**
+    * The list of all the existing listeners
+    */
+   private final List<ConnectionEventListener> listeners;
+
+   ManagedSessionImpl(SessionImpl session)
+   {
+      this.session = session;
+      this.listeners = new CopyOnWriteArrayList<ConnectionEventListener>();
+      session.registerLifecycleListener(new SessionLifecycleListener()
+      {
+         public void onCloseSession(ExtendedSession session)
+         {
+            onConnectionClosed();
+         }         
+      });
+   }
+
+   /**
+    * @see javax.resource.spi.ManagedConnection#addConnectionEventListener(javax.resource.spi.ConnectionEventListener)
+    */
+   public void addConnectionEventListener(ConnectionEventListener listener)
+   {
+      listeners.add(listener);
+   }
+
+   /**
+    * @see javax.resource.spi.ManagedConnection#associateConnection(java.lang.Object)
+    */
+   public void associateConnection(Object connection) throws ResourceException
+   {
+      throw new NotSupportedException("The JCR sessions are not shareable");
+   }
+
+   /**
+    * @see javax.resource.spi.ManagedConnection#cleanup()
+    */
+   public void cleanup() throws ResourceException
+   {
+   }
+
+   /**
+    * @see javax.resource.spi.ManagedConnection#destroy()
+    */
+   public void destroy() throws ResourceException
+   {
+      session.logout();
+   }
+
+   /**
+    * @see javax.resource.spi.ManagedConnection#getConnection(javax.security.auth.Subject, javax.resource.spi.ConnectionRequestInfo)
+    */
+   public Object getConnection(Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException
+   {
+      return session;
+   }
+
+   /**
+    * @see javax.resource.spi.ManagedConnection#getLocalTransaction()
+    */
+   public LocalTransaction getLocalTransaction() throws ResourceException
+   {
+      throw new NotSupportedException("Local transactions are not supported");
+   }
+
+   /**
+    * @see javax.resource.spi.ManagedConnection#getLogWriter()
+    */
+   public PrintWriter getLogWriter() throws ResourceException
+   {
+      return null;
+   }
+
+   /**
+    * @see javax.resource.spi.ManagedConnection#getMetaData()
+    */
+   public ManagedConnectionMetaData getMetaData() throws ResourceException
+   {
+      return new ManagedConnectionMetaData()
+      {
+         public String getUserName() throws ResourceException
+         {
+            return session.getUserID();
+         }
+         
+         public int getMaxConnections() throws ResourceException
+         {
+            return 0;
+         }
+         
+         public String getEISProductVersion() throws ResourceException
+         {
+            return "1.14";
+         }
+         
+         public String getEISProductName() throws ResourceException
+         {
+            return "eXo JCR";
+         }
+      };
+   }
+
+   /**
+    * @see javax.resource.spi.ManagedConnection#getXAResource()
+    */
+   public XAResource getXAResource() throws ResourceException
+   {
+      return session.getXAResource();
+   }
+
+   /**
+    * @see javax.resource.spi.ManagedConnection#removeConnectionEventListener(javax.resource.spi.ConnectionEventListener)
+    */
+   public void removeConnectionEventListener(ConnectionEventListener listener)
+   {
+      listeners.remove(listener);
+   }
+
+   /**
+    * @see javax.resource.spi.ManagedConnection#setLogWriter(java.io.PrintWriter)
+    */
+   public void setLogWriter(PrintWriter out) throws ResourceException
+   {
+   }
+
+   /**
+    * Broadcasts the connection closed event
+    */
+   private void onConnectionClosed()
+   {
+      ConnectionEvent evt = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED);
+      for (ConnectionEventListener listener : listeners)
+      {
+         try
+         {
+            listener.connectionClosed(evt);
+         }
+         catch (Exception e1)
+         {
+            LOG.warn("An error occurs while notifying the listener " + listener, e1);
+         }
+      }
+   }
+}

Added: jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/impl/adapter/RepositoryResourceAdapter.java
===================================================================
--- jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/impl/adapter/RepositoryResourceAdapter.java	                        (rev 0)
+++ jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/impl/adapter/RepositoryResourceAdapter.java	2011-05-23 13:24:45 UTC (rev 4411)
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.connectors.jcr.impl.adapter;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ActivationSpec;
+import javax.resource.spi.BootstrapContext;
+import javax.resource.spi.ResourceAdapter;
+import javax.resource.spi.ResourceAdapterInternalException;
+import javax.resource.spi.endpoint.MessageEndpointFactory;
+import javax.transaction.xa.XAResource;
+
+/**
+ * A dummy ResourceAdapter
+ * 
+ * @author <a href="mailto:nfilotto at exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ *
+ */
+public class RepositoryResourceAdapter implements ResourceAdapter
+{
+
+   /**
+    * @see javax.resource.spi.ResourceAdapter#endpointActivation(javax.resource.spi.endpoint.MessageEndpointFactory, javax.resource.spi.ActivationSpec)
+    */
+   public void endpointActivation(MessageEndpointFactory endpointFactory, ActivationSpec spec) throws ResourceException
+   {
+   }
+
+   /**
+    * @see javax.resource.spi.ResourceAdapter#endpointDeactivation(javax.resource.spi.endpoint.MessageEndpointFactory, javax.resource.spi.ActivationSpec)
+    */
+   public void endpointDeactivation(MessageEndpointFactory endpointFactory, ActivationSpec spec)
+   {
+   }
+
+   /**
+    * @see javax.resource.spi.ResourceAdapter#getXAResources(javax.resource.spi.ActivationSpec[])
+    */
+   public XAResource[] getXAResources(ActivationSpec[] specs) throws ResourceException
+   {
+      return new XAResource[0];
+   }
+
+   /**
+    * @see javax.resource.spi.ResourceAdapter#start(javax.resource.spi.BootstrapContext)
+    */
+   public void start(BootstrapContext ctx) throws ResourceAdapterInternalException
+   {
+   }
+
+   /**
+    * @see javax.resource.spi.ResourceAdapter#stop()
+    */
+   public void stop()
+   {
+   }
+}

Added: jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/impl/adapter/SessionFactoryImpl.java
===================================================================
--- jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/impl/adapter/SessionFactoryImpl.java	                        (rev 0)
+++ jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/impl/adapter/SessionFactoryImpl.java	2011-05-23 13:24:45 UTC (rev 4411)
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.connectors.jcr.impl.adapter;
+
+import org.exoplatform.connectors.jcr.adapter.SessionFactory;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionManager;
+
+/**
+ * The default implementation of the {@link SessionFactory}.
+ * 
+ * @author <a href="mailto:nfilotto at exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ *
+ */
+public class SessionFactoryImpl implements SessionFactory
+{
+
+   /**
+    * Logger
+    */
+   private static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.SessionFactoryImpl");
+
+   /**
+    * The serial version UID
+    */
+   private static final long serialVersionUID = 6643308860647346790L;
+
+   /**
+    * The reference
+    */
+   private Reference reference;
+
+   /**
+    * The connection manager
+    */
+   private final ConnectionManager cm;
+
+   /**
+    * The managed session factory
+    */
+   private final ManagedSessionFactory msf;
+
+   /**
+    * The default constructor
+    */
+   SessionFactoryImpl(ConnectionManager cm, ManagedSessionFactory msf)
+   {
+      this.cm = cm;
+      this.msf = msf;
+   }
+
+   /**
+    * @see javax.resource.Referenceable#setReference(javax.naming.Reference)
+    */
+   public void setReference(Reference reference)
+   {
+      this.reference = reference;
+   }
+
+   /**
+    * @see javax.naming.Referenceable#getReference()
+    */
+   public Reference getReference() throws NamingException
+   {
+      return reference;
+   }
+
+   /**
+    * @see org.exoplatform.connectors.jcr.adapter.SessionFactory#getSession()
+    */
+   public Session getSession() throws RepositoryException
+   {
+      return getSession(null);
+   }
+
+   /**
+    * @see org.exoplatform.connectors.jcr.adapter.SessionFactory#getSession(java.lang.String, java.lang.String)
+    */
+   public Session getSession(String userName, String password) throws RepositoryException
+   {
+      return getSession(null, userName, password);
+   }
+
+   /**
+    * @see org.exoplatform.connectors.jcr.adapter.SessionFactory#getSession(java.lang.String)
+    */
+   public Session getSession(String workspace) throws RepositoryException
+   {
+      return getSession(workspace, null, null);
+   }
+
+   /**
+    * @see org.exoplatform.connectors.jcr.adapter.SessionFactory#getSession(java.lang.String, java.lang.String, java.lang.String)
+    */
+   public Session getSession(String workspace, String userName, String password) throws RepositoryException
+   {
+      SessionRequestInfo sri = new SessionRequestInfo(workspace, userName, password);
+      if (LOG.isDebugEnabled())
+      {
+         LOG.debug("getSession " + sri);
+      }
+      try
+      {
+         return (Session)cm.allocateConnection(msf, sri);
+      }
+      catch (ResourceException e)
+      {
+         throw new RepositoryException("Could not allocate a connection", e);
+      }
+   }
+}

Added: jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/impl/adapter/SessionRequestInfo.java
===================================================================
--- jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/impl/adapter/SessionRequestInfo.java	                        (rev 0)
+++ jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/impl/adapter/SessionRequestInfo.java	2011-05-23 13:24:45 UTC (rev 4411)
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.connectors.jcr.impl.adapter;
+
+import javax.resource.spi.ConnectionRequestInfo;
+
+/**
+ * @author <a href="mailto:nfilotto at exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ *
+ */
+public class SessionRequestInfo implements ConnectionRequestInfo
+{
+
+   /**
+    * The name of the expected workspace
+    */
+   private final String workspace;
+
+   /**
+    * The user name to use for the authentication
+    */
+   private final String userName;
+
+   /**
+    * The password to use for the authentication
+    */
+   private final String password;
+
+   /**
+    * The default constructor
+    */
+   SessionRequestInfo(String workspace, String userName, String password)
+   {
+      this.workspace = workspace;
+      this.userName = userName;
+      this.password = password;
+   }
+
+   /**
+    * @return the workspace
+    */
+   public String getWorkspace()
+   {
+      return workspace;
+   }
+
+   /**
+    * @return the userName
+    */
+   public String getUserName()
+   {
+      return userName;
+   }
+
+   /**
+    * @return the password
+    */
+   public String getPassword()
+   {
+      return password;
+   }
+
+   /**
+    * @see java.lang.Object#toString()
+    */
+   @Override
+   public String toString()
+   {
+      return "SessionRequestInfo [workspace=" + workspace + ", userName=" + userName + ", password=" + password + "]";
+   }
+
+   /**
+    * @see java.lang.Object#hashCode()
+    */
+   @Override
+   public int hashCode()
+   {
+      final int prime = 31;
+      int result = 1;
+      result = prime * result + ((workspace == null) ? 0 : workspace.hashCode());
+      result = prime * result + ((userName == null) ? 0 : userName.hashCode());
+      result = prime * result + ((password == null) ? 0 : password.hashCode());
+      return result;
+   }
+
+   /**
+    * @see java.lang.Object#equals(java.lang.Object)
+    */
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (this == obj)
+         return true;
+      if (obj == null)
+         return false;
+      if (getClass() != obj.getClass())
+         return false;
+      SessionRequestInfo other = (SessionRequestInfo)obj;
+      if (workspace == null)
+      {
+         if (other.workspace != null)
+            return false;
+      }
+      else if (!workspace.equals(other.workspace))
+         return false;
+      if (userName == null)
+      {
+         if (other.userName != null)
+            return false;
+      }
+      else if (!userName.equals(other.userName))
+         return false;
+      if (password == null)
+      {
+         if (other.password != null)
+            return false;
+      }
+      else if (!password.equals(other.password))
+         return false;
+      return true;
+   }
+}

Added: jcr/trunk/exo.jcr.connectors.jca/src/main/rar/META-INF/ra.xml
===================================================================
--- jcr/trunk/exo.jcr.connectors.jca/src/main/rar/META-INF/ra.xml	                        (rev 0)
+++ jcr/trunk/exo.jcr.connectors.jca/src/main/rar/META-INF/ra.xml	2011-05-23 13:24:45 UTC (rev 4411)
@@ -0,0 +1,66 @@
+<?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.
+
+-->
+<connector xmlns="http://java.sun.com/xml/ns/j2ee"
+           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+           xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+           http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
+           version="1.5">
+
+   <description>Resource Adapter for eXo JCR</description>
+   <display-name>eXo JCR ResourceAdapter</display-name>
+
+   <vendor-name>eXo Platform SAS</vendor-name>
+   <eis-type />
+   <resourceadapter-version>${project.version}</resourceadapter-version>
+   <license>
+      <license-required>false</license-required>
+   </license>
+   
+   <resourceadapter>
+      <resourceadapter-class>org.exoplatform.connectors.jcr.impl.adapter.RepositoryResourceAdapter</resourceadapter-class>
+      <outbound-resourceadapter>
+         <connection-definition>
+            <managedconnectionfactory-class>org.exoplatform.connectors.jcr.impl.adapter.ManagedSessionFactory</managedconnectionfactory-class>
+            <config-property>
+               <description>In case of the portal mode, if no portal container can be found in the context of the request, the adapter will use the value of this parameter to get the name of the expected portal container to create the JCR sessions. In case of a standalone mode, this parameter is not used. This parameter is optional, by default the default portal container will be used.</description>
+               <config-property-name>PortalContainer</config-property-name>
+               <config-property-type>java.lang.String</config-property-type>
+            </config-property>
+            <config-property>
+               <description>The repository name used to create JCR sessions. This parameter is optional, by default the current repository will be used.</description>
+               <config-property-name>Repository</config-property-name>
+               <config-property-type>java.lang.String</config-property-type>
+            </config-property>
+            <connectionfactory-interface>org.exoplatform.connectors.jcr.adapter.SessionFactory</connectionfactory-interface>
+            <connectionfactory-impl-class>org.exoplatform.connectors.jcr.impl.adapter.SessionFactoryImpl</connectionfactory-impl-class>
+            <connection-interface>javax.jcr.Session</connection-interface>
+            <connection-impl-class>org.exoplatform.services.jcr.impl.core.SessionImpl</connection-impl-class>
+         </connection-definition>
+         <transaction-support>XATransaction</transaction-support>
+         <authentication-mechanism>
+            <authentication-mechanism-type>BasicPassword</authentication-mechanism-type>
+            <credential-interface>javax.resource.spi.security.PasswordCredential</credential-interface>
+         </authentication-mechanism>
+         <reauthentication-support>false</reauthentication-support>
+      </outbound-resourceadapter>
+   </resourceadapter>
+</connector>
\ No newline at end of file

Added: jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/jca.xml
===================================================================
--- jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/jca.xml	                        (rev 0)
+++ jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/jca.xml	2011-05-23 13:24:45 UTC (rev 4411)
@@ -0,0 +1,137 @@
+<?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="JCR.JCA">
+  <?dbhtml filename="ch-jca.html"?>
+
+  <title>The <emphasis>JCA</emphasis> Resource Adapter</title>
+
+  <section>
+    <title>Overview</title>
+
+    <para>eXo JCR supports <emphasis>J2EE Connector Architecture</emphasis>
+    1.5, thus If you would like to delegate the JCR Session lifecycle to your
+    application server, you can use the JCA Resource Adapter for eXo JCR if
+    your application server supports JCA 1.5. This adapter only supports XA
+    Transaction, in other words you cannot use it for local transactions.
+    Since the JCR Sessions have not been designed to be shareable, the session
+    pooling is simply not covered by the adapter.</para>
+  </section>
+
+  <section>
+    <title>The <emphasis>SessionFactory</emphasis></title>
+
+    <para>The equivalent of the
+    <emphasis>javax.resource.cci.ConnectionFactory</emphasis> in JCA
+    terminology is
+    <emphasis>org.exoplatform.connectors.jcr.adapter.SessionFactory</emphasis>
+    in the context of eXo JCR, the resource that you will get thanks to a JNDI
+    lookup is of type <emphasis>SessionFactory</emphasis> and provides the
+    following methods:</para>
+
+    <programlisting>   /**
+    * Get a JCR session corresponding to the repository
+    * defined in the configuration and the default workspace.
+    * @return a JCR session corresponding to the criteria
+    * @throws RepositoryException if the session could not be created
+    */
+   Session getSession() throws RepositoryException;
+
+   /**
+    * Get a JCR session corresponding to the repository
+    * defined in the configuration and the default workspace, using
+    * the given user name and password.
+    * @param userName the user name to use for the authentication
+    * @param password the password to use for the authentication
+    * @return a JCR session corresponding to the criteria
+    * @throws RepositoryException if the session could not be created
+    */
+   Session getSession(String userName, String password) throws RepositoryException;
+
+   /**
+    * Get a JCR session corresponding to the repository
+    * defined in the configuration and the given workspace.
+    * @param workspace the name of the expected workspace
+    * @return a JCR session corresponding to the criteria
+    * @throws RepositoryException if the session could not be created
+    */
+   Session getSession(String workspace) throws RepositoryException;
+
+   /**
+    * Get a JCR session corresponding to the repository
+    * defined in the configuration and the given workspace, using
+    * the given user name and password.
+    * @param workspace the name of the expected workspace
+    * @param userName the user name to use for the authentication
+    * @param password the password to use for the authentication
+    * @return a JCR session corresponding to the criteria
+    * @throws RepositoryException if the session could not be created
+    */
+   Session getSession(String workspace, String userName, String password) throws RepositoryException;</programlisting>
+  </section>
+
+  <section>
+    <title>Configuration</title>
+
+    <table>
+      <title>Configuration Properties</title>
+
+      <tgroup cols="2">
+        <tbody>
+          <row>
+            <entry><emphasis>PortalContainer</emphasis></entry>
+
+            <entry>In case of the portal mode, if no portal container can be
+            found in the context of the request, the adapter will use the
+            value of this parameter to get the name of the expected portal
+            container to create the JCR sessions. In case of a standalone
+            mode, this parameter is not used. This parameter is optional, by
+            default the default portal container will be used.</entry>
+          </row>
+
+          <row>
+            <entry><emphasis>Repository</emphasis></entry>
+
+            <entry>The repository name used to create JCR sessions. This
+            parameter is optional, by default the current repository will be
+            used.</entry>
+          </row>
+        </tbody>
+      </tgroup>
+    </table>
+  </section>
+
+  <section>
+    <title>Deployment</title>
+
+    <para>In case of the standalone mode where the JCR and its dependencies
+    are not provided, you will need to deploy the whole ear file corresponding
+    to the artifactId <emphasis>exo.jcr.ear</emphasis> and groupId
+    <emphasis>org.exoplatform.jcr</emphasis>, the rar file is embedded into
+    the ear file. In case the JCR and its dependencies are provided like when
+    you use it with gateIn for example, you will need to deploy only the rar
+    file corresponding to the artifactId
+    <emphasis>exo.jcr.connectors.jca</emphasis> and groupId
+    <emphasis>org.exoplatform.jcr</emphasis>.</para>
+
+    <para>Then you will need to configure the connector itself, for example
+    for JBoss AS, you need to create in your deploy directory a file of type
+    <emphasis>*-ds.xml</emphasis> (jcr-ds.xml for example) with the following
+    content:</para>
+
+    <programlisting>&lt;connection-factories&gt;
+  &lt;tx-connection-factory&gt;
+    &lt;jndi-name&gt;jcr/repository&lt;/jndi-name&gt;
+    &lt;xa-transaction/&gt;
+    &lt;!-- The rar name will be exo.jcr.connectors.jca.X.Y.Z.rar in case you deploy only the rar file --&gt;
+    &lt;rar-name&gt;exo.jcr.ear.ear#exo-jcr.rar&lt;/rar-name&gt;
+    &lt;adapter-display-name&gt;eXo JCR Adapter&lt;/adapter-display-name&gt;
+    &lt;connection-definition&gt;org.exoplatform.connectors.jcr.adapter.SessionFactory&lt;/connection-definition&gt;
+    &lt;!--
+    &lt;config-property name="PortalContainer" type="java.lang.String"&gt;portal&lt;/config-property&gt;
+    --&gt;
+    &lt;config-property name="Repository" type="java.lang.String"&gt;repository&lt;/config-property&gt;
+  &lt;/tx-connection-factory&gt;
+&lt;/connection-factories&gt;</programlisting>
+  </section>
+</chapter>

Modified: jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr.xml
===================================================================
--- jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr.xml	2011-05-23 13:19:32 UTC (rev 4410)
+++ jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr.xml	2011-05-23 13:24:45 UTC (rev 4411)
@@ -132,6 +132,9 @@
   <xi:include href="jcr/jta.xml"
               xmlns:xi="http://www.w3.org/2001/XInclude" />
 
+  <xi:include href="jcr/jca.xml"
+              xmlns:xi="http://www.w3.org/2001/XInclude" />
+
   <xi:include href="jcr/other/acl.xml"
               xmlns:xi="http://www.w3.org/2001/XInclude" />                            
               

Modified: jcr/trunk/pom.xml
===================================================================
--- jcr/trunk/pom.xml	2011-05-23 13:19:32 UTC (rev 4410)
+++ jcr/trunk/pom.xml	2011-05-23 13:24:45 UTC (rev 4411)
@@ -191,7 +191,7 @@
       </dependency>
       <dependency>
         <groupId>org.exoplatform.jcr</groupId>
-        <artifactId>exo.jcr.connectors.localadapter</artifactId>
+        <artifactId>exo.jcr.connectors.jca</artifactId>
         <type>rar</type>
         <version>${project.version}</version>
       </dependency>
@@ -473,7 +473,7 @@
     <module>exo.jcr.component.ext</module>
     <module>exo.jcr.component.ftp</module>
     <module>exo.jcr.component.webdav</module>
-    <module>exo.jcr.connectors.localadapter</module>
+    <module>exo.jcr.connectors.jca</module>
     <module>exo.jcr.framework.command</module>
     <module>exo.jcr.framework.web</module>
     <module>exo.jcr.framework.ftpclient</module>



More information about the exo-jcr-commits mailing list