[jboss-svn-commits] JBL Code SVN: r34959 - in labs/jbossrules/branches/kstam_guvnor_modeshape/drools-repository-jrc-api: src and 5 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Sep 1 11:54:14 EDT 2010
Author: kurt.stam at jboss.com
Date: 2010-09-01 11:54:14 -0400 (Wed, 01 Sep 2010)
New Revision: 34959
Added:
labs/jbossrules/branches/kstam_guvnor_modeshape/drools-repository-jrc-api/pom.xml
labs/jbossrules/branches/kstam_guvnor_modeshape/drools-repository-jrc-api/src/
labs/jbossrules/branches/kstam_guvnor_modeshape/drools-repository-jrc-api/src/main/
labs/jbossrules/branches/kstam_guvnor_modeshape/drools-repository-jrc-api/src/main/java/
labs/jbossrules/branches/kstam_guvnor_modeshape/drools-repository-jrc-api/src/main/java/org/
labs/jbossrules/branches/kstam_guvnor_modeshape/drools-repository-jrc-api/src/main/java/org/drools/
labs/jbossrules/branches/kstam_guvnor_modeshape/drools-repository-jrc-api/src/main/java/org/drools/repository/
labs/jbossrules/branches/kstam_guvnor_modeshape/drools-repository-jrc-api/src/main/java/org/drools/repository/JCRRepositoryConfigurator.java
Modified:
labs/jbossrules/branches/kstam_guvnor_modeshape/drools-repository-jrc-api/
Log:
adding api
Property changes on: labs/jbossrules/branches/kstam_guvnor_modeshape/drools-repository-jrc-api
___________________________________________________________________
Name: svn:ignore
+ .settings
target
.classpath
.project
Added: labs/jbossrules/branches/kstam_guvnor_modeshape/drools-repository-jrc-api/pom.xml
===================================================================
--- labs/jbossrules/branches/kstam_guvnor_modeshape/drools-repository-jrc-api/pom.xml (rev 0)
+++ labs/jbossrules/branches/kstam_guvnor_modeshape/drools-repository-jrc-api/pom.xml 2010-09-01 15:54:14 UTC (rev 34959)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<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>
+ <artifactId>drools</artifactId>
+ <groupId>org.drools</groupId>
+ <version>5.2.0.SNAPSHOT</version>
+ </parent>
+ <artifactId>drools-repository-jcr-api</artifactId>
+ <packaging>jar</packaging>
+ <name>Drools :: Repository</name>
+ <dependencies>
+
+ <dependency>
+ <groupId>javax.jcr</groupId>
+ <artifactId>jcr</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.8</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
Added: labs/jbossrules/branches/kstam_guvnor_modeshape/drools-repository-jrc-api/src/main/java/org/drools/repository/JCRRepositoryConfigurator.java
===================================================================
--- labs/jbossrules/branches/kstam_guvnor_modeshape/drools-repository-jrc-api/src/main/java/org/drools/repository/JCRRepositoryConfigurator.java (rev 0)
+++ labs/jbossrules/branches/kstam_guvnor_modeshape/drools-repository-jrc-api/src/main/java/org/drools/repository/JCRRepositoryConfigurator.java 2010-09-01 15:54:14 UTC (rev 34959)
@@ -0,0 +1,80 @@
+/**
+ * Copyright 2010 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.drools.repository;
+
+import java.util.Properties;
+import java.util.ServiceLoader;
+
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.RepositoryFactory;
+import javax.jcr.Session;
+
+/**
+ * This abstract class is required so different JCR implementations can provide their own configuration mechanism.
+ *
+ * * This contains code to initialise the repository using the {@link javax.jcr.RepositoryFactory} interface defined by the JCR 2.0
+ * specification. This configurator loads the properties from the {@link PROPERTIES_FILE "/drools_repository.properties"}
+ * resource, and passes these to the {@link javax.jcr.RepositoryFactory#getRepository(java.util.Map)}.
+ *
+ * @author Michael Neale
+ */
+public abstract class JCRRepositoryConfigurator {
+
+ protected RepositoryFactory factory;
+
+ public static final String JCR_IMPL_CLASS = "org.drools.repository.jcr.impl";
+ public static final String REPOSITORY_ROOT_DIRECTORY = "repository.root.directory";
+
+ /**
+ * @return a new Repository instance. There should only be one instance of this in an application. Generally, one repository
+ * (which may be binded to JNDI) can spawn multiple sessions for each user as needed. Typically this would be created
+ * on application startup.
+ * @param repositoryRootDirectory The directory where the data is stored. If empty, the repository will be generated there the
+ * first time it is used. If it is null, then a default location will be used (it won't fail).
+ */
+ public Repository getJCRRepository( Properties properties ) throws RepositoryException {
+ try {
+
+ String jcrImplementationClass = properties.getProperty(JCR_IMPL_CLASS);
+ //Instantiate real repo.
+
+ if (jcrImplementationClass==null) {
+ // Use the JCR 2.0 RepositoryFactory to get a repository using the properties as input ...
+ for (RepositoryFactory factory : ServiceLoader.load(RepositoryFactory.class)) {
+ Repository repo = factory.getRepository(properties);
+ if (repo != null) {
+ this.factory = factory;
+ return repo;
+ }
+ }
+ }
+ } catch (RepositoryException re) {
+ throw new RepositoryException(re);
+ }
+ // If here, then we couldn't find a repository factory ...
+ String msg = "Unable to find an appropriate JCR 2.0 RepositoryFactory; check the 'drools_repository.properties' configuration file.";
+ throw new RepositoryException(msg);
+ }
+
+ public abstract void registerNodeTypesFromCndFile(String cndFileName, Session session) throws RepositoryException;
+
+ /**
+ * Method called when the JCR implementation is no longer needed.
+ */
+ public abstract void shutdown();
+}
More information about the jboss-svn-commits
mailing list