jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edgarp...@apache.org
Subject svn commit: r414709 - in /jackrabbit/trunk/jca: ./ deploy/jboss/4.x/ src/java/org/apache/jackrabbit/jca/ src/rar/META-INF/ src/rar10/ src/rar10/META-INF/
Date Fri, 16 Jun 2006 00:15:21 GMT
Author: edgarpoce
Date: Thu Jun 15 17:15:20 2006
New Revision: 414709

URL: http://svn.apache.org/viewvc?rev=414709&view=rev
Log:
JCR-366 Allow o.a.j.jca.JCARepositoryManager to load repository configuration from the classpath.
JCR-462 Improve lifecycle management of JCA connector
JCR-460 Add RAR META-INF/ra.xml descriptor to be used with JCA1.5
- add respository.xml to maven resources
- change jboss deployment descriptor to load config file from the classpath.
- move jca 1.0 descriptor. jca 1.5 descriptor as default.

Added:
    jackrabbit/trunk/jca/src/java/org/apache/jackrabbit/jca/JCAResourceAdapter.java
    jackrabbit/trunk/jca/src/rar10/
    jackrabbit/trunk/jca/src/rar10/META-INF/
    jackrabbit/trunk/jca/src/rar10/META-INF/ra.xml
Modified:
    jackrabbit/trunk/jca/deploy/jboss/4.x/jcr-ds.xml
    jackrabbit/trunk/jca/project.xml
    jackrabbit/trunk/jca/src/java/org/apache/jackrabbit/jca/JCAManagedConnectionFactory.java
    jackrabbit/trunk/jca/src/java/org/apache/jackrabbit/jca/JCARepositoryManager.java
    jackrabbit/trunk/jca/src/rar/META-INF/ra.xml

Modified: jackrabbit/trunk/jca/deploy/jboss/4.x/jcr-ds.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jca/deploy/jboss/4.x/jcr-ds.xml?rev=414709&r1=414708&r2=414709&view=diff
==============================================================================
--- jackrabbit/trunk/jca/deploy/jboss/4.x/jcr-ds.xml (original)
+++ jackrabbit/trunk/jca/deploy/jboss/4.x/jcr-ds.xml Thu Jun 15 17:15:20 2006
@@ -1,13 +1,10 @@
 <connection-factories> 
     <tx-connection-factory>
-	<jndi-name>jcr</jndi-name> 
-	<adapter-display-name>JCR Adapter</adapter-display-name>
-	<rar-name>jackrabbit-jca.rar</rar-name>
-	<connection-definition>javax.jcr.Session</connection-definition>
-	<xa-transaction/>
-	
-	<!-- Configuration properties. -->
-	<config-property name="homeDir">\dev\jcr</config-property>
-	<config-property name="configFile">\dev\jcr\repository.xml</config-property>
+		<jndi-name>jcr/local</jndi-name> 
+		<xa-transaction/>
+		<rar-name>jackrabbit-jca.rar</rar-name>
+		<connection-definition>javax.jcr.Repository</connection-definition>
+		<config-property name="homeDir" type="java.lang.String">/temp/jackrabbit</config-property>
+		<config-property name="configFile" type="java.lang.String">classpath:repository.xml</config-property>
     </tx-connection-factory>
-</connection-factories> 
+</connection-factories>
\ No newline at end of file

Modified: jackrabbit/trunk/jca/project.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jca/project.xml?rev=414709&r1=414708&r2=414709&view=diff
==============================================================================
--- jackrabbit/trunk/jca/project.xml (original)
+++ jackrabbit/trunk/jca/project.xml Thu Jun 15 17:15:20 2006
@@ -120,6 +120,12 @@
                     <include>README.txt</include>
                 </includes>
             </resource>
+			<resource>
+			    <directory>applications/test</directory>
+			    <includes>
+					<include>*.xml</include>
+			    </includes>
+			</resource>
         </resources>
 	<unitTest>
 	    <includes>

