[jboss-cvs] JBossAS SVN: r73326 - in projects/ejb3/trunk/proxy: src/main/java and 17 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue May 13 02:03:39 EDT 2008
Author: ALRubinger
Date: 2008-05-13 02:03:39 -0400 (Tue, 13 May 2008)
New Revision: 73326
Added:
projects/ejb3/trunk/proxy/src/main/java/org/
projects/ejb3/trunk/proxy/src/main/java/org/jboss/
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactory.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/service/
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/service/ServiceProxyFactory.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/SessionProxyFactory.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/McProxyObjectFactory.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyFactoryReferenceAddressTypes.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyObjectFactory.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/session/
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/session/SessionProxyObjectFactory.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/plugin/
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/plugin/inmemory/
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/plugin/inmemory/registry/
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/plugin/inmemory/registry/InMemoryProxyFactoryRegistry.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/plugin/jndi/
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/plugin/jndi/registry/
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/plugin/jndi/registry/JndiProxyFactoryRegistry.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/spi/
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/spi/registry/
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/spi/registry/MapBackedProxyFactoryRegistry.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/spi/registry/ProxyFactoryAlreadyRegisteredException.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/spi/registry/ProxyFactoryNotRegisteredException.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/spi/registry/ProxyFactoryRegistry.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/spi/registry/SetBackedProxyFactoryRegistry.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/test/
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/test/Main.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/test/ProxyObjectFactory.java
Modified:
projects/ejb3/trunk/proxy/.classpath
projects/ejb3/trunk/proxy/pom.xml
Log:
[EJBTHREE-1345] Added working ProxyFactoryRegistry implementations (im-memory and JNDI) along with partial development for JNDI ObjectFactories, Proxy Factories
Modified: projects/ejb3/trunk/proxy/.classpath
===================================================================
--- projects/ejb3/trunk/proxy/.classpath 2008-05-13 04:39:21 UTC (rev 73325)
+++ projects/ejb3/trunk/proxy/.classpath 2008-05-13 06:03:39 UTC (rev 73326)
@@ -5,4 +5,44 @@
<classpathentry kind="src" path="src/test/resources" output="target/tests-classes" excluding="**/*.java"/>
<classpathentry kind="output" path="target/classes"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var" path="M2_REPO/javax/activation/activation/1.0.2/activation-1.0.2.jar"/>
+ <classpathentry kind="var" path="M2_REPO/ant/ant/1.6.5/ant-1.6.5.jar" sourcepath="M2_REPO/ant/ant/1.6.5/ant-1.6.5-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/ant/ant-junit/1.6.5/ant-junit-1.6.5.jar"/>
+ <classpathentry kind="var" path="M2_REPO/wutka-dtdparser/dtdparser121/1.2.1/dtdparser121-1.2.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/javassist/3.6.0.GA/javassist-3.6.0.GA.jar" sourcepath="M2_REPO/org/jboss/javassist/3.6.0.GA/javassist-3.6.0.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/javax/xml/bind/jaxb-api/2.1/jaxb-api-2.1.jar" sourcepath="M2_REPO/javax/xml/bind/jaxb-api/2.1/jaxb-api-2.1-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/aop/jboss-aop/2.0.0.CR7/jboss-aop-2.0.0.CR7.jar" sourcepath="M2_REPO/org/jboss/aop/jboss-aop/2.0.0.CR7/jboss-aop-2.0.0.CR7-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-common-core/2.2.5.GA/jboss-common-core-2.2.5.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-common-core/2.2.5.GA/jboss-common-core-2.2.5.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-common-logging-log4j/2.0.4.GA/jboss-common-logging-log4j-2.0.4.GA.jar" sourcepath="M2_REPO/jboss/jboss-common-logging-log4j/2.0.4.GA/jboss-common-logging-log4j-2.0.4.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-common-logging-spi/2.0.4.GA/jboss-common-logging-spi-2.0.4.GA.jar" sourcepath="M2_REPO/jboss/jboss-common-logging-spi/2.0.4.GA/jboss-common-logging-spi-2.0.4.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-container/2.0.0.Beta9/jboss-container-2.0.0.Beta9.jar" sourcepath="M2_REPO/org/jboss/microcontainer/jboss-container/2.0.0.Beta9/jboss-container-2.0.0.Beta9-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-dependency/2.0.0.Beta9/jboss-dependency-2.0.0.Beta9.jar" sourcepath="M2_REPO/org/jboss/microcontainer/jboss-dependency/2.0.0.Beta9/jboss-dependency-2.0.0.Beta9-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-ejb-api/3.0.0.CR1/jboss-ejb-api-3.0.0.CR1.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-ejb-api/3.0.0.CR1/jboss-ejb-api-3.0.0.CR1-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-ext-api/0.3/jboss-ejb3-ext-api-0.3.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-ext-api/0.3/jboss-ejb3-ext-api-0.3-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jbossws/jboss-jaxrpc/1.0.4.GA/jboss-jaxrpc-1.0.4.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-jaxws/2.0.1.GA/jboss-jaxws-2.0.1.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-jms-api/1.1.0.CR1/jboss-jms-api-1.1.0.CR1.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-jms-api/1.1.0.CR1/jboss-jms-api-1.1.0.CR1-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-kernel/2.0.0.Beta9/jboss-kernel-2.0.0.Beta9.jar" sourcepath="M2_REPO/org/jboss/microcontainer/jboss-kernel/2.0.0.Beta9/jboss-kernel-2.0.0.Beta9-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-logging-spi/2.0.3.GA/jboss-logging-spi-2.0.3.GA.jar" sourcepath="M2_REPO/jboss/jboss-logging-spi/2.0.3.GA/jboss-logging-spi-2.0.3.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-managed/2.0.0.Beta9/jboss-managed-2.0.0.Beta9.jar" sourcepath="M2_REPO/org/jboss/microcontainer/jboss-managed/2.0.0.Beta9/jboss-managed-2.0.0.Beta9-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-mdr/2.0.0.Beta15/jboss-mdr-2.0.0.Beta15.jar" sourcepath="M2_REPO/org/jboss/jboss-mdr/2.0.0.Beta15/jboss-mdr-2.0.0.Beta15-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/metadata/jboss-metadata/1.0.0.Beta15/jboss-metadata-1.0.0.Beta15.jar" sourcepath="M2_REPO/org/jboss/metadata/jboss-metadata/1.0.0.Beta15/jboss-metadata-1.0.0.Beta15-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-metatype/2.0.0.Beta9/jboss-metatype-2.0.0.Beta9.jar" sourcepath="M2_REPO/org/jboss/microcontainer/jboss-metatype/2.0.0.Beta9/jboss-metatype-2.0.0.Beta9-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-persistence-api/3.0.0.CR1/jboss-persistence-api-3.0.0.CR1.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-persistence-api/3.0.0.CR1/jboss-persistence-api-3.0.0.CR1-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/profiler/jvmti/jboss-profiler-jvmti/1.0.0.CR5/jboss-profiler-jvmti-1.0.0.CR5.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-reflect/2.0.0.Beta11/jboss-reflect-2.0.0.Beta11.jar" sourcepath="M2_REPO/org/jboss/jboss-reflect/2.0.0.Beta11/jboss-reflect-2.0.0.Beta11-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-test/1.0.4.GA/jboss-test-1.0.4.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-test/1.0.4.GA/jboss-test-1.0.4.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-transaction-api/1.0.1.CR1/jboss-transaction-api-1.0.1.CR1.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-transaction-api/1.0.1.CR1/jboss-transaction-api-1.0.1.CR1-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-vfs/2.0.0.Beta11/jboss-vfs-2.0.0.Beta11.jar" sourcepath="M2_REPO/org/jboss/jboss-vfs/2.0.0.Beta11/jboss-vfs-2.0.0.Beta11-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/ws/jbossws-spi/1.0.3.GA/jbossws-spi-1.0.3.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jbossxb/2.0.0.CR9/jbossxb-2.0.0.CR9.jar" sourcepath="M2_REPO/org/jboss/jbossxb/2.0.0.CR9/jbossxb-2.0.0.CR9-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/naming/jnpserver/5.0.0.CR1/jnpserver-5.0.0.CR1.jar" sourcepath="M2_REPO/org/jboss/naming/jnpserver/5.0.0.CR1/jnpserver-5.0.0.CR1-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/junit/junit/4.4/junit-4.4.jar" sourcepath="M2_REPO/junit/junit/4.4/junit-4.4-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14.jar" sourcepath="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/qdox/qdox/1.6/qdox-1.6.jar" sourcepath="M2_REPO/qdox/qdox/1.6/qdox-1.6-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar" sourcepath="M2_REPO/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/trove/trove/1.0.2/trove-1.0.2.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-xerces/xercesImpl/2.9.1/xercesImpl-2.9.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-xerces/xml-apis/2.7.1/xml-apis-2.7.1.jar"/>
</classpath>
\ No newline at end of file
Modified: projects/ejb3/trunk/proxy/pom.xml
===================================================================
--- projects/ejb3/trunk/proxy/pom.xml 2008-05-13 04:39:21 UTC (rev 73325)
+++ projects/ejb3/trunk/proxy/pom.xml 2008-05-13 06:03:39 UTC (rev 73326)
@@ -4,25 +4,24 @@
-->
<!--
-
+
JBoss EJB3 Proxy Component
-
- -->
+
+-->
<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 -->
+
+ <!-- Parent -->
<parent>
<groupId>org.jboss.ejb3</groupId>
<artifactId>jboss-ejb3-build</artifactId>
<version>0.13.3-SNAPSHOT</version>
- <relativePath>../build/pom.xml</relativePath>
</parent>
-
- <!-- Model Version -->
+
+ <!-- Model Version -->
<modelVersion>4.0.0</modelVersion>
-
+
<!-- Artifact Configuration -->
<groupId>org.jboss.ejb3</groupId>
<artifactId>jboss-ejb3-proxy</artifactId>
@@ -30,15 +29,60 @@
<name>JBoss EJB 3.0 Proxy</name>
<description>JBoss EJB3 Proxy Component</description>
<url>http://www.jboss.org/jbossejb3</url>
-
+
<!-- Build Configuration -->
<build>
-
+
+ <plugins>
+ <!-- Surefire -->
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <printSummary>true</printSummary>
+ <testFailureIgnore>false</testFailureIgnore>
+ <includes>
+ <include>**/*TestCase.java</include>
+ <include>**/*TestSuite.java</include>
+ </includes>
+ <forkMode>always</forkMode>
+ <argLine>-ea</argLine>
+ <!--
+ <argLine>-Djboss.aop.verbose=true</argLine>
+ <argLine>
+ -javaagent:${project.build.directory}/dependencies/lib/jboss-aop-jdk50.jar
+ </argLine> -->
+ </configuration>
+ </plugin>
+
+ </plugins>
+
</build>
-
+
<!-- Dependencies -->
<dependencies>
-
+
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.naming</groupId>
+ <artifactId>jnpserver</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.metadata</groupId>
+ <artifactId>jboss-metadata</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ </dependency>
+
</dependencies>
-
+
</project>
Added: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactory.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactory.java 2008-05-13 06:03:39 UTC (rev 73326)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.factory;
+
+/**
+ * ProxyFactory
+ *
+ * Contract for a generic Proxy Factory, specifying
+ * a simple lifecycle and functions common to
+ * all Proxy Factories
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface ProxyFactory
+{
+ // --------------------------------------------------------------------------------||
+ // Lifecycle Methods --------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Lifecycle callback to be invoked by the ProxyFactoryDeployer
+ * before the ProxyFactory is able to service requests
+ *
+ * @throws Exception
+ */
+ void start() throws Exception;
+
+ /**
+ * Lifecycle callback to be invoked by the ProxyFactoryDeployer
+ * before the ProxyFactory is taken out of service,
+ * possibly GC'd
+ *
+ * @throws Exception
+ */
+ void stop() throws Exception;
+}
Added: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/service/ServiceProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/service/ServiceProxyFactory.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/service/ServiceProxyFactory.java 2008-05-13 06:03:39 UTC (rev 73326)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.factory.service;
+
+import org.jboss.ejb3.proxy.factory.ProxyFactory;
+
+/**
+ * ServiceProxyFactory
+ *
+ * Defines functions required of a Proxy Factory
+ * responsible for generating Proxies to
+ * JBoss EJB3 JMX Service Beans
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface ServiceProxyFactory extends ProxyFactory
+{
+ /**
+ * Create a JBoss Service EJB3 proxy implementing all appropriate
+ * business interfaces.
+ *
+ * @return
+ */
+ Object createProxy();
+}
Added: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/SessionProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/SessionProxyFactory.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/SessionProxyFactory.java 2008-05-13 06:03:39 UTC (rev 73326)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.factory.session;
+
+import org.jboss.ejb3.proxy.factory.ProxyFactory;
+
+/**
+ * SessionProxyFactory
+ *
+ * Contract for a Proxy Factory responsible
+ * for creation of both EJB3 and EJB2.x
+ * Session Bean Proxies
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface SessionProxyFactory extends ProxyFactory
+{
+ /**
+ * Create an EJB2.x Home Proxy
+ *
+ * @return
+ */
+ Object createProxyHome();
+
+ /**
+ * Create an EJB3 Business proxy with no
+ * specific target business interface. The
+ * returned proxy will implement all appropriate
+ * business interfaces.
+ *
+ * @return
+ */
+ Object createProxyBusiness();
+
+ /**
+ * Create a Proxy for both EJB2.x Home and
+ * Business Views, used when both the Home and Business
+ * interfaces are bound together
+ *
+ * @return
+ */
+ Object createProxyBusinessAndHome();
+
+ /**
+ * Create an EJB3 Business Proxy specific to the specified
+ * target business interface name (expressed as
+ * a fully-qualified class name)
+ *
+ * @param id
+ * @param businessInterfaceName
+ * @return
+ */
+ Object createProxyBusiness(String businessInterfaceName);
+}
Added: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/McProxyObjectFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/McProxyObjectFactory.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/McProxyObjectFactory.java 2008-05-13 06:03:39 UTC (rev 73326)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.objectfactory;
+
+import java.io.Serializable;
+
+import javax.naming.spi.ObjectFactory;
+
+import org.jboss.ejb3.proxy.spi.registry.ProxyFactoryRegistry;
+
+/**
+ * McProxyObjectFactory
+ *
+ * A Proxy Object Factory using an underlying
+ * Proxy Factory Registry intended to be obtained
+ * as a managed object from the MicroContainer
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public abstract class McProxyObjectFactory extends ProxyObjectFactory implements ObjectFactory, Serializable
+{
+
+ private static final long serialVersionUID = 7854430641125529016L;
+
+ //TODO
+ // Inject from MC via AOP upon instanciation
+ private ProxyFactoryRegistry proxyFactoryRegistry;
+
+ @Override
+ protected ProxyFactoryRegistry getProxyFactoryRegistry()
+ {
+ return this.proxyFactoryRegistry;
+ }
+
+ public void setProxyFactoryRegistry(ProxyFactoryRegistry proxyFactoryRegistry)
+ {
+ this.proxyFactoryRegistry = proxyFactoryRegistry;
+ }
+
+}
Added: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyFactoryReferenceAddressTypes.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyFactoryReferenceAddressTypes.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyFactoryReferenceAddressTypes.java 2008-05-13 06:03:39 UTC (rev 73326)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.objectfactory;
+
+import org.jboss.ejb3.proxy.spi.registry.ProxyFactoryRegistry;
+
+/**
+ * ProxyFactoryReferenceAddressTypes
+ *
+ * This interface defines the key constants used as
+ * valid factory reference address types expected by the
+ * ProxyObjectFactory
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface ProxyFactoryReferenceAddressTypes
+{
+ // --------------------------------------------------------------------------------||
+ // Constants ----------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /*
+ * The following are Reference Address Types denoting the type of interface
+ * represented by the contents, which should be the fully-qualified class
+ * name of the interface
+ */
+
+ /**
+ * Reference Address Type for EJB3 Remote Business Interfaces
+ */
+ String REF_ADDR_TYPE_PROXY_BUSINESS_INTERFACE_REMOTE = "Remote Business Interface";
+
+ /**
+ * Reference Address Type for EJB3 Local Business Interfaces
+ */
+ String REF_ADDR_TYPE_PROXY_BUSINESS_INTERFACE_LOCAL = "Local Business Interface";
+
+ /**
+ * Reference Address Type for EJB2.x Remote Home Interfaces
+ */
+ String REF_ADDR_TYPE_PROXY_EJB2x_INTERFACE_HOME_REMOTE = "EJB 2.x Remote Home Interface";
+
+ /**
+ * Reference Address Type for EJB2.x Local Home Interfaces
+ */
+ String REF_ADDR_TYPE_PROXY_EJB2x_INTERFACE_HOME_LOCAL = "EJB 2.x Local Home Interface";
+
+ /*
+ * The following are Reference Address Types denoting metadata
+ * used for interaction with the ProxyFactoryRegistry
+ */
+
+ /**
+ * Reference Address Type for the key to which the desired ProxyFactory
+ * is bound in the ProxyFactoryRegistry
+ */
+ String REF_ADDR_TYPE_PROXY_FACTORY_REGISTRY_KEY = ProxyFactoryRegistry.class.getSimpleName() + "Key";
+
+}
Added: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyObjectFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyObjectFactory.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyObjectFactory.java 2008-05-13 06:03:39 UTC (rev 73326)
@@ -0,0 +1,186 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.objectfactory;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.RefAddr;
+import javax.naming.Reference;
+import javax.naming.spi.ObjectFactory;
+
+import org.jboss.ejb3.proxy.factory.ProxyFactory;
+import org.jboss.ejb3.proxy.spi.registry.ProxyFactoryNotRegisteredException;
+import org.jboss.ejb3.proxy.spi.registry.ProxyFactoryRegistry;
+import org.jboss.logging.Logger;
+
+/**
+ * ProxyObjectFactory
+ *
+ * Base upon which Proxy Object Factories may build. Defines
+ * abstractions to:
+ *
+ * <ul>
+ * <li>Obtain a proxy based on metadata received
+ * from Reference Address information associated with the bound
+ * Reference</li>
+ * <li>Use a pluggable ProxyFactoryRegistry</li>
+ * </ul>
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public abstract class ProxyObjectFactory implements ObjectFactory, Serializable
+{
+ // --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(ProxyObjectFactory.class.getName());
+
+ // --------------------------------------------------------------------------------||
+ // Required Implementations ------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Returns an appropriate Proxy based on the Reference Address information
+ * associated with the Reference (obj) bound at name in the specified nameCtx with
+ * specified environment.
+ *
+ * @see javax.naming.spi.ObjectFactory#getObjectInstance(java.lang.Object,
+ * javax.naming.Name, javax.naming.Context, java.util.Hashtable)
+ */
+ public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment)
+ throws Exception
+ {
+ // Log
+ log.debug(ProxyObjectFactory.class.getName() + " servicing request for " + name.toString());
+
+ // Cast Reference
+ assert (Reference.class.isAssignableFrom(obj.getClass())) : "Object bound at " + name.toString()
+ + " was not of expected type " + Reference.class.getName();
+ Reference ref = (Reference) obj;
+
+ // Get a useful object for handling Reference Addresses
+ Map<String, List<String>> refAddrs = this.getReferenceAddresses(ref);
+
+ // Obtain the key used for looking up the appropriate ProxyFactory in the Registry
+ List<String> proxyFactoryRegistryKeys = refAddrs
+ .get(ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_FACTORY_REGISTRY_KEY);
+ assert proxyFactoryRegistryKeys.size() == 1 : "Exactly one Reference Address of type \""
+ + ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_FACTORY_REGISTRY_KEY + "\" is required, found "
+ + proxyFactoryRegistryKeys;
+ String proxyFactoryRegistryKey = proxyFactoryRegistryKeys.get(0);
+
+ // Obtain Proxy Factory Registry
+ ProxyFactoryRegistry registry = this.getProxyFactoryRegistry();
+ assert registry != null : "Returned null " + ProxyFactoryRegistry.class.getName();
+
+ // Obtain Proxy Factory
+ ProxyFactory proxyFactory = null;
+ try
+ {
+ proxyFactory = registry.getProxyFactory(proxyFactoryRegistryKey);
+ }
+ catch (ProxyFactoryNotRegisteredException pfnre)
+ {
+ throw new RuntimeException(pfnre);
+ }
+ assert proxyFactory != null : ProxyFactory.class.getName() + " returned from " + registry + " at key "
+ + proxyFactoryRegistryKey + " was null";
+
+ // Return the proxy returned from the ProxyFactory
+ Object proxy = this.getProxy(proxyFactory, name, refAddrs);
+ assert proxy != null : "Proxy factory returned from " + proxyFactory + " was null.";
+ return proxy;
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Specifications -----------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ protected abstract Object getProxy(ProxyFactory proxyFactory, Name name, Map<String, List<String>> referenceAddresses);
+
+ protected abstract ProxyFactoryRegistry getProxyFactoryRegistry();
+
+ // --------------------------------------------------------------------------------||
+ // Internal Helper Methods --------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Underlying Enumeration for handling Reference Addresses is clumsy (though ordered properly);
+ * iterate through and put in a useful form for this implementation
+ *
+ * @param ref
+ * @return A Map consisting of keys holding reference types, and values of
+ * Lists containing their contents
+ */
+ private Map<String, List<String>> getReferenceAddresses(Reference ref)
+ {
+
+ // Initialize and instanciate a more reasonable object for handling Reference Addresses
+ Map<String, List<String>> referenceAddresses = new HashMap<String, List<String>>();
+
+ // For all Reference Addresses
+ int count = 0;
+ Enumeration<RefAddr> refAddrs = ref.getAll();
+ while (refAddrs.hasMoreElements())
+ {
+ // Get the current Reference Address information
+ RefAddr refAddr = refAddrs.nextElement();
+ String type = refAddr.getType();
+ Class<?> expectedContentsType = String.class;
+ assert (expectedContentsType.isAssignableFrom(refAddr.getContent().getClass())) : "Content of Reference Address of type \""
+ + type + "\" at index " + count + " was not of expected Java type " + expectedContentsType.getName();
+ String content = (String) refAddr.getContent();
+
+ // If our map doesn't yet contain an entry for this type
+ if (!referenceAddresses.containsKey(type))
+ {
+ // Create an entry in the Map to hold the reference addresses
+ referenceAddresses.put(type, new ArrayList<String>());
+ }
+
+ // Place an entry for the contents at index "type"
+ referenceAddresses.get(type).add(content);
+ log.trace("Found reference type \"" + type + "\" with content \"" + content + "\"");
+
+ // Increase the internal counter
+ count++;
+ }
+
+ // Return
+ return referenceAddresses;
+
+ }
+
+}
Added: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/session/SessionProxyObjectFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/session/SessionProxyObjectFactory.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/session/SessionProxyObjectFactory.java 2008-05-13 06:03:39 UTC (rev 73326)
@@ -0,0 +1,275 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.objectfactory.session;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.Name;
+import javax.naming.RefAddr;
+
+import org.jboss.ejb3.proxy.factory.ProxyFactory;
+import org.jboss.ejb3.proxy.factory.session.SessionProxyFactory;
+import org.jboss.ejb3.proxy.objectfactory.McProxyObjectFactory;
+import org.jboss.ejb3.proxy.objectfactory.ProxyFactoryReferenceAddressTypes;
+import org.jboss.ejb3.proxy.spi.registry.ProxyFactoryNotRegisteredException;
+import org.jboss.ejb3.proxy.spi.registry.ProxyFactoryRegistry;
+import org.jboss.logging.Logger;
+
+/**
+ * SessionProxyObjectFactory
+ *
+ * A JNDI Object Factory responsible for parsing metadata
+ * obtained from Reference Address information, and
+ * returning the appropriate Session Proxy
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class SessionProxyObjectFactory extends McProxyObjectFactory
+{
+
+ // --------------------------------------------------------------------------------||
+ // Class Members -----------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private static final long serialVersionUID = 7446415796335133868L;
+
+ private static final Logger log = Logger.getLogger(SessionProxyObjectFactory.class);
+
+ // --------------------------------------------------------------------------------||
+ // Required Implementations ------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /*
+ * TODO
+ *
+ * This implementation simply creates a new proxy upon each lookup. We should
+ * improve performance by providing an additional implementation for SLSB
+ * which employs a caching mechanism to cache:
+ *
+ * Home
+ * Business
+ * One per interface-specific business
+ */
+
+ @Override
+ protected Object getProxy(ProxyFactory proxyFactory, Name name, Map<String, List<String>> referenceAddresses)
+ {
+ // Initialize
+
+ Object proxy = null;
+
+ // Determine if a home is defined here
+ boolean hasHome = this.hasHome(name, referenceAddresses);
+
+ // Determine if a business interface is defined here
+ boolean hasBusiness = this.hasBusiness(name, referenceAddresses);
+
+ // Obtain Proxy Factory Registry
+ ProxyFactoryRegistry registry = this.getProxyFactoryRegistry();
+ assert registry != null : ProxyFactoryRegistry.class.getSimpleName() + " is required but found null reference";
+
+ // Obtain Proxy Factory
+ SessionProxyFactory factory = null;
+ Object pFactory = null;
+ String proxyFactoryRegistryKey = ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_FACTORY_REGISTRY_KEY;
+ assert proxyFactoryRegistryKey != null && !proxyFactoryRegistryKey.equals("") : "Required "
+ + RefAddr.class.getSimpleName() + " of type "
+ + ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_FACTORY_REGISTRY_KEY
+ + " is required present in JNDI at " + name.toString() + " but was not found";
+ try
+ {
+ // Get the Factory
+ pFactory = registry
+ .getProxyFactory(ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_FACTORY_REGISTRY_KEY);
+ // Cast into a SessionProxyFactory
+ factory = SessionProxyFactory.class.cast(pFactory);
+ log.debug("Using: " + factory + " as specified from JNDI reference " + name.toString());
+ }
+ catch (ProxyFactoryNotRegisteredException e)
+ {
+ throw new RuntimeException("Expected " + SessionProxyFactory.class.getName() + " in " + registry
+ + " under key \"" + proxyFactoryRegistryKey + "\" but found none", e);
+ }
+ catch (ClassCastException cce)
+ {
+ throw new RuntimeException("Found Proxy Factory in " + registry + " under key \"" + proxyFactoryRegistryKey
+ + "\", but was of type " + pFactory.getClass().getName() + " instead of expected "
+ + SessionProxyFactory.class.getName(), cce);
+ }
+
+ // If home and business are bound together
+ if (hasHome && hasBusiness)
+ {
+ proxy = factory.createProxyBusinessAndHome();
+ log.debug("Created Proxy " + proxy + " for both EJB2.x and EJB3 Business Interfaces.");
+ }
+ // If bound to home only
+ else if (hasHome)
+ {
+ proxy = factory.createProxyHome();
+ log.debug("Created Proxy " + proxy + " for EJB2.x Home Interface(s)");
+ }
+ // If bound to business only
+ else if (hasBusiness)
+ {
+ // Initialize
+ String type = null;
+
+ // If local
+ if (this.hasLocalBusiness(referenceAddresses))
+ {
+ type = ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_BUSINESS_INTERFACE_LOCAL;
+ }
+ // If remote
+ else
+ {
+ type = ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_BUSINESS_INTERFACE_REMOTE;
+ }
+
+ // Get all business interfaces to be used
+ List<String> businessInterfaces = referenceAddresses.get(type);
+
+ // If only one is defined
+ if (businessInterfaces.size() == 1)
+ {
+ // Obtain a proxy specific to this business interface
+ String businessInterface = businessInterfaces.get(0);
+ proxy = factory.createProxyBusiness(businessInterface);
+ log.debug("Created Proxy " + proxy + " for EJB3 Business Interface: " + businessInterface);
+ }
+ else
+ {
+ // Use a general-purpose proxy for all business interfaces
+ proxy = factory.createProxyBusiness();
+ log.debug("Created Proxy " + proxy + " for EJB3 Business Interfaces: " + businessInterfaces);
+ }
+ }
+ // No valid type is bound here
+ else
+ {
+ throw new RuntimeException(factory + " found associated with JNDI Binding " + name.toString()
+ + " is not bound to create/return any valid EJB2.x Home or EJB3 Business Interfaces");
+ }
+
+ // Return
+ return proxy;
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Internal Helper Methods -------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Looks to the metadata specified by the reference addresses to determine if
+ * an EJB2.x home interface is defined here. Additionally checks to ensure
+ * that both remote and local homes are not bound to the same JNDI Address
+ *
+ * @param name
+ * @param referenceAddresses
+ * @return
+ */
+ private boolean hasHome(Name name, Map<String, List<String>> referenceAddresses)
+ {
+ // Initialize
+ boolean hasHome = false;
+
+ // Obtain metadata
+ boolean hasLocalHome = referenceAddresses
+ .containsKey(ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_EJB2x_INTERFACE_HOME_LOCAL);
+ boolean hasRemoteHome = referenceAddresses
+ .containsKey(ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_EJB2x_INTERFACE_HOME_REMOTE);
+
+ // Ensure both local and remote home are not specified here
+ String errorMessage = "ObjectFactory at JNDI \"" + name.toString()
+ + "\" contains references to both local and remote homes";
+ assert !(hasLocalHome && hasRemoteHome) : errorMessage;
+ if (hasLocalHome && hasRemoteHome)
+ {
+ throw new RuntimeException(errorMessage);
+ }
+
+ // Set if has home defined
+ hasHome = hasLocalHome || hasRemoteHome;
+
+ // Return
+ return hasHome;
+ }
+
+ /**
+ * Looks to the metadata specified by the reference addresses to determine if
+ * an EJB3 Business View is defined here. Additionally checks that both local
+ * and remote business interfaces are not bound to the same JNDI Address
+ *
+ * @param name
+ * @param referenceAddresses
+ * @return
+ */
+ private boolean hasBusiness(Name name, Map<String, List<String>> referenceAddresses)
+ {
+ // Initialize
+ boolean hasBusiness = false;
+
+ // Obtain metadata
+ boolean hasLocalBusiness = this.hasLocalBusiness(referenceAddresses);
+ boolean hasRemoteBusiness = this.hasRemoteBusiness(referenceAddresses);
+
+ // Ensure both local and remote home are not specified here
+ String errorMessage = "ObjectFactory at JNDI \"" + name.toString()
+ + "\" contains references to both local and remote business interfaces";
+ assert !(hasLocalBusiness && hasRemoteBusiness) : errorMessage;
+ if (hasLocalBusiness && hasRemoteBusiness)
+ {
+ throw new RuntimeException(errorMessage);
+ }
+
+ // Return
+ return hasBusiness;
+
+ }
+
+ /**
+ * Determines if the specified metadata contains a type of local business
+ *
+ * @param referenceAddresses
+ * @return
+ */
+ private boolean hasLocalBusiness(Map<String, List<String>> referenceAddresses)
+ {
+ return referenceAddresses
+ .containsKey(ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_BUSINESS_INTERFACE_LOCAL);
+ }
+
+ /**
+ * Determines if the specified metadata contains a type of remote business
+ *
+ * @param referenceAddresses
+ * @return
+ */
+ private boolean hasRemoteBusiness(Map<String, List<String>> referenceAddresses)
+ {
+ return referenceAddresses
+ .containsKey(ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_BUSINESS_INTERFACE_REMOTE);
+ }
+
+}
Added: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/plugin/inmemory/registry/InMemoryProxyFactoryRegistry.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/plugin/inmemory/registry/InMemoryProxyFactoryRegistry.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/plugin/inmemory/registry/InMemoryProxyFactoryRegistry.java 2008-05-13 06:03:39 UTC (rev 73326)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.plugin.inmemory.registry;
+
+import java.util.HashMap;
+
+import org.jboss.ejb3.proxy.factory.ProxyFactory;
+import org.jboss.ejb3.proxy.spi.registry.MapBackedProxyFactoryRegistry;
+
+/**
+ * InMemoryProxyFactoryRegistry
+ *
+ * A Proxy Factory Registry that uses an
+ * in-memory implementation to store proxy factories.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class InMemoryProxyFactoryRegistry extends MapBackedProxyFactoryRegistry<HashMap<String, ProxyFactory>>
+{
+ // --------------------------------------------------------------------------------||
+ // Constructors -------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ public InMemoryProxyFactoryRegistry()
+ {
+ // Call super
+ super(new HashMap<String, ProxyFactory>());
+ }
+}
Added: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/plugin/jndi/registry/JndiProxyFactoryRegistry.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/plugin/jndi/registry/JndiProxyFactoryRegistry.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/plugin/jndi/registry/JndiProxyFactoryRegistry.java 2008-05-13 06:03:39 UTC (rev 73326)
@@ -0,0 +1,217 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.plugin.jndi.registry;
+
+import java.util.HashSet;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.ejb3.proxy.factory.ProxyFactory;
+import org.jboss.ejb3.proxy.spi.registry.ProxyFactoryAlreadyRegisteredException;
+import org.jboss.ejb3.proxy.spi.registry.ProxyFactoryNotRegisteredException;
+import org.jboss.ejb3.proxy.spi.registry.SetBackedProxyFactoryRegistry;
+import org.jboss.logging.Logger;
+import org.jboss.naming.Util;
+
+/**
+ * JndiProxyFactoryRegistry
+ *
+ * A Proxy Factory Registry implementation that
+ * binds the proxy factory into JNDI at the name
+ * specified by the factory's key. To speed lookups,
+ * a Set of keys for registered factories is maintained, but
+ * the factories themselves are bound only in JNDI and
+ * are not necessarily available in RAM.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class JndiProxyFactoryRegistry extends SetBackedProxyFactoryRegistry<HashSet<String>>
+{
+ // --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(JndiProxyFactoryRegistry.class);
+
+ // --------------------------------------------------------------------------------||
+ // Instance Members ---------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ //TODO Inject from MC
+ private Context context;
+
+ // --------------------------------------------------------------------------------||
+ // Constructors -------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ public JndiProxyFactoryRegistry()
+ {
+ // Call super
+ super(new HashSet<String>());
+
+ // Create Context
+ try
+ {
+ // Use default environment
+ //TODO Inject from MC
+ context = new InitialContext();
+ }
+ catch (NamingException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Required Implementations -------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Register the specified Proxy Factory with the
+ * specified key. Is additionally responsible for calling the
+ * ProxyFactory.start()
+ *
+ * @param key
+ * @param value
+ * @throws ProxyFactoryAlreadyRegisteredException When a proxy factory is already registered under the
+ * specified key
+ */
+ @Override
+ public void registerProxyFactory(String key, ProxyFactory value) throws ProxyFactoryAlreadyRegisteredException
+ {
+ // Register
+ super.registerProxyFactory(key, value);
+
+ // Bind to JNDI at the specified key
+ try
+ {
+ Util.rebind(context, key, value);
+ }
+ catch (NamingException ne)
+ {
+ // Deregister as the factory was not bound
+ try
+ {
+ this.deregisterProxyFactory(key);
+ }
+ catch (ProxyFactoryNotRegisteredException pfnre)
+ {
+ log.error("Could not deregister " + ProxyFactory.class.getSimpleName() + " with key \"" + key
+ + "\" after binding to JNDI failed with: " + ne.getMessage(), pfnre);
+ }
+
+ // Rethrow
+ throw new RuntimeException(ne);
+ }
+
+ }
+
+ /**
+ * Register the specified Proxy Factory with the
+ * specified key. Is additionally responsible for calling the
+ * ProxyFactory.stop()
+ *
+ * @param key
+ * @throws ProxyFactoryNotRegisteredException If no Proxy Factory is registered under the specified key
+ */
+ public void deregisterProxyFactory(String key) throws ProxyFactoryNotRegisteredException
+ {
+ // Deregister
+ super.deregisterProxyFactoryFromBackingSet(key);
+
+ // Obtain
+ ProxyFactory factory = this.getProxyFactory(key);
+ assert factory != null : ProxyFactory.class.getSimpleName() + " at key \"" + key
+ + "\" found as registered, but was null when obtained";
+
+ // Remove from JNDI
+ try
+ {
+ Util.unbind(this.getContext(), key);
+ }
+ catch (NamingException e)
+ {
+ // Log an error only if the JNDI location could not be unbound
+ log.error("Deregistered " + ProxyFactory.class.getSimpleName() + " bound to key \"" + key
+ + "\", but could not unbind from JNDI", e);
+ }
+
+ // Stop
+ try
+ {
+ factory.stop();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Error in stopping " + factory, e);
+ }
+ }
+
+ /**
+ * Obtains the ProxyFactory registered with the specified key
+ *
+ * @param key
+ * @return
+ * @throws ProxyFactoryNotRegisteredException If no Proxy Factory is registered under the specified key
+ */
+ public ProxyFactory getProxyFactory(String key) throws ProxyFactoryNotRegisteredException
+ {
+ // Ensure exists
+ if (!this.isRegistered(key))
+ {
+ throw new ProxyFactoryNotRegisteredException(ProxyFactory.class.getSimpleName() + " under key \"" + key
+ + "\" is not registered");
+ }
+
+ // Obtain and return
+ Object fromJndi = null;
+ try
+ {
+ fromJndi = Util.lookup(key, ProxyFactory.class);
+ assert fromJndi != null : ProxyFactory.class.getSimpleName() + " under key \"" + key
+ + "\" is registered but returned null on lookup";
+ return ProxyFactory.class.cast(fromJndi);
+ }
+ catch (ClassCastException cce)
+ {
+ throw new RuntimeException("Expected " + ProxyFactory.class.getName() + " in JNDI at address \"" + key
+ + "\", instead found " + fromJndi, cce);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Accessors / Mutators -----------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ protected Context getContext()
+ {
+ return context;
+ }
+}
Added: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/spi/registry/MapBackedProxyFactoryRegistry.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/spi/registry/MapBackedProxyFactoryRegistry.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/spi/registry/MapBackedProxyFactoryRegistry.java 2008-05-13 06:03:39 UTC (rev 73326)
@@ -0,0 +1,207 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.spi.registry;
+
+import java.util.Map;
+
+import org.jboss.ejb3.proxy.factory.ProxyFactory;
+import org.jboss.logging.Logger;
+
+/**
+ * MapBackedProxyFactoryRegistry
+ *
+ * Base upon which Proxy Factory Registry implementations may build.
+ *
+ * The type parameter T defines the implementation class to be used as the backing
+ * resource for holding the Proxy Factories.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public abstract class MapBackedProxyFactoryRegistry<T extends Map<String, ProxyFactory>>
+ implements
+ ProxyFactoryRegistry
+{
+ // --------------------------------------------------------------------------------||
+ // Class Members ---------------------------------------------------------------||
+ // --------------------------------------------------------------------------------|
+
+ private static final Logger log = Logger.getLogger(MapBackedProxyFactoryRegistry.class);
+
+ // --------------------------------------------------------------------------------||
+ // Instance Members ---------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private T proxyFactories;
+
+ // --------------------------------------------------------------------------------||
+ // Constructors -------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Create a new registry backed by an object of same type
+ * as the specified mock object
+ *
+ * @param mockFactories An object to denote the type
+ * to be used in holding the backing registry
+ */
+ @SuppressWarnings("unchecked")
+ public MapBackedProxyFactoryRegistry(T mockFactories)
+ {
+ // Log
+ log.debug("Using " + this.getClass().getName() + " implementation of " + ProxyFactoryRegistry.class.getName());
+
+ try
+ {
+ this.setProxyFactories((T) mockFactories.getClass().newInstance());
+ }
+ catch (InstantiationException e)
+ {
+ throw new RuntimeException(e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Required Implementations -------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Determines whether a ProxyFactory is registered at the specified key
+ *
+ * @param key
+ * @return
+ */
+ public boolean isRegistered(String key)
+ {
+ return this.getProxyFactories().containsKey(key);
+ }
+
+ /**
+ * Obtains the ProxyFactory registered with the specified key
+ *
+ * @param key
+ * @return
+ * @throws ProxyFactoryNotRegisteredException If no Proxy Factory is registered under the specified key
+ */
+ public ProxyFactory getProxyFactory(String key) throws ProxyFactoryNotRegisteredException
+ {
+ // Check is exists
+ boolean registered = this.isRegistered(key);
+
+ // Ensure a ProxyFactory was found for this key
+ if (!registered)
+ {
+ throw new ProxyFactoryNotRegisteredException("No " + ProxyFactory.class.getSimpleName()
+ + " could not be found registered under the key\"" + key + "\"");
+ }
+
+ // Return
+ ProxyFactory factory = this.getProxyFactories().get(key);
+ assert factory != null : ProxyFactory.class.getSimpleName() + " is marked as registered under key \"" + key
+ + "\" but returned null on lookup";
+ return factory;
+ }
+
+ /**
+ * Register the specified Proxy Factory with the
+ * specified key. Is additionally responsible for calling the
+ * ProxyFactory.start()
+ *
+ * @param key
+ * @param value
+ * @throws ProxyFactoryAlreadyRegisteredException When a proxy factory is already registered under the
+ * specified key
+ */
+ public void registerProxyFactory(String key, ProxyFactory value) throws ProxyFactoryAlreadyRegisteredException
+ {
+ // Ensure not already registered
+ if (this.getProxyFactories().containsKey(key))
+ {
+ throw new ProxyFactoryAlreadyRegisteredException("Cannot register " + value + " as there is already a "
+ + value.getClass().getSimpleName() + " associated with key \"" + key + "\"");
+ }
+
+ // Start
+ try
+ {
+ value.start();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Error in starting " + value, e);
+ }
+
+ // Place in the registry
+ this.getProxyFactories().put(key, value);
+ }
+
+ /**
+ * Deregister the specified Proxy Factory with the
+ * specified key. Is additionally responsible for calling
+ * ProxyFactory.stop()
+ *
+ * @param key
+ * @throws ProxyFactoryNotRegisteredException If no Proxy Factory is registered under the specified key
+ */
+ public void deregisterProxyFactory(String key) throws ProxyFactoryNotRegisteredException
+ {
+ // Deregister
+ ProxyFactory proxyFactory = this.getProxyFactories().remove(key);
+
+ // Ensure registered
+ if (proxyFactory == null)
+ {
+ throw new ProxyFactoryNotRegisteredException("Cannot deregister a " + ProxyFactory.class.getName()
+ + " associated with key \"" + key + "\" as the key is currently not registered");
+ }
+
+ // Stop
+ try
+ {
+ proxyFactory.stop();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Accessors / Mutators -----------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ public T getProxyFactories()
+ {
+ return proxyFactories;
+ }
+
+ private void setProxyFactories(T proxyFactories)
+ {
+ this.proxyFactories = proxyFactories;
+ }
+
+}
Added: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/spi/registry/ProxyFactoryAlreadyRegisteredException.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/spi/registry/ProxyFactoryAlreadyRegisteredException.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/spi/registry/ProxyFactoryAlreadyRegisteredException.java 2008-05-13 06:03:39 UTC (rev 73326)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.spi.registry;
+
+/**
+ * ProxyFactoryNotRegisteredException
+ *
+ * Thrown when a registration for Proxy Factory fails because a
+ * Proxy Factory is already registered to the specified key
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class ProxyFactoryAlreadyRegisteredException extends Exception
+{
+ // --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private static final long serialVersionUID = -1536631857330661692L;
+
+ // --------------------------------------------------------------------------------||
+ // Constructors----- --------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ public ProxyFactoryAlreadyRegisteredException()
+ {
+ super();
+ }
+
+ public ProxyFactoryAlreadyRegisteredException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public ProxyFactoryAlreadyRegisteredException(String message)
+ {
+ super(message);
+ }
+
+ public ProxyFactoryAlreadyRegisteredException(Throwable cause)
+ {
+ super(cause);
+ }
+
+}
Added: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/spi/registry/ProxyFactoryNotRegisteredException.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/spi/registry/ProxyFactoryNotRegisteredException.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/spi/registry/ProxyFactoryNotRegisteredException.java 2008-05-13 06:03:39 UTC (rev 73326)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.spi.registry;
+
+/**
+ * ProxyFactoryNotRegisteredException
+ *
+ * Thrown when a lookup for a Proxy Factory fails because no
+ * Proxy Factory is registered to the specified key
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class ProxyFactoryNotRegisteredException extends Exception
+{
+ // --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private static final long serialVersionUID = -3768826545180525184L;
+
+ // --------------------------------------------------------------------------------||
+ // Constructors----- --------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ public ProxyFactoryNotRegisteredException()
+ {
+ super();
+ }
+
+ public ProxyFactoryNotRegisteredException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public ProxyFactoryNotRegisteredException(String message)
+ {
+ super(message);
+ }
+
+ public ProxyFactoryNotRegisteredException(Throwable cause)
+ {
+ super(cause);
+ }
+
+}
Added: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/spi/registry/ProxyFactoryRegistry.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/spi/registry/ProxyFactoryRegistry.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/spi/registry/ProxyFactoryRegistry.java 2008-05-13 06:03:39 UTC (rev 73326)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.spi.registry;
+
+import org.jboss.ejb3.proxy.factory.ProxyFactory;
+
+/**
+ * ProxyFactoryRegistry
+ *
+ * A Proxy Factory Registry implementation is responsible for
+ * maintaining a Collection of Proxy Factories, each bound
+ * to a unique key.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface ProxyFactoryRegistry
+{
+ /**
+ * Determines whether a ProxyFactory is registered at the specified key
+ *
+ * @param key
+ * @return
+ */
+ boolean isRegistered(String key);
+
+ /**
+ * Obtains the ProxyFactory registered with the specified key
+ *
+ * @param key
+ * @return
+ * @throws ProxyFactoryNotRegisteredException If no Proxy Factory is registered under the specified key
+ */
+ ProxyFactory getProxyFactory(String key) throws ProxyFactoryNotRegisteredException;
+
+ /**
+ * Register the specified Proxy Factory with the
+ * specified key. Is additionally responsible for calling the
+ * ProxyFactory.start()
+ *
+ * @param key
+ * @param value
+ * @throws ProxyFactoryAlreadyRegisteredException When a proxy factory is already registered under the
+ * specified key
+ */
+ void registerProxyFactory(String key, ProxyFactory value) throws ProxyFactoryAlreadyRegisteredException;
+
+ /**
+ * Register the specified Proxy Factory with the
+ * specified key. Is additionally responsible for calling the
+ * ProxyFactory.stop()
+ *
+ * @param key
+ * @throws ProxyFactoryNotRegisteredException If no Proxy Factory is registered under the specified key
+ */
+ void deregisterProxyFactory(String key) throws ProxyFactoryNotRegisteredException;
+
+}
Added: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/spi/registry/SetBackedProxyFactoryRegistry.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/spi/registry/SetBackedProxyFactoryRegistry.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/spi/registry/SetBackedProxyFactoryRegistry.java 2008-05-13 06:03:39 UTC (rev 73326)
@@ -0,0 +1,169 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.spi.registry;
+
+import java.util.Set;
+
+import org.jboss.ejb3.proxy.factory.ProxyFactory;
+import org.jboss.logging.Logger;
+
+/**
+ * SetBackedProxyFactoryRegistry
+ *
+ * Base upon which Proxy Factory Registry implementations may build.
+ *
+ * The type parameter T defines the implementation class to be used as the backing
+ * resource for holding representative keys to locate Proxy Factory References.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public abstract class SetBackedProxyFactoryRegistry<T extends Set<String>> implements ProxyFactoryRegistry
+{
+ // --------------------------------------------------------------------------------||
+ // Class Members ---------------------------------------------------------------||
+ // --------------------------------------------------------------------------------|
+
+ private static final Logger log = Logger.getLogger(SetBackedProxyFactoryRegistry.class);
+
+ // --------------------------------------------------------------------------------||
+ // Instance Members ---------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private T proxyFactories;
+
+ // --------------------------------------------------------------------------------||
+ // Constructors -------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Create a new registry backed by an object of same type
+ * as the specified mock object
+ *
+ * @param mockFactories An object to denote the type
+ * to be used in holding the backing registry
+ */
+ @SuppressWarnings("unchecked")
+ public SetBackedProxyFactoryRegistry(T mockFactories)
+ {
+ // Log
+ log.debug("Using " + this.getClass().getName() + " implementation of " + ProxyFactoryRegistry.class.getName());
+
+ // Create backing instance
+ try
+ {
+ this.setProxyFactories((T) mockFactories.getClass().newInstance());
+ }
+ catch (InstantiationException e)
+ {
+ throw new RuntimeException(e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Required Implementations -------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Register the specified Proxy Factory with the
+ * specified key. Is additionally responsible for calling the
+ * ProxyFactory.start()
+ *
+ * @param key
+ * @param value
+ * @throws ProxyFactoryAlreadyRegisteredException When a proxy factory is already registered under the
+ * specified key
+ */
+ public void registerProxyFactory(String key, ProxyFactory value) throws ProxyFactoryAlreadyRegisteredException
+ {
+ // Ensure not already registered
+ if (this.getProxyFactories().contains(key))
+ {
+ throw new ProxyFactoryAlreadyRegisteredException("Cannot register " + value + " as there is already a "
+ + value.getClass().getSimpleName() + " associated with key \"" + key + "\"");
+ }
+
+ // Start
+ try
+ {
+ value.start();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Error in starting " + value, e);
+ }
+
+ // Place in the registry
+ this.getProxyFactories().add(key);
+ }
+
+ /**
+ * Deregister the specified Proxy Factory with the
+ * specified key. Full deregistration requires calling
+ * lifecycle "stop" on ProxyFactory, which this cannot perform
+ *
+ * @param key
+ * @throws ProxyFactoryNotRegisteredException If no Proxy Factory is registered under the specified key
+ */
+ protected void deregisterProxyFactoryFromBackingSet(String key) throws ProxyFactoryNotRegisteredException
+ {
+ // Deregister
+ boolean removed = this.getProxyFactories().remove(key);
+
+ // Ensure registered
+ if (!removed)
+ {
+ throw new ProxyFactoryNotRegisteredException("Cannot deregister a " + ProxyFactory.class.getName()
+ + " associated with key \"" + key + "\" as the key is currently not registered");
+ }
+ }
+
+ /**
+ * Determines whether a ProxyFactory is registered at the specified key
+ *
+ * @param key
+ * @return
+ */
+ public boolean isRegistered(String key)
+ {
+ return this.getProxyFactories().contains(key);
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Accessors / Mutators -----------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ public T getProxyFactories()
+ {
+ return proxyFactories;
+ }
+
+ private void setProxyFactories(T proxyFactories)
+ {
+ this.proxyFactories = proxyFactories;
+ }
+
+}
Added: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/test/Main.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/test/Main.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/test/Main.java 2008-05-13 06:03:39 UTC (rev 73326)
@@ -0,0 +1,139 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.test;
+
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.LinkRef;
+import javax.naming.NamingException;
+import javax.naming.RefAddr;
+import javax.naming.Reference;
+import javax.naming.StringRefAddr;
+
+import org.jboss.naming.Util;
+
+
+/**
+ * Main
+ *
+ * Test Class for Proof of Concept
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class Main
+{
+
+ private Context ctx;
+
+ private static final String BIND_LOCATION_OBJECT_FACTORY = "/remote";
+
+ private static final String BIND_LOCATION_REFERENCE = "AllBusinessInterfaces";
+
+ private static final String BIND_LOCATION_SECOND_REF = "OneInterface";
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args)
+ {
+ Main main = new Main();
+ try
+ {
+ main.bindObjectFactory();
+ main.bindLinkRefs();
+ main.lookupReference();
+ //main.unbindAll();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+
+ }
+
+ public Main()
+ {
+
+ Properties properties = new Properties();
+ properties.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
+ properties.put("java.naming.provider.url", "jnp://localhost:1099");
+ properties.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
+ try
+ {
+ this.ctx = new InitialContext(properties);
+ }
+ catch (NamingException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void bindObjectFactory() throws Exception
+ {
+ // Bind an object factory as a reference
+ RefAddr refAddr1 = new StringRefAddr("Business Interface Proxy", "org.jboss.ejb3.BusinessInterface1");
+ RefAddr refAddr2 = new StringRefAddr("Business Interface Proxy", "org.jboss.ejb3.BusinessInterface2");
+ Reference objRef = new Reference(
+ "Proxy for org.jboss.ejb3.BusinessInterface1, org.jboss.ejb3.BusinessInterface2", refAddr1,
+ ProxyObjectFactory.class.getName(), null);
+ objRef.add(refAddr2);
+ Util.rebind(this.ctx, Main.BIND_LOCATION_OBJECT_FACTORY, objRef);
+ }
+
+ private void bindLinkRefs() throws Exception
+ {
+ RefAddr refAddr1 = new StringRefAddr("org.jboss.ejb3.BusinessInterface1", "org.jboss.ejb3.BusinessInterface1");
+ RefAddr refAddr2 = new StringRefAddr("org.jboss.ejb3.BusinessInterface2", "org.jboss.ejb3.BusinessInterface2");
+ LinkRef ref = new LinkRef(Main.BIND_LOCATION_OBJECT_FACTORY);
+ ref.add(refAddr1);
+ ref.add(refAddr2);
+ Util.rebind(this.ctx, Main.BIND_LOCATION_REFERENCE, ref);
+
+ Reference ref2 = new LinkRef(Main.BIND_LOCATION_OBJECT_FACTORY);
+ RefAddr refAddr3 = new StringRefAddr("org.jboss.ejb3.BusinessInterface2", "org.jboss.ejb3.BusinessInterface2");
+ ref2.add(refAddr3);
+ Util.rebind(this.ctx, Main.BIND_LOCATION_SECOND_REF, ref2);
+ }
+
+// private void unbindAll() throws Exception
+// {
+// Util.unbind(this.ctx, Main.BIND_LOCATION_REFERENCE);
+// Util.unbind(this.ctx, Main.BIND_LOCATION_OBJECT_FACTORY);
+// }
+
+ private void lookupReference() throws Exception
+ {
+ ctx.lookup(Main.BIND_LOCATION_SECOND_REF);
+ ctx.lookup(Main.BIND_LOCATION_SECOND_REF);
+ ctx.lookup(Main.BIND_LOCATION_SECOND_REF);
+ String s = (String) ctx.lookup(Main.BIND_LOCATION_SECOND_REF);
+ if (!s.equals(ProxyObjectFactory.EXPECTED_OBJ))
+ {
+ throw new RuntimeException("Found \"" + s + "\" where \"" + ProxyObjectFactory.EXPECTED_OBJ + "\" expected.");
+ }
+ System.out.println("Found expected result \"" + s + "\" from JNDI at " + Main.BIND_LOCATION_SECOND_REF);
+ }
+
+}
Added: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/test/ProxyObjectFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/test/ProxyObjectFactory.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/test/ProxyObjectFactory.java 2008-05-13 06:03:39 UTC (rev 73326)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.test;
+
+import java.io.Serializable;
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.RefAddr;
+import javax.naming.Reference;
+import javax.naming.spi.ObjectFactory;
+
+/**
+ * ProxyObjectFactory
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class ProxyObjectFactory implements ObjectFactory, Serializable
+{
+ private static final long serialVersionUID = 1L;
+ public static final String EXPECTED_OBJ = "Expected";
+
+ public ProxyObjectFactory()
+ {
+
+ }
+
+ public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment)
+ throws Exception
+ {
+ System.out.println(ProxyObjectFactory.class.getName() + " servicing request for " + name.toString());
+
+// Set<?> keys = environment.keySet();
+// for(Object key : keys)
+// {
+// System.out.println(key);
+// }
+
+ System.out.println("Name: " + name.toString());
+ System.out.println("Object: " + obj);
+ Reference ref = (Reference)obj;
+
+ Enumeration<RefAddr> refAddrs = ref.getAll();
+ while(refAddrs.hasMoreElements())
+ {
+ RefAddr refAddr = refAddrs.nextElement();
+ System.out.print("Type: "+refAddr.getType());
+ System.out.println(", Content: " + refAddr.getContent());
+ }
+
+ System.out.println("");
+
+ return ProxyObjectFactory.EXPECTED_OBJ;
+ }
+
+}
More information about the jboss-cvs-commits
mailing list