[jboss-cvs] JBossAS SVN: r109449 - in projects/jpa/trunk/deployers: src/main/java/org/jboss/jpa/deployers and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Nov 24 11:02:47 EST 2010


Author: smarlow at redhat.com
Date: 2010-11-24 11:02:46 -0500 (Wed, 24 Nov 2010)
New Revision: 109449

Added:
   projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployers/switchboard/
   projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployers/switchboard/PersistenceUnitRefResource.java
   projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployers/switchboard/PersistenceUnitResourceProvider.java
Modified:
   projects/jpa/trunk/deployers/pom.xml
Log:
JBJPA-33 switchboard PersistenceUnit ResourceProvider support

Modified: projects/jpa/trunk/deployers/pom.xml
===================================================================
--- projects/jpa/trunk/deployers/pom.xml	2010-11-24 15:56:38 UTC (rev 109448)
+++ projects/jpa/trunk/deployers/pom.xml	2010-11-24 16:02:46 UTC (rev 109449)
@@ -22,6 +22,8 @@
   
   <properties>
     <version.org.jboss.deployers>2.0.5.GA</version.org.jboss.deployers>
+    <version.switchboard>1.0.0-alpha-8</version.switchboard>
+    <version.jndi>0.1.5-SNAPSHOT</version.jndi>
   </properties>
 
   <dependencies>
@@ -146,6 +148,24 @@
       <artifactId>jboss-common-core</artifactId>
       <version>2.2.11.GA</version>
     </dependency>
-    
+
+    <dependency>
+        <groupId>org.jboss.switchboard</groupId>
+        <artifactId>jboss-switchboard-mc-spi</artifactId>
+        <version>${version.switchboard}</version>
+    </dependency>
+
+    <!-- switchboard -->
+    <dependency>
+        <groupId>org.jboss.switchboard</groupId>
+        <artifactId>jboss-switchboard-javaee</artifactId>
+        <version>${version.switchboard}</version>
+    </dependency>
+     <dependency>
+         <groupId>org.jboss.ejb3.jndi</groupId>
+         <artifactId>jboss-ejb3-jndi-deployers</artifactId>
+         <version>${version.jndi}</version>
+     </dependency>
+
   </dependencies>
 </project>

Added: projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployers/switchboard/PersistenceUnitRefResource.java
===================================================================
--- projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployers/switchboard/PersistenceUnitRefResource.java	                        (rev 0)
+++ projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployers/switchboard/PersistenceUnitRefResource.java	2010-11-24 16:02:46 UTC (rev 109449)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.switchboard;
+
+import org.jboss.jpa.deployment.PersistenceUnitDeployment;
+import org.jboss.jpa.spi.PersistenceUnitRegistry;
+import org.jboss.switchboard.spi.Resource;
+
+/**
+ *
+ * <p>
+ *
+ * </p>
+ *
+ * @author Scott Marlow
+ */
+public class PersistenceUnitRefResource implements Resource
+{
+
+   private final String name;
+   private final String persistenceUnitDeploymentMCBeanName;
+
+   public PersistenceUnitRefResource(String persistenceUnitDeploymentMCBeanName, String name)
+   {
+      this.name = name;
+      this.persistenceUnitDeploymentMCBeanName = persistenceUnitDeploymentMCBeanName;
+   }
+
+   public Object getDependency()
+   {
+      // We need the PersistenceUnitDeployer MC bean to be started before we can bind
+      // the PersistenceUnitDeployment.getManagedFactory() to JNDI
+      return persistenceUnitDeploymentMCBeanName;
+   }
+
+   public Object getTarget()
+   {
+      return ((PersistenceUnitDeployment)PersistenceUnitRegistry.getPersistenceUnit(name)).getManagedFactory();
+   }
+}

Added: projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployers/switchboard/PersistenceUnitResourceProvider.java
===================================================================
--- projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployers/switchboard/PersistenceUnitResourceProvider.java	                        (rev 0)
+++ projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployers/switchboard/PersistenceUnitResourceProvider.java	2010-11-24 16:02:46 UTC (rev 109449)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.switchboard;
+
+import org.jboss.beans.metadata.api.annotations.Inject;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.jpa.resolvers.PersistenceUnitDependencyResolver;
+import org.jboss.logging.Logger;
+import org.jboss.switchboard.javaee.environment.PersistenceUnitRefType;
+import org.jboss.switchboard.mc.spi.MCBasedResourceProvider;
+import org.jboss.switchboard.spi.Resource;
+
+/**
+ * {@link MCBasedResourceProvider} for processing PersistenceUnit references in a
+ * Java EE component.
+ *
+ * @see #provide(DeploymentUnit, PersistenceUnitRefType)
+ *
+ * @author Scott Marlow
+ */
+public class PersistenceUnitResourceProvider implements MCBasedResourceProvider<PersistenceUnitRefType>
+{
+   private static final Logger LOG = Logger.getLogger(PersistenceUnitResourceProvider.class);
+   private PersistenceUnitDependencyResolver persistenceUnitDependencyResolver;
+   private final String persistenceUnitDeploymentMCBeanName;
+   /**
+    *
+    * @param persistenceUnitDeploymentMCBeanName The name of PersistenceUnitDeployment MC bean
+    * @param resolver For resolve the PU bean name   
+    */
+   public PersistenceUnitResourceProvider(String persistenceUnitDeploymentMCBeanName, PersistenceUnitDependencyResolver resolver)
+   {
+      this.persistenceUnitDeploymentMCBeanName = persistenceUnitDeploymentMCBeanName;
+      this.persistenceUnitDependencyResolver = resolver;
+   }
+
+
+   @Override
+   public Resource provide(DeploymentUnit deploymentUnit, PersistenceUnitRefType persistenceUnitRefType)
+   {
+      String lookupName = persistenceUnitRefType.getLookupName();
+      LOG.trace("PersistenceUnitResourceProvider.provide: " + deploymentUnit.getName() + " " + lookupName);
+      String persistenceUnitName = persistenceUnitDependencyResolver.createBeanName(deploymentUnit,deploymentUnit.getName());
+      return new PersistenceUnitRefResource(persistenceUnitDeploymentMCBeanName, persistenceUnitName);
+   }
+
+   public Class<PersistenceUnitRefType> getEnvironmentEntryType()
+   {
+      return PersistenceUnitRefType.class; 
+   }
+
+
+}



More information about the jboss-cvs-commits mailing list