Modified: jackrabbit/trunk/jca/src/java/org/apache/jackrabbit/jca/JCAManagedConnectionFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jca/src/java/org/apache/jackrabbit/jca/JCAManagedConnectionFactory.java?rev=414709&r1=414708&r2=414709&view=diff
==============================================================================
--- jackrabbit/trunk/jca/src/java/org/apache/jackrabbit/jca/JCAManagedConnectionFactory.java
(original)
+++ jackrabbit/trunk/jca/src/java/org/apache/jackrabbit/jca/JCAManagedConnectionFactory.java
Thu Jun 15 17:15:20 2006
@@ -247,13 +247,6 @@
     }
 
     /**
-     * Shutdown the repository.
-     */
-    protected void finalize() {
-        shutdownRepository();
-    }
-
-    /**
      * Create repository.
      */
     private void createRepository()
@@ -280,11 +273,12 @@
         }
     }
 
-    /**
-     * Shutdown the repository.
-     */
-    private void shutdownRepository() {
+	/**
+	 * Shutdown the repository.
+	 */
+	protected void finalize() {
         JCARepositoryManager mgr = JCARepositoryManager.getInstance();
-        mgr.shutdownRepository(homeDir, configFile);
-    }
+        mgr.autoShutdownRepository(homeDir, configFile);
+	}
+
 }

Modified: jackrabbit/trunk/jca/src/java/org/apache/jackrabbit/jca/JCARepositoryManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jca/src/java/org/apache/jackrabbit/jca/JCARepositoryManager.java?rev=414709&r1=414708&r2=414709&view=diff
==============================================================================
--- jackrabbit/trunk/jca/src/java/org/apache/jackrabbit/jca/JCARepositoryManager.java (original)
+++ jackrabbit/trunk/jca/src/java/org/apache/jackrabbit/jca/JCARepositoryManager.java Thu
Jun 15 17:15:20 2006
@@ -20,13 +20,20 @@
 import org.apache.jackrabbit.core.config.RepositoryConfig;
 
 import javax.jcr.RepositoryException;
