[jboss-cvs] JBossAS SVN: r101088 - in projects/jpa/trunk: deployers/src/main/java/org/jboss/jpa/deployers and 29 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Feb 17 15:01:33 EST 2010
Author: johnbailey
Date: 2010-02-17 15:01:32 -0500 (Wed, 17 Feb 2010)
New Revision: 101088
Added:
projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployment/PersistenceUnitDeploymentFactory.java
projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/util/ServiceLoader.java
projects/jpa/trunk/deployers/src/test/java/org/jboss/jpa/deployers/test/common/MockPersistenceUnitDeployment.java
projects/jpa/trunk/deployers/src/test/java/org/jboss/jpa/deployers/test/common/MockPersistenceUnitDeploymentFactory.java
projects/jpa/trunk/deployers/src/test/resources/META-INF/services/
projects/jpa/trunk/deployers/src/test/resources/META-INF/services/org.jboss.jpa.deployment.PersistenceUnitDeploymentFactory
projects/jpa/trunk/vfs2/
projects/jpa/trunk/vfs2/pom.xml
projects/jpa/trunk/vfs2/src/
projects/jpa/trunk/vfs2/src/main/
projects/jpa/trunk/vfs2/src/main/java/
projects/jpa/trunk/vfs2/src/main/java/org/
projects/jpa/trunk/vfs2/src/main/java/org/jboss/
projects/jpa/trunk/vfs2/src/main/java/org/jboss/jpa/
projects/jpa/trunk/vfs2/src/main/java/org/jboss/jpa/deployment/
projects/jpa/trunk/vfs2/src/main/java/org/jboss/jpa/deployment/vfs2/
projects/jpa/trunk/vfs2/src/main/java/org/jboss/jpa/deployment/vfs2/PersistenceUnitDeploymentFactoryImpl.java
projects/jpa/trunk/vfs2/src/main/java/org/jboss/jpa/deployment/vfs2/PersistenceUnitDeploymentImpl.java
projects/jpa/trunk/vfs2/src/main/resources/
projects/jpa/trunk/vfs2/src/main/resources/META-INF/
projects/jpa/trunk/vfs2/src/main/resources/META-INF/services/
projects/jpa/trunk/vfs2/src/main/resources/META-INF/services/org.jboss.jpa.deployment.PersistenceUnitDeploymentFactory
projects/jpa/trunk/vfs3/
projects/jpa/trunk/vfs3/pom.xml
projects/jpa/trunk/vfs3/src/
projects/jpa/trunk/vfs3/src/main/
projects/jpa/trunk/vfs3/src/main/java/
projects/jpa/trunk/vfs3/src/main/java/org/
projects/jpa/trunk/vfs3/src/main/java/org/jboss/
projects/jpa/trunk/vfs3/src/main/java/org/jboss/jpa/
projects/jpa/trunk/vfs3/src/main/java/org/jboss/jpa/deployment/
projects/jpa/trunk/vfs3/src/main/java/org/jboss/jpa/deployment/vfs3/
projects/jpa/trunk/vfs3/src/main/java/org/jboss/jpa/deployment/vfs3/PersistenceUnitDeploymentFactoryImpl.java
projects/jpa/trunk/vfs3/src/main/java/org/jboss/jpa/deployment/vfs3/PersistenceUnitDeploymentImpl.java
projects/jpa/trunk/vfs3/src/main/resources/
projects/jpa/trunk/vfs3/src/main/resources/META-INF/
projects/jpa/trunk/vfs3/src/main/resources/META-INF/services/
projects/jpa/trunk/vfs3/src/main/resources/META-INF/services/org.jboss.jpa.deployment.PersistenceUnitDeploymentFactory
Modified:
projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployers/PersistenceUnitDeployer.java
projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployment/PersistenceDeployment.java
projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployment/PersistenceUnitDeployment.java
Log:
[JBJPA-21] - Created VFS abstractions to remove the VFS compile time dependency from deployers
Modified: projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployers/PersistenceUnitDeployer.java
===================================================================
--- projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployers/PersistenceUnitDeployer.java 2010-02-17 17:28:07 UTC (rev 101087)
+++ projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployers/PersistenceUnitDeployer.java 2010-02-17 20:01:32 UTC (rev 101088)
@@ -39,6 +39,7 @@
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.jpa.deployment.PersistenceUnitDeployment;
+import org.jboss.jpa.deployment.PersistenceUnitDeploymentFactory;
import org.jboss.jpa.resolvers.DataSourceDependencyResolver;
import org.jboss.jpa.resolvers.PersistenceUnitDependencyResolver;
import org.jboss.metadata.jpa.spec.PersistenceUnitMetaData;
@@ -109,7 +110,7 @@
InitialContext initialContext = new InitialContext();
List<String> explicitEntityClasses = new ArrayList<String>();
VFSDeploymentUnit deploymentUnit = (VFSDeploymentUnit) unit.getParent();
- PersistenceUnitDeployment pu = new PersistenceUnitDeployment(initialContext, null, explicitEntityClasses, metaData, name, deploymentUnit, defaultPersistenceProperties);
+ PersistenceUnitDeployment pu = PersistenceUnitDeploymentFactory.getInstance().create(initialContext, null, explicitEntityClasses, metaData, name, deploymentUnit, defaultPersistenceProperties);
AbstractBeanMetaData beanMetaData = new AbstractBeanMetaData(name, PersistenceUnitDeployment.class.getName());
BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(beanMetaData);
Modified: projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployment/PersistenceDeployment.java
===================================================================
--- projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployment/PersistenceDeployment.java 2010-02-17 17:28:07 UTC (rev 101087)
+++ projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployment/PersistenceDeployment.java 2010-02-17 20:01:32 UTC (rev 101088)
@@ -203,7 +203,7 @@
metaData.setProperties(properties);
}
- PersistenceUnitDeployment deployment = new PersistenceUnitDeployment(initialContext, this, explicitEntityClasses, metaData, "wrong-kernel-name", getDeploymentUnit(), null);
+ PersistenceUnitDeployment deployment = PersistenceUnitDeploymentFactory.getInstance().create(initialContext, this, explicitEntityClasses, metaData, "wrong-kernel-name", getDeploymentUnit(), null);
PersistenceUnitRegistry.register(deployment);
persistenceUnitDeployments.add(deployment);
}
Modified: projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployment/PersistenceUnitDeployment.java
===================================================================
--- projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployment/PersistenceUnitDeployment.java 2010-02-17 17:28:07 UTC (rev 101087)
+++ projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployment/PersistenceUnitDeployment.java 2010-02-17 20:01:32 UTC (rev 101088)
@@ -21,8 +21,6 @@
*/
package org.jboss.jpa.deployment;
-import java.io.IOException;
-import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
@@ -49,8 +47,6 @@
import org.jboss.logging.Logger;
import org.jboss.metadata.jpa.spec.PersistenceUnitMetaData;
import org.jboss.util.naming.NonSerializableFactory;
-import org.jboss.virtual.VFSUtils;
-import org.jboss.virtual.VirtualFile;
/**
* Comment
@@ -58,7 +54,7 @@
* @author <a href="mailto:bill at jboss.org">Bill Burke</a>
* @version $Revision$
*/
-public class PersistenceUnitDeployment //extends AbstractJavaEEComponent
+public abstract class PersistenceUnitDeployment //extends AbstractJavaEEComponent
implements PersistenceUnit
{
private static final Logger log = Logger.getLogger(PersistenceUnitDeployment.class);
@@ -145,24 +141,11 @@
}
/**
- * Find the persistence unit root, which can be the root of a jar
+ * Find the persistence unit URL, which can be the root of a jar
* or WEB-INF/classes of a war.
- * @return the persistence unit root
+ * @return the persistence unit ULR
*/
- protected VirtualFile getPersistenceUnitRoot()
- {
- // FIXME: What is the correct way to find the persistence unit root?
- try
- {
- VirtualFile metaData = di.getMetaDataFile("persistence.xml");
- assert metaData != null : "Can't find persistence.xml in " + di;
- return metaData.getParent().getParent();
- }
- catch(IOException e)
- {
- throw new RuntimeException(e);
- }
- }
+ protected abstract URL getPersistenceUnitURL();
public EntityManagerFactory getContainerEntityManagerFactory()
{
@@ -187,30 +170,8 @@
return (properties != null) ? properties : Collections.<String, String>emptyMap();
}
- private URL getRelativeURL(String jar)
- {
- try
- {
- return new URL(jar);
- }
- catch (MalformedURLException e)
- {
- try
- {
- VirtualFile deploymentUnitFile = di.getFile("");
- VirtualFile parent = deploymentUnitFile.getParent();
- VirtualFile baseDir = (parent != null ? parent : deploymentUnitFile);
- VirtualFile jarFile = baseDir.getChild(jar);
- if(jarFile == null)
- throw new RuntimeException("could not find child '" + jar + "' on '" + baseDir + "'");
- return jarFile.toURL();
- }
- catch (Exception e1)
- {
- throw new RuntimeException("could not find relative path: " + jar, e1);
- }
- }
- }
+ protected abstract URL getRelativeURL(String jar);
+
public EntityManager getTransactionScopedEntityManager()
{
@@ -286,10 +247,8 @@
}
}
- VirtualFile root = getPersistenceUnitRoot();
- log.debug("Persistence root: " + root);
- // hack the JPA url
- URL url = VFSUtils.getCompatibleURL(root);
+ URL url = getPersistenceUnitURL();
+ log.debug("Persistence url: " + url);
PersistenceUnitInfoImpl pi = new PersistenceUnitInfoImpl(metaData, props, di.getClassLoader(), url, jarFiles, initialContext);
if (explicitEntityClasses.size() > 0)
Added: projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployment/PersistenceUnitDeploymentFactory.java
===================================================================
--- projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployment/PersistenceUnitDeploymentFactory.java (rev 0)
+++ projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployment/PersistenceUnitDeploymentFactory.java 2010-02-17 20:01:32 UTC (rev 101088)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.jboss.jpa.deployment;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import javax.naming.InitialContext;
+
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.jpa.util.ServiceLoader;
+import org.jboss.metadata.jpa.spec.PersistenceUnitMetaData;
+
+/**
+ * Factory used to create {@link PersistenceUnitDeployment} instances.
+ *
+ * @author John Bailey
+ */
+public abstract class PersistenceUnitDeploymentFactory
+{
+ /**
+ * Get a factory instance.
+ *
+ * @return factory instance
+ */
+ public static PersistenceUnitDeploymentFactory getInstance() {
+ ServiceLoader<PersistenceUnitDeploymentFactory> factoryLoader = ServiceLoader.load(PersistenceUnitDeploymentFactory.class);
+
+ Iterator<PersistenceUnitDeploymentFactory> factoryIterator = factoryLoader.iterator();
+
+ PersistenceUnitDeploymentFactory factory = null;
+ if(factoryIterator.hasNext())
+ {
+ factory = factoryIterator.next();
+ if(factoryIterator.hasNext())
+ {
+ throw new RuntimeException("More the one factories found, please ensure only one factory implementation is found on the classpath.");
+ }
+ }
+ else
+ {
+ throw new RuntimeException("No factories found");
+ }
+
+ return factory;
+ }
+
+ /**
+ * Template method for factory implementations to create {@link PersistenceUnitDeployment} instances.
+ *
+ * @param initialContext
+ * @param deployment
+ * @param explicitEntityClasses
+ * @param metadata
+ * @param kernelName
+ * @param deploymentUnit
+ * @param defaultPersistenceProperties
+ * @return a {@link PersistenceUnitDeployment} instance
+ */
+ public abstract PersistenceUnitDeployment create(InitialContext initialContext, PersistenceDeployment deployment, List<String> explicitEntityClasses, PersistenceUnitMetaData metadata, String kernelName, VFSDeploymentUnit deploymentUnit, Properties defaultPersistenceProperties);
+}
Added: projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/util/ServiceLoader.java
===================================================================
--- projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/util/ServiceLoader.java (rev 0)
+++ projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/util/ServiceLoader.java 2010-02-17 20:01:32 UTC (rev 101088)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.jboss.jpa.util;
+
+import java.util.Iterator;
+
+import javax.imageio.spi.ServiceRegistry;
+
+
+/**
+ * Service loader following the API from http://java.sun.com/javase/6/docs/api/java/util/ServiceLoader.html which is compatible with JDK 5.
+ *
+ * @author John Bailey
+ * @param <S> the service
+ */
+public class ServiceLoader<S> implements Iterable<S>
+{
+
+ /**
+ * @See <a href="http://java.sun.com/javase/6/docs/api/java/util/ServiceLoader.html#load%28java.lang.Class%29">ServiceLoader.load(Class)</a>
+ */
+ public static <S> ServiceLoader<S> load(Class<S> serviceClass)
+ {
+ return load(serviceClass, Thread.currentThread().getContextClassLoader());
+ }
+
+ /**
+ * @See <a href="http://java.sun.com/javase/6/docs/api/java/util/ServiceLoader.html#load%28java.lang.Class,%20java.lang.ClassLoader%29">ServiceLoader.load(Class, ClassL oader)</a>
+ */
+ public static <S> ServiceLoader<S> load(Class<S> service, ClassLoader loader)
+ {
+ return new ServiceLoader<S>(service, loader);
+ }
+
+ private final Class<S> serviceClass;
+ private final ClassLoader loader;
+ private Iterator<S> serviceIterator;
+
+
+ /**
+ * ServiceLoader constructor
+ * @param serviceClass the service class
+ * @param loader classloader to load service from
+ */
+ private ServiceLoader(Class<S> serviceClass, ClassLoader loader)
+ {
+ this.serviceClass = serviceClass;
+ this.loader = loader;
+ reload();
+ }
+
+ /**
+ * @See <a href="http://java.sun.com/javase/6/docs/api/java/util/ServiceLoader.html#iterator%28%29">ServiceLoader.iterator</a>
+ */
+ public Iterator<S> iterator()
+ {
+ return serviceIterator;
+ }
+
+ /**
+ * @See <a href="http://java.sun.com/javase/6/docs/api/java/util/ServiceLoader.html#reload%29">ServiceLoader.reload</a>
+ */
+ public void reload()
+ {
+ serviceIterator = ServiceRegistry.lookupProviders(serviceClass, loader);
+ }
+}
Added: projects/jpa/trunk/deployers/src/test/java/org/jboss/jpa/deployers/test/common/MockPersistenceUnitDeployment.java
===================================================================
--- projects/jpa/trunk/deployers/src/test/java/org/jboss/jpa/deployers/test/common/MockPersistenceUnitDeployment.java (rev 0)
+++ projects/jpa/trunk/deployers/src/test/java/org/jboss/jpa/deployers/test/common/MockPersistenceUnitDeployment.java 2010-02-17 20:01:32 UTC (rev 101088)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.jboss.jpa.deployers.test.common;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+import java.util.Properties;
+
+import javax.naming.InitialContext;
+
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.jpa.deployment.PersistenceDeployment;
+import org.jboss.jpa.deployment.PersistenceUnitDeployment;
+import org.jboss.metadata.jpa.spec.PersistenceUnitMetaData;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Instance of PersistenceUnitDeployment that uses VFS2 roots
+ *
+ * @author John Bailey
+ */
+public class MockPersistenceUnitDeployment extends PersistenceUnitDeployment
+{
+
+ /**
+ * Constructs a new PersistenceUnitDeploymentImpl
+ *
+ * @param initialContext
+ * @param deployment
+ * @param explicitEntityClasses
+ * @param metadata
+ * @param kernelName
+ * @param deploymentUnit
+ * @param defaultPersistenceProperties
+ */
+ public MockPersistenceUnitDeployment(InitialContext initialContext, PersistenceDeployment deployment,
+ List<String> explicitEntityClasses, PersistenceUnitMetaData metadata, String kernelName,
+ VFSDeploymentUnit deploymentUnit, Properties defaultPersistenceProperties)
+ {
+ super(initialContext, deployment, explicitEntityClasses, metadata, kernelName, deploymentUnit, defaultPersistenceProperties);
+ }
+
+ /** {@inheritdoc} */
+ @Override
+ protected URL getPersistenceUnitURL()
+ {
+ try {
+ VirtualFile metaData = di.getMetaDataFile("persistence.xml");
+ assert metaData != null : "Can't find persistence.xml in " + di;
+ return metaData.getParent().getParent().toURL();
+ }
+ catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /** {@inheritdoc} */
+ @Override
+ protected URL getRelativeURL(String jar)
+ {
+ try {
+ return new URL(jar);
+ }
+ catch (MalformedURLException e) {
+ try {
+ VirtualFile deploymentUnitFile = di.getFile("");
+ VirtualFile parent = deploymentUnitFile.getParent();
+ VirtualFile baseDir = (parent != null ? parent : deploymentUnitFile);
+ VirtualFile jarFile = baseDir.getChild(jar);
+ if (jarFile == null)
+ throw new RuntimeException("could not find child '" + jar + "' on '" + baseDir + "'");
+ return jarFile.toURL();
+ }
+ catch (Exception e1) {
+ throw new RuntimeException("could not find relative path: " + jar, e1);
+ }
+ }
+ }
+
+}
Added: projects/jpa/trunk/deployers/src/test/java/org/jboss/jpa/deployers/test/common/MockPersistenceUnitDeploymentFactory.java
===================================================================
--- projects/jpa/trunk/deployers/src/test/java/org/jboss/jpa/deployers/test/common/MockPersistenceUnitDeploymentFactory.java (rev 0)
+++ projects/jpa/trunk/deployers/src/test/java/org/jboss/jpa/deployers/test/common/MockPersistenceUnitDeploymentFactory.java 2010-02-17 20:01:32 UTC (rev 101088)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.jboss.jpa.deployers.test.common;
+
+import java.util.List;
+import java.util.Properties;
+
+import javax.naming.InitialContext;
+
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.jpa.deployment.PersistenceDeployment;
+import org.jboss.jpa.deployment.PersistenceUnitDeployment;
+import org.jboss.jpa.deployment.PersistenceUnitDeploymentFactory;
+import org.jboss.metadata.jpa.spec.PersistenceUnitMetaData;
+
+/**
+ * Implementation of {@link PersistenceUnitDeploymentFactory} that creates {@link PersistenceUnitDeployment} backed with VFS2 roots.
+ *
+ * @author John Bailey
+ */
+public class MockPersistenceUnitDeploymentFactory extends PersistenceUnitDeploymentFactory
+{
+
+ /** {@inheritdoc} */
+ @Override
+ public PersistenceUnitDeployment create(InitialContext initialContext, PersistenceDeployment deployment,
+ List<String> explicitEntityClasses, PersistenceUnitMetaData metadata, String kernelName,
+ VFSDeploymentUnit deploymentUnit, Properties defaultPersistenceProperties)
+ {
+ return new MockPersistenceUnitDeployment(initialContext, deployment, explicitEntityClasses, metadata, kernelName, deploymentUnit, defaultPersistenceProperties);
+ }
+
+}
Added: projects/jpa/trunk/deployers/src/test/resources/META-INF/services/org.jboss.jpa.deployment.PersistenceUnitDeploymentFactory
===================================================================
--- projects/jpa/trunk/deployers/src/test/resources/META-INF/services/org.jboss.jpa.deployment.PersistenceUnitDeploymentFactory (rev 0)
+++ projects/jpa/trunk/deployers/src/test/resources/META-INF/services/org.jboss.jpa.deployment.PersistenceUnitDeploymentFactory 2010-02-17 20:01:32 UTC (rev 101088)
@@ -0,0 +1 @@
+org.jboss.jpa.deployers.test.common.MockPersistenceUnitDeploymentFactory
\ No newline at end of file
Property changes on: projects/jpa/trunk/vfs2
___________________________________________________________________
Name: svn:ignore
+ target
.classpath
.project
.settings
Added: projects/jpa/trunk/vfs2/pom.xml
===================================================================
--- projects/jpa/trunk/vfs2/pom.xml (rev 0)
+++ projects/jpa/trunk/vfs2/pom.xml 2010-02-17 20:01:32 UTC (rev 101088)
@@ -0,0 +1,45 @@
+<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.jboss.jpa</groupId>
+ <artifactId>jboss-jpa-build</artifactId>
+ <relativePath>../build/pom.xml</relativePath>
+ <version>1.0.1</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>jboss-jpa-vfs2</artifactId>
+ <version>1.0.2-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>JBoss Container Managed JPA VFS2 Integration</name>
+ <description>
+ Integration project to support VFS2.
+ </description>
+
+ <properties>
+ <version.org.jboss.jpa-deployers>1.0.2-SNAPSHOT</version.org.jboss.jpa-deployers>
+ <version.org.jboss.vfs>2.2.0.Alpha2</version.org.jboss.vfs>
+ <version.org.jboss.deployers>2.2.0.Alpha1</version.org.jboss.deployers>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.jpa</groupId>
+ <artifactId>jboss-jpa-deployers</artifactId>
+ <version>${version.org.jboss.jpa-deployers}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-vfs</artifactId>
+ <version>${version.org.jboss.vfs}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.deployers</groupId>
+ <artifactId>jboss-deployers-vfs</artifactId>
+ <version>${version.org.jboss.deployers}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.deployers</groupId>
+ <artifactId>jboss-deployers-vfs-spi</artifactId>
+ <version>${version.org.jboss.deployers}</version>
+ </dependency>
+ </dependencies>
+</project>
Added: projects/jpa/trunk/vfs2/src/main/java/org/jboss/jpa/deployment/vfs2/PersistenceUnitDeploymentFactoryImpl.java
===================================================================
--- projects/jpa/trunk/vfs2/src/main/java/org/jboss/jpa/deployment/vfs2/PersistenceUnitDeploymentFactoryImpl.java (rev 0)
+++ projects/jpa/trunk/vfs2/src/main/java/org/jboss/jpa/deployment/vfs2/PersistenceUnitDeploymentFactoryImpl.java 2010-02-17 20:01:32 UTC (rev 101088)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.jboss.jpa.deployment.vfs2;
+
+import java.util.List;
+import java.util.Properties;
+
+import javax.naming.InitialContext;
+
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.jpa.deployment.PersistenceDeployment;
+import org.jboss.jpa.deployment.PersistenceUnitDeployment;
+import org.jboss.jpa.deployment.PersistenceUnitDeploymentFactory;
+import org.jboss.metadata.jpa.spec.PersistenceUnitMetaData;
+
+/**
+ * Implementation of {@link PersistenceUnitDeploymentFactory} that creates {@link PersistenceUnitDeployment} backed with VFS2 roots.
+ *
+ * @author John Bailey
+ */
+public class PersistenceUnitDeploymentFactoryImpl extends PersistenceUnitDeploymentFactory
+{
+
+ /** {@inheritdoc} */
+ @Override
+ public PersistenceUnitDeployment create(InitialContext initialContext, PersistenceDeployment deployment,
+ List<String> explicitEntityClasses, PersistenceUnitMetaData metadata, String kernelName,
+ VFSDeploymentUnit deploymentUnit, Properties defaultPersistenceProperties)
+ {
+ return new PersistenceUnitDeploymentImpl(initialContext, deployment, explicitEntityClasses, metadata, kernelName, deploymentUnit, defaultPersistenceProperties);
+ }
+
+}
Added: projects/jpa/trunk/vfs2/src/main/java/org/jboss/jpa/deployment/vfs2/PersistenceUnitDeploymentImpl.java
===================================================================
--- projects/jpa/trunk/vfs2/src/main/java/org/jboss/jpa/deployment/vfs2/PersistenceUnitDeploymentImpl.java (rev 0)
+++ projects/jpa/trunk/vfs2/src/main/java/org/jboss/jpa/deployment/vfs2/PersistenceUnitDeploymentImpl.java 2010-02-17 20:01:32 UTC (rev 101088)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.jboss.jpa.deployment.vfs2;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+import java.util.Properties;
+
+import javax.naming.InitialContext;
+
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.jpa.deployment.PersistenceDeployment;
+import org.jboss.jpa.deployment.PersistenceUnitDeployment;
+import org.jboss.metadata.jpa.spec.PersistenceUnitMetaData;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Instance of PersistenceUnitDeployment that uses VFS2 roots
+ *
+ * @author John Bailey
+ */
+public class PersistenceUnitDeploymentImpl extends PersistenceUnitDeployment
+{
+
+ /**
+ * Constructs a new PersistenceUnitDeploymentImpl
+ *
+ * @param initialContext
+ * @param deployment
+ * @param explicitEntityClasses
+ * @param metadata
+ * @param kernelName
+ * @param deploymentUnit
+ * @param defaultPersistenceProperties
+ */
+ public PersistenceUnitDeploymentImpl(InitialContext initialContext, PersistenceDeployment deployment,
+ List<String> explicitEntityClasses, PersistenceUnitMetaData metadata, String kernelName,
+ VFSDeploymentUnit deploymentUnit, Properties defaultPersistenceProperties)
+ {
+ super(initialContext, deployment, explicitEntityClasses, metadata, kernelName, deploymentUnit, defaultPersistenceProperties);
+ }
+
+ /** {@inheritdoc} */
+ @Override
+ protected URL getPersistenceUnitURL()
+ {
+ try {
+ VirtualFile metaData = di.getMetaDataFile("persistence.xml");
+ assert metaData != null : "Can't find persistence.xml in " + di;
+ return metaData.getParent().getParent().toURL();
+ }
+ catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /** {@inheritdoc} */
+ @Override
+ protected URL getRelativeURL(String jar)
+ {
+ try {
+ return new URL(jar);
+ }
+ catch (MalformedURLException e) {
+ try {
+ VirtualFile deploymentUnitFile = di.getFile("");
+ VirtualFile parent = deploymentUnitFile.getParent();
+ VirtualFile baseDir = (parent != null ? parent : deploymentUnitFile);
+ VirtualFile jarFile = baseDir.getChild(jar);
+ if (jarFile == null)
+ throw new RuntimeException("could not find child '" + jar + "' on '" + baseDir + "'");
+ return jarFile.toURL();
+ }
+ catch (Exception e1) {
+ throw new RuntimeException("could not find relative path: " + jar, e1);
+ }
+ }
+ }
+
+}
Added: projects/jpa/trunk/vfs2/src/main/resources/META-INF/services/org.jboss.jpa.deployment.PersistenceUnitDeploymentFactory
===================================================================
--- projects/jpa/trunk/vfs2/src/main/resources/META-INF/services/org.jboss.jpa.deployment.PersistenceUnitDeploymentFactory (rev 0)
+++ projects/jpa/trunk/vfs2/src/main/resources/META-INF/services/org.jboss.jpa.deployment.PersistenceUnitDeploymentFactory 2010-02-17 20:01:32 UTC (rev 101088)
@@ -0,0 +1 @@
+org.jboss.jpa.deployment.vfs2.PersistenceUnitDeploymentFactoryImpl
\ No newline at end of file
Property changes on: projects/jpa/trunk/vfs3
___________________________________________________________________
Name: svn:ignore
+ target
.settings
.classpath
.project
Added: projects/jpa/trunk/vfs3/pom.xml
===================================================================
--- projects/jpa/trunk/vfs3/pom.xml (rev 0)
+++ projects/jpa/trunk/vfs3/pom.xml 2010-02-17 20:01:32 UTC (rev 101088)
@@ -0,0 +1,45 @@
+<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.jboss.jpa</groupId>
+ <artifactId>jboss-jpa-build</artifactId>
+ <relativePath>../build/pom.xml</relativePath>
+ <version>1.0.1</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>jboss-jpa-vfs3</artifactId>
+ <version>1.0.2-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>JBoss Container Managed JPA VFS3 Integration</name>
+ <description>
+ Integration project to support VFS3.
+ </description>
+
+ <properties>
+ <version.org.jboss.jpa-deployers>1.0.2-SNAPSHOT</version.org.jboss.jpa-deployers>
+ <version.org.jboss.vfs>3.0.0.CR1</version.org.jboss.vfs>
+ <version.org.jboss.deployers>2.2.0.Alpha2</version.org.jboss.deployers>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.jpa</groupId>
+ <artifactId>jboss-jpa-deployers</artifactId>
+ <version>${version.org.jboss.jpa-deployers}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-vfs</artifactId>
+ <version>${version.org.jboss.vfs}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.deployers</groupId>
+ <artifactId>jboss-deployers-vfs</artifactId>
+ <version>${version.org.jboss.deployers}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.deployers</groupId>
+ <artifactId>jboss-deployers-vfs-spi</artifactId>
+ <version>${version.org.jboss.deployers}</version>
+ </dependency>
+ </dependencies>
+</project>
Added: projects/jpa/trunk/vfs3/src/main/java/org/jboss/jpa/deployment/vfs3/PersistenceUnitDeploymentFactoryImpl.java
===================================================================
--- projects/jpa/trunk/vfs3/src/main/java/org/jboss/jpa/deployment/vfs3/PersistenceUnitDeploymentFactoryImpl.java (rev 0)
+++ projects/jpa/trunk/vfs3/src/main/java/org/jboss/jpa/deployment/vfs3/PersistenceUnitDeploymentFactoryImpl.java 2010-02-17 20:01:32 UTC (rev 101088)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.jboss.jpa.deployment.vfs3;
+
+import java.util.List;
+import java.util.Properties;
+
+import javax.naming.InitialContext;
+
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.jpa.deployment.PersistenceDeployment;
+import org.jboss.jpa.deployment.PersistenceUnitDeployment;
+import org.jboss.jpa.deployment.PersistenceUnitDeploymentFactory;
+import org.jboss.metadata.jpa.spec.PersistenceUnitMetaData;
+
+/**
+ * Implementation of {@link PersistenceUnitDeploymentFactory} that creates {@link PersistenceUnitDeployment} backed with VFS3 roots.
+ *
+ * @author John Bailey
+ */
+public class PersistenceUnitDeploymentFactoryImpl extends PersistenceUnitDeploymentFactory
+{
+
+ /** {@inheritdoc} */
+ @Override
+ public PersistenceUnitDeployment create(InitialContext initialContext, PersistenceDeployment deployment,
+ List<String> explicitEntityClasses, PersistenceUnitMetaData metadata, String kernelName,
+ VFSDeploymentUnit deploymentUnit, Properties defaultPersistenceProperties)
+ {
+ return new PersistenceUnitDeploymentImpl(initialContext, deployment, explicitEntityClasses, metadata, kernelName, deploymentUnit, defaultPersistenceProperties);
+ }
+
+}
Added: projects/jpa/trunk/vfs3/src/main/java/org/jboss/jpa/deployment/vfs3/PersistenceUnitDeploymentImpl.java
===================================================================
--- projects/jpa/trunk/vfs3/src/main/java/org/jboss/jpa/deployment/vfs3/PersistenceUnitDeploymentImpl.java (rev 0)
+++ projects/jpa/trunk/vfs3/src/main/java/org/jboss/jpa/deployment/vfs3/PersistenceUnitDeploymentImpl.java 2010-02-17 20:01:32 UTC (rev 101088)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.jboss.jpa.deployment.vfs3;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+import java.util.Properties;
+
+import javax.naming.InitialContext;
+
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.jpa.deployment.PersistenceDeployment;
+import org.jboss.jpa.deployment.PersistenceUnitDeployment;
+import org.jboss.metadata.jpa.spec.PersistenceUnitMetaData;
+import org.jboss.vfs.VirtualFile;
+
+/**
+ * Instance of PersistenceUnitDeployment that uses VFS2 roots
+ *
+ * @author John Bailey
+ */
+public class PersistenceUnitDeploymentImpl extends PersistenceUnitDeployment
+{
+
+ /**
+ * Constructs a new PersistenceUnitDeploymentImpl
+ *
+ * @param initialContext
+ * @param deployment
+ * @param explicitEntityClasses
+ * @param metadata
+ * @param kernelName
+ * @param deploymentUnit
+ * @param defaultPersistenceProperties
+ */
+ public PersistenceUnitDeploymentImpl(InitialContext initialContext, PersistenceDeployment deployment,
+ List<String> explicitEntityClasses, PersistenceUnitMetaData metadata, String kernelName,
+ VFSDeploymentUnit deploymentUnit, Properties defaultPersistenceProperties)
+ {
+ super(initialContext, deployment, explicitEntityClasses, metadata, kernelName, deploymentUnit, defaultPersistenceProperties);
+ }
+
+ /** {@inheritdoc} */
+ @Override
+ protected URL getPersistenceUnitURL()
+ {
+ try {
+ VirtualFile metaData = di.getMetaDataFile("persistence.xml");
+ assert metaData != null : "Can't find persistence.xml in " + di;
+ return metaData.getParent().getParent().toURL();
+ }
+ catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /** {@inheritdoc} */
+ @Override
+ protected URL getRelativeURL(String jar)
+ {
+ try {
+ return new URL(jar);
+ }
+ catch (MalformedURLException e) {
+ try {
+ VirtualFile deploymentUnitFile = di.getFile("");
+ VirtualFile parent = deploymentUnitFile.getParent();
+ VirtualFile baseDir = (parent != null ? parent : deploymentUnitFile);
+ VirtualFile jarFile = baseDir.getChild(jar);
+ if (jarFile == null)
+ throw new RuntimeException("could not find child '" + jar + "' on '" + baseDir + "'");
+ return jarFile.toURL();
+ }
+ catch (Exception e1) {
+ throw new RuntimeException("could not find relative path: " + jar, e1);
+ }
+ }
+ }
+
+}
Added: projects/jpa/trunk/vfs3/src/main/resources/META-INF/services/org.jboss.jpa.deployment.PersistenceUnitDeploymentFactory
===================================================================
--- projects/jpa/trunk/vfs3/src/main/resources/META-INF/services/org.jboss.jpa.deployment.PersistenceUnitDeploymentFactory (rev 0)
+++ projects/jpa/trunk/vfs3/src/main/resources/META-INF/services/org.jboss.jpa.deployment.PersistenceUnitDeploymentFactory 2010-02-17 20:01:32 UTC (rev 101088)
@@ -0,0 +1 @@
+org.jboss.jpa.deployment.vfs3.PersistenceUnitDeploymentFactoryImpl
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list