+
+import java.io.InputStream;
+import java.util.Collection;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Map;
 
 /**
  * This class implements the repository manager.
  */
 public final class JCARepositoryManager {
+	
+    /** The config file prefix that signifies the file is to be loaded from the classpath.
*/
+    public static final String CLASSPATH_CONFIG_PREFIX = "classpath:";
 
     /**
      * Instance of manager.
@@ -38,6 +45,13 @@
      * References.
      */
     private final Map references;
+    
+    /**
+     * Flag indicating that the life cycle 
+     * of the resource is not managed by the
+     * application server 
+     */
+    private boolean autoShutdown = true ;
 
     /**
      * Construct the manager.
@@ -56,12 +70,18 @@
     }
 
     /**
-     * Shutdown the repository.
+     * Shutdown all the repositories.
      */
-    public void shutdownRepository(String homeDir, String configFile) {
-        Reference ref = getReference(homeDir, configFile);
-        ref.shutdown();
+    public void shutdown() {
+    	Collection references = this.references.values() ;
+    	Iterator iter = references.iterator() ;
+    	while (iter.hasNext()) {
+			Reference ref = (Reference) iter.next();
+			ref.shutdown();	
+		}
+        this.references.clear();
     }
+    
 
     /**
      * Return the reference.
@@ -97,7 +117,7 @@
         /**
          * Configuration file.
          */
-        private final String configFile;
+        private String configFile;
 
         /**
          * Repository instance.
@@ -105,18 +125,12 @@
         private RepositoryImpl repository;
 
         /**
-         * Reference count.
-         */
-        private int count;
-
-        /**
          * Construct the manager.
          */
         private Reference(String homeDir, String configFile) {
             this.homeDir = homeDir;
             this.configFile = configFile;
             this.repository = null;
-            this.count = 0;
         }
 
         /**
@@ -125,11 +139,23 @@
         public RepositoryImpl create()
                 throws RepositoryException {
             if (repository == null) {
-                RepositoryConfig config = RepositoryConfig.create(configFile, homeDir);
+                RepositoryConfig config = null;
+
+                if (configFile.startsWith(CLASSPATH_CONFIG_PREFIX)) {
+                    ClassLoader cl = Thread.currentThread().getContextClassLoader();
+                    if (cl == null) {
+                        cl = this.getClass().getClassLoader();
+                    }
+                    
+                    InputStream configInputStream = cl.getResourceAsStream(
+                        configFile.substring(CLASSPATH_CONFIG_PREFIX.length()));
+                    config = RepositoryConfig.create(configInputStream, homeDir);
+                } else {
+                    config = RepositoryConfig.create(configFile, homeDir);
+                }
                 repository = RepositoryImpl.create(config);
             }
 
-            count++;
             return repository;
         }
 
@@ -137,14 +163,7 @@
          * Shutdown the repository.
          */
         public void shutdown() {
-            if (count > 0) {
-                count--;
-
-                if (count == 0) {
-                    repository.shutdown();
-                    repository = null;
-                }
-            }
+	        repository.shutdown();
         }
 
         /**
@@ -190,5 +209,24 @@
             }
         }
     }
+
+	public boolean isAutoShutdown() {
+		return autoShutdown;
+	}
+
+	public void setAutoShutdown(boolean autoShutdown) {
+		this.autoShutdown = autoShutdown;
+	}
+
+	/**
+	 * Try to shutdown the repository only if
+	 * {@link JCARepositoryManager#autoShutdown} is true.
+	 */
+	public void autoShutdownRepository(String homeDir, String configFile) {
+		if (this.isAutoShutdown()) {
+		    Reference ref = getReference(homeDir, configFile);
+		    ref.shutdown();
+		}
+	}
 }
 

Added: jackrabbit/trunk/jca/src/java/org/apache/jackrabbit/jca/JCAResourceAdapter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jca/src/java/org/apache/jackrabbit/jca/JCAResourceAdapter.java?rev=414709&view=auto
==============================================================================
--- jackrabbit/trunk/jca/src/java/org/apache/jackrabbit/jca/JCAResourceAdapter.java (added)
+++ jackrabbit/trunk/jca/src/java/org/apache/jackrabbit/jca/JCAResourceAdapter.java Thu Jun
15 17:15:20 2006
@@ -0,0 +1,44 @@
+package org.apache.jackrabbit.jca;
+
+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;
+
+
+/**
+ * JCR ResourceAdapter. 
+ */
+public class JCAResourceAdapter implements ResourceAdapter {
+	private final XAResource[] xaResources = new XAResource[0];
+
+	/**
+	 * Notify the RepositoryManager that the lifecycle is managed by
+	 * the container
+	 */
+	public void start(BootstrapContext ctx) throws ResourceAdapterInternalException {
+		JCARepositoryManager.getInstance().setAutoShutdown(false);
+	}
+
+	/**
+	 * Shutdown jackrabbit repositories
+	 */
+	public void stop() {
+		JCARepositoryManager.getInstance().shutdown();
+	}
+
+	public void endpointActivation(MessageEndpointFactory mef, ActivationSpec as) throws ResourceException
{
+	}
+
+	public void endpointDeactivation(MessageEndpointFactory mef, ActivationSpec as) {
+	}
+
+	public XAResource[] getXAResources(ActivationSpec[] as) throws ResourceException {
+		return xaResources;
+	}
+
+
+}

Modified: jackrabbit/trunk/jca/src/rar/META-INF/ra.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jca/src/rar/META-INF/ra.xml?rev=414709&r1=414708&r2=414709&view=diff
==============================================================================
--- jackrabbit/trunk/jca/src/rar/META-INF/ra.xml (original)
+++ jackrabbit/trunk/jca/src/rar/META-INF/ra.xml Thu Jun 15 17:15:20 2006
@@ -1,35 +1,42 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE connector PUBLIC
-    '-//Sun Microsystems, Inc.//DTD Connector 1.0//EN'
-    'http://java.sun.com/dtd/connector_1_0.dtd'>
-<connector>
-    <display-name>Jackrabbit JCR Adapter</display-name>
-    <vendor-name>Apache.org</vendor-name>
-    <spec-version>1.0</spec-version>
-    <eis-type>JCR Adapter</eis-type>
-    <version>1.0</version>
-    
-    <license>
-	<description>ASF</description>
-	<license-required>false</license-required>
-    </license>
+<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">
 
-    <resourceadapter>
-	<managedconnectionfactory-class>org.apache.jackrabbit.jca.JCAManagedConnectionFactory</managedconnectionfactory-class>
-	<connectionfactory-interface>javax.jcr.Repository</connectionfactory-interface>
-	<connectionfactory-impl-class>org.apache.jackrabbit.jca.JCARepositoryHandle</connectionfactory-impl-class>
-	<connection-interface>javax.jcr.Session</connection-interface>
-	<connection-impl-class>org.apache.jackrabbit.jca.JCASessionHandle</connection-impl-class>
-	<transaction-support>XATransaction</transaction-support>
-	<config-property>
-	    <config-property-name>HomeDir</config-property-name>
-	    <config-property-type>java.lang.String</config-property-type>
-	</config-property>
-	<config-property>
-	    <config-property-name>ConfigFile</config-property-name>
-	    <config-property-type>java.lang.String</config-property-type>
-	</config-property>
-	<reauthentication-support>false</reauthentication-support>	
-    </resourceadapter>
+	<display-name>Jackrabbit JCR Adapter</display-name>
+	<vendor-name>Apache.org</vendor-name>
+	<eis-type>JCR Adapter</eis-type>
+	<resourceadapter-version>1.0</resourceadapter-version>
+
+	<resourceadapter>
+		<resourceadapter-class>org.apache.jackrabbit.jca.JCAResourceAdapter</resourceadapter-class>
+		<outbound-resourceadapter>
+		
+			<connection-definition>
+			
+				<managedconnectionfactory-class>org.apache.jackrabbit.jca.JCAManagedConnectionFactory</managedconnectionfactory-class>
+				
+				<config-property>
+					<config-property-name>HomeDir</config-property-name>
+					<config-property-type>java.lang.String</config-property-type>
+				</config-property>
+				<config-property>
+					<config-property-name>ConfigFile</config-property-name>
+					<config-property-type>java.lang.String</config-property-type>
+				</config-property>
+				
+				<connectionfactory-interface>javax.jcr.Repository</connectionfactory-interface>
+				<connectionfactory-impl-class>org.apache.jackrabbit.jca.JCARepositoryHandle</connectionfactory-impl-class>
+				
+				<connection-interface>javax.jcr.Session</connection-interface>
+				<connection-impl-class>org.apache.jackrabbit.jca.JCASessionHandle</connection-impl-class>
+
+			</connection-definition>
+			
+			<transaction-support>XATransaction</transaction-support>
+			<reauthentication-support>false</reauthentication-support>
+		</outbound-resourceadapter>			
+	</resourceadapter>
 </connector>
-	   
\ No newline at end of file

Added: jackrabbit/trunk/jca/src/rar10/META-INF/ra.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jca/src/rar10/META-INF/ra.xml?rev=414709&view=auto
==============================================================================
--- jackrabbit/trunk/jca/src/rar10/META-INF/ra.xml (added)
+++ jackrabbit/trunk/jca/src/rar10/META-INF/ra.xml Thu Jun 15 17:15:20 2006
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE connector PUBLIC
+    '-//Sun Microsystems, Inc.//DTD Connector 1.0//EN'
+    'http://java.sun.com/dtd/connector_1_0.dtd'>
+<connector>
+    <display-name>Jackrabbit JCR Adapter</display-name>
+    <vendor-name>Apache.org</vendor-name>
+    <spec-version>1.0</spec-version>
+    <eis-type>JCR Adapter</eis-type>
+    <version>1.0</version>
+    
+    <license>
+	<description>ASF</description>
+	<license-required>false</license-required>
+    </license>
+
+    <resourceadapter>
+	<managedconnectionfactory-class>org.apache.jackrabbit.jca.JCAManagedConnectionFactory</managedconnectionfactory-class>
+	<connectionfactory-interface>javax.jcr.Repository</connectionfactory-interface>
+	<connectionfactory-impl-class>org.apache.jackrabbit.jca.JCARepositoryHandle</connectionfactory-impl-class>
+	<connection-interface>javax.jcr.Session</connection-interface>
+	<connection-impl-class>org.apache.jackrabbit.jca.JCASessionHandle</connection-impl-class>
+	<transaction-support>XATransaction</transaction-support>
+	<config-property>
+	    <config-property-name>HomeDir</config-property-name>
+	    <config-property-type>java.lang.String</config-property-type>
+	</config-property>
+	<config-property>
+	    <config-property-name>ConfigFile</config-property-name>
+	    <config-property-type>java.lang.String</config-property-type>
+	</config-property>
+	<reauthentication-support>false</reauthentication-support>	
+    </resourceadapter>
+</connector>
+	   
\ No newline at end of file



Mime
View raw message