[jboss-cvs] JBossAS SVN: r77405 - in projects/ejb3/tags: jboss-ejb3-core-0.1.15 and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Aug 25 01:28:04 EDT 2008


Author: ALRubinger
Date: 2008-08-25 01:28:04 -0400 (Mon, 25 Aug 2008)
New Revision: 77405

Added:
   projects/ejb3/tags/jboss-ejb3-core-0.1.15/
   projects/ejb3/tags/jboss-ejb3-core-0.1.15/pom.xml
   projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/java/org/jboss/ejb3/EJBContainer.java
   projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/java/org/jboss/ejb3/session/SessionContainer.java
   projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java
   projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java
   projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/resources/META-INF/ejb3-deployers-jboss-beans.xml
Removed:
   projects/ejb3/tags/jboss-ejb3-core-0.1.15/pom.xml
   projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/java/org/jboss/ejb3/EJBContainer.java
   projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/java/org/jboss/ejb3/session/SessionContainer.java
   projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java
   projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java
   projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/resources/META-INF/ejb3-deployers-jboss-beans.xml
Log:
[maven-release-plugin]  copy for tag jboss-ejb3-core-0.1.15

Copied: projects/ejb3/tags/jboss-ejb3-core-0.1.15 (from rev 77394, projects/ejb3/trunk/core)

Deleted: projects/ejb3/tags/jboss-ejb3-core-0.1.15/pom.xml
===================================================================
--- projects/ejb3/trunk/core/pom.xml	2008-08-25 02:13:51 UTC (rev 77394)
+++ projects/ejb3/tags/jboss-ejb3-core-0.1.15/pom.xml	2008-08-25 05:28:04 UTC (rev 77405)
@@ -1,571 +0,0 @@
-<!--
-  vi:ts=2:sw=2:expandtab
--->
-<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>
-    <groupId>org.jboss.ejb3</groupId>
-    <artifactId>jboss-ejb3-build</artifactId>
-    <version>0.13.14</version>
-    <relativePath>../build/pom.xml</relativePath>
-  </parent>
-
-  <!-- POM Model Version -->
-  <modelVersion>4.0.0</modelVersion>
-
-  <!-- Artifact Information -->
-  <artifactId>jboss-ejb3-core</artifactId>
-  <packaging>jar</packaging>
-  <version>0.1.15-SNAPSHOT</version>
-  <name>JBoss EJB 3.0 Core</name>
-  <url>http://labs.jboss.com/jbossejb3</url>
-  <description>JBoss EJB 3.0 Core</description>
-
-  <repositories>
-    <!-- APIviz repository -->
-    <repository>
-      <id>apiviz.release</id>
-      <name>APIviz releases</name>
-      <url>http://apiviz.googlecode.com/svn/site/repo/mvn/release</url>
-      <releases>
-
-        <enabled>true</enabled>
-      </releases>
-      <snapshots>
-        <enabled>false</enabled>
-      </snapshots>
-    </repository>
-  </repositories>
-
-  <!-- Properties -->
-
-  <properties>
-    <version.org.jboss.jboss-as>5.0.0.Beta4</version.org.jboss.jboss-as>
-  </properties>
-
-  <!-- Build Information -->
-  <build>
-
-    <plugins>
-
-      <!-- Assembly Plugin -->
-      <plugin>
-        <artifactId>maven-assembly-plugin</artifactId>
-        <version>2.2-beta-1</version>
-        <executions>
-          <execution>
-            <id>make-assembly</id><!-- this is used for inheritance merges -->
-            <phase>package</phase>
-            <goals>
-              <goal>attached</goal>
-            </goals>
-          </execution>
-        </executions>
-        <configuration>
-          <!-- JBoss EJB3 Client JAR -->
-          <descriptors>
-            <descriptor>jboss-ejb3-client.xml</descriptor>
-          </descriptors>
-          <attach>true</attach>
-        </configuration>
-        <inherited>false</inherited>
-      </plugin>
-
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-javadoc-plugin</artifactId>
-<!--
-        <executions>
-          <execution>
-            <id>attach-javadoc</id>
-            <phase>package</phase>
-            <goals>
-              <goal>jar</goal>
-            </goals>
-          </execution>
-        </executions>
--->
-        <configuration>
-          <doclet>net.gleamynode.apiviz.APIviz</doclet>
-          <docletArtifact>
-            <groupId>net.gleamynode.apiviz</groupId>
-            <artifactId>apiviz</artifactId>
-            <version>1.0.3</version>
-          </docletArtifact>
-<!--
-          <aggregate>true</aggregate>
-          <encoding>UTF-8</encoding>
-          <locale>en_US</locale>
--->
-        </configuration>
-      </plugin>
-
-    </plugins>
-
-  </build>
-
-  <!-- Dependencies -->
-
-  <dependencies>
-
-    <!-- Because AOP doesn't declare a proper dependency -->
-    <dependency>
-      <groupId>javassist</groupId>
-      <artifactId>javassist</artifactId>
-      <version>3.7.1.GA</version>
-    </dependency>
-
-    <dependency>
-      <groupId>javax.xml.soap</groupId>
-      <artifactId>saaj-api</artifactId>
-      <version>1.3</version>
-      <scope>test</scope>
-    </dependency>
-    
-    <dependency>
-      <groupId>javax.mail</groupId>
-      <artifactId>mail</artifactId>
-      <version>1.4</version>
-      <scope>test</scope>
-    </dependency>
-    
-    <dependency>
-      <groupId>jboss.jbossts</groupId>
-      <artifactId>jbossjta</artifactId>
-      <version>4.3.0.GA</version>
-      <scope>test</scope>
-    </dependency>
-    
-    <!-- To actually run SimpleTransactionService -->
-    <dependency>
-      <groupId>jboss.jbossts</groupId>
-      <artifactId>jbossts-common</artifactId>
-      <version>4.3.0.GA</version>
-      <scope>test</scope>
-    </dependency>
-    
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <scope>test</scope>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.hibernate</groupId>
-      <artifactId>hibernate</artifactId>
-      <version>3.2.6.ga</version>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.hibernate</groupId>
-      <artifactId>hibernate-annotations</artifactId>
-      <version>3.3.1.GA</version>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.hibernate</groupId>
-      <artifactId>hibernate-entitymanager</artifactId>
-      <version>3.3.2.GA</version>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.jboss.metadata</groupId>
-      <artifactId>jboss-metadata</artifactId>
-      <exclusions>
-        <exclusion>
-          <groupId>org.jboss.javaee</groupId>
-          <artifactId>jboss-javaee</artifactId>
-        </exclusion>
-      </exclusions>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.jboss.logging</groupId>
-      <artifactId>jboss-logging-spi</artifactId>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.jboss.test</groupId>
-      <artifactId>jboss-test</artifactId>
-      <scope>test</scope>
-    </dependency>
-
-    <dependency>
-      <groupId>org.jboss.jbossas</groupId>
-      <artifactId>jboss-server-manager</artifactId>
-      <scope>test</scope>      
-    </dependency>  
-      
-    <dependency>
-      <groupId>org.jboss</groupId>
-      <artifactId>jboss-transaction-spi</artifactId>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.jboss</groupId>
-      <artifactId>jboss-vfs</artifactId>
-      <version>2.0.0.Beta13</version>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.jboss.naming</groupId>
-      <artifactId>jnpserver</artifactId>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.jboss.aop</groupId>
-      <artifactId>jboss-aop</artifactId>
-      <exclusions>
-        <exclusion>
-          <groupId>org.jboss</groupId>
-          <artifactId>javassist</artifactId>
-        </exclusion>        
-        <exclusion>
-          <groupId>org.jboss.microcontainer</groupId>
-          <artifactId>jboss-container</artifactId>
-        </exclusion>        
-      </exclusions>      
-    </dependency>
-    
-    <dependency>
-      <groupId>org.jboss.aop</groupId>
-      <artifactId>jboss-aop-aspects</artifactId>
-    </dependency>
-    
-    <!-- used in the basicbootstrap-beans.xml -->
-    <dependency>
-      <groupId>org.jboss.aop</groupId>
-      <artifactId>jboss-aop-deployer-jdk50</artifactId>
-      <version>2.0.0.CR10</version>
-      <scope>test</scope>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.jboss.cache</groupId>
-      <artifactId>jbosscache-core</artifactId>
-      <!-- not used anywhere else -->
-      <version>2.1.1.GA</version>
-      <exclusions>
-        <exclusion>
-          <groupId>org.jboss.javaee</groupId>
-          <artifactId>jboss-javaee</artifactId>
-        </exclusion>
-      </exclusions>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.jboss.aspects</groupId>
-      <artifactId>jboss-aspects-test</artifactId>
-      <version>1.0.0.Beta1</version>
-      <scope>test</scope>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.jboss.aspects</groupId>
-      <artifactId>jboss-remoting-aspects</artifactId>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.jboss.cluster</groupId>
-      <artifactId>jboss-ha-client</artifactId>
-      <version>1.1.0.CR4</version>
-      <exclusions>
-        <exclusion>
-          <groupId>org.jboss.aspects</groupId>
-          <artifactId>jboss-remoting-aspects</artifactId>            
-        </exclusion>
-        <exclusion>
-          <groupId>jboss.remoting</groupId>
-          <artifactId>jboss-remoting</artifactId>            
-        </exclusion>
-        <exclusion>
-          <groupId>org.jboss.aop</groupId>
-          <artifactId>jboss-aop</artifactId>            
-        </exclusion>
-      </exclusions>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.jboss.cluster</groupId>
-      <artifactId>jboss-ha-server-api</artifactId>
-      <version>1.1.0.CR4</version>
-      <exclusions>
-        <exclusion>
-          <groupId>org.jboss</groupId>
-          <artifactId>jboss-common-core</artifactId>            
-        </exclusion>
-        <exclusion>
-          <groupId>org.jboss.logging</groupId>
-          <artifactId>jboss-logging-spi</artifactId>            
-        </exclusion>
-        <exclusion>
-          <groupId>org.jboss.cache</groupId>
-          <artifactId>jbosscache-core</artifactId>            
-        </exclusion>
-        <exclusion>
-          <groupId>org.jboss.cache</groupId>
-          <artifactId>jbosscache-pojo</artifactId>            
-        </exclusion>
-        <exclusion>
-          <groupId>jgroups</groupId>
-          <artifactId>jgroups</artifactId>            
-        </exclusion>
-      </exclusions>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.jboss.ejb3</groupId>
-      <artifactId>jboss-ejb3-async</artifactId>
-      <version>0.1.1</version>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.jboss.ejb3</groupId>
-      <artifactId>jboss-ejb3-cache</artifactId>
-      <version>0.13.0</version>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.jboss.ejb3</groupId>
-      <artifactId>jboss-ejb3-common</artifactId>
-      <version>0.1.6</version>
-    </dependency>
-
-    <dependency>
-      <groupId>org.jboss.ejb3</groupId>
-      <artifactId>jboss-ejb3-security</artifactId>
-      <version>0.13.1</version>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.jboss.ejb3</groupId>
-      <artifactId>jboss-ejb3-ext-api</artifactId>
-      <version>0.4</version>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.jboss.ejb3</groupId>
-      <artifactId>jboss-ejb3-ext-api-impl</artifactId>
-      <version>0.4.1</version>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.jboss.ejb3</groupId>
-      <artifactId>jboss-ejb3-interceptors</artifactId>
-      <version>0.13.4</version>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.jboss.ejb3</groupId>
-      <artifactId>jboss-ejb3-metadata</artifactId>
-      <version>0.13.0</version>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.jboss.ejb3</groupId>
-      <artifactId>jboss-ejb3-proxy</artifactId>
-      <version>0.1.2</version>
-    </dependency>
-   
-    <dependency>
-      <groupId>org.jboss.ejb3</groupId>
-      <artifactId>jboss-ejb3-test</artifactId>
-      <version>0.1.3</version>
-      <scope>test</scope>
-    </dependency>
-
-    <dependency>
-      <groupId>org.jboss.ejb3</groupId>
-      <artifactId>jboss-ejb3-transactions</artifactId>
-      <version>0.13.5</version>
-    </dependency>
-
-    <dependency>
-      <groupId>org.jboss.embedded</groupId>
-      <artifactId>jboss-embedded</artifactId>
-      <version>beta3</version>
-      <scope>test</scope>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.jboss.javaee</groupId>
-      <artifactId>jboss-ejb-api</artifactId>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.jboss.javaee</groupId>
-      <artifactId>jboss-jacc-api</artifactId>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.jboss.javaee</groupId>
-      <artifactId>jboss-jca-api</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>org.jboss.javaee</groupId>
-      <artifactId>jboss-jms-api</artifactId>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.jboss.javaee</groupId>
-      <artifactId>jboss-servlet-api</artifactId>
-    </dependency>
-    
-    <!-- those needs to be removed - EJBTHREE-1340 -->
-    <dependency>
-      <groupId>org.jboss.jbossas</groupId>
-      <artifactId>jboss-as-main</artifactId>
-      <version>${version.org.jboss.jboss-as}</version>
-      <scope>provided</scope>
-    </dependency>     
-    <dependency>
-      <groupId>org.jboss.jbossas</groupId>
-      <artifactId>jboss-as-system</artifactId>
-      <version>${version.org.jboss.jboss-as}</version>
-      <scope>provided</scope>
-      <exclusions>
-        <exclusion>
-          <groupId>org.jboss</groupId>
-          <artifactId>javassist</artifactId>
-        </exclusion>
-        <exclusion>
-          <groupId>org.jboss.microcontainer</groupId>
-          <artifactId>jboss-aop-mc-int</artifactId>
-        </exclusion>
-        <exclusion>
-          <groupId>org.jboss.microcontainer</groupId>
-          <artifactId>jboss-container</artifactId>
-        </exclusion>
-        <exclusion>
-          <groupId>org.jboss.microcontainer</groupId>
-          <artifactId>jboss-deployers-impl</artifactId>
-        </exclusion>
-        <exclusion>
-          <groupId>org.jboss.microcontainer</groupId>
-          <artifactId>jboss-deployers-spi</artifactId>
-        </exclusion>
-      </exclusions>
-    </dependency>
-    <dependency>
-      <groupId>org.jboss.jbossas</groupId>
-      <artifactId>jboss-as-system-jmx</artifactId>
-      <version>${version.org.jboss.jboss-as}</version>
-      <scope>provided</scope>
-      <exclusions>
-        <exclusion>
-          <groupId>org.jboss</groupId>
-          <artifactId>javassist</artifactId>
-        </exclusion>
-        <exclusion>
-          <groupId>org.jboss.microcontainer</groupId>
-          <artifactId>jboss-aop-mc-int</artifactId>
-        </exclusion>
-        <exclusion>
-          <groupId>org.jboss.microcontainer</groupId>
-          <artifactId>jboss-container</artifactId>
-        </exclusion>
-        <exclusion>
-          <groupId>org.jboss.microcontainer</groupId>
-          <artifactId>jboss-deployers-impl</artifactId>
-        </exclusion>
-        <exclusion>
-          <groupId>org.jboss.microcontainer</groupId>
-          <artifactId>jboss-deployers-spi</artifactId>
-        </exclusion>
-      </exclusions>
-    </dependency>
-    <dependency>
-      <groupId>org.jboss.jbossas</groupId>
-      <artifactId>jboss-as-mbeans</artifactId>
-      <version>${version.org.jboss.jboss-as}</version>
-      <exclusions>
-        <exclusion>
-          <groupId>org.jboss</groupId>
-          <artifactId>jboss-test</artifactId>
-        </exclusion>        
-      </exclusions>      
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.jboss.jbossas</groupId>
-      <artifactId>jboss-as-j2se</artifactId>
-      <version>${version.org.jboss.jboss-as}</version>
-      <scope>provided</scope>
-      <exclusions>
-        <exclusion>
-          <groupId>org.jboss.microcontainer</groupId>
-          <artifactId>jboss-container</artifactId>
-        </exclusion>
-      </exclusions>
-    </dependency>
-    
-    <!-- this needs to be removed - EJBTHREE-1343 -->
-    <dependency>
-      <groupId>org.jboss.jbossas</groupId>
-      <artifactId>jboss-as-server</artifactId>
-      <version>${version.org.jboss.jboss-as}</version>
-      <exclusions>
-        <exclusion>
-          <groupId>jboss</groupId>
-          <artifactId>jboss-remoting</artifactId>
-        </exclusion>        
-        <exclusion>
-          <groupId>org.jboss</groupId>
-          <artifactId>jboss-metadata</artifactId>
-        </exclusion>        
-        <exclusion>
-          <groupId>org.jboss.jbossas</groupId>
-          <artifactId>jboss-as-security</artifactId>
-        </exclusion>        
-      </exclusions>      
-      <scope>provided</scope>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.jboss.jpa</groupId>
-      <artifactId>jboss-jpa-deployers</artifactId>
-      <version>0.1.1</version>
-    </dependency>
-
-    <dependency>
-      <groupId>org.jboss.microcontainer</groupId>
-      <artifactId>jboss-deployers-core-spi</artifactId>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.jboss.microcontainer</groupId>
-      <artifactId>jboss-kernel</artifactId>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.jboss.security</groupId>
-      <artifactId>jboss-security-spi</artifactId>
-      <version>2.0.2.CR5</version>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.jboss.security</groupId>
-      <artifactId>jbosssx</artifactId>
-      <version>2.0.2.CR5</version>
-    </dependency>
-    
-     <dependency>
-      <groupId>org.jboss.ws</groupId>
-      <artifactId>jbossws-spi</artifactId>
-    </dependency>
-    
-    <dependency>
-      <groupId>quartz</groupId>
-      <artifactId>quartz</artifactId>
-      <version>1.6.0</version>
-    </dependency>
-    
-    <dependency>
-      <groupId>trove</groupId>
-      <artifactId>trove</artifactId>
-    </dependency>
-    
-  </dependencies>
-</project>

Copied: projects/ejb3/tags/jboss-ejb3-core-0.1.15/pom.xml (from rev 77404, projects/ejb3/trunk/core/pom.xml)
===================================================================
--- projects/ejb3/tags/jboss-ejb3-core-0.1.15/pom.xml	                        (rev 0)
+++ projects/ejb3/tags/jboss-ejb3-core-0.1.15/pom.xml	2008-08-25 05:28:04 UTC (rev 77405)
@@ -0,0 +1,583 @@
+<!--
+  vi:ts=2:sw=2:expandtab
+-->
+<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>
+    <groupId>org.jboss.ejb3</groupId>
+    <artifactId>jboss-ejb3-build</artifactId>
+    <version>0.13.14</version>
+    <relativePath>../build/pom.xml</relativePath>
+  </parent>
+
+  <!-- POM Model Version -->
+  <modelVersion>4.0.0</modelVersion>
+
+  <!-- Artifact Information -->
+  <artifactId>jboss-ejb3-core</artifactId>
+  <packaging>jar</packaging>
+  <version>0.1.15</version>
+  <name>JBoss EJB 3.0 Core</name>
+  <url>http://labs.jboss.com/jbossejb3</url>
+  <description>JBoss EJB 3.0 Core</description>
+
+  <repositories>
+    <!-- APIviz repository -->
+    <repository>
+      <id>apiviz.release</id>
+      <name>APIviz releases</name>
+      <url>http://apiviz.googlecode.com/svn/site/repo/mvn/release</url>
+      <releases>
+
+        <enabled>true</enabled>
+      </releases>
+      <snapshots>
+        <enabled>false</enabled>
+      </snapshots>
+    </repository>
+  </repositories>
+
+  <!-- Properties -->
+
+  <properties>
+    <version.org.jboss.jboss-as>5.0.0.Beta4</version.org.jboss.jboss-as>
+  </properties>
+
+  <!-- Build Information -->
+  <build>
+
+    <plugins>
+
+      <!-- Assembly Plugin -->
+      <plugin>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <version>2.2-beta-1</version>
+        <executions>
+          <execution>
+            <id>make-assembly</id><!-- this is used for inheritance merges -->
+            <phase>package</phase>
+            <goals>
+              <goal>attached</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <!-- JBoss EJB3 Client JAR -->
+          <descriptors>
+            <descriptor>jboss-ejb3-client.xml</descriptor>
+          </descriptors>
+          <attach>true</attach>
+        </configuration>
+        <inherited>false</inherited>
+      </plugin>
+
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-javadoc-plugin</artifactId>
+<!--
+        <executions>
+          <execution>
+            <id>attach-javadoc</id>
+            <phase>package</phase>
+            <goals>
+              <goal>jar</goal>
+            </goals>
+          </execution>
+        </executions>
+-->
+        <configuration>
+          <doclet>net.gleamynode.apiviz.APIviz</doclet>
+          <docletArtifact>
+            <groupId>net.gleamynode.apiviz</groupId>
+            <artifactId>apiviz</artifactId>
+            <version>1.0.3</version>
+          </docletArtifact>
+<!--
+          <aggregate>true</aggregate>
+          <encoding>UTF-8</encoding>
+          <locale>en_US</locale>
+-->
+        </configuration>
+      </plugin>
+
+    </plugins>
+
+  </build>
+
+  <!-- Dependencies -->
+
+  <dependencies>
+
+    <!-- Because AOP doesn't declare a proper dependency -->
+    <dependency>
+      <groupId>javassist</groupId>
+      <artifactId>javassist</artifactId>
+      <version>3.7.1.GA</version>
+    </dependency>
+
+    <dependency>
+      <groupId>javax.xml.soap</groupId>
+      <artifactId>saaj-api</artifactId>
+      <version>1.3</version>
+      <scope>test</scope>
+    </dependency>
+    
+    <dependency>
+      <groupId>javax.mail</groupId>
+      <artifactId>mail</artifactId>
+      <version>1.4</version>
+      <scope>test</scope>
+    </dependency>
+    
+    <dependency>
+      <groupId>jboss.jbossts</groupId>
+      <artifactId>jbossjta</artifactId>
+      <version>4.3.0.GA</version>
+      <scope>test</scope>
+    </dependency>
+    
+    <!-- To actually run SimpleTransactionService -->
+    <dependency>
+      <groupId>jboss.jbossts</groupId>
+      <artifactId>jbossts-common</artifactId>
+      <version>4.3.0.GA</version>
+      <scope>test</scope>
+    </dependency>
+    
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.hibernate</groupId>
+      <artifactId>hibernate</artifactId>
+      <version>3.2.6.ga</version>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.hibernate</groupId>
+      <artifactId>hibernate-annotations</artifactId>
+      <version>3.3.1.GA</version>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.hibernate</groupId>
+      <artifactId>hibernate-entitymanager</artifactId>
+      <version>3.3.2.GA</version>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.metadata</groupId>
+      <artifactId>jboss-metadata</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>org.jboss.javaee</groupId>
+          <artifactId>jboss-javaee</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.logging</groupId>
+      <artifactId>jboss-logging-spi</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.test</groupId>
+      <artifactId>jboss-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.jboss.jbossas</groupId>
+      <artifactId>jboss-server-manager</artifactId>
+      <scope>test</scope>      
+    </dependency>  
+      
+    <dependency>
+      <groupId>org.jboss</groupId>
+      <artifactId>jboss-transaction-spi</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss</groupId>
+      <artifactId>jboss-vfs</artifactId>
+      <version>2.0.0.Beta13</version>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.naming</groupId>
+      <artifactId>jnpserver</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.aop</groupId>
+      <artifactId>jboss-aop</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>org.jboss</groupId>
+          <artifactId>javassist</artifactId>
+        </exclusion>        
+        <exclusion>
+          <groupId>org.jboss.microcontainer</groupId>
+          <artifactId>jboss-container</artifactId>
+        </exclusion>        
+      </exclusions>      
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.aop</groupId>
+      <artifactId>jboss-aop-aspects</artifactId>
+    </dependency>
+    
+    <!-- used in the basicbootstrap-beans.xml -->
+    <dependency>
+      <groupId>org.jboss.aop</groupId>
+      <artifactId>jboss-aop-deployer-jdk50</artifactId>
+      <version>2.0.0.CR10</version>
+      <scope>test</scope>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.cache</groupId>
+      <artifactId>jbosscache-core</artifactId>
+      <!-- not used anywhere else -->
+      <version>2.1.1.GA</version>
+      <exclusions>
+        <exclusion>
+          <groupId>org.jboss.javaee</groupId>
+          <artifactId>jboss-javaee</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.aspects</groupId>
+      <artifactId>jboss-aspects-test</artifactId>
+      <version>1.0.0.Beta1</version>
+      <scope>test</scope>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.aspects</groupId>
+      <artifactId>jboss-remoting-aspects</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.cluster</groupId>
+      <artifactId>jboss-ha-client</artifactId>
+      <version>1.1.0.CR4</version>
+      <exclusions>
+        <exclusion>
+          <groupId>org.jboss.aspects</groupId>
+          <artifactId>jboss-remoting-aspects</artifactId>            
+        </exclusion>
+        <exclusion>
+          <groupId>jboss.remoting</groupId>
+          <artifactId>jboss-remoting</artifactId>            
+        </exclusion>
+        <exclusion>
+          <groupId>org.jboss.aop</groupId>
+          <artifactId>jboss-aop</artifactId>            
+        </exclusion>
+      </exclusions>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.cluster</groupId>
+      <artifactId>jboss-ha-server-api</artifactId>
+      <version>1.1.0.CR4</version>
+      <exclusions>
+        <exclusion>
+          <groupId>org.jboss</groupId>
+          <artifactId>jboss-common-core</artifactId>            
+        </exclusion>
+        <exclusion>
+          <groupId>org.jboss.logging</groupId>
+          <artifactId>jboss-logging-spi</artifactId>            
+        </exclusion>
+        <exclusion>
+          <groupId>org.jboss.cache</groupId>
+          <artifactId>jbosscache-core</artifactId>            
+        </exclusion>
+        <exclusion>
+          <groupId>org.jboss.cache</groupId>
+          <artifactId>jbosscache-pojo</artifactId>            
+        </exclusion>
+        <exclusion>
+          <groupId>jgroups</groupId>
+          <artifactId>jgroups</artifactId>            
+        </exclusion>
+      </exclusions>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.ejb3</groupId>
+      <artifactId>jboss-ejb3-async</artifactId>
+      <version>0.1.1</version>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.ejb3</groupId>
+      <artifactId>jboss-ejb3-cache</artifactId>
+      <version>0.13.0</version>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.ejb3</groupId>
+      <artifactId>jboss-ejb3-common</artifactId>
+      <version>0.1.6</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.jboss.ejb3</groupId>
+      <artifactId>jboss-ejb3-security</artifactId>
+      <version>0.13.1</version>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.ejb3</groupId>
+      <artifactId>jboss-ejb3-ext-api</artifactId>
+      <version>0.4</version>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.ejb3</groupId>
+      <artifactId>jboss-ejb3-ext-api-impl</artifactId>
+      <version>0.4.1</version>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.ejb3</groupId>
+      <artifactId>jboss-ejb3-interceptors</artifactId>
+      <version>0.13.4</version>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.ejb3</groupId>
+      <artifactId>jboss-ejb3-metadata</artifactId>
+      <version>0.13.0</version>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.ejb3</groupId>
+      <artifactId>jboss-ejb3-proxy</artifactId>
+      <version>0.1.2</version>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.ejb3</groupId>
+      <artifactId>jboss-ejb3-proxy-clustered</artifactId>
+      <version>0.1.3</version>
+    </dependency>
+   
+    <dependency>
+      <groupId>org.jboss.ejb3</groupId>
+      <artifactId>jboss-ejb3-test</artifactId>
+      <version>0.1.3</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.jboss.ejb3</groupId>
+      <artifactId>jboss-ejb3-transactions</artifactId>
+      <version>0.13.5</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.jboss.embedded</groupId>
+      <artifactId>jboss-embedded</artifactId>
+      <version>beta3</version>
+      <scope>test</scope>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.javaee</groupId>
+      <artifactId>jboss-ejb-api</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.javaee</groupId>
+      <artifactId>jboss-jacc-api</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.javaee</groupId>
+      <artifactId>jboss-jca-api</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.jboss.javaee</groupId>
+      <artifactId>jboss-jms-api</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.javaee</groupId>
+      <artifactId>jboss-servlet-api</artifactId>
+    </dependency>
+    
+    <!-- those needs to be removed - EJBTHREE-1340 -->
+    <dependency>
+      <groupId>org.jboss.jbossas</groupId>
+      <artifactId>jboss-as-main</artifactId>
+      <version>${version.org.jboss.jboss-as}</version>
+      <scope>provided</scope>
+    </dependency>     
+    <dependency>
+      <groupId>org.jboss.jbossas</groupId>
+      <artifactId>jboss-as-system</artifactId>
+      <version>${version.org.jboss.jboss-as}</version>
+      <scope>provided</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>org.jboss</groupId>
+          <artifactId>javassist</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.jboss.microcontainer</groupId>
+          <artifactId>jboss-aop-mc-int</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.jboss.microcontainer</groupId>
+          <artifactId>jboss-container</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.jboss.microcontainer</groupId>
+          <artifactId>jboss-deployers-impl</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.jboss.microcontainer</groupId>
+          <artifactId>jboss-deployers-spi</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.jbossas</groupId>
+      <artifactId>jboss-as-system-jmx</artifactId>
+      <version>${version.org.jboss.jboss-as}</version>
+      <scope>provided</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>org.jboss</groupId>
+          <artifactId>javassist</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.jboss.microcontainer</groupId>
+          <artifactId>jboss-aop-mc-int</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.jboss.microcontainer</groupId>
+          <artifactId>jboss-container</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.jboss.microcontainer</groupId>
+          <artifactId>jboss-deployers-impl</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.jboss.microcontainer</groupId>
+          <artifactId>jboss-deployers-spi</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.jbossas</groupId>
+      <artifactId>jboss-as-mbeans</artifactId>
+      <version>${version.org.jboss.jboss-as}</version>
+      <exclusions>
+        <exclusion>
+          <groupId>org.jboss</groupId>
+          <artifactId>jboss-test</artifactId>
+        </exclusion>        
+      </exclusions>      
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.jbossas</groupId>
+      <artifactId>jboss-as-j2se</artifactId>
+      <version>${version.org.jboss.jboss-as}</version>
+      <scope>provided</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>org.jboss.microcontainer</groupId>
+          <artifactId>jboss-container</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    
+    <!-- this needs to be removed - EJBTHREE-1343 -->
+    <dependency>
+      <groupId>org.jboss.jbossas</groupId>
+      <artifactId>jboss-as-server</artifactId>
+      <version>${version.org.jboss.jboss-as}</version>
+      <exclusions>
+        <exclusion>
+          <groupId>jboss</groupId>
+          <artifactId>jboss-remoting</artifactId>
+        </exclusion>        
+        <exclusion>
+          <groupId>org.jboss</groupId>
+          <artifactId>jboss-metadata</artifactId>
+        </exclusion>        
+        <exclusion>
+          <groupId>org.jboss.jbossas</groupId>
+          <artifactId>jboss-as-security</artifactId>
+        </exclusion>        
+      </exclusions>      
+      <scope>provided</scope>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.jpa</groupId>
+      <artifactId>jboss-jpa-deployers</artifactId>
+      <version>0.1.1</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.jboss.microcontainer</groupId>
+      <artifactId>jboss-deployers-core-spi</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.microcontainer</groupId>
+      <artifactId>jboss-kernel</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.security</groupId>
+      <artifactId>jboss-security-spi</artifactId>
+      <version>2.0.2.CR5</version>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.security</groupId>
+      <artifactId>jbosssx</artifactId>
+      <version>2.0.2.CR5</version>
+    </dependency>
+    
+     <dependency>
+      <groupId>org.jboss.ws</groupId>
+      <artifactId>jbossws-spi</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>quartz</groupId>
+      <artifactId>quartz</artifactId>
+      <version>1.6.0</version>
+    </dependency>
+    
+    <dependency>
+      <groupId>trove</groupId>
+      <artifactId>trove</artifactId>
+    </dependency>
+    
+  </dependencies>
+
+  <scm>
+    <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/ejb3/tags/jboss-ejb3-core-0.1.15</connection>
+    <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/ejb3/tags/jboss-ejb3-core-0.1.15</developerConnection>
+    <url>http://anonsvn.jboss.org/repos/jbossas/projects/ejb3/tags/jboss-ejb3-core-0.1.15</url>
+  </scm>
+</project>

Deleted: projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/java/org/jboss/ejb3/EJBContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java	2008-08-25 02:13:51 UTC (rev 77394)
+++ projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/java/org/jboss/ejb3/EJBContainer.java	2008-08-25 05:28:04 UTC (rev 77405)
@@ -1,1548 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, 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;
-
-import java.lang.annotation.Annotation;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.ejb.EJBContext;
-import javax.ejb.EJBException;
-import javax.ejb.Local;
-import javax.ejb.Remote;
-import javax.ejb.TimedObject;
-import javax.ejb.Timeout;
-import javax.ejb.Timer;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.LinkRef;
-import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
-import javax.naming.Reference;
-import javax.naming.StringRefAddr;
-
-import org.jboss.aop.Advisor;
-import org.jboss.aop.Domain;
-import org.jboss.aop.MethodInfo;
-import org.jboss.aop.advice.Interceptor;
-import org.jboss.aop.annotation.AnnotationRepository;
-import org.jboss.aop.joinpoint.ConstructionInvocation;
-import org.jboss.aop.util.MethodHashing;
-import org.jboss.ejb.AllowedOperationsAssociation;
-import org.jboss.ejb3.annotation.Clustered;
-import org.jboss.ejb3.annotation.SecurityDomain;
-import org.jboss.ejb3.annotation.defaults.PoolDefaults;
-import org.jboss.ejb3.aop.BeanContainer;
-import org.jboss.ejb3.deployers.JBoss5DependencyPolicy;
-import org.jboss.ejb3.entity.PersistenceUnitDeployment;
-import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
-import org.jboss.ejb3.interceptor.InterceptorInjector;
-import org.jboss.ejb3.interceptors.aop.LifecycleCallbacks;
-import org.jboss.ejb3.interceptors.container.ManagedObjectAdvisor;
-import org.jboss.ejb3.interceptors.direct.DirectContainer;
-import org.jboss.ejb3.interceptors.direct.IndirectContainer;
-import org.jboss.ejb3.javaee.JavaEEComponent;
-import org.jboss.ejb3.javaee.JavaEEComponentHelper;
-import org.jboss.ejb3.javaee.JavaEEModule;
-import org.jboss.ejb3.pool.Pool;
-import org.jboss.ejb3.pool.PoolFactory;
-import org.jboss.ejb3.pool.PoolFactoryRegistry;
-import org.jboss.ejb3.proxy.container.InvokableContext;
-import org.jboss.ejb3.proxy.factory.ProxyFactoryHelper;
-import org.jboss.ejb3.security.SecurityDomainManager;
-import org.jboss.ejb3.statistics.InvocationStatistics;
-import org.jboss.ejb3.tx.UserTransactionImpl;
-import org.jboss.injection.DependsHandler;
-import org.jboss.injection.EJBHandler;
-import org.jboss.injection.EncInjector;
-import org.jboss.injection.ExtendedInjectionContainer;
-import org.jboss.injection.InjectionHandler;
-import org.jboss.injection.InjectionUtil;
-import org.jboss.injection.Injector;
-import org.jboss.injection.JndiInjectHandler;
-import org.jboss.injection.PersistenceContextHandler;
-import org.jboss.injection.PersistenceUnitHandler;
-import org.jboss.injection.ResourceHandler;
-import org.jboss.injection.WebServiceRefHandler;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.ejb.jboss.JBossAssemblyDescriptorMetaData;
-import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
-import org.jboss.metadata.ejb.jboss.JBossMetaData;
-import org.jboss.metadata.ejb.spec.InterceptorMetaData;
-import org.jboss.metadata.ejb.spec.InterceptorsMetaData;
-import org.jboss.metadata.ejb.spec.NamedMethodMetaData;
-import org.jboss.metadata.javaee.spec.Environment;
-import org.jboss.metadata.javaee.spec.ServiceReferenceMetaData;
-import org.jboss.util.StringPropertyReplacer;
-import org.jboss.util.naming.Util;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public abstract class EJBContainer implements Container, IndirectContainer<EJBContainer, DirectContainer<EJBContainer>>, ExtendedInjectionContainer, JavaEEComponent
-{
-   private static final Logger log = Logger.getLogger(EJBContainer.class);
-
-   private String name;
-   
-   private BeanContainer beanContainer;
-   
-   private DirectContainer<EJBContainer> directContainer;
-   
-   protected EjbEncFactory encFactory = new DefaultEjbEncFactory();
-
-   protected Pool pool;
-
-   protected String ejbName;
-
-   protected ObjectName objectName;
-
-   protected int defaultConstructorIndex;
-
-   protected String beanClassName;
-   
-   private Class<?> beanClass;
-
-   protected ClassLoader classloader;
-
-   // for performance there is an array.
-   protected List<Injector> injectors = new ArrayList<Injector>();
-
-   protected Context enc;
-
-//   protected LifecycleInterceptorHandler callbackHandler;
-
-   protected Hashtable initialContextProperties;
-
-   protected Map<String, EncInjector> encInjectors = new HashMap<String, EncInjector>();
-
-   protected JBossEnterpriseBeanMetaData xml;
-   protected JBossAssemblyDescriptorMetaData assembly;
-
-   protected Map<String, Map<AccessibleObject, Injector>> encInjections = new HashMap<String, Map<AccessibleObject, Injector>>();
-
-//   protected List<InterceptorInfo> classInterceptors = new ArrayList<InterceptorInfo>();
-//
-//   protected LinkedHashSet<InterceptorInfo> applicableInterceptors;
-
-   private HashMap<Class<?>, InterceptorInjector> interceptorInjectors = new HashMap<Class<?>, InterceptorInjector>();
-
-   private Ejb3Deployment deployment;
-
-   private DependencyPolicy dependencyPolicy;
-
-   private String jaccContextId;
-
-   protected InvocationStatistics invokeStats = new InvocationStatistics();
-   
-   private String partitionName;
-   
-   private List<Class<?>> businessInterfaces;
-   
-   private ThreadLocalStack<BeanContext<?>> currentBean = new ThreadLocalStack<BeanContext<?>>();
-   
-   protected boolean reinitialize = false;
-   
-   // To support clean startup/shutdown
-   private ReadWriteLock containerLock = new ReentrantReadWriteLock();
-   
-   /**
-    * @param name                  Advisor name
-    * @param manager               Domain to get interceptor bindings from
-    * @param cl                    the EJB's classloader
-    * @param beanClassName
-    * @param ejbName
-    * @param ctxProperties
-    * @param interceptorRepository
-    * @param deployment
-    * @param beanMetaData           the meta data for this bean or null
-    */
-
-   public EJBContainer(String name, Domain domain, ClassLoader cl,
-                       String beanClassName, String ejbName, Hashtable ctxProperties,
-                       Ejb3Deployment deployment, JBossEnterpriseBeanMetaData beanMetaData) throws ClassNotFoundException
-   {
-      assert name != null : "name is null";
-      assert deployment != null : "deployment is null";
-      
-      this.name = name;
-      this.deployment = deployment;
-      this.beanClassName = beanClassName;
-      this.classloader = cl;
-      this.xml = beanMetaData;
-         
-      this.beanClass = classloader.loadClass(beanClassName);
-      
-      // We can't type cast the direct container, because we just loaded the beanClass
-      // so assuming we have an object is a safe bet.
-      this.beanContainer = new BeanContainer(this);
-      
-      this.ejbName = ejbName;
-      
-      // Because interceptors will query back the EJBContainer for annotations
-      // we must have set beanContainer first and then do the advisor. 
-      try
-      {
-         beanContainer.initialize(ejbName, domain, beanClass, beanMetaData, cl);
-      }
-      catch(Exception e)
-      {
-         throw new RuntimeException("failed to initialize bean container ",e);
-      }
-      String on = createObjectName(ejbName);
-     
-      try
-      {
-         objectName = new ObjectName(on);
-      }
-      catch (MalformedObjectNameException e)
-      {
-         throw new RuntimeException("failed to create object name for: " + on, e);
-      }
-      
-      //annotations = new AnnotationRepositoryToMetaData(this);
-      
-      initialContextProperties = ctxProperties;
-      try
-      {
-         Util.createSubcontext(getEnc(), "env");
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException(e);
-      }
-      bindORB();
-      bindEJBContext();
-      
-      this.dependencyPolicy = deployment.createDependencyPolicy(this);
-   }
-
-   private void bindEJBContext()
-   {
-      try 
-      {
-         Reference ref = new Reference(EJBContext.class.getName(), EJBContextFactory.class.getName(), null);
-         ref.add(new StringRefAddr("containerGuid", Ejb3Registry.guid(this)));
-         ref.add(new StringRefAddr("containerClusterUid", Ejb3Registry.clusterUid(this)));
-         ref.add(new StringRefAddr("isClustered", Boolean.toString(isClustered())));
-         Util.rebind(getEnc(), "EJBContext", ref);
-      }
-      catch (NamingException e)
-      {
-         throw new RuntimeException(e);
-      }
-   }
-   
-   private void bindORB()
-   {
-      try
-      {
-         Util.rebind(getEnc(), "ORB", new LinkRef("java:/JBossCorbaORB"));
-      }
-      catch(NamingException e)
-      {
-         throw new RuntimeException(e);
-      }
-   }
-   
-   public abstract BeanContext<?> createBeanContext();
-   
-   public String createObjectName(String ejbName)
-   {
-      return JavaEEComponentHelper.createObjectName(deployment, ejbName);
-   }
-   
-   /**
-    * Do not call, for BeanContainer.
-    * @throws IllegalAccessException 
-    * @throws InstantiationException 
-    */
-   public Object createInterceptor(Class<?> interceptorClass) throws InstantiationException, IllegalAccessException
-   {
-      Object instance = interceptorClass.newInstance();
-      InterceptorInjector interceptorInjector = interceptorInjectors.get(interceptorClass);
-      assert interceptorInjector != null : "interceptorInjector not found for " + interceptorClass;
-      interceptorInjector.inject(null, instance);
-      return instance;
-   }
-   
-   public String createObjectName(String unitName, String ejbName)
-   {
-      return JavaEEComponentHelper.createObjectName(deployment, unitName, ejbName);
-   }
-   
-   // TODO: re-evaluate this exposure
-   @Deprecated
-   public Advisor getAdvisor()
-   {
-      return beanContainer._getAdvisor();
-   }
-
-   /*
-    * TODO: re-evalute this exposure
-    */
-   @Deprecated
-   public AnnotationRepository getAnnotations()
-   {
-      return beanContainer.getAnnotationRepository();
-   }
-
-   protected BeanContainer getBeanContainer()
-   {
-      return beanContainer;
-   }
-   
-   /**
-    * 
-    * @return   the bean class of this container
-    * @deprecated   use getBeanClass
-    */
-   public Class<?> getClazz()
-   {
-      return getBeanClass();
-   }
-   
-   @SuppressWarnings("unchecked")
-   public static <C extends EJBContainer> C getEJBContainer(Advisor advisor)
-   {
-      try
-      {
-         return (C) ((ManagedObjectAdvisor<Object, BeanContainer>) advisor).getContainer().getEJBContainer();
-      }
-      catch(ClassCastException e)
-      {
-         throw new ClassCastException(e.getMessage() + " using " + advisor);
-      }
-   }
-   
-   public String getName()
-   {
-      return name;
-   }
-   
-   public void pushContext(BeanContext<?> beanContext)
-   {
-      currentBean.push(beanContext);
-   }
-   
-   /**
-    * Makes sure that EJB's ENC is available
-    * Delegates to whatever implementation is used to push the ENC of the EJB
-    * onto the stack
-    *
-    */
-   protected void pushEnc()
-   {
-      encFactory.pushEnc(this);
-   }
-
-   public BeanContext<?> peekContext()
-   {
-      BeanContext<?> ctx = currentBean.get();
-      assert ctx != null : "ctx is null";
-      return ctx;
-   }
-   
-   public BeanContext<?> popContext()
-   {
-      return currentBean.pop();
-   }
-   
-   /**
-    * Pops EJB's ENC from the stack.  Delegates to whatever implementation
-    * is used to pop the EJB's ENC from the stock
-    *
-    */
-   protected void popEnc()
-   {
-      encFactory.popEnc(this);
-   }
-   
-   public Environment getEnvironmentRefGroup()
-   {
-      return xml;
-   }
-
-   public List<Injector> getInjectors()
-   {
-      return injectors;
-   }
-
-
-   public String getJaccContextId()
-   {
-      return jaccContextId;
-   }
-
-   /**
-    * Do not call, used by BeanContainer.
-    * @return
-    */
-   public List<Method> getVirtualMethods()
-   {
-      return null;
-   }
-   
-   public void setJaccContextId(String jaccContextId)
-   {
-      this.jaccContextId = jaccContextId;
-   }
-   
-   public VirtualFile getRootFile()
-   {
-      return getDeploymentUnit().getRootFile();
-   }
-   
-   /**
-    * Return all the business interfaces implemented by this bean.
-    * 
-    * Available after the meta data has been processed.
-    * 
-    * @return   an array of business interfaces or empty if no interface is provided
-    */
-   public List<Class<?>> getBusinessInterfaces()
-   {
-      if(businessInterfaces == null) throw new IllegalStateException("businessInterfaces not yet initialized");
-      return businessInterfaces;
-   }
-      
-   public String getDeploymentQualifiedName()
-   {
-      return objectName.getCanonicalName();
-   }
-   
-   /**
-    * Returns a String identifier for this bean that is qualified by the
-    * deployment, and hence should be unique across deployments. Name is of the 
-    * form "ear=foo.ear,jar=foo.jar,name=Bar", where "Bar" is the value 
-    * returned by {@link #getEjbName()}. The "ear=foo.ear" portion is ommitted 
-    * if the bean is not packaged in an ear.
-    */
-   public String getDeploymentPropertyListString()
-   {
-      return objectName.getCanonicalKeyPropertyListString();
-   }
-   
-   public DeploymentUnit getDeploymentUnit()
-   {
-      return deployment.getDeploymentUnit();
-   }
-
-   public Ejb3Deployment getDeployment()
-   {
-      return deployment;
-   }
-
-   public DependencyPolicy getDependencyPolicy()
-   {
-      return dependencyPolicy;
-   }
-
-   public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
-   {
-      return beanContainer.isAnnotationPresent(annotationType);
-   }
-   
-   /**
-    * Is the method a business method of this container.
-    * 
-    * @param businessMethod     the method in question
-    * @return   true if so, otherwise false
-    */
-   public boolean isBusinessMethod(Method businessMethod)
-   {
-      for(Class<?> businessInterface : getBusinessInterfaces())
-      {
-         for(Method method : businessInterface.getMethods())
-         {
-            if(isCallable(method, businessMethod))
-               return true;
-         }
-      }
-      return false;
-   }
-   
-   /**
-    * Can method definition method be used to call method other.
-    * For example if the method is defined in an interface it can be used to call a method
-    * in a class.
-    * 
-    * @param method
-    * @param other
-    * @return
-    */
-   private static boolean isCallable(Method method, Method other)
-   {
-      if ((method.getDeclaringClass().isAssignableFrom(other.getDeclaringClass())) && (method.getName().equals(other.getName())))
-      {
-         if (!method.getReturnType().equals(other.getReturnType()))
-            return false;
-         Class<?>[] params1 = method.getParameterTypes();
-         Class<?>[] params2 = other.getParameterTypes();
-         if (params1.length == params2.length)
-         {
-            for (int i = 0; i < params1.length; i++)
-            {
-               if (params1[i] != params2[i])
-                  return false;
-            }
-            return true;
-         }
-      }
-      return false;
-   }   
-   
-   /**
-    * introspects EJB container to find all dependencies
-    * and initialize any extra metadata.
-    * <p/>
-    * This must be called before container is registered with any microcontainer
-    *
-    * @param dependencyPolicy
-    */
-   public void processMetadata()
-   {
-      // XML must be done first so that any annotation overrides are initialized
-      
-      // todo injection handlers should be pluggable from XML
-      Collection<InjectionHandler<Environment>> handlers = this.deployment.getHandlers();
-      if(handlers == null)
-      {
-         handlers = new ArrayList<InjectionHandler<Environment>>();
-         handlers.add(new EJBHandler<Environment>());
-         handlers.add(new DependsHandler<Environment>());
-         handlers.add(new JndiInjectHandler<Environment>());
-         handlers.add(new PersistenceContextHandler<Environment>());
-         handlers.add(new PersistenceUnitHandler<Environment>());
-         handlers.add(new ResourceHandler<Environment>());
-         handlers.add(new WebServiceRefHandler<Environment>());
-      }
-
-      ClassLoader old = Thread.currentThread().getContextClassLoader();
-      Thread.currentThread().setContextClassLoader(classloader);
-      try
-      {
-         // EJB container's XML must be processed before interceptor's as it may override interceptor's references
-         for (InjectionHandler<Environment> handler : handlers) handler.loadXml(xml, this);
-
-         Map<AccessibleObject, Injector> tmp = InjectionUtil.processAnnotations(this, handlers, getBeanClass());
-         injectors.addAll(tmp.values());
-
-         /*
-         initialiseInterceptors();
-         */
-         for (Class<?> interceptorClass : beanContainer.getInterceptorClasses())
-         {
-            InterceptorMetaData interceptorMetaData = findInterceptor(interceptorClass);
-            if(interceptorMetaData == null)
-               continue;
-            
-            for (InjectionHandler<Environment> handler : handlers)
-            {
-               handler.loadXml(interceptorMetaData, this);
-            }
-         }
-         for (Class<?> interceptorClass : beanContainer.getInterceptorClasses())
-         {
-            Map<AccessibleObject, Injector> injections = InjectionUtil.processAnnotations(this, handlers, interceptorClass);
-            InterceptorInjector injector = new InterceptorInjector(injections);
-            interceptorInjectors.put(interceptorClass, injector);
-         }
-
-         // When @WebServiceRef is not used service-ref won't be processed
-         // In this case we process them late
-         if(xml != null && xml.getServiceReferences() != null)
-         {
-            for(ServiceReferenceMetaData sref : xml.getServiceReferences())
-            {
-               // FIXME: fix WS metadata
-               /*
-               if(!sref.isProcessed())
-               {
-                  try
-                  {
-                     String name = sref.getServiceRefName();
-                     String encName = "env/" + name;
-                     Context encCtx = getEnc();
-
-                     UnifiedVirtualFile vfsRoot = new VirtualFileAdaptor(getRootFile());
-                     new ServiceRefDelegate().bindServiceRef(encCtx, encName, vfsRoot, getClassloader(), sref);
-
-                  }
-                  catch (Exception e)
-                  {
-                     log.error("Failed to bind service-ref", e);
-                  }
-               }
-               */
-            }
-         }
-         
-         // EJBTHREE-1025
-         this.checkForDuplicateLocalAndRemoteInterfaces();
-         
-         for(Class<?> businessInterface : getBusinessInterfaces())
-            ((JBoss5DependencyPolicy) getDependencyPolicy()).addSupply(businessInterface);
-         
-         Class localHomeInterface = ProxyFactoryHelper.getLocalHomeInterface(this);
-         if(localHomeInterface != null)
-            ((JBoss5DependencyPolicy) getDependencyPolicy()).addSupply(localHomeInterface);
-         
-         Class remoteHomeInterface = ProxyFactoryHelper.getRemoteHomeInterface(this);
-         if(remoteHomeInterface != null)
-            ((JBoss5DependencyPolicy) getDependencyPolicy()).addSupply(remoteHomeInterface);
-      }
-      finally
-      {
-         Thread.currentThread().setContextClassLoader(old);
-      }
-   }
-   
-   /**
-    * Ensures that the bean does not implement any one interface as both @Local and @Remote
-    *
-    * @throws EJBException If the bean does implements any one interface as both @Local and @Remote
-    */
-   protected void checkForDuplicateLocalAndRemoteInterfaces() throws EJBException
-   {
-      // Initialize issue used in Error Message
-      String issue = "(EJBTHREE-1025)";
-
-      // Obtain annotations, if found
-      Local local = (Local) resolveAnnotation(Local.class);
-      Remote remote = (Remote) resolveAnnotation(Remote.class);
-
-      // If either local or remote is unspecified, return safely - there can be no overlap
-      if (local == null || remote == null)
-      {
-         return;
-      }
-
-      // Ensure "value" attribute of both local and remote are not blank
-      if (local.value().length < 1 && local.value().length < 1)
-      {
-         throw new EJBException("Cannot designate both " + Local.class.getName() + " and " + Remote.class.getName()
-               + " annotations without 'value' attribute on " + this.getEjbName() + ". " + issue);
-      }
-
-      // Iterate through local and remote interfaces, ensuring any one interface is not being used for both local and remote exposure
-      for (Class<?> localClass : local.value())
-      {
-         for (Class<?> remoteClass : remote.value())
-         {
-            if (localClass.equals(remoteClass))
-            {
-               throw new EJBException("Cannot designate " + localClass.getName() + " as both " + Local.class.getName()
-                     + " and " + Remote.class.getName() + " on " + this.getEjbName() + ". " + issue);
-            }
-         }
-      }
-   }
-
-   public JBossEnterpriseBeanMetaData getXml()
-   {
-      return xml;
-   }
-
-   public JBossAssemblyDescriptorMetaData getAssemblyDescriptor()
-   {
-      return assembly;
-   }
-
-   // FIXME: remove
-   @Deprecated
-   public void setAssemblyDescriptor(JBossAssemblyDescriptorMetaData assembly)
-   {
-      this.assembly = assembly;
-   }
-
-   protected abstract List<Class<?>> resolveBusinessInterfaces();
-   
-   public InterceptorInfoRepository getInterceptorRepository()
-   {
-      throw new RuntimeException("invalid");
-   }
-   
-   public Map<String, EncInjector> getEncInjectors()
-   {
-      return encInjectors;
-   }
-
-   public ClassLoader getClassloader()
-   {
-      return classloader;
-   }
-
-   public InitialContext getInitialContext()
-   {
-      try
-      {
-         return InitialContextFactory.getInitialContext(initialContextProperties);
-      }
-      catch (NamingException e)
-      {
-         throw new RuntimeException(e);
-      }
-   }
-
-   public Map<String, Map<AccessibleObject, Injector>> getEncInjections()
-   {
-      return encInjections;
-   }
-
-   public Context getEnc()
-   {
-      if (enc == null)
-      {
-         enc = encFactory.getEnc(this);
-      }
-      return enc;
-   }
-
-   public Hashtable getInitialContextProperties()
-   {
-      return initialContextProperties;
-   }
-
-   public ObjectName getObjectName()
-   {
-      return objectName;
-   }
-
-   public String getEjbName()
-   {
-      return ejbName;
-   }
-
-   public String getBeanClassName()
-   {
-      return beanClassName;
-   }
-
-   public Class<?> getBeanClass()
-   {
-      return beanClass;
-   }
-
-   public Pool getPool()
-   {
-      return pool;
-   }
-   
-   /**
-    * Gets the name of the cluster partition with which this container is
-    * associated. Not available until <code>EJBContainer.start()</code>
-    * is completed.
-    * 
-    * @return the name of the cluster partition with which this container is
-    *         associated, or <code>null</code> if the container is not clustered
-    */
-   public String getPartitionName()
-   {
-      if (partitionName == null)
-         this.findPartitionName();
-      return partitionName;
-   }
-
-   protected Object construct()
-   {
-      /*
-      try
-      {
-         return beanContainer.construct();
-      }
-      catch (SecurityException e)
-      {
-         throw new RuntimeException(e);
-      }
-      catch (NoSuchMethodException e)
-      {
-         throw new RuntimeException(e);
-      }
-      */
-      try
-      {
-         return beanClass.newInstance();
-      }
-      catch (InstantiationException e)
-      {
-         throw new RuntimeException(e);
-      }
-      catch (IllegalAccessException e)
-      {
-         throw new RuntimeException(e);
-      }
-   }
-   
-   protected void reinitialize()
-   {
-      // FIXME: is this correct?
-      beanContainer.reinitializeAdvisor();
-      
-      /*
-      initClassMetaDataBindingsList();
-      adviceBindings.clear();
-      doesHaveAspects = false;
-      constructorInfos = null;
-      rebuildInterceptors();
-      */
-      
-      bindEJBContext();
-      
-      reinitialize = false;
-   }
-
-   public void create() throws Exception
-   {
-      // Lock until start()
-      this.getContainerLock().lock();
-      /*
-      initializeClassContainer();
-      for (int i = 0; i < constructors.length; i++)
-      {
-         if (constructors[i].getParameterTypes().length == 0)
-         {
-            defaultConstructorIndex = i;
-            break;
-         }
-      }
-      */
-   }
-
-   public final void start() throws Exception
-   {
-      this.lockedStart();
-      
-      this.getContainerLock().unlock();
-   }
-   
-   // Everything must be done in start to make sure all dependencies have been satisfied
-   protected void lockedStart() throws Exception
-   {
-      if (reinitialize)
-         reinitialize();
-       
-      initializePool();
-
-      for (EncInjector injector : encInjectors.values())
-      {
-         injector.inject(this);   
-      }
-      
-      // creating of injector array should come after injection into ENC as an ENC injector
-      // may add additional injectors into the injector list.  An example is an extended persistence
-      // context which mush be created and added to the SFSB bean context.
-
-      Injector[] injectors2 = injectors.toArray(new Injector[injectors.size()]);
-      if (pool != null) pool.setInjectors(injectors2);
-
-//      createCallbackHandler();
-      
-      // If we're clustered, find our partition name
-      findPartitionName();
-      
-      log.info("STARTED EJB: " + beanClass.getName() + " ejbName: " + ejbName);
-   }
-
-   public final void stop() throws Exception
-   {
-      this.getContainerLock().lockInterruptibly();
-      
-      this.lockedStop();
-   }
-   
-   protected void lockedStop() throws Exception
-   {
-      reinitialize = true;
-      
-      //encFactory.cleanupEnc(this);
-      
-      if (pool != null)
-      {
-         pool.destroy();
-         pool = null;
-      }
-      
-      injectors = new ArrayList<Injector>();
-      encInjectors = new HashMap<String, EncInjector>();
-      
-      InitialContextFactory.close(enc, this.initialContextProperties);
-      enc = null; 
-      
-      log.info("STOPPED EJB: " + beanClass.getName() + " ejbName: " + ejbName);
-   }
-
-   public void destroy() throws Exception
-   {
-      encFactory.cleanupEnc(this);
-      
-      // TODO: clean up BeanContainer?
-      //super.cleanup();
-   }
-
-   @SuppressWarnings("unchecked")
-   public <T> T getSecurityManager(Class<T> type)
-   {
-      try
-      {
-         InitialContext ctx = getInitialContext();
-         SecurityDomain securityAnnotation = (SecurityDomain) resolveAnnotation(SecurityDomain.class);
-         if (securityAnnotation != null && securityAnnotation.value().length() > 0)
-         {
-            return (T) SecurityDomainManager.getSecurityManager(securityAnnotation.value(),ctx);
-         }
-         return null;
-      }
-      catch (NamingException e)
-      {
-         throw new RuntimeException(e);
-      }
-   }
-   
-   protected Method getTimeoutCallback(NamedMethodMetaData timeoutMethodMetaData, Class<?> beanClass)
-   {
-      JBossEnterpriseBeanMetaData metaData = xml;
-      if(metaData != null)
-      {
-         if(timeoutMethodMetaData != null)
-         {
-            String methodName = timeoutMethodMetaData.getMethodName();
-            try
-            {
-               return beanClass.getMethod(methodName, Timer.class);
-            }
-            catch (SecurityException e)
-            {
-               throw new RuntimeException(e);
-            }
-            catch (NoSuchMethodException e)
-            {
-               throw new RuntimeException("No method " + methodName + "(javax.ejb.Timer timer) found on bean " + ejbName, e);
-            }
-         }
-      }
-      
-      if(TimedObject.class.isAssignableFrom(beanClass))
-      {
-         try
-         {
-            return TimedObject.class.getMethod("ejbTimeout", Timer.class);
-         }
-         catch (SecurityException e)
-         {
-            throw new RuntimeException(e);
-         }
-         catch (NoSuchMethodException e)
-         {
-            throw new RuntimeException(e);
-         }
-      }
-      
-      if(metaData != null)
-      {  
-         // TODO: cross cutting concern
-         if(metaData.getEjbJarMetaData().isMetadataComplete())
-            return null;
-      }
-      
-      for (Method method : beanClass.getMethods())
-      {
-         if (getAnnotation(Timeout.class, method) != null)
-         {
-            if (Modifier.isPublic(method.getModifiers()) &&
-                  method.getReturnType().equals(Void.TYPE) &&
-                  method.getParameterTypes().length == 1 &&
-                  method.getParameterTypes()[0].equals(Timer.class))
-            {
-               // TODO: check for multiples
-               return method;
-            }
-            else
-            {
-               throw new RuntimeException("@Timeout method " + method + " must have signature: void <METHOD>(javax.ejb.Timer timer) (EJB3 18.2.2)");
-            }
-         }
-      }
-      
-      return null;
-   }
-   
-   protected void initializePool() throws Exception
-   {
-      org.jboss.ejb3.annotation.Pool poolAnnotation = getAnnotation(org.jboss.ejb3.annotation.Pool.class);
-      if (poolAnnotation == null)
-         throw new IllegalStateException("No pool annotation");
-      String registeredPoolName = poolAnnotation.value();
-      // EJBTHREE-1119
-      if(registeredPoolName==null||registeredPoolName.trim().equals(""))
-      {
-         // Default the Pool Implementation
-         registeredPoolName = PoolDefaults.POOL_IMPLEMENTATION_THREADLOCAL;
-      }
-      int maxSize = poolAnnotation.maxSize();
-      long timeout = poolAnnotation.timeout();
-      PoolFactoryRegistry registry = deployment.getPoolFactoryRegistry();
-      PoolFactory factory = registry.getPoolFactory(registeredPoolName);
-      pool = factory.createPool();
-      pool.initialize(this, maxSize, timeout);
-
-      resolveInjectors();
-      pool.setInjectors(injectors.toArray(new Injector[injectors.size()]));
-   }
-
-   /**
-    * Note that this method is a WIP.
-    * 
-    * @param beanContext
-    * @param callbackAnnotationClass    on of PostConstruct, PreDestroy, PostActivate or PrePassivate
-    */
-   protected void invokeCallback(BeanContext<?> beanContext, Class<? extends Annotation> callbackAnnotationClass)
-   {
-      try
-      {
-         // Do lifecycle callbacks
-         List<Class<?>> lifecycleInterceptorClasses = beanContainer.getInterceptorRegistry().getLifecycleInterceptorClasses();
-         Advisor advisor = getAdvisor();
-         Interceptor interceptors[] = LifecycleCallbacks.createLifecycleCallbackInterceptors(advisor, lifecycleInterceptorClasses, beanContext, callbackAnnotationClass);
-         
-         Constructor<?> constructor = beanClass.getConstructor();
-         Object initargs[] = null;
-         ConstructionInvocation invocation = new ConstructionInvocation(interceptors, constructor, initargs);
-         invocation.setAdvisor(advisor);
-         invocation.setTargetObject(beanContext.getInstance());
-         invocation.invokeNext();
-      }
-      catch(Throwable t)
-      {
-         throw new RuntimeException(t);
-      }
-   }
-   
-   public void invokePostConstruct(BeanContext<?> beanContext)
-   {
-      // FIXME: This is a dirty hack to notify AS EJBTimerService about what's going on
-      AllowedOperationsAssociation.pushInMethodFlag(AllowedOperationsAssociation.IN_EJB_CREATE);
-      try
-      {
-         invokeCallback(beanContext, PostConstruct.class);
-      }
-      finally
-      {
-         AllowedOperationsAssociation.popInMethodFlag();
-      }
-   }
-
-   @Deprecated
-   public void invokePostConstruct(BeanContext beanContext, Object[] params)
-   {
-      invokePostConstruct(beanContext);
-   }
-
-   public void invokePreDestroy(BeanContext beanContext)
-   {
-      // This is the correct way to destroy an instance, do
-      // not call invokeCallback here.
-      beanContainer.destroy(beanContext);
-   }
-
-   public void invokePostActivate(BeanContext beanContext)
-   {
-      throw new RuntimeException("PostActivate not implemented for container");
-   }
-
-   public void invokePrePassivate(BeanContext beanContext)
-   {
-      throw new RuntimeException("PrePassivate not implemented for container");
-   }
-
-   public void invokeInit(Object bean, Class[] initParameterTypes,
-                          Object[] initParameterValues)
-   {
-      // do nothing, only useful on a stateful session bean
-   }
-
-   public static final String MANAGED_ENTITY_MANAGER_FACTORY = "ManagedEntityManagerFactory";
-
-   public static final String ENTITY_MANAGER_FACTORY = "EntityManagerFactory";
-
-   protected void resolveInjectors() throws Exception
-   {
-      pushEnc();
-      try
-      {
-         Thread.currentThread().setContextClassLoader(classloader);
-         try
-         {
-            Util.rebind(getEnc(), "UserTransaction", new UserTransactionImpl());
-         }
-         catch (NamingException e)
-         {
-            NamingException namingException = new NamingException("Could not bind user transaction for ejb name " + ejbName + " into JNDI under jndiName: " + getEnc().getNameInNamespace() + "/" + "UserTransaction");
-            namingException.setRootCause(e);
-            throw namingException;
-         }
-         try
-         {
-            Util.rebind(getEnc(), "TransactionSynchronizationRegistry", new LinkRef("java:TransactionSynchronizationRegistry"));
-            log.debug("Linked java:comp/TransactionSynchronizationRegistry to JNDI name: java:TransactionSynchronizationRegistry");
-         }
-         catch (NamingException e)
-         {
-            NamingException namingException = new NamingException("Could not bind TransactionSynchronizationRegistry for ejb name " + ejbName + " into JNDI under jndiName: " + getEnc().getNameInNamespace() + "/" + "TransactionSynchronizationRegistry");
-            namingException.setRootCause(e);
-            throw namingException;
-         }
-      }
-      finally
-      {
-         popEnc();
-      }
-   }
-
-   /*
-   protected void createCallbackHandler()
-   {
-      try
-      {
-         callbackHandler = new LifecycleInterceptorHandler(this,
-                 getHandledCallbacks());
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException("Error creating callback handler for bean "
-                 + beanClassName, e);
-      }
-   }
-   */
-
-   protected Class[] getHandledCallbacks()
-   {
-      return new Class[]
-              {PostConstruct.class, PreDestroy.class, Timeout.class};
-   }
-
-   // TODO: once injection is finalized this method will disappear
-   private InterceptorMetaData findInterceptor(Class<?> interceptorClass)
-   {
-      if(xml == null)
-         return null;
-      JBossMetaData ejbJarMetaData = xml.getEjbJarMetaData();
-      if(ejbJarMetaData == null)
-         return null;
-      InterceptorsMetaData interceptors = ejbJarMetaData.getInterceptors();
-      if(interceptors == null)
-         return null;
-      for(InterceptorMetaData interceptorMetaData : interceptors)
-      {
-         if(interceptorMetaData.getInterceptorClass().equals(interceptorClass.getName()))
-            return interceptorMetaData;
-      }
-      return null;
-   }
-   
-   protected void findPartitionName()
-   {
-      Clustered clustered = (Clustered) getAnnotation(Clustered.class);
-      if (clustered == null)
-      {
-         partitionName = null;
-         return;
-      }
-      
-      String value = clustered.partition();
-      try
-      {
-         String replacedValue = StringPropertyReplacer.replaceProperties(value);
-         if (value != replacedValue)
-         {            
-            log.debug("Replacing @Clustered partition attribute " + value + " with " + replacedValue);
-            value = replacedValue;
-         }
-      }
-      catch (Exception e)
-      {
-         log.warn("Unable to replace @Clustered partition attribute " + value + 
-                  ". Caused by " + e.getClass() + " " + e.getMessage());         
-      }
-      
-      partitionName = value;
-   }
-
-   public <T> T getBusinessObject(BeanContext<?> beanContext, Class<T> businessInterface) throws IllegalStateException
-   {
-      throw new IllegalStateException("Not implemented");
-   }
-
-   public Object getInvokedBusinessInterface(BeanContext beanContext) throws IllegalStateException
-   {
-      throw new IllegalStateException("Not implemented");
-   }
-
-   protected Object getInvokedInterface(Method method)
-   {
-      Remote remoteAnnotation = (Remote) resolveAnnotation(Remote.class);
-      if (remoteAnnotation != null)
-      {
-         Class[] remotes = remoteAnnotation.value();
-         for (int i = 0; i < remotes.length; ++i)
-         {
-            try
-            {
-               remotes[i].getMethod(method.getName(), method.getParameterTypes());
-               return remotes[i];
-            }
-            catch (NoSuchMethodException e)
-            {
-            }
-         }
-      }
-
-      Local localAnnotation = (Local) resolveAnnotation(Local.class);
-      if (localAnnotation != null)
-      {
-         Class[] locals = localAnnotation.value();
-         for (int i = 0; i < locals.length; ++i)
-         {
-            Method[] interfaceMethods = locals[i].getMethods();
-            for (int j = 0; j < interfaceMethods.length; ++j)
-            {
-               if (interfaceMethods[j].equals(method))
-                  return locals[i];
-            }
-         }
-      }
-
-      return null;
-   }
-
-   // todo these method overrides for aop are for performance reasons
-   private Class loadPublicAnnotation(String annotation)
-   {
-      try
-      {
-         Class ann = classloader.loadClass(annotation);
-         if (!ann.isAnnotation()) return null;
-         Retention retention = (Retention) ann.getAnnotation(Retention.class);
-         if (retention != null && retention.value() == RetentionPolicy.RUNTIME) return ann;
-
-      }
-      catch (ClassNotFoundException ignored)
-      {
-      }
-      return null;
-   }
-
-   /*
-   @Override
-   public boolean hasAnnotation(Class tgt, String annotation)
-   {
-      if (annotations.hasClassAnnotation(annotation)) return true;
-      if (tgt == null) return false;
-      try
-      {
-         Class ann = loadPublicAnnotation(annotation);
-         // it is metadata or CLASS annotation
-         if (ann == null) return AnnotationElement.isAnyAnnotationPresent(tgt, annotation);
-         return tgt.isAnnotationPresent(ann);
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException(e);  //To change body of catch statement use Options | File Templates.
-      }
-   }
-
-
-   @Override
-   public boolean hasAnnotation(Method m, String annotation)
-   {
-      if (annotations.hasAnnotation(m, annotation)) return true;
-      try
-      {
-         Class ann = loadPublicAnnotation(annotation);
-         // it is metadata or CLASS annotation
-         if (ann == null) return AnnotationElement.isAnyAnnotationPresent(m, annotation);
-         return m.isAnnotationPresent(ann);
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException(e);  //To change body of catch statement use Options | File Templates.
-      }
-   }
-
-   @Override
-   public boolean hasAnnotation(Field m, String annotation)
-   {
-      if (annotations.hasAnnotation(m, annotation)) return true;
-      try
-      {
-         Class ann = loadPublicAnnotation(annotation);
-         // it is metadata or CLASS annotation
-         if (ann == null) return AnnotationElement.isAnyAnnotationPresent(m, annotation);
-         return m.isAnnotationPresent(ann);
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException(e);  //To change body of catch statement use Options | File Templates.
-      }
-   }
-
-   @Override
-   public boolean hasAnnotation(Constructor m, String annotation)
-   {
-      if (annotations.hasAnnotation(m, annotation)) return true;
-      try
-      {
-         Class ann = loadPublicAnnotation(annotation);
-         // it is metadata or CLASS annotation
-         if (ann == null) return AnnotationElement.isAnyAnnotationPresent(m, annotation);
-         return m.isAnnotationPresent(ann);
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException(e);  //To change body of catch statement use Options | File Templates.
-      }
-   }
-   */
-   
-   public Container resolveEjbContainer(String link, Class businessIntf)
-   {
-      return deployment.getEjbContainer(link, businessIntf);
-   }
-
-   public Container resolveEjbContainer(Class businessIntf) throws NameNotFoundException
-   {
-      return deployment.getEjbContainer(businessIntf);
-   }
-
-   public String resolveMessageDestination(String link)
-   {
-      return deployment.resolveMessageDestination(link);
-   }
-   
-   public String resolvePersistenceUnitSupplier(String unitName)
-   {
-      return getDeployment().resolvePersistenceUnitSupplier(unitName);
-   }
-   
-   public <T extends Annotation> T getAnnotation(Class<T> annotationType)
-   {
-      if (this.getAnnotations().isDisabled(annotationType))
-         return null;
-      
-      return beanContainer.getAnnotation(annotationType);
-   }
-   
-   public <T extends Annotation> T getAnnotation(Class<T> annotationType, Class<?> clazz)
-   {
-      return beanContainer.getAnnotation(clazz, annotationType);
-   }
-
-   public <T extends Annotation> T getAnnotation(Class<T> annotationType, Class<?> clazz, Method method)
-   {
-      return beanContainer.getAnnotation(annotationType, clazz, method);
-   }
-   
-   public <T extends Annotation> T getAnnotation(Class<T> annotationType, Method method)
-   {
-      if (this.getAnnotations().isDisabled(method, annotationType))
-         return null;
-      
-      return beanContainer.getAnnotation(annotationType, method);
-   }
-
-   public <T extends Annotation> T getAnnotation(Class<T> annotationType, Class<?> clazz, Field field)
-   {
-      return beanContainer.getAnnotation(annotationType, clazz, field);
-   }
-   
-   public <T extends Annotation> T getAnnotation(Class<T> annotationType, Field field)
-   {
-      return beanContainer.getAnnotation(annotationType, field);
-   }
-   
-   /**
-    * @deprecated use getAnnotation
-    */
-   @SuppressWarnings("unchecked")
-   public Object resolveAnnotation(Class annotationType)
-   {
-      return getAnnotation(annotationType);
-   }
-   
-   /**
-    * @deprecated use getAnnotation
-    */
-   @SuppressWarnings("unchecked")
-   public Object resolveAnnotation(Field field, Class annotationType)
-   {
-      return getAnnotation(annotationType, field);
-   }
-   
-   /**
-    * @deprecated use getAnnotation
-    */
-   @SuppressWarnings("unchecked")
-   public Object resolveAnnotation(Method method, Class annotationType)
-   {
-      return getAnnotation(annotationType, method);
-   }
-   
-   /**
-    * @deprecated this is going to be gone soon
-    */
-   @SuppressWarnings("unchecked")
-   public Object resolveAnnotation(Method m, Class[] annotationChoices)
-   {
-      Object value = null;
-      int i = 0;
-      while (value == null && i < annotationChoices.length){
-         value = resolveAnnotation(m, annotationChoices[i++]);
-      }
-      
-      return value;
-   }
-
-   public String getIdentifier()
-   {
-      return getEjbName();
-   }
-
-   public String getDeploymentDescriptorType()
-   {
-      return "ejb-jar.xml";
-   }
-
-   public PersistenceUnitDeployment getPersistenceUnitDeployment(String unitName) throws NameNotFoundException
-   {
-      return deployment.getPersistenceUnitDeployment(unitName);
-   }
-
-   public String getEjbJndiName(Class businessInterface) throws NameNotFoundException
-   {
-      return deployment.getEjbJndiName(businessInterface);
-   }
-
-   public String getEjbJndiName(String link, Class businessInterface)
-   {
-      return deployment.getEjbJndiName(link, businessInterface);
-   }
-   
-   public InvocationStatistics getInvokeStats()
-   {
-      return invokeStats;
-   }
-
-   @Deprecated
-   protected MethodInfo getMethodInfo(Method method)
-   {
-      long hash = MethodHashing.calculateHash(method);
-      MethodInfo info = getAdvisor().getMethodInfo(hash);
-      if (info == null)
-      {
-         throw new RuntimeException("Could not resolve beanClass method from proxy call: " + method.toString());
-      }
-      return info;
-   }
-   
-   public boolean isClustered()
-   {
-      return false;
-   }
-   
-   public JavaEEModule getModule()
-   {
-      return deployment;
-   }
-   
-   public abstract boolean hasJNDIBinding(String jndiName);
-   
-   /**
-    * After XML processing has been done this allows the container
-    * to further initialize the meta data.
-    */
-   public void instantiated()
-   {
-      this.businessInterfaces = resolveBusinessInterfaces();
-      
-      // Before we start to process annotations, make sure we also have the ones from interceptors-aop.
-      // FIXME: because of the flaked life cycle of an EJBContainer (we add annotations after it's been
-      // constructed), we must reinitialize the whole thing. 
-      beanContainer.reinitializeAdvisor();
-   }
-   
-   public void setDirectContainer(DirectContainer<EJBContainer> container)
-   {
-      this.directContainer = container;
-   }
-   
-   protected Method getNonBridgeMethod(Method bridgeMethod)
-   {
-      Class clazz = bridgeMethod.getDeclaringClass();
-      Method[] methods = clazz.getMethods();
-      for (Method method : methods)
-      {
-         if (!method.isBridge() && method.getParameterTypes().length == bridgeMethod.getParameterTypes().length)
-         {
-            return method;
-         }
-      }
-      
-      return bridgeMethod;
-   }
-   
-   public Lock getInvocationLock()
-   {
-      return this.containerLock.readLock();
-   }
-   
-   private Lock getContainerLock()
-   {
-      return this.containerLock.writeLock();
-   }
-   
-   public String toString()
-   {
-      return getObjectName().getCanonicalName();
-   }
-}

Copied: projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/java/org/jboss/ejb3/EJBContainer.java (from rev 77399, projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java)
===================================================================
--- projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/java/org/jboss/ejb3/EJBContainer.java	                        (rev 0)
+++ projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/java/org/jboss/ejb3/EJBContainer.java	2008-08-25 05:28:04 UTC (rev 77405)
@@ -0,0 +1,1548 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.ejb.EJBContext;
+import javax.ejb.EJBException;
+import javax.ejb.Local;
+import javax.ejb.Remote;
+import javax.ejb.TimedObject;
+import javax.ejb.Timeout;
+import javax.ejb.Timer;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.LinkRef;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.naming.StringRefAddr;
+
+import org.jboss.aop.Advisor;
+import org.jboss.aop.Domain;
+import org.jboss.aop.MethodInfo;
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.annotation.AnnotationRepository;
+import org.jboss.aop.joinpoint.ConstructionInvocation;
+import org.jboss.aop.util.MethodHashing;
+import org.jboss.ejb.AllowedOperationsAssociation;
+import org.jboss.ejb3.annotation.Clustered;
+import org.jboss.ejb3.annotation.SecurityDomain;
+import org.jboss.ejb3.annotation.defaults.PoolDefaults;
+import org.jboss.ejb3.aop.BeanContainer;
+import org.jboss.ejb3.deployers.JBoss5DependencyPolicy;
+import org.jboss.ejb3.entity.PersistenceUnitDeployment;
+import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
+import org.jboss.ejb3.interceptor.InterceptorInjector;
+import org.jboss.ejb3.interceptors.aop.LifecycleCallbacks;
+import org.jboss.ejb3.interceptors.container.ManagedObjectAdvisor;
+import org.jboss.ejb3.interceptors.direct.DirectContainer;
+import org.jboss.ejb3.interceptors.direct.IndirectContainer;
+import org.jboss.ejb3.javaee.JavaEEComponent;
+import org.jboss.ejb3.javaee.JavaEEComponentHelper;
+import org.jboss.ejb3.javaee.JavaEEModule;
+import org.jboss.ejb3.pool.Pool;
+import org.jboss.ejb3.pool.PoolFactory;
+import org.jboss.ejb3.pool.PoolFactoryRegistry;
+import org.jboss.ejb3.proxy.container.InvokableContext;
+import org.jboss.ejb3.proxy.factory.ProxyFactoryHelper;
+import org.jboss.ejb3.security.SecurityDomainManager;
+import org.jboss.ejb3.statistics.InvocationStatistics;
+import org.jboss.ejb3.tx.UserTransactionImpl;
+import org.jboss.injection.DependsHandler;
+import org.jboss.injection.EJBHandler;
+import org.jboss.injection.EncInjector;
+import org.jboss.injection.ExtendedInjectionContainer;
+import org.jboss.injection.InjectionHandler;
+import org.jboss.injection.InjectionUtil;
+import org.jboss.injection.Injector;
+import org.jboss.injection.JndiInjectHandler;
+import org.jboss.injection.PersistenceContextHandler;
+import org.jboss.injection.PersistenceUnitHandler;
+import org.jboss.injection.ResourceHandler;
+import org.jboss.injection.WebServiceRefHandler;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossAssemblyDescriptorMetaData;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.spec.InterceptorMetaData;
+import org.jboss.metadata.ejb.spec.InterceptorsMetaData;
+import org.jboss.metadata.ejb.spec.NamedMethodMetaData;
+import org.jboss.metadata.javaee.spec.Environment;
+import org.jboss.metadata.javaee.spec.ServiceReferenceMetaData;
+import org.jboss.util.StringPropertyReplacer;
+import org.jboss.util.naming.Util;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision$
+ */
+public abstract class EJBContainer implements Container, IndirectContainer<EJBContainer, DirectContainer<EJBContainer>>, ExtendedInjectionContainer, JavaEEComponent
+{
+   private static final Logger log = Logger.getLogger(EJBContainer.class);
+
+   private String name;
+   
+   private BeanContainer beanContainer;
+   
+   private DirectContainer<EJBContainer> directContainer;
+   
+   protected EjbEncFactory encFactory = new DefaultEjbEncFactory();
+
+   protected Pool pool;
+
+   protected String ejbName;
+
+   protected ObjectName objectName;
+
+   protected int defaultConstructorIndex;
+
+   protected String beanClassName;
+   
+   private Class<?> beanClass;
+
+   protected ClassLoader classloader;
+
+   // for performance there is an array.
+   protected List<Injector> injectors = new ArrayList<Injector>();
+
+   protected Context enc;
+
+//   protected LifecycleInterceptorHandler callbackHandler;
+
+   protected Hashtable initialContextProperties;
+
+   protected Map<String, EncInjector> encInjectors = new HashMap<String, EncInjector>();
+
+   protected JBossEnterpriseBeanMetaData xml;
+   protected JBossAssemblyDescriptorMetaData assembly;
+
+   protected Map<String, Map<AccessibleObject, Injector>> encInjections = new HashMap<String, Map<AccessibleObject, Injector>>();
+
+//   protected List<InterceptorInfo> classInterceptors = new ArrayList<InterceptorInfo>();
+//
+//   protected LinkedHashSet<InterceptorInfo> applicableInterceptors;
+
+   private HashMap<Class<?>, InterceptorInjector> interceptorInjectors = new HashMap<Class<?>, InterceptorInjector>();
+
+   private Ejb3Deployment deployment;
+
+   private DependencyPolicy dependencyPolicy;
+
+   private String jaccContextId;
+
+   protected InvocationStatistics invokeStats = new InvocationStatistics();
+   
+   private String partitionName;
+   
+   private List<Class<?>> businessInterfaces;
+   
+   private ThreadLocalStack<BeanContext<?>> currentBean = new ThreadLocalStack<BeanContext<?>>();
+   
+   protected boolean reinitialize = false;
+   
+   // To support clean startup/shutdown
+   private ReadWriteLock containerLock = new ReentrantReadWriteLock();
+   
+   /**
+    * @param name                  Advisor name
+    * @param manager               Domain to get interceptor bindings from
+    * @param cl                    the EJB's classloader
+    * @param beanClassName
+    * @param ejbName
+    * @param ctxProperties
+    * @param interceptorRepository
+    * @param deployment
+    * @param beanMetaData           the meta data for this bean or null
+    */
+
+   public EJBContainer(String name, Domain domain, ClassLoader cl,
+                       String beanClassName, String ejbName, Hashtable ctxProperties,
+                       Ejb3Deployment deployment, JBossEnterpriseBeanMetaData beanMetaData) throws ClassNotFoundException
+   {
+      assert name != null : "name is null";
+      assert deployment != null : "deployment is null";
+      
+      this.name = name;
+      this.deployment = deployment;
+      this.beanClassName = beanClassName;
+      this.classloader = cl;
+      this.xml = beanMetaData;
+         
+      this.beanClass = classloader.loadClass(beanClassName);
+      
+      // We can't type cast the direct container, because we just loaded the beanClass
+      // so assuming we have an object is a safe bet.
+      this.beanContainer = new BeanContainer(this);
+      
+      this.ejbName = ejbName;
+      
+      String on = createObjectName(ejbName);     
+      try
+      {
+         objectName = new ObjectName(on);
+      }
+      catch (MalformedObjectNameException e)
+      {
+         throw new RuntimeException("failed to create object name for: " + on, e);
+      }
+      
+      // Because interceptors will query back the EJBContainer for annotations
+      // we must have set beanContainer first and then do the advisor. 
+      try
+      {
+         beanContainer.initialize(ejbName, domain, beanClass, beanMetaData, cl);
+      }
+      catch(Exception e)
+      {
+         throw new RuntimeException("failed to initialize bean container ",e);
+      }
+      
+      //annotations = new AnnotationRepositoryToMetaData(this);
+      
+      initialContextProperties = ctxProperties;
+      try
+      {
+         Util.createSubcontext(getEnc(), "env");
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException(e);
+      }
+      bindORB();
+      bindEJBContext();
+      
+      this.dependencyPolicy = deployment.createDependencyPolicy(this);
+   }
+
+   private void bindEJBContext()
+   {
+      try 
+      {
+         Reference ref = new Reference(EJBContext.class.getName(), EJBContextFactory.class.getName(), null);
+         ref.add(new StringRefAddr("containerGuid", Ejb3Registry.guid(this)));
+         ref.add(new StringRefAddr("containerClusterUid", Ejb3Registry.clusterUid(this)));
+         ref.add(new StringRefAddr("isClustered", Boolean.toString(isClustered())));
+         Util.rebind(getEnc(), "EJBContext", ref);
+      }
+      catch (NamingException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+   
+   private void bindORB()
+   {
+      try
+      {
+         Util.rebind(getEnc(), "ORB", new LinkRef("java:/JBossCorbaORB"));
+      }
+      catch(NamingException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+   
+   public abstract BeanContext<?> createBeanContext();
+   
+   public String createObjectName(String ejbName)
+   {
+      return JavaEEComponentHelper.createObjectName(deployment, ejbName);
+   }
+   
+   /**
+    * Do not call, for BeanContainer.
+    * @throws IllegalAccessException 
+    * @throws InstantiationException 
+    */
+   public Object createInterceptor(Class<?> interceptorClass) throws InstantiationException, IllegalAccessException
+   {
+      Object instance = interceptorClass.newInstance();
+      InterceptorInjector interceptorInjector = interceptorInjectors.get(interceptorClass);
+      assert interceptorInjector != null : "interceptorInjector not found for " + interceptorClass;
+      interceptorInjector.inject(null, instance);
+      return instance;
+   }
+   
+   public String createObjectName(String unitName, String ejbName)
+   {
+      return JavaEEComponentHelper.createObjectName(deployment, unitName, ejbName);
+   }
+   
+   // TODO: re-evaluate this exposure
+   @Deprecated
+   public Advisor getAdvisor()
+   {
+      return beanContainer._getAdvisor();
+   }
+
+   /*
+    * TODO: re-evalute this exposure
+    */
+   @Deprecated
+   public AnnotationRepository getAnnotations()
+   {
+      return beanContainer.getAnnotationRepository();
+   }
+
+   protected BeanContainer getBeanContainer()
+   {
+      return beanContainer;
+   }
+   
+   /**
+    * 
+    * @return   the bean class of this container
+    * @deprecated   use getBeanClass
+    */
+   public Class<?> getClazz()
+   {
+      return getBeanClass();
+   }
+   
+   @SuppressWarnings("unchecked")
+   public static <C extends EJBContainer> C getEJBContainer(Advisor advisor)
+   {
+      try
+      {
+         return (C) ((ManagedObjectAdvisor<Object, BeanContainer>) advisor).getContainer().getEJBContainer();
+      }
+      catch(ClassCastException e)
+      {
+         throw new ClassCastException(e.getMessage() + " using " + advisor);
+      }
+   }
+   
+   public String getName()
+   {
+      return name;
+   }
+   
+   public void pushContext(BeanContext<?> beanContext)
+   {
+      currentBean.push(beanContext);
+   }
+   
+   /**
+    * Makes sure that EJB's ENC is available
+    * Delegates to whatever implementation is used to push the ENC of the EJB
+    * onto the stack
+    *
+    */
+   protected void pushEnc()
+   {
+      encFactory.pushEnc(this);
+   }
+
+   public BeanContext<?> peekContext()
+   {
+      BeanContext<?> ctx = currentBean.get();
+      assert ctx != null : "ctx is null";
+      return ctx;
+   }
+   
+   public BeanContext<?> popContext()
+   {
+      return currentBean.pop();
+   }
+   
+   /**
+    * Pops EJB's ENC from the stack.  Delegates to whatever implementation
+    * is used to pop the EJB's ENC from the stock
+    *
+    */
+   protected void popEnc()
+   {
+      encFactory.popEnc(this);
+   }
+   
+   public Environment getEnvironmentRefGroup()
+   {
+      return xml;
+   }
+
+   public List<Injector> getInjectors()
+   {
+      return injectors;
+   }
+
+
+   public String getJaccContextId()
+   {
+      return jaccContextId;
+   }
+
+   /**
+    * Do not call, used by BeanContainer.
+    * @return
+    */
+   public List<Method> getVirtualMethods()
+   {
+      return null;
+   }
+   
+   public void setJaccContextId(String jaccContextId)
+   {
+      this.jaccContextId = jaccContextId;
+   }
+   
+   public VirtualFile getRootFile()
+   {
+      return getDeploymentUnit().getRootFile();
+   }
+   
+   /**
+    * Return all the business interfaces implemented by this bean.
+    * 
+    * Available after the meta data has been processed.
+    * 
+    * @return   an array of business interfaces or empty if no interface is provided
+    */
+   public List<Class<?>> getBusinessInterfaces()
+   {
+      if(businessInterfaces == null) throw new IllegalStateException("businessInterfaces not yet initialized");
+      return businessInterfaces;
+   }
+      
+   public String getDeploymentQualifiedName()
+   {
+      return objectName.getCanonicalName();
+   }
+   
+   /**
+    * Returns a String identifier for this bean that is qualified by the
+    * deployment, and hence should be unique across deployments. Name is of the 
+    * form "ear=foo.ear,jar=foo.jar,name=Bar", where "Bar" is the value 
+    * returned by {@link #getEjbName()}. The "ear=foo.ear" portion is ommitted 
+    * if the bean is not packaged in an ear.
+    */
+   public String getDeploymentPropertyListString()
+   {
+      return objectName.getCanonicalKeyPropertyListString();
+   }
+   
+   public DeploymentUnit getDeploymentUnit()
+   {
+      return deployment.getDeploymentUnit();
+   }
+
+   public Ejb3Deployment getDeployment()
+   {
+      return deployment;
+   }
+
+   public DependencyPolicy getDependencyPolicy()
+   {
+      return dependencyPolicy;
+   }
+
+   public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
+   {
+      return beanContainer.isAnnotationPresent(annotationType);
+   }
+   
+   /**
+    * Is the method a business method of this container.
+    * 
+    * @param businessMethod     the method in question
+    * @return   true if so, otherwise false
+    */
+   public boolean isBusinessMethod(Method businessMethod)
+   {
+      for(Class<?> businessInterface : getBusinessInterfaces())
+      {
+         for(Method method : businessInterface.getMethods())
+         {
+            if(isCallable(method, businessMethod))
+               return true;
+         }
+      }
+      return false;
+   }
+   
+   /**
+    * Can method definition method be used to call method other.
+    * For example if the method is defined in an interface it can be used to call a method
+    * in a class.
+    * 
+    * @param method
+    * @param other
+    * @return
+    */
+   private static boolean isCallable(Method method, Method other)
+   {
+      if ((method.getDeclaringClass().isAssignableFrom(other.getDeclaringClass())) && (method.getName().equals(other.getName())))
+      {
+         if (!method.getReturnType().equals(other.getReturnType()))
+            return false;
+         Class<?>[] params1 = method.getParameterTypes();
+         Class<?>[] params2 = other.getParameterTypes();
+         if (params1.length == params2.length)
+         {
+            for (int i = 0; i < params1.length; i++)
+            {
+               if (params1[i] != params2[i])
+                  return false;
+            }
+            return true;
+         }
+      }
+      return false;
+   }   
+   
+   /**
+    * introspects EJB container to find all dependencies
+    * and initialize any extra metadata.
+    * <p/>
+    * This must be called before container is registered with any microcontainer
+    *
+    * @param dependencyPolicy
+    */
+   public void processMetadata()
+   {
+      // XML must be done first so that any annotation overrides are initialized
+      
+      // todo injection handlers should be pluggable from XML
+      Collection<InjectionHandler<Environment>> handlers = this.deployment.getHandlers();
+      if(handlers == null)
+      {
+         handlers = new ArrayList<InjectionHandler<Environment>>();
+         handlers.add(new EJBHandler<Environment>());
+         handlers.add(new DependsHandler<Environment>());
+         handlers.add(new JndiInjectHandler<Environment>());
+         handlers.add(new PersistenceContextHandler<Environment>());
+         handlers.add(new PersistenceUnitHandler<Environment>());
+         handlers.add(new ResourceHandler<Environment>());
+         handlers.add(new WebServiceRefHandler<Environment>());
+      }
+
+      ClassLoader old = Thread.currentThread().getContextClassLoader();
+      Thread.currentThread().setContextClassLoader(classloader);
+      try
+      {
+         // EJB container's XML must be processed before interceptor's as it may override interceptor's references
+         for (InjectionHandler<Environment> handler : handlers) handler.loadXml(xml, this);
+
+         Map<AccessibleObject, Injector> tmp = InjectionUtil.processAnnotations(this, handlers, getBeanClass());
+         injectors.addAll(tmp.values());
+
+         /*
+         initialiseInterceptors();
+         */
+         for (Class<?> interceptorClass : beanContainer.getInterceptorClasses())
+         {
+            InterceptorMetaData interceptorMetaData = findInterceptor(interceptorClass);
+            if(interceptorMetaData == null)
+               continue;
+            
+            for (InjectionHandler<Environment> handler : handlers)
+            {
+               handler.loadXml(interceptorMetaData, this);
+            }
+         }
+         for (Class<?> interceptorClass : beanContainer.getInterceptorClasses())
+         {
+            Map<AccessibleObject, Injector> injections = InjectionUtil.processAnnotations(this, handlers, interceptorClass);
+            InterceptorInjector injector = new InterceptorInjector(injections);
+            interceptorInjectors.put(interceptorClass, injector);
+         }
+
+         // When @WebServiceRef is not used service-ref won't be processed
+         // In this case we process them late
+         if(xml != null && xml.getServiceReferences() != null)
+         {
+            for(ServiceReferenceMetaData sref : xml.getServiceReferences())
+            {
+               // FIXME: fix WS metadata
+               /*
+               if(!sref.isProcessed())
+               {
+                  try
+                  {
+                     String name = sref.getServiceRefName();
+                     String encName = "env/" + name;
+                     Context encCtx = getEnc();
+
+                     UnifiedVirtualFile vfsRoot = new VirtualFileAdaptor(getRootFile());
+                     new ServiceRefDelegate().bindServiceRef(encCtx, encName, vfsRoot, getClassloader(), sref);
+
+                  }
+                  catch (Exception e)
+                  {
+                     log.error("Failed to bind service-ref", e);
+                  }
+               }
+               */
+            }
+         }
+         
+         // EJBTHREE-1025
+         this.checkForDuplicateLocalAndRemoteInterfaces();
+         
+         for(Class<?> businessInterface : getBusinessInterfaces())
+            ((JBoss5DependencyPolicy) getDependencyPolicy()).addSupply(businessInterface);
+         
+         Class localHomeInterface = ProxyFactoryHelper.getLocalHomeInterface(this);
+         if(localHomeInterface != null)
+            ((JBoss5DependencyPolicy) getDependencyPolicy()).addSupply(localHomeInterface);
+         
+         Class remoteHomeInterface = ProxyFactoryHelper.getRemoteHomeInterface(this);
+         if(remoteHomeInterface != null)
+            ((JBoss5DependencyPolicy) getDependencyPolicy()).addSupply(remoteHomeInterface);
+      }
+      finally
+      {
+         Thread.currentThread().setContextClassLoader(old);
+      }
+   }
+   
+   /**
+    * Ensures that the bean does not implement any one interface as both @Local and @Remote
+    *
+    * @throws EJBException If the bean does implements any one interface as both @Local and @Remote
+    */
+   protected void checkForDuplicateLocalAndRemoteInterfaces() throws EJBException
+   {
+      // Initialize issue used in Error Message
+      String issue = "(EJBTHREE-1025)";
+
+      // Obtain annotations, if found
+      Local local = (Local) resolveAnnotation(Local.class);
+      Remote remote = (Remote) resolveAnnotation(Remote.class);
+
+      // If either local or remote is unspecified, return safely - there can be no overlap
+      if (local == null || remote == null)
+      {
+         return;
+      }
+
+      // Ensure "value" attribute of both local and remote are not blank
+      if (local.value().length < 1 && local.value().length < 1)
+      {
+         throw new EJBException("Cannot designate both " + Local.class.getName() + " and " + Remote.class.getName()
+               + " annotations without 'value' attribute on " + this.getEjbName() + ". " + issue);
+      }
+
+      // Iterate through local and remote interfaces, ensuring any one interface is not being used for both local and remote exposure
+      for (Class<?> localClass : local.value())
+      {
+         for (Class<?> remoteClass : remote.value())
+         {
+            if (localClass.equals(remoteClass))
+            {
+               throw new EJBException("Cannot designate " + localClass.getName() + " as both " + Local.class.getName()
+                     + " and " + Remote.class.getName() + " on " + this.getEjbName() + ". " + issue);
+            }
+         }
+      }
+   }
+
+   public JBossEnterpriseBeanMetaData getXml()
+   {
+      return xml;
+   }
+
+   public JBossAssemblyDescriptorMetaData getAssemblyDescriptor()
+   {
+      return assembly;
+   }
+
+   // FIXME: remove
+   @Deprecated
+   public void setAssemblyDescriptor(JBossAssemblyDescriptorMetaData assembly)
+   {
+      this.assembly = assembly;
+   }
+
+   protected abstract List<Class<?>> resolveBusinessInterfaces();
+   
+   public InterceptorInfoRepository getInterceptorRepository()
+   {
+      throw new RuntimeException("invalid");
+   }
+   
+   public Map<String, EncInjector> getEncInjectors()
+   {
+      return encInjectors;
+   }
+
+   public ClassLoader getClassloader()
+   {
+      return classloader;
+   }
+
+   public InitialContext getInitialContext()
+   {
+      try
+      {
+         return InitialContextFactory.getInitialContext(initialContextProperties);
+      }
+      catch (NamingException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+
+   public Map<String, Map<AccessibleObject, Injector>> getEncInjections()
+   {
+      return encInjections;
+   }
+
+   public Context getEnc()
+   {
+      if (enc == null)
+      {
+         enc = encFactory.getEnc(this);
+      }
+      return enc;
+   }
+
+   public Hashtable getInitialContextProperties()
+   {
+      return initialContextProperties;
+   }
+
+   public ObjectName getObjectName()
+   {
+      return objectName;
+   }
+
+   public String getEjbName()
+   {
+      return ejbName;
+   }
+
+   public String getBeanClassName()
+   {
+      return beanClassName;
+   }
+
+   public Class<?> getBeanClass()
+   {
+      return beanClass;
+   }
+
+   public Pool getPool()
+   {
+      return pool;
+   }
+   
+   /**
+    * Gets the name of the cluster partition with which this container is
+    * associated. Not available until <code>EJBContainer.start()</code>
+    * is completed.
+    * 
+    * @return the name of the cluster partition with which this container is
+    *         associated, or <code>null</code> if the container is not clustered
+    */
+   public String getPartitionName()
+   {
+      if (partitionName == null)
+         this.findPartitionName();
+      return partitionName;
+   }
+
+   protected Object construct()
+   {
+      /*
+      try
+      {
+         return beanContainer.construct();
+      }
+      catch (SecurityException e)
+      {
+         throw new RuntimeException(e);
+      }
+      catch (NoSuchMethodException e)
+      {
+         throw new RuntimeException(e);
+      }
+      */
+      try
+      {
+         return beanClass.newInstance();
+      }
+      catch (InstantiationException e)
+      {
+         throw new RuntimeException(e);
+      }
+      catch (IllegalAccessException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+   
+   protected void reinitialize()
+   {
+      // FIXME: is this correct?
+      beanContainer.reinitializeAdvisor();
+      
+      /*
+      initClassMetaDataBindingsList();
+      adviceBindings.clear();
+      doesHaveAspects = false;
+      constructorInfos = null;
+      rebuildInterceptors();
+      */
+      
+      bindEJBContext();
+      
+      reinitialize = false;
+   }
+
+   public void create() throws Exception
+   {
+      // Lock until start()
+      this.getContainerLock().lock();
+      /*
+      initializeClassContainer();
+      for (int i = 0; i < constructors.length; i++)
+      {
+         if (constructors[i].getParameterTypes().length == 0)
+         {
+            defaultConstructorIndex = i;
+            break;
+         }
+      }
+      */
+   }
+
+   public final void start() throws Exception
+   {
+      this.lockedStart();
+      
+      this.getContainerLock().unlock();
+   }
+   
+   // Everything must be done in start to make sure all dependencies have been satisfied
+   protected void lockedStart() throws Exception
+   {
+      if (reinitialize)
+         reinitialize();
+       
+      initializePool();
+
+      for (EncInjector injector : encInjectors.values())
+      {
+         injector.inject(this);   
+      }
+      
+      // creating of injector array should come after injection into ENC as an ENC injector
+      // may add additional injectors into the injector list.  An example is an extended persistence
+      // context which mush be created and added to the SFSB bean context.
+
+      Injector[] injectors2 = injectors.toArray(new Injector[injectors.size()]);
+      if (pool != null) pool.setInjectors(injectors2);
+
+//      createCallbackHandler();
+      
+      // If we're clustered, find our partition name
+      findPartitionName();
+      
+      log.info("STARTED EJB: " + beanClass.getName() + " ejbName: " + ejbName);
+   }
+
+   public final void stop() throws Exception
+   {
+      this.getContainerLock().lockInterruptibly();
+      
+      this.lockedStop();
+   }
+   
+   protected void lockedStop() throws Exception
+   {
+      reinitialize = true;
+      
+      //encFactory.cleanupEnc(this);
+      
+      if (pool != null)
+      {
+         pool.destroy();
+         pool = null;
+      }
+      
+      injectors = new ArrayList<Injector>();
+      encInjectors = new HashMap<String, EncInjector>();
+      
+      InitialContextFactory.close(enc, this.initialContextProperties);
+      enc = null; 
+      
+      log.info("STOPPED EJB: " + beanClass.getName() + " ejbName: " + ejbName);
+   }
+
+   public void destroy() throws Exception
+   {
+      encFactory.cleanupEnc(this);
+      
+      // TODO: clean up BeanContainer?
+      //super.cleanup();
+   }
+
+   @SuppressWarnings("unchecked")
+   public <T> T getSecurityManager(Class<T> type)
+   {
+      try
+      {
+         InitialContext ctx = getInitialContext();
+         SecurityDomain securityAnnotation = (SecurityDomain) resolveAnnotation(SecurityDomain.class);
+         if (securityAnnotation != null && securityAnnotation.value().length() > 0)
+         {
+            return (T) SecurityDomainManager.getSecurityManager(securityAnnotation.value(),ctx);
+         }
+         return null;
+      }
+      catch (NamingException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+   
+   protected Method getTimeoutCallback(NamedMethodMetaData timeoutMethodMetaData, Class<?> beanClass)
+   {
+      JBossEnterpriseBeanMetaData metaData = xml;
+      if(metaData != null)
+      {
+         if(timeoutMethodMetaData != null)
+         {
+            String methodName = timeoutMethodMetaData.getMethodName();
+            try
+            {
+               return beanClass.getMethod(methodName, Timer.class);
+            }
+            catch (SecurityException e)
+            {
+               throw new RuntimeException(e);
+            }
+            catch (NoSuchMethodException e)
+            {
+               throw new RuntimeException("No method " + methodName + "(javax.ejb.Timer timer) found on bean " + ejbName, e);
+            }
+         }
+      }
+      
+      if(TimedObject.class.isAssignableFrom(beanClass))
+      {
+         try
+         {
+            return TimedObject.class.getMethod("ejbTimeout", Timer.class);
+         }
+         catch (SecurityException e)
+         {
+            throw new RuntimeException(e);
+         }
+         catch (NoSuchMethodException e)
+         {
+            throw new RuntimeException(e);
+         }
+      }
+      
+      if(metaData != null)
+      {  
+         // TODO: cross cutting concern
+         if(metaData.getEjbJarMetaData().isMetadataComplete())
+            return null;
+      }
+      
+      for (Method method : beanClass.getMethods())
+      {
+         if (getAnnotation(Timeout.class, method) != null)
+         {
+            if (Modifier.isPublic(method.getModifiers()) &&
+                  method.getReturnType().equals(Void.TYPE) &&
+                  method.getParameterTypes().length == 1 &&
+                  method.getParameterTypes()[0].equals(Timer.class))
+            {
+               // TODO: check for multiples
+               return method;
+            }
+            else
+            {
+               throw new RuntimeException("@Timeout method " + method + " must have signature: void <METHOD>(javax.ejb.Timer timer) (EJB3 18.2.2)");
+            }
+         }
+      }
+      
+      return null;
+   }
+   
+   protected void initializePool() throws Exception
+   {
+      org.jboss.ejb3.annotation.Pool poolAnnotation = getAnnotation(org.jboss.ejb3.annotation.Pool.class);
+      if (poolAnnotation == null)
+         throw new IllegalStateException("No pool annotation");
+      String registeredPoolName = poolAnnotation.value();
+      // EJBTHREE-1119
+      if(registeredPoolName==null||registeredPoolName.trim().equals(""))
+      {
+         // Default the Pool Implementation
+         registeredPoolName = PoolDefaults.POOL_IMPLEMENTATION_THREADLOCAL;
+      }
+      int maxSize = poolAnnotation.maxSize();
+      long timeout = poolAnnotation.timeout();
+      PoolFactoryRegistry registry = deployment.getPoolFactoryRegistry();
+      PoolFactory factory = registry.getPoolFactory(registeredPoolName);
+      pool = factory.createPool();
+      pool.initialize(this, maxSize, timeout);
+
+      resolveInjectors();
+      pool.setInjectors(injectors.toArray(new Injector[injectors.size()]));
+   }
+
+   /**
+    * Note that this method is a WIP.
+    * 
+    * @param beanContext
+    * @param callbackAnnotationClass    on of PostConstruct, PreDestroy, PostActivate or PrePassivate
+    */
+   protected void invokeCallback(BeanContext<?> beanContext, Class<? extends Annotation> callbackAnnotationClass)
+   {
+      try
+      {
+         // Do lifecycle callbacks
+         List<Class<?>> lifecycleInterceptorClasses = beanContainer.getInterceptorRegistry().getLifecycleInterceptorClasses();
+         Advisor advisor = getAdvisor();
+         Interceptor interceptors[] = LifecycleCallbacks.createLifecycleCallbackInterceptors(advisor, lifecycleInterceptorClasses, beanContext, callbackAnnotationClass);
+         
+         Constructor<?> constructor = beanClass.getConstructor();
+         Object initargs[] = null;
+         ConstructionInvocation invocation = new ConstructionInvocation(interceptors, constructor, initargs);
+         invocation.setAdvisor(advisor);
+         invocation.setTargetObject(beanContext.getInstance());
+         invocation.invokeNext();
+      }
+      catch(Throwable t)
+      {
+         throw new RuntimeException(t);
+      }
+   }
+   
+   public void invokePostConstruct(BeanContext<?> beanContext)
+   {
+      // FIXME: This is a dirty hack to notify AS EJBTimerService about what's going on
+      AllowedOperationsAssociation.pushInMethodFlag(AllowedOperationsAssociation.IN_EJB_CREATE);
+      try
+      {
+         invokeCallback(beanContext, PostConstruct.class);
+      }
+      finally
+      {
+         AllowedOperationsAssociation.popInMethodFlag();
+      }
+   }
+
+   @Deprecated
+   public void invokePostConstruct(BeanContext beanContext, Object[] params)
+   {
+      invokePostConstruct(beanContext);
+   }
+
+   public void invokePreDestroy(BeanContext beanContext)
+   {
+      // This is the correct way to destroy an instance, do
+      // not call invokeCallback here.
+      beanContainer.destroy(beanContext);
+   }
+
+   public void invokePostActivate(BeanContext beanContext)
+   {
+      throw new RuntimeException("PostActivate not implemented for container");
+   }
+
+   public void invokePrePassivate(BeanContext beanContext)
+   {
+      throw new RuntimeException("PrePassivate not implemented for container");
+   }
+
+   public void invokeInit(Object bean, Class[] initParameterTypes,
+                          Object[] initParameterValues)
+   {
+      // do nothing, only useful on a stateful session bean
+   }
+
+   public static final String MANAGED_ENTITY_MANAGER_FACTORY = "ManagedEntityManagerFactory";
+
+   public static final String ENTITY_MANAGER_FACTORY = "EntityManagerFactory";
+
+   protected void resolveInjectors() throws Exception
+   {
+      pushEnc();
+      try
+      {
+         Thread.currentThread().setContextClassLoader(classloader);
+         try
+         {
+            Util.rebind(getEnc(), "UserTransaction", new UserTransactionImpl());
+         }
+         catch (NamingException e)
+         {
+            NamingException namingException = new NamingException("Could not bind user transaction for ejb name " + ejbName + " into JNDI under jndiName: " + getEnc().getNameInNamespace() + "/" + "UserTransaction");
+            namingException.setRootCause(e);
+            throw namingException;
+         }
+         try
+         {
+            Util.rebind(getEnc(), "TransactionSynchronizationRegistry", new LinkRef("java:TransactionSynchronizationRegistry"));
+            log.debug("Linked java:comp/TransactionSynchronizationRegistry to JNDI name: java:TransactionSynchronizationRegistry");
+         }
+         catch (NamingException e)
+         {
+            NamingException namingException = new NamingException("Could not bind TransactionSynchronizationRegistry for ejb name " + ejbName + " into JNDI under jndiName: " + getEnc().getNameInNamespace() + "/" + "TransactionSynchronizationRegistry");
+            namingException.setRootCause(e);
+            throw namingException;
+         }
+      }
+      finally
+      {
+         popEnc();
+      }
+   }
+
+   /*
+   protected void createCallbackHandler()
+   {
+      try
+      {
+         callbackHandler = new LifecycleInterceptorHandler(this,
+                 getHandledCallbacks());
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException("Error creating callback handler for bean "
+                 + beanClassName, e);
+      }
+   }
+   */
+
+   protected Class[] getHandledCallbacks()
+   {
+      return new Class[]
+              {PostConstruct.class, PreDestroy.class, Timeout.class};
+   }
+
+   // TODO: once injection is finalized this method will disappear
+   private InterceptorMetaData findInterceptor(Class<?> interceptorClass)
+   {
+      if(xml == null)
+         return null;
+      JBossMetaData ejbJarMetaData = xml.getEjbJarMetaData();
+      if(ejbJarMetaData == null)
+         return null;
+      InterceptorsMetaData interceptors = ejbJarMetaData.getInterceptors();
+      if(interceptors == null)
+         return null;
+      for(InterceptorMetaData interceptorMetaData : interceptors)
+      {
+         if(interceptorMetaData.getInterceptorClass().equals(interceptorClass.getName()))
+            return interceptorMetaData;
+      }
+      return null;
+   }
+   
+   protected void findPartitionName()
+   {
+      Clustered clustered = (Clustered) getAnnotation(Clustered.class);
+      if (clustered == null)
+      {
+         partitionName = null;
+         return;
+      }
+      
+      String value = clustered.partition();
+      try
+      {
+         String replacedValue = StringPropertyReplacer.replaceProperties(value);
+         if (value != replacedValue)
+         {            
+            log.debug("Replacing @Clustered partition attribute " + value + " with " + replacedValue);
+            value = replacedValue;
+         }
+      }
+      catch (Exception e)
+      {
+         log.warn("Unable to replace @Clustered partition attribute " + value + 
+                  ". Caused by " + e.getClass() + " " + e.getMessage());         
+      }
+      
+      partitionName = value;
+   }
+
+   public <T> T getBusinessObject(BeanContext<?> beanContext, Class<T> businessInterface) throws IllegalStateException
+   {
+      throw new IllegalStateException("Not implemented");
+   }
+
+   public Object getInvokedBusinessInterface(BeanContext beanContext) throws IllegalStateException
+   {
+      throw new IllegalStateException("Not implemented");
+   }
+
+   protected Object getInvokedInterface(Method method)
+   {
+      Remote remoteAnnotation = (Remote) resolveAnnotation(Remote.class);
+      if (remoteAnnotation != null)
+      {
+         Class[] remotes = remoteAnnotation.value();
+         for (int i = 0; i < remotes.length; ++i)
+         {
+            try
+            {
+               remotes[i].getMethod(method.getName(), method.getParameterTypes());
+               return remotes[i];
+            }
+            catch (NoSuchMethodException e)
+            {
+            }
+         }
+      }
+
+      Local localAnnotation = (Local) resolveAnnotation(Local.class);
+      if (localAnnotation != null)
+      {
+         Class[] locals = localAnnotation.value();
+         for (int i = 0; i < locals.length; ++i)
+         {
+            Method[] interfaceMethods = locals[i].getMethods();
+            for (int j = 0; j < interfaceMethods.length; ++j)
+            {
+               if (interfaceMethods[j].equals(method))
+                  return locals[i];
+            }
+         }
+      }
+
+      return null;
+   }
+
+   // todo these method overrides for aop are for performance reasons
+   private Class loadPublicAnnotation(String annotation)
+   {
+      try
+      {
+         Class ann = classloader.loadClass(annotation);
+         if (!ann.isAnnotation()) return null;
+         Retention retention = (Retention) ann.getAnnotation(Retention.class);
+         if (retention != null && retention.value() == RetentionPolicy.RUNTIME) return ann;
+
+      }
+      catch (ClassNotFoundException ignored)
+      {
+      }
+      return null;
+   }
+
+   /*
+   @Override
+   public boolean hasAnnotation(Class tgt, String annotation)
+   {
+      if (annotations.hasClassAnnotation(annotation)) return true;
+      if (tgt == null) return false;
+      try
+      {
+         Class ann = loadPublicAnnotation(annotation);
+         // it is metadata or CLASS annotation
+         if (ann == null) return AnnotationElement.isAnyAnnotationPresent(tgt, annotation);
+         return tgt.isAnnotationPresent(ann);
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException(e);  //To change body of catch statement use Options | File Templates.
+      }
+   }
+
+
+   @Override
+   public boolean hasAnnotation(Method m, String annotation)
+   {
+      if (annotations.hasAnnotation(m, annotation)) return true;
+      try
+      {
+         Class ann = loadPublicAnnotation(annotation);
+         // it is metadata or CLASS annotation
+         if (ann == null) return AnnotationElement.isAnyAnnotationPresent(m, annotation);
+         return m.isAnnotationPresent(ann);
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException(e);  //To change body of catch statement use Options | File Templates.
+      }
+   }
+
+   @Override
+   public boolean hasAnnotation(Field m, String annotation)
+   {
+      if (annotations.hasAnnotation(m, annotation)) return true;
+      try
+      {
+         Class ann = loadPublicAnnotation(annotation);
+         // it is metadata or CLASS annotation
+         if (ann == null) return AnnotationElement.isAnyAnnotationPresent(m, annotation);
+         return m.isAnnotationPresent(ann);
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException(e);  //To change body of catch statement use Options | File Templates.
+      }
+   }
+
+   @Override
+   public boolean hasAnnotation(Constructor m, String annotation)
+   {
+      if (annotations.hasAnnotation(m, annotation)) return true;
+      try
+      {
+         Class ann = loadPublicAnnotation(annotation);
+         // it is metadata or CLASS annotation
+         if (ann == null) return AnnotationElement.isAnyAnnotationPresent(m, annotation);
+         return m.isAnnotationPresent(ann);
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException(e);  //To change body of catch statement use Options | File Templates.
+      }
+   }
+   */
+   
+   public Container resolveEjbContainer(String link, Class businessIntf)
+   {
+      return deployment.getEjbContainer(link, businessIntf);
+   }
+
+   public Container resolveEjbContainer(Class businessIntf) throws NameNotFoundException
+   {
+      return deployment.getEjbContainer(businessIntf);
+   }
+
+   public String resolveMessageDestination(String link)
+   {
+      return deployment.resolveMessageDestination(link);
+   }
+   
+   public String resolvePersistenceUnitSupplier(String unitName)
+   {
+      return getDeployment().resolvePersistenceUnitSupplier(unitName);
+   }
+   
+   public <T extends Annotation> T getAnnotation(Class<T> annotationType)
+   {
+      if (this.getAnnotations().isDisabled(annotationType))
+         return null;
+      
+      return beanContainer.getAnnotation(annotationType);
+   }
+   
+   public <T extends Annotation> T getAnnotation(Class<T> annotationType, Class<?> clazz)
+   {
+      return beanContainer.getAnnotation(clazz, annotationType);
+   }
+
+   public <T extends Annotation> T getAnnotation(Class<T> annotationType, Class<?> clazz, Method method)
+   {
+      return beanContainer.getAnnotation(annotationType, clazz, method);
+   }
+   
+   public <T extends Annotation> T getAnnotation(Class<T> annotationType, Method method)
+   {
+      if (this.getAnnotations().isDisabled(method, annotationType))
+         return null;
+      
+      return beanContainer.getAnnotation(annotationType, method);
+   }
+
+   public <T extends Annotation> T getAnnotation(Class<T> annotationType, Class<?> clazz, Field field)
+   {
+      return beanContainer.getAnnotation(annotationType, clazz, field);
+   }
+   
+   public <T extends Annotation> T getAnnotation(Class<T> annotationType, Field field)
+   {
+      return beanContainer.getAnnotation(annotationType, field);
+   }
+   
+   /**
+    * @deprecated use getAnnotation
+    */
+   @SuppressWarnings("unchecked")
+   public Object resolveAnnotation(Class annotationType)
+   {
+      return getAnnotation(annotationType);
+   }
+   
+   /**
+    * @deprecated use getAnnotation
+    */
+   @SuppressWarnings("unchecked")
+   public Object resolveAnnotation(Field field, Class annotationType)
+   {
+      return getAnnotation(annotationType, field);
+   }
+   
+   /**
+    * @deprecated use getAnnotation
+    */
+   @SuppressWarnings("unchecked")
+   public Object resolveAnnotation(Method method, Class annotationType)
+   {
+      return getAnnotation(annotationType, method);
+   }
+   
+   /**
+    * @deprecated this is going to be gone soon
+    */
+   @SuppressWarnings("unchecked")
+   public Object resolveAnnotation(Method m, Class[] annotationChoices)
+   {
+      Object value = null;
+      int i = 0;
+      while (value == null && i < annotationChoices.length){
+         value = resolveAnnotation(m, annotationChoices[i++]);
+      }
+      
+      return value;
+   }
+
+   public String getIdentifier()
+   {
+      return getEjbName();
+   }
+
+   public String getDeploymentDescriptorType()
+   {
+      return "ejb-jar.xml";
+   }
+
+   public PersistenceUnitDeployment getPersistenceUnitDeployment(String unitName) throws NameNotFoundException
+   {
+      return deployment.getPersistenceUnitDeployment(unitName);
+   }
+
+   public String getEjbJndiName(Class businessInterface) throws NameNotFoundException
+   {
+      return deployment.getEjbJndiName(businessInterface);
+   }
+
+   public String getEjbJndiName(String link, Class businessInterface)
+   {
+      return deployment.getEjbJndiName(link, businessInterface);
+   }
+   
+   public InvocationStatistics getInvokeStats()
+   {
+      return invokeStats;
+   }
+
+   @Deprecated
+   protected MethodInfo getMethodInfo(Method method)
+   {
+      long hash = MethodHashing.calculateHash(method);
+      MethodInfo info = getAdvisor().getMethodInfo(hash);
+      if (info == null)
+      {
+         throw new RuntimeException("Could not resolve beanClass method from proxy call: " + method.toString());
+      }
+      return info;
+   }
+   
+   public boolean isClustered()
+   {
+      return false;
+   }
+   
+   public JavaEEModule getModule()
+   {
+      return deployment;
+   }
+   
+   public abstract boolean hasJNDIBinding(String jndiName);
+   
+   /**
+    * After XML processing has been done this allows the container
+    * to further initialize the meta data.
+    */
+   public void instantiated()
+   {
+      this.businessInterfaces = resolveBusinessInterfaces();
+      
+      // Before we start to process annotations, make sure we also have the ones from interceptors-aop.
+      // FIXME: because of the flaked life cycle of an EJBContainer (we add annotations after it's been
+      // constructed), we must reinitialize the whole thing. 
+      beanContainer.reinitializeAdvisor();
+   }
+   
+   public void setDirectContainer(DirectContainer<EJBContainer> container)
+   {
+      this.directContainer = container;
+   }
+   
+   protected Method getNonBridgeMethod(Method bridgeMethod)
+   {
+      Class clazz = bridgeMethod.getDeclaringClass();
+      Method[] methods = clazz.getMethods();
+      for (Method method : methods)
+      {
+         if (!method.isBridge() && method.getParameterTypes().length == bridgeMethod.getParameterTypes().length)
+         {
+            return method;
+         }
+      }
+      
+      return bridgeMethod;
+   }
+   
+   public Lock getInvocationLock()
+   {
+      return this.containerLock.readLock();
+   }
+   
+   private Lock getContainerLock()
+   {
+      return this.containerLock.writeLock();
+   }
+   
+   public String toString()
+   {
+      return getObjectName().getCanonicalName();
+   }
+}

Deleted: projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/java/org/jboss/ejb3/session/SessionContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionContainer.java	2008-08-25 02:13:51 UTC (rev 77394)
+++ projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/java/org/jboss/ejb3/session/SessionContainer.java	2008-08-25 05:28:04 UTC (rev 77405)
@@ -1,702 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, 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.session;
-
-import java.io.Serializable;
-import java.lang.reflect.Method;
-import java.rmi.NoSuchObjectException;
-import java.rmi.Remote;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.ejb.EJBHome;
-import javax.ejb.EJBLocalHome;
-import javax.ejb.EJBLocalObject;
-import javax.ejb.EJBObject;
-import javax.ejb.Handle;
-import javax.ejb.LocalHome;
-import javax.ejb.NoSuchEJBException;
-import javax.ejb.NoSuchObjectLocalException;
-import javax.ejb.RemoteHome;
-
-import org.jboss.aop.Dispatcher;
-import org.jboss.aop.Domain;
-import org.jboss.aop.MethodInfo;
-import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.aop.joinpoint.InvocationResponse;
-import org.jboss.aop.util.MethodHashing;
-import org.jboss.aspects.asynch.FutureHolder;
-import org.jboss.ejb3.EJBContainer;
-import org.jboss.ejb3.Ejb3Deployment;
-import org.jboss.ejb3.Ejb3Module;
-import org.jboss.ejb3.annotation.LocalBinding;
-import org.jboss.ejb3.annotation.RemoteBinding;
-import org.jboss.ejb3.annotation.RemoteBindings;
-import org.jboss.ejb3.proxy.ProxyFactory;
-import org.jboss.ejb3.proxy.ProxyUtils;
-import org.jboss.ejb3.proxy.container.InvokableContext;
-import org.jboss.ejb3.proxy.factory.ProxyFactoryHelper;
-import org.jboss.ejb3.proxy.factory.RemoteProxyFactory;
-import org.jboss.ejb3.proxy.factory.SessionProxyFactory;
-import org.jboss.ejb3.remoting.IsLocalInterceptor;
-import org.jboss.ejb3.stateful.StatefulContainerInvocation;
-import org.jboss.ha.framework.server.HATarget;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
-import org.jboss.metadata.ejb.spec.BusinessLocalsMetaData;
-import org.jboss.metadata.ejb.spec.BusinessRemotesMetaData;
-import org.jboss.serial.io.MarshalledObjectForLocalCalls;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public abstract class SessionContainer extends EJBContainer
-{
-   @SuppressWarnings("unused")
-   private static final Logger log = Logger.getLogger(SessionContainer.class);
-
-   protected ProxyDeployer proxyDeployer;
-   private Map<String, HATarget> clusterFamilies;
-   
-   /**
-    * Returns a remote binding for this container
-    * 
-    * @deprecated Non-deterministic, more than one binding may be specified 
-    * for this container
-    * @return
-    */
-   @Deprecated
-   protected RemoteBinding getRemoteBinding()
-   {
-      RemoteBinding binding = null;
-      RemoteBindings bindings = getAnnotation(RemoteBindings.class);
-      if (bindings != null)
-         binding = bindings.value()[0];
-      else
-         binding = getAnnotation(RemoteBinding.class);
-      
-      return binding;
-   }
-
-   public SessionContainer(ClassLoader cl, String beanClassName, String ejbName, Domain domain,
-                           Hashtable ctxProperties, Ejb3Deployment deployment, JBossSessionBeanMetaData beanMetaData) throws ClassNotFoundException
-   {
-      super(Ejb3Module.BASE_EJB3_JMX_NAME + ",name=" + ejbName, domain, cl, beanClassName, ejbName, ctxProperties, deployment, beanMetaData);
-      proxyDeployer = new ProxyDeployer(this);
-   }
-
-   /**
-    * Create a local proxy factory.
-    * @return
-    */
-   protected abstract ProxyFactory getProxyFactory(LocalBinding binding);
-   
-   /**
-    * Create a remote proxy factory on the given binding.
-    * 
-    * @param binding
-    * @return
-    */
-   protected abstract RemoteProxyFactory getProxyFactory(RemoteBinding binding);
-   
-   public abstract InvocationResponse dynamicInvoke(Object target, Invocation invocation) throws Throwable;
-
-   public JBossSessionBeanMetaData getMetaData()
-   {
-      // TODO: resolve this cast using generics on EJBContainer
-      return (JBossSessionBeanMetaData) getXml();
-   }
-   
-   @Override
-   public void instantiated()
-   {
-      super.instantiated();
-      proxyDeployer.initializeRemoteBindingMetadata();
-      proxyDeployer.initializeLocalBindingMetadata();
-   }
-
-   @Override
-   protected List<Class<?>> resolveBusinessInterfaces()
-   {
-      // Obtain all business interfaces
-      List<Class<?>> list = new ArrayList<Class<?>>();
-      list.addAll(Arrays.asList(ProxyFactoryHelper.getLocalBusinessInterfaces(this)));
-      list.addAll(Arrays.asList(ProxyFactoryHelper.getRemoteBusinessInterfaces(this)));
-      
-      return list;
-   }
-   
-   protected void lockedStart() throws Exception
-   {
-      super.lockedStart();
-      this.registerWithAopDispatcher();
-      
-      //TODO Remove
-      //      proxyDeployer.start();
-   }
-   
-   /**
-    * Registers this Container with Remoting
-    */
-   protected void registerWithAopDispatcher()
-   {
-      // So that Remoting layer can reference this container easily.
-      Dispatcher.singleton.registerTarget(getObjectName().getCanonicalName(), new ClassProxyHack(this));
-   }
-
-   /**
-    * This gets called by replicants manager interceptor factory
-    * during the initialization of the bean container (during construction of EJBContainer).
-    * So we have detached construction here.
-    * 
-    * @return the cluster families, never null
-    */
-   public Map<String, HATarget> getClusterFamilies()
-   {
-      if(clusterFamilies != null)
-         return clusterFamilies;
-      
-      synchronized (this)
-      {
-         if(clusterFamilies == null)
-            clusterFamilies = new HashMap<String, HATarget>();
-      }
-      return clusterFamilies;
-   }
-
-   protected void lockedStop() throws Exception
-   {
-      //TODO Remove
-//      try
-//      {
-//         proxyDeployer.stop();
-//      }
-//      catch (Exception ignore)
-//      {
-//         log.debug("Proxy deployer stop failed", ignore);
-//      }
-      try
-      {
-         Dispatcher.singleton.unregisterTarget(getObjectName().getCanonicalName());
-      }
-      catch (Exception ignore)
-      {
-         log.debug("Dispatcher unregister target failed", ignore);
-      }
-      super.lockedStop();
-   }
-
-   @Override
-   public List<Method> getVirtualMethods()
-   {
-      List<Method> virtualMethods = new ArrayList<Method>();
-      try
-      {
-         RemoteHome home = getAnnotation(RemoteHome.class);
-         if (home != null)
-         {
-            Method[] declaredMethods = home.value().getMethods();
-            for(Method declaredMethod : declaredMethods)
-               virtualMethods.add(declaredMethod);
-
-            declaredMethods = javax.ejb.EJBObject.class.getMethods();
-            for(Method declaredMethod : declaredMethods)
-               virtualMethods.add(declaredMethod);
-         }
-
-         LocalHome localHome = getAnnotation(LocalHome.class);
-         if (localHome != null)
-         {
-            Method[] declaredMethods = localHome.value().getMethods();
-            for(Method declaredMethod : declaredMethods)
-               virtualMethods.add(declaredMethod);
-
-            declaredMethods = javax.ejb.EJBLocalObject.class.getMethods();
-            for(Method declaredMethod : declaredMethods)
-               virtualMethods.add(declaredMethod);
-         }
-      }
-      catch (SecurityException e)
-      {
-         // TODO: privileged?
-         throw new RuntimeException(e);
-      }
-      return virtualMethods;
-   }
-   
-   
-//   /**
-//    * Obtains a List of all methods handled by the bean class
-//    * 
-//    * @return The methods handled by the bean class directly
-//    */
-//   @Override
-//   //FIXME: Should be adapted to use metadata view from metadata bridge
-//   // such that *-aop.xml annotations may be included
-//   public List<Method> getVirtualMethods()
-//   {
-//      // Initialize
-//      List<Method> virtualMethods = new ArrayList<Method>();
-//
-//      // Obtain Metadata
-//      JBossSessionBeanMetaData smd = this.getMetaData();
-//
-//      // Obtain CL
-//      ClassLoader cl = this.getClassloader();
-//
-//      /*
-//       * Business Remotes
-//       */
-//
-//      // Obtain all specified business remotes
-//      BusinessRemotesMetaData businessRemotes = smd.getBusinessRemotes();
-//      if (businessRemotes != null)
-//      {
-//         // For each business remote
-//         for (String businessRemote : businessRemotes)
-//         {
-//            // Load the Class
-//            Class<?> businessRemoteClass = null;
-//            try
-//            {
-//               businessRemoteClass = Class.forName(businessRemote, true, cl);
-//            }
-//            catch (ClassNotFoundException e)
-//            {
-//               throw new RuntimeException("Could not find specified business remote class: " + businessRemote, e);
-//            }
-//
-//            // Obtain all methods declared by the class
-//            Method[] declaredMethods = businessRemoteClass.getMethods();
-//
-//            // Add each method
-//            for (Method declaredMethod : declaredMethods)
-//            {
-//               virtualMethods.add(declaredMethod);
-//            }
-//         }
-//      }
-//
-//      /*
-//       * Business Locals
-//       */
-//
-//      // Obtain all specified business locals
-//      BusinessLocalsMetaData businessLocals = smd.getBusinessLocals();
-//      if (businessLocals != null)
-//      {
-//         // For each business local
-//         for (String businessLocal : businessLocals)
-//         {
-//            // Load the Class
-//            Class<?> businessLocalClass = null;
-//            try
-//            {
-//               businessLocalClass = Class.forName(businessLocal, true, cl);
-//            }
-//            catch (ClassNotFoundException e)
-//            {
-//               throw new RuntimeException("Could not find specified business local class: " + businessLocal, e);
-//            }
-//
-//            // Obtain all methods declared by the class
-//            Method[] declaredMethods = businessLocalClass.getMethods();
-//
-//            // Add each method
-//            for (Method declaredMethod : declaredMethods)
-//            {
-//               virtualMethods.add(declaredMethod);
-//            }
-//         }
-//      }
-//
-//      // Remote Home
-//      String remoteHomeClassName = smd.getHome();
-//      if (remoteHomeClassName != null)
-//      {
-//         Class<?> remoteHomeClass = null;
-//         try
-//         {
-//            remoteHomeClass = Class.forName(remoteHomeClassName, true, cl);
-//         }
-//         catch (ClassNotFoundException e)
-//         {
-//            throw new RuntimeException("Could not find specified Remote Home Class: " + remoteHomeClassName, e);
-//         }
-//         if (remoteHomeClass != null)
-//         {
-//            Method[] declaredMethods = remoteHomeClass.getMethods();
-//            for (Method declaredMethod : declaredMethods)
-//               virtualMethods.add(declaredMethod);
-//
-//            declaredMethods = javax.ejb.EJBObject.class.getMethods();
-//            for (Method declaredMethod : declaredMethods)
-//               virtualMethods.add(declaredMethod);
-//         }
-//      }
-//
-//      // Local Home
-//      String localHomeClassName = smd.getLocalHome();
-//      if (localHomeClassName != null)
-//      {
-//         Class<?> localHomeClass = null;
-//         try
-//         {
-//            localHomeClass = Class.forName(localHomeClassName, true, cl);
-//         }
-//         catch (ClassNotFoundException e)
-//         {
-//            throw new RuntimeException("Could not find specified Local Home Class: " + localHomeClass, e);
-//         }
-//         if (localHomeClass != null)
-//         {
-//            Method[] declaredMethods = localHomeClass.getMethods();
-//            for (Method declaredMethod : declaredMethods)
-//               virtualMethods.add(declaredMethod);
-//
-//            declaredMethods = javax.ejb.EJBLocalObject.class.getMethods();
-//            for (Method declaredMethod : declaredMethods)
-//               virtualMethods.add(declaredMethod);
-//         }
-//      }
-//      
-//      log.debug("Found virtual methods: ");
-//      for(Method m : virtualMethods)
-//      {
-//         log.debug("\t" + m + " - " + MethodHashing.calculateHash(m));
-//      }
-//      
-//
-//      return virtualMethods;
-//   }
-   
-   /*
-   protected void createMethodMap()
-   {
-      super.createMethodMap();
-      try
-      {
-         RemoteHome home = (RemoteHome) resolveAnnotation(RemoteHome.class);
-         if (home != null)
-         {
-            Method[] declaredMethods = home.value().getMethods();
-            for (int i = 0; i < declaredMethods.length; i++)
-            {
-               long hash = MethodHashing.methodHash(declaredMethods[i]);
-               advisedMethods.put(hash, declaredMethods[i]);
-            }
-
-            declaredMethods = javax.ejb.EJBObject.class.getMethods();
-            for (int i = 0; i < declaredMethods.length; i++)
-            {
-               long hash = MethodHashing.methodHash(declaredMethods[i]);
-               advisedMethods.put(hash, declaredMethods[i]);
-            }
-         }
-
-         LocalHome localHome = (LocalHome) resolveAnnotation(LocalHome.class);
-         if (localHome != null)
-         {
-            Method[] declaredMethods = localHome.value().getMethods();
-            for (int i = 0; i < declaredMethods.length; i++)
-            {
-               long hash = MethodHashing.methodHash(declaredMethods[i]);
-               advisedMethods.put(hash, declaredMethods[i]);
-            }
-
-            declaredMethods = javax.ejb.EJBLocalObject.class.getMethods();
-            for (int i = 0; i < declaredMethods.length; i++)
-            {
-               long hash = MethodHashing.methodHash(declaredMethods[i]);
-               advisedMethods.put(hash, declaredMethods[i]);
-            }
-         }
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException(e);
-      }
-   }
-   */
-
-   public static InvocationResponse marshallException(Invocation invocation, Throwable exception, Map responseContext) throws Throwable
-   {
-      if (invocation.getMetaData(IsLocalInterceptor.IS_LOCAL,IsLocalInterceptor.IS_LOCAL) == null) throw exception;
-
-      InvocationResponse response = new InvocationResponse();
-      response.setContextInfo(responseContext);
-
-      response.addAttachment(IsLocalInterceptor.IS_LOCAL_EXCEPTION, new MarshalledObjectForLocalCalls(exception));
-
-      return response;
-   }
-
-   public static InvocationResponse marshallResponse(Invocation invocation, Object rtn, Map responseContext)
-           throws java.io.IOException
-   {
-      InvocationResponse response;
-      // marshall return value
-      if (rtn != null && invocation.getMetaData(IsLocalInterceptor.IS_LOCAL, IsLocalInterceptor.IS_LOCAL) != null)
-      {
-         response = new InvocationResponse(new MarshalledObjectForLocalCalls(rtn));
-      }
-      else
-      {
-         response = new InvocationResponse(rtn);
-      }
-      response.setContextInfo(responseContext);
-      return response;
-   }
-   
-   /**
-    * Invoke a method on the virtual EJB bean. The method must be one of the methods defined in one
-    * of the business interfaces (or home interface) of the bean.
-    * 
-    * TODO: work in progress
-    * 
-    * @param factory    the originating end point
-    * @param id         unique identifier (primary key), can be null for stateless
-    * @param method     the business or home method to invoke
-    * @param args       the arguments for the method
-    * @param provider   for asynchronous usage
-    * @deprecated Use "invoke" as defined by InvokableContext
-    */
-   @Deprecated
-   public Object invoke(SessionProxyFactory factory, Object id, Method method, Object args[], FutureHolder provider) throws Throwable
-   {
-      ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
-      pushEnc();
-      try
-      {
-         long hash = MethodHashing.calculateHash(method);
-         MethodInfo info = getAdvisor().getMethodInfo(hash);
-         if (info == null)
-         {
-            throw new RuntimeException(
-                    "Could not resolve beanClass method from proxy call: "
-                            + method.toString());
-         }
-
-         
-         // Handled now by SessionSpecContainer
-         //Method unadvisedMethod = info.getUnadvisedMethod();
-//         if (unadvisedMethod != null && isHomeMethod(unadvisedMethod))
-//         {
-//            return invokeHomeMethod(factory, info, args);
-//         }
-//         else if (unadvisedMethod != null && isEJBObjectMethod(unadvisedMethod))
-//         {
-//            return invokeEJBObjectMethod(factory, id, info, args);
-//         }
-
-         // FIXME: Ahem, stateful container invocation works on all.... (violating contract though)
-         StatefulContainerInvocation nextInvocation = new StatefulContainerInvocation(info, id);
-         //StatefulSessionContainerMethodInvocation nextInvocation = new StatefulSessionContainerMethodInvocation(info,null);
-         //EJBContainerInvocation nextInvocation = new StatefulContainerInvocation(info, id);
-         nextInvocation.setAdvisor(getAdvisor());
-         nextInvocation.setArguments(args);
-         
-         // allow a container to supplement information into an invocation
-         nextInvocation = populateInvocation(nextInvocation);
-
-         ProxyUtils.addLocalAsynchronousInfo(nextInvocation, provider);
-         return nextInvocation.invokeNext();
-      }
-      finally
-      {
-         Thread.currentThread().setContextClassLoader(oldLoader);
-         popEnc();
-      }
-   }
-   
-   /**
-    * Create session to an EJB bean.
-    * 
-    * @param initParameterTypes     the parameter types used by the home's create method
-    * @param initParameterValues    the arguments for the home's create method
-    * @return   the identifier of the session
-    */
-   abstract public Serializable createSession(Class<?> initParameterTypes[], Object initParameterValues[]);
-   
-   abstract public Object localInvoke(Object id, Method method, Object[] args, FutureHolder provider) throws Throwable;
-   
-   abstract public Object localHomeInvoke(Method method, Object[] args) throws Throwable;
-   
-   public Serializable createSession()
-   {
-      return createSession(new Class<?>[]{}, new Object[]{});
-   }
-   
-   /**
-    * Destroy a created session.
-    * 
-    * @param id     the identifier of the session
-    */
-   protected void destroySession(Object id)
-   {
-      throw new RuntimeException("NYI");
-   }
-   
-   /**
-    * Checks if this session bean binds to the given JNDI name.
-    */
-   @Override
-   public boolean hasJNDIBinding(String jndiName)
-   {
-      return proxyDeployer.hasJNDIBinding(jndiName);
-   }
-   
-   protected Object invokeEJBObjectMethod(Object id, MethodInfo info, Object args[]) throws Exception
-   {
-      Method unadvisedMethod = info.getUnadvisedMethod();
-      if(unadvisedMethod.getName().equals("getEJBHome"))
-      {
-         return this.getInitialContext().lookup(this.getMetaData().getHomeJndiName());
-      }
-      if(unadvisedMethod.getName().equals("getPrimaryKey"))
-      {
-         return id;
-      }
-      if(unadvisedMethod.getName().equals("isIdentical"))
-      {
-         // object has no identity
-         if(id == null)
-            return false;
-         
-         EJBObject bean = (EJBObject) args[0];
-
-         Object primaryKey = bean.getPrimaryKey();
-         if(primaryKey == null)
-            return false;
-
-         boolean isIdentical = id.equals(primaryKey);
-
-         return isIdentical;
-      }
-      if (unadvisedMethod.getName().equals("remove"))
-      {
-         try
-         {
-            destroySession(id);
-         }
-         catch(NoSuchEJBException nsee)
-         {
-            String invokingClassName = unadvisedMethod.getDeclaringClass().getName();
-            Exception newException = (Exception) this.constructProperNoSuchEjbException(nsee, invokingClassName);
-            throw newException;
-         }
-
-         return null;
-      }
-      throw new RuntimeException("NYI");
-   }
-   
-   /**
-    * Obtains the proper Exception to return to the caller in 
-    * the event a "remove" call is made on a bean that doesn't exist.
-    * 
-    * Implements EJB 3.0 Core Specification 14.3.9
-    * 
-    * @param original
-    * @param invokingClassName
-    * @return
-    */
-   protected Throwable constructProperNoSuchEjbException(NoSuchEJBException original,String invokingClassName)
-   {
-      /*
-       * EJB 3.0 Core Specification 14.3.9
-       * 
-       * If a client makes a call to a stateful session or entity 
-       * object that has been removed, the container should throw the 
-       * javax.ejb.NoSuchEJBException. If the EJB 2.1 client view is used, 
-       * the container should throw the java.rmi.NoSuchObjectException 
-       * (which is a subclass of java.rmi.RemoteException) to a remote client, 
-       * or the javax.ejb.NoSuchObjectLocalException to a local client.
-       */
-      
-      // Initialize
-      Throwable t = original;
-      ClassLoader cl = this.getClassloader();
-      
-      // Obtain the actual invoked class
-      Class<?> actualInvokingClass = null;
-      try
-      {
-         actualInvokingClass = Class.forName(invokingClassName, true, cl);
-      }
-      catch (ClassNotFoundException e)
-      {
-         throw new RuntimeException("Could not obtain invoking class", e);
-      }
-
-      // If local EJB2.x Client
-      if (EJBLocalObject.class.isAssignableFrom(actualInvokingClass)
-            || EJBLocalHome.class.isAssignableFrom(actualInvokingClass))
-      {
-         t = new NoSuchObjectLocalException(original.getMessage());
-      }
-      // If remote EJB2.x Client
-      else if (Remote.class.isAssignableFrom(actualInvokingClass)
-            || EJBObject.class.isAssignableFrom(actualInvokingClass)
-            || EJBHome.class.isAssignableFrom(actualInvokingClass))
-      {
-         t = new NoSuchObjectException(original.getMessage());
-      }
-      // Business interface
-      else
-      {
-         // Take no action, this is here just for readability
-      }
-
-      // Log
-      if (log.isTraceEnabled())
-      {
-         log.trace("Throwing " + t.getClass().getName(), t);
-      }
-
-      // Return
-      return t;
-   }
-   
-   /**
-    * Allow a container sub class to supplement an invocation. Per default nothing to supplement.
-    * 
-    * @param invocation
-    * @return
-    */
-   protected StatefulContainerInvocation populateInvocation(
-         StatefulContainerInvocation invocation)
-   {
-      return invocation;
-   }
-   
-   abstract protected void removeHandle(Handle handle) throws Exception;
-}

Copied: projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/java/org/jboss/ejb3/session/SessionContainer.java (from rev 77399, projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionContainer.java)
===================================================================
--- projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/java/org/jboss/ejb3/session/SessionContainer.java	                        (rev 0)
+++ projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/java/org/jboss/ejb3/session/SessionContainer.java	2008-08-25 05:28:04 UTC (rev 77405)
@@ -0,0 +1,704 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.session;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.rmi.NoSuchObjectException;
+import java.rmi.Remote;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.ejb.EJBHome;
+import javax.ejb.EJBLocalHome;
+import javax.ejb.EJBLocalObject;
+import javax.ejb.EJBObject;
+import javax.ejb.Handle;
+import javax.ejb.LocalHome;
+import javax.ejb.NoSuchEJBException;
+import javax.ejb.NoSuchObjectLocalException;
+import javax.ejb.RemoteHome;
+
+import org.jboss.aop.Dispatcher;
+import org.jboss.aop.Domain;
+import org.jboss.aop.MethodInfo;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.InvocationResponse;
+import org.jboss.aop.util.MethodHashing;
+import org.jboss.aspects.asynch.FutureHolder;
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.ejb3.Ejb3Module;
+import org.jboss.ejb3.annotation.LocalBinding;
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.ejb3.annotation.RemoteBindings;
+import org.jboss.ejb3.common.registrar.spi.Ejb3Registrar;
+import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
+import org.jboss.ejb3.proxy.ProxyFactory;
+import org.jboss.ejb3.proxy.ProxyUtils;
+import org.jboss.ejb3.proxy.clustered.objectstore.ClusteredObjectStoreBindings;
+import org.jboss.ejb3.proxy.clustered.registry.ProxyClusteringRegistry;
+import org.jboss.ejb3.proxy.container.InvokableContext;
+import org.jboss.ejb3.proxy.factory.ProxyFactoryHelper;
+import org.jboss.ejb3.proxy.factory.RemoteProxyFactory;
+import org.jboss.ejb3.proxy.factory.SessionProxyFactory;
+import org.jboss.ejb3.remoting.IsLocalInterceptor;
+import org.jboss.ejb3.stateful.StatefulContainerInvocation;
+import org.jboss.ha.framework.server.HATarget;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.ejb.spec.BusinessLocalsMetaData;
+import org.jboss.metadata.ejb.spec.BusinessRemotesMetaData;
+import org.jboss.serial.io.MarshalledObjectForLocalCalls;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision$
+ */
+public abstract class SessionContainer extends EJBContainer
+{
+   @SuppressWarnings("unused")
+   private static final Logger log = Logger.getLogger(SessionContainer.class);
+
+   protected ProxyDeployer proxyDeployer;
+   private Map<String, HATarget> clusterFamilies;
+   
+   /**
+    * Returns a remote binding for this container
+    * 
+    * @deprecated Non-deterministic, more than one binding may be specified 
+    * for this container
+    * @return
+    */
+   @Deprecated
+   protected RemoteBinding getRemoteBinding()
+   {
+      RemoteBinding binding = null;
+      RemoteBindings bindings = getAnnotation(RemoteBindings.class);
+      if (bindings != null)
+         binding = bindings.value()[0];
+      else
+         binding = getAnnotation(RemoteBinding.class);
+      
+      return binding;
+   }
+
+   public SessionContainer(ClassLoader cl, String beanClassName, String ejbName, Domain domain,
+                           Hashtable ctxProperties, Ejb3Deployment deployment, JBossSessionBeanMetaData beanMetaData) throws ClassNotFoundException
+   {
+      super(Ejb3Module.BASE_EJB3_JMX_NAME + ",name=" + ejbName, domain, cl, beanClassName, ejbName, ctxProperties, deployment, beanMetaData);
+      proxyDeployer = new ProxyDeployer(this);
+   }
+
+   /**
+    * Create a local proxy factory.
+    * @return
+    */
+   protected abstract ProxyFactory getProxyFactory(LocalBinding binding);
+   
+   /**
+    * Create a remote proxy factory on the given binding.
+    * 
+    * @param binding
+    * @return
+    */
+   protected abstract RemoteProxyFactory getProxyFactory(RemoteBinding binding);
+   
+   public abstract InvocationResponse dynamicInvoke(Object target, Invocation invocation) throws Throwable;
+
+   public JBossSessionBeanMetaData getMetaData()
+   {
+      // TODO: resolve this cast using generics on EJBContainer
+      return (JBossSessionBeanMetaData) getXml();
+   }
+   
+   @Override
+   public void instantiated()
+   {
+      super.instantiated();
+      proxyDeployer.initializeRemoteBindingMetadata();
+      proxyDeployer.initializeLocalBindingMetadata();
+   }
+
+   @Override
+   protected List<Class<?>> resolveBusinessInterfaces()
+   {
+      // Obtain all business interfaces
+      List<Class<?>> list = new ArrayList<Class<?>>();
+      list.addAll(Arrays.asList(ProxyFactoryHelper.getLocalBusinessInterfaces(this)));
+      list.addAll(Arrays.asList(ProxyFactoryHelper.getRemoteBusinessInterfaces(this)));
+      
+      return list;
+   }
+   
+   protected void lockedStart() throws Exception
+   {
+      super.lockedStart();
+      this.registerWithAopDispatcher();
+      
+      //TODO Remove
+      //      proxyDeployer.start();
+   }
+   
+   /**
+    * Registers this Container with Remoting
+    */
+   protected void registerWithAopDispatcher()
+   {
+      // So that Remoting layer can reference this container easily.
+      Dispatcher.singleton.registerTarget(getObjectName().getCanonicalName(), new ClassProxyHack(this));
+   }
+
+   /**
+    * This gets called by replicants manager interceptor factory
+    * during the initialization of the bean container (during construction of EJBContainer).
+    * So we have detached construction here.
+    * 
+    * @return the cluster families, never null
+    */
+   public Map<String, HATarget> getClusterFamilies()
+   {
+      if(clusterFamilies == null)
+      {      
+         Ejb3Registrar registrar = Ejb3RegistrarLocator.locateRegistrar();
+         ProxyClusteringRegistry registry = (ProxyClusteringRegistry) registrar.lookup(ClusteredObjectStoreBindings.CLUSTERED_OBJECTSTORE_BEAN_NAME_PROXY_CLUSTERING_REGISTRY);
+         clusterFamilies = registry.getHATargets(this.getObjectName().getCanonicalName());
+      }
+      return clusterFamilies;
+   }
+
+   protected void lockedStop() throws Exception
+   {
+      //TODO Remove
+//      try
+//      {
+//         proxyDeployer.stop();
+//      }
+//      catch (Exception ignore)
+//      {
+//         log.debug("Proxy deployer stop failed", ignore);
+//      }
+      try
+      {
+         Dispatcher.singleton.unregisterTarget(getObjectName().getCanonicalName());
+      }
+      catch (Exception ignore)
+      {
+         log.debug("Dispatcher unregister target failed", ignore);
+      }
+      super.lockedStop();
+   }
+
+   @Override
+   public List<Method> getVirtualMethods()
+   {
+      List<Method> virtualMethods = new ArrayList<Method>();
+      try
+      {
+         RemoteHome home = getAnnotation(RemoteHome.class);
+         if (home != null)
+         {
+            Method[] declaredMethods = home.value().getMethods();
+            for(Method declaredMethod : declaredMethods)
+               virtualMethods.add(declaredMethod);
+
+            declaredMethods = javax.ejb.EJBObject.class.getMethods();
+            for(Method declaredMethod : declaredMethods)
+               virtualMethods.add(declaredMethod);
+         }
+
+         LocalHome localHome = getAnnotation(LocalHome.class);
+         if (localHome != null)
+         {
+            Method[] declaredMethods = localHome.value().getMethods();
+            for(Method declaredMethod : declaredMethods)
+               virtualMethods.add(declaredMethod);
+
+            declaredMethods = javax.ejb.EJBLocalObject.class.getMethods();
+            for(Method declaredMethod : declaredMethods)
+               virtualMethods.add(declaredMethod);
+         }
+      }
+      catch (SecurityException e)
+      {
+         // TODO: privileged?
+         throw new RuntimeException(e);
+      }
+      return virtualMethods;
+   }
+   
+   
+//   /**
+//    * Obtains a List of all methods handled by the bean class
+//    * 
+//    * @return The methods handled by the bean class directly
+//    */
+//   @Override
+//   //FIXME: Should be adapted to use metadata view from metadata bridge
+//   // such that *-aop.xml annotations may be included
+//   public List<Method> getVirtualMethods()
+//   {
+//      // Initialize
+//      List<Method> virtualMethods = new ArrayList<Method>();
+//
+//      // Obtain Metadata
+//      JBossSessionBeanMetaData smd = this.getMetaData();
+//
+//      // Obtain CL
+//      ClassLoader cl = this.getClassloader();
+//
+//      /*
+//       * Business Remotes
+//       */
+//
+//      // Obtain all specified business remotes
+//      BusinessRemotesMetaData businessRemotes = smd.getBusinessRemotes();
+//      if (businessRemotes != null)
+//      {
+//         // For each business remote
+//         for (String businessRemote : businessRemotes)
+//         {
+//            // Load the Class
+//            Class<?> businessRemoteClass = null;
+//            try
+//            {
+//               businessRemoteClass = Class.forName(businessRemote, true, cl);
+//            }
+//            catch (ClassNotFoundException e)
+//            {
+//               throw new RuntimeException("Could not find specified business remote class: " + businessRemote, e);
+//            }
+//
+//            // Obtain all methods declared by the class
+//            Method[] declaredMethods = businessRemoteClass.getMethods();
+//
+//            // Add each method
+//            for (Method declaredMethod : declaredMethods)
+//            {
+//               virtualMethods.add(declaredMethod);
+//            }
+//         }
+//      }
+//
+//      /*
+//       * Business Locals
+//       */
+//
+//      // Obtain all specified business locals
+//      BusinessLocalsMetaData businessLocals = smd.getBusinessLocals();
+//      if (businessLocals != null)
+//      {
+//         // For each business local
+//         for (String businessLocal : businessLocals)
+//         {
+//            // Load the Class
+//            Class<?> businessLocalClass = null;
+//            try
+//            {
+//               businessLocalClass = Class.forName(businessLocal, true, cl);
+//            }
+//            catch (ClassNotFoundException e)
+//            {
+//               throw new RuntimeException("Could not find specified business local class: " + businessLocal, e);
+//            }
+//
+//            // Obtain all methods declared by the class
+//            Method[] declaredMethods = businessLocalClass.getMethods();
+//
+//            // Add each method
+//            for (Method declaredMethod : declaredMethods)
+//            {
+//               virtualMethods.add(declaredMethod);
+//            }
+//         }
+//      }
+//
+//      // Remote Home
+//      String remoteHomeClassName = smd.getHome();
+//      if (remoteHomeClassName != null)
+//      {
+//         Class<?> remoteHomeClass = null;
+//         try
+//         {
+//            remoteHomeClass = Class.forName(remoteHomeClassName, true, cl);
+//         }
+//         catch (ClassNotFoundException e)
+//         {
+//            throw new RuntimeException("Could not find specified Remote Home Class: " + remoteHomeClassName, e);
+//         }
+//         if (remoteHomeClass != null)
+//         {
+//            Method[] declaredMethods = remoteHomeClass.getMethods();
+//            for (Method declaredMethod : declaredMethods)
+//               virtualMethods.add(declaredMethod);
+//
+//            declaredMethods = javax.ejb.EJBObject.class.getMethods();
+//            for (Method declaredMethod : declaredMethods)
+//               virtualMethods.add(declaredMethod);
+//         }
+//      }
+//
+//      // Local Home
+//      String localHomeClassName = smd.getLocalHome();
+//      if (localHomeClassName != null)
+//      {
+//         Class<?> localHomeClass = null;
+//         try
+//         {
+//            localHomeClass = Class.forName(localHomeClassName, true, cl);
+//         }
+//         catch (ClassNotFoundException e)
+//         {
+//            throw new RuntimeException("Could not find specified Local Home Class: " + localHomeClass, e);
+//         }
+//         if (localHomeClass != null)
+//         {
+//            Method[] declaredMethods = localHomeClass.getMethods();
+//            for (Method declaredMethod : declaredMethods)
+//               virtualMethods.add(declaredMethod);
+//
+//            declaredMethods = javax.ejb.EJBLocalObject.class.getMethods();
+//            for (Method declaredMethod : declaredMethods)
+//               virtualMethods.add(declaredMethod);
+//         }
+//      }
+//      
+//      log.debug("Found virtual methods: ");
+//      for(Method m : virtualMethods)
+//      {
+//         log.debug("\t" + m + " - " + MethodHashing.calculateHash(m));
+//      }
+//      
+//
+//      return virtualMethods;
+//   }
+   
+   /*
+   protected void createMethodMap()
+   {
+      super.createMethodMap();
+      try
+      {
+         RemoteHome home = (RemoteHome) resolveAnnotation(RemoteHome.class);
+         if (home != null)
+         {
+            Method[] declaredMethods = home.value().getMethods();
+            for (int i = 0; i < declaredMethods.length; i++)
+            {
+               long hash = MethodHashing.methodHash(declaredMethods[i]);
+               advisedMethods.put(hash, declaredMethods[i]);
+            }
+
+            declaredMethods = javax.ejb.EJBObject.class.getMethods();
+            for (int i = 0; i < declaredMethods.length; i++)
+            {
+               long hash = MethodHashing.methodHash(declaredMethods[i]);
+               advisedMethods.put(hash, declaredMethods[i]);
+            }
+         }
+
+         LocalHome localHome = (LocalHome) resolveAnnotation(LocalHome.class);
+         if (localHome != null)
+         {
+            Method[] declaredMethods = localHome.value().getMethods();
+            for (int i = 0; i < declaredMethods.length; i++)
+            {
+               long hash = MethodHashing.methodHash(declaredMethods[i]);
+               advisedMethods.put(hash, declaredMethods[i]);
+            }
+
+            declaredMethods = javax.ejb.EJBLocalObject.class.getMethods();
+            for (int i = 0; i < declaredMethods.length; i++)
+            {
+               long hash = MethodHashing.methodHash(declaredMethods[i]);
+               advisedMethods.put(hash, declaredMethods[i]);
+            }
+         }
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+   */
+
+   public static InvocationResponse marshallException(Invocation invocation, Throwable exception, Map responseContext) throws Throwable
+   {
+      if (invocation.getMetaData(IsLocalInterceptor.IS_LOCAL,IsLocalInterceptor.IS_LOCAL) == null) throw exception;
+
+      InvocationResponse response = new InvocationResponse();
+      response.setContextInfo(responseContext);
+
+      response.addAttachment(IsLocalInterceptor.IS_LOCAL_EXCEPTION, new MarshalledObjectForLocalCalls(exception));
+
+      return response;
+   }
+
+   public static InvocationResponse marshallResponse(Invocation invocation, Object rtn, Map responseContext)
+           throws java.io.IOException
+   {
+      InvocationResponse response;
+      // marshall return value
+      if (rtn != null && invocation.getMetaData(IsLocalInterceptor.IS_LOCAL, IsLocalInterceptor.IS_LOCAL) != null)
+      {
+         response = new InvocationResponse(new MarshalledObjectForLocalCalls(rtn));
+      }
+      else
+      {
+         response = new InvocationResponse(rtn);
+      }
+      response.setContextInfo(responseContext);
+      return response;
+   }
+   
+   /**
+    * Invoke a method on the virtual EJB bean. The method must be one of the methods defined in one
+    * of the business interfaces (or home interface) of the bean.
+    * 
+    * TODO: work in progress
+    * 
+    * @param factory    the originating end point
+    * @param id         unique identifier (primary key), can be null for stateless
+    * @param method     the business or home method to invoke
+    * @param args       the arguments for the method
+    * @param provider   for asynchronous usage
+    * @deprecated Use "invoke" as defined by InvokableContext
+    */
+   @Deprecated
+   public Object invoke(SessionProxyFactory factory, Object id, Method method, Object args[], FutureHolder provider) throws Throwable
+   {
+      ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
+      pushEnc();
+      try
+      {
+         long hash = MethodHashing.calculateHash(method);
+         MethodInfo info = getAdvisor().getMethodInfo(hash);
+         if (info == null)
+         {
+            throw new RuntimeException(
+                    "Could not resolve beanClass method from proxy call: "
+                            + method.toString());
+         }
+
+         
+         // Handled now by SessionSpecContainer
+         //Method unadvisedMethod = info.getUnadvisedMethod();
+//         if (unadvisedMethod != null && isHomeMethod(unadvisedMethod))
+//         {
+//            return invokeHomeMethod(factory, info, args);
+//         }
+//         else if (unadvisedMethod != null && isEJBObjectMethod(unadvisedMethod))
+//         {
+//            return invokeEJBObjectMethod(factory, id, info, args);
+//         }
+
+         // FIXME: Ahem, stateful container invocation works on all.... (violating contract though)
+         StatefulContainerInvocation nextInvocation = new StatefulContainerInvocation(info, id);
+         //StatefulSessionContainerMethodInvocation nextInvocation = new StatefulSessionContainerMethodInvocation(info,null);
+         //EJBContainerInvocation nextInvocation = new StatefulContainerInvocation(info, id);
+         nextInvocation.setAdvisor(getAdvisor());
+         nextInvocation.setArguments(args);
+         
+         // allow a container to supplement information into an invocation
+         nextInvocation = populateInvocation(nextInvocation);
+
+         ProxyUtils.addLocalAsynchronousInfo(nextInvocation, provider);
+         return nextInvocation.invokeNext();
+      }
+      finally
+      {
+         Thread.currentThread().setContextClassLoader(oldLoader);
+         popEnc();
+      }
+   }
+   
+   /**
+    * Create session to an EJB bean.
+    * 
+    * @param initParameterTypes     the parameter types used by the home's create method
+    * @param initParameterValues    the arguments for the home's create method
+    * @return   the identifier of the session
+    */
+   abstract public Serializable createSession(Class<?> initParameterTypes[], Object initParameterValues[]);
+   
+   abstract public Object localInvoke(Object id, Method method, Object[] args, FutureHolder provider) throws Throwable;
+   
+   abstract public Object localHomeInvoke(Method method, Object[] args) throws Throwable;
+   
+   public Serializable createSession()
+   {
+      return createSession(new Class<?>[]{}, new Object[]{});
+   }
+   
+   /**
+    * Destroy a created session.
+    * 
+    * @param id     the identifier of the session
+    */
+   protected void destroySession(Object id)
+   {
+      throw new RuntimeException("NYI");
+   }
+   
+   /**
+    * Checks if this session bean binds to the given JNDI name.
+    */
+   @Override
+   public boolean hasJNDIBinding(String jndiName)
+   {
+      return proxyDeployer.hasJNDIBinding(jndiName);
+   }
+   
+   protected Object invokeEJBObjectMethod(Object id, MethodInfo info, Object args[]) throws Exception
+   {
+      Method unadvisedMethod = info.getUnadvisedMethod();
+      if(unadvisedMethod.getName().equals("getEJBHome"))
+      {
+         return this.getInitialContext().lookup(this.getMetaData().getHomeJndiName());
+      }
+      if(unadvisedMethod.getName().equals("getPrimaryKey"))
+      {
+         return id;
+      }
+      if(unadvisedMethod.getName().equals("isIdentical"))
+      {
+         // object has no identity
+         if(id == null)
+            return false;
+         
+         EJBObject bean = (EJBObject) args[0];
+
+         Object primaryKey = bean.getPrimaryKey();
+         if(primaryKey == null)
+            return false;
+
+         boolean isIdentical = id.equals(primaryKey);
+
+         return isIdentical;
+      }
+      if (unadvisedMethod.getName().equals("remove"))
+      {
+         try
+         {
+            destroySession(id);
+         }
+         catch(NoSuchEJBException nsee)
+         {
+            String invokingClassName = unadvisedMethod.getDeclaringClass().getName();
+            Exception newException = (Exception) this.constructProperNoSuchEjbException(nsee, invokingClassName);
+            throw newException;
+         }
+
+         return null;
+      }
+      throw new RuntimeException("NYI");
+   }
+   
+   /**
+    * Obtains the proper Exception to return to the caller in 
+    * the event a "remove" call is made on a bean that doesn't exist.
+    * 
+    * Implements EJB 3.0 Core Specification 14.3.9
+    * 
+    * @param original
+    * @param invokingClassName
+    * @return
+    */
+   protected Throwable constructProperNoSuchEjbException(NoSuchEJBException original,String invokingClassName)
+   {
+      /*
+       * EJB 3.0 Core Specification 14.3.9
+       * 
+       * If a client makes a call to a stateful session or entity 
+       * object that has been removed, the container should throw the 
+       * javax.ejb.NoSuchEJBException. If the EJB 2.1 client view is used, 
+       * the container should throw the java.rmi.NoSuchObjectException 
+       * (which is a subclass of java.rmi.RemoteException) to a remote client, 
+       * or the javax.ejb.NoSuchObjectLocalException to a local client.
+       */
+      
+      // Initialize
+      Throwable t = original;
+      ClassLoader cl = this.getClassloader();
+      
+      // Obtain the actual invoked class
+      Class<?> actualInvokingClass = null;
+      try
+      {
+         actualInvokingClass = Class.forName(invokingClassName, true, cl);
+      }
+      catch (ClassNotFoundException e)
+      {
+         throw new RuntimeException("Could not obtain invoking class", e);
+      }
+
+      // If local EJB2.x Client
+      if (EJBLocalObject.class.isAssignableFrom(actualInvokingClass)
+            || EJBLocalHome.class.isAssignableFrom(actualInvokingClass))
+      {
+         t = new NoSuchObjectLocalException(original.getMessage());
+      }
+      // If remote EJB2.x Client
+      else if (Remote.class.isAssignableFrom(actualInvokingClass)
+            || EJBObject.class.isAssignableFrom(actualInvokingClass)
+            || EJBHome.class.isAssignableFrom(actualInvokingClass))
+      {
+         t = new NoSuchObjectException(original.getMessage());
+      }
+      // Business interface
+      else
+      {
+         // Take no action, this is here just for readability
+      }
+
+      // Log
+      if (log.isTraceEnabled())
+      {
+         log.trace("Throwing " + t.getClass().getName(), t);
+      }
+
+      // Return
+      return t;
+   }
+   
+   /**
+    * Allow a container sub class to supplement an invocation. Per default nothing to supplement.
+    * 
+    * @param invocation
+    * @return
+    */
+   protected StatefulContainerInvocation populateInvocation(
+         StatefulContainerInvocation invocation)
+   {
+      return invocation;
+   }
+   
+   abstract protected void removeHandle(Handle handle) throws Exception;
+}

Deleted: projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java	2008-08-25 02:13:51 UTC (rev 77394)
+++ projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java	2008-08-25 05:28:04 UTC (rev 77405)
@@ -1,1481 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, 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.stateful;
-
-import java.io.Serializable;
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.rmi.NoSuchObjectException;
-import java.rmi.Remote;
-import java.rmi.RemoteException;
-import java.util.Hashtable;
-import java.util.Map;
-
-import javax.ejb.EJBHome;
-import javax.ejb.EJBLocalHome;
-import javax.ejb.EJBLocalObject;
-import javax.ejb.EJBObject;
-import javax.ejb.Handle;
-import javax.ejb.Init;
-import javax.ejb.NoSuchEJBException;
-import javax.ejb.NoSuchObjectLocalException;
-import javax.ejb.PostActivate;
-import javax.ejb.PrePassivate;
-import javax.ejb.RemoteHome;
-import javax.ejb.RemoveException;
-import javax.ejb.TimerService;
-
-import org.jboss.aop.Advisor;
-import org.jboss.aop.Domain;
-import org.jboss.aop.MethodInfo;
-import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.aop.joinpoint.InvocationResponse;
-import org.jboss.aop.util.MethodHashing;
-import org.jboss.aop.util.PayloadKey;
-import org.jboss.aspects.asynch.FutureHolder;
-import org.jboss.ejb3.BeanContext;
-import org.jboss.ejb3.EJBContainerInvocation;
-import org.jboss.ejb3.Ejb3Deployment;
-import org.jboss.ejb3.annotation.Cache;
-import org.jboss.ejb3.annotation.CacheConfig;
-import org.jboss.ejb3.annotation.Clustered;
-import org.jboss.ejb3.annotation.LocalBinding;
-import org.jboss.ejb3.annotation.RemoteBinding;
-import org.jboss.ejb3.annotation.RemoteBindings;
-import org.jboss.ejb3.cache.CacheFactoryRegistry;
-import org.jboss.ejb3.cache.Ejb3CacheFactory;
-import org.jboss.ejb3.cache.StatefulCache;
-import org.jboss.ejb3.cache.StatefulObjectFactory;
-import org.jboss.ejb3.common.lang.SerializableMethod;
-import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
-import org.jboss.ejb3.interceptors.container.StatefulSessionContainerMethodInvocation;
-import org.jboss.ejb3.proxy.ProxyFactory;
-import org.jboss.ejb3.proxy.ProxyUtils;
-import org.jboss.ejb3.proxy.container.StatefulSessionInvokableContext;
-import org.jboss.ejb3.proxy.factory.ProxyFactoryHelper;
-import org.jboss.ejb3.proxy.factory.session.stateful.StatefulSessionProxyFactory;
-import org.jboss.ejb3.proxy.factory.stateful.BaseStatefulRemoteProxyFactory;
-import org.jboss.ejb3.proxy.factory.stateful.StatefulClusterProxyFactory;
-import org.jboss.ejb3.proxy.factory.stateful.StatefulLocalProxyFactory;
-import org.jboss.ejb3.proxy.factory.stateful.StatefulRemoteProxyFactory;
-import org.jboss.ejb3.proxy.impl.EJBMetaDataImpl;
-import org.jboss.ejb3.proxy.impl.HomeHandleImpl;
-import org.jboss.ejb3.proxy.jndiregistrar.JndiSessionRegistrarBase;
-import org.jboss.ejb3.proxy.jndiregistrar.JndiStatefulSessionRegistrar;
-import org.jboss.ejb3.proxy.objectstore.ObjectStoreBindings;
-import org.jboss.ejb3.proxy.remoting.SessionSpecRemotingMetadata;
-import org.jboss.ejb3.proxy.remoting.StatefulSessionRemotingMetadata;
-import org.jboss.ejb3.session.Ejb2xMethodNames;
-import org.jboss.ejb3.session.SessionContainer;
-import org.jboss.ejb3.session.SessionSpecContainer;
-import org.jboss.injection.Injector;
-import org.jboss.injection.JndiPropertyInjector;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
-import org.jboss.util.NotImplementedException;
-
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class StatefulContainer extends SessionSpecContainer
-      implements
-         StatefulObjectFactory<StatefulBeanContext>,
-         StatefulSessionInvokableContext
-{
-   private static final Logger log = Logger.getLogger(StatefulContainer.class);
-
-   protected StatefulCache cache;
-   private StatefulDelegateWrapper mbean = new StatefulDelegateWrapper(this);
-
-   public StatefulContainer(ClassLoader cl, String beanClassName, String ejbName, Domain domain,
-                            Hashtable ctxProperties, Ejb3Deployment deployment, JBossSessionBeanMetaData beanMetaData) throws ClassNotFoundException
-   {
-      super(cl, beanClassName, ejbName, domain, ctxProperties, deployment, beanMetaData);
-   }
-
-   public StatefulBeanContext create(Class<?>[] initTypes, Object[] initValues)
-   {
-      StatefulBeanContext sfctx = (StatefulBeanContext) createBeanContext();
-      // Tell context how to handle replication
-      CacheConfig config = getAnnotation(CacheConfig.class);
-      if (config != null)
-      {
-         sfctx.setReplicationIsPassivation(config.replicationIsPassivation());
-      }
-
-      // this is for propagated extended PC's
-      sfctx = sfctx.pushContainedIn();
-      
-      pushContext(sfctx);
-      try
-      {
-         if (injectors != null)
-         {
-            for (Injector injector : injectors)
-            {
-               injector.inject(sfctx);
-            }
-         }
-
-         sfctx.initialiseInterceptorInstances();
-
-      }
-      finally
-      {
-         popContext();
-         // this is for propagated extended PC's
-         sfctx.popContainedIn();
-      }
-      
-      invokePostConstruct(sfctx, initValues);
-      
-      //TODO This needs to be reimplemented as replacement for create() on home interface
-      invokeInit(sfctx.getInstance(), initTypes, initValues);
-      
-      return sfctx;
-   }
-   
-   @Override
-   public BeanContext<?> createBeanContext()
-   {
-      return new StatefulBeanContext(this, construct());
-   }
-   
-   @Override
-   protected StatefulLocalProxyFactory getProxyFactory(LocalBinding binding)
-   {
-      StatefulLocalProxyFactory factory = (StatefulLocalProxyFactory) this.proxyDeployer.getProxyFactory(binding);
-
-      if (factory == null)
-      {
-         factory = new StatefulLocalProxyFactory(this, binding);
-
-         try
-         {
-            factory.init();
-         }
-         catch (Exception e)
-         {
-            throw new RuntimeException(e);
-         }
-      }
-      
-      return factory;
-   }
-   
-   public Object createProxyLocalEjb21(Object id, LocalBinding binding, String businessInterfaceType) throws Exception
-   {
-      StatefulLocalProxyFactory proxyFactory = this.getProxyFactory(binding);
-      return proxyFactory.createProxyEjb21(id,businessInterfaceType);
-   }
-   
-   public Object createProxyRemoteEjb21(Object id, String businessInterfaceType) throws Exception
-   {
-      RemoteBinding binding = this.getRemoteBinding();
-      return this.createProxyRemoteEjb21(id,binding, businessInterfaceType);
-   }
-
-   public Object createProxyRemoteEjb21(Object id, RemoteBinding binding, String businessInterfaceType) throws Exception
-   { 
-      BaseStatefulRemoteProxyFactory proxyFactory = this.getProxyFactory(binding);
-      return proxyFactory.createProxyEjb21(id, businessInterfaceType);
-   }
-   
-   public Object createProxyLocalEjb21(Object id, String businessInterfaceType) throws Exception
-   {
-      LocalBinding binding = this.getAnnotation(LocalBinding.class);
-      return this.createProxyLocalEjb21(id,binding, businessInterfaceType);
-   }
-   
-   @Override
-   public Object createProxyLocalEjb21(LocalBinding binding, String businessInterfaceType) throws Exception
-   {
-      Object id = this.createSession();
-      return this.createProxyLocalEjb21(id,binding, businessInterfaceType);
-   }
-
-   @Override
-   public Object createProxyRemoteEjb21(RemoteBinding binding, String businessInterfaceType) throws Exception
-   {
-      Object id = this.createSession();
-      return this.createProxyRemoteEjb21(id, binding, businessInterfaceType);
-   }
-   
-   @Override
-   protected BaseStatefulRemoteProxyFactory getProxyFactory(RemoteBinding binding)
-   {
-      BaseStatefulRemoteProxyFactory factory = (BaseStatefulRemoteProxyFactory) this.proxyDeployer
-            .getProxyFactory(binding);
-
-      if (factory == null)
-      {
-
-         Clustered clustered = getAnnotation(Clustered.class);
-         if (clustered != null)
-         {
-            factory = new StatefulClusterProxyFactory(this, binding, clustered);
-         }
-         else
-         {
-            factory = new StatefulRemoteProxyFactory(this, binding);
-         }
-         
-         try
-         {
-            factory.init();
-         }
-         catch(Exception e)
-         {
-            throw new RuntimeException(e);
-         }
-      }
-
-      return factory;
-   }
-   
-   public void destroy(StatefulBeanContext ctx)
-   {
-      try
-      {
-         invokePreDestroy(ctx);
-      }
-      finally
-      {
-         ctx.remove();
-      }
-   }
-   
-   public Object getMBean()
-   {
-      return mbean;
-   }
-   
-   /**
-    * Creates and starts the configured cache, if not
-    * started already
-    * 
-    * @throws Exception
-    */
-   protected void createAndStartCache() throws Exception {
-      
-      // If Cache is initialized, exit
-      if(this.cache!=null && this.cache.isStarted())
-      {
-         return;
-      }
-      
-      Cache cacheConfig = getAnnotation(Cache.class);
-      CacheFactoryRegistry registry = getCacheFactoryRegistry();
-      Ejb3CacheFactory factory = registry.getCacheFactory(cacheConfig.value());
-      this.cache = factory.createCache();
-      this.cache.initialize(this);
-      this.cache.start();
-   }
-   
-   @Override
-   protected void lockedStart() throws Exception
-   {
-      try
-      {
-         super.lockedStart();
-         this.createAndStartCache();
-      }
-      catch (Exception e)
-      {
-         try
-         {
-            this.lockedStop();
-         }
-         catch (Exception ignore)
-         {
-            log.debug("Failed to cleanup after start() failure", ignore);
-         }
-         throw e;
-      }
-
-   }
-
-   @Override
-   protected void lockedStop() throws Exception
-   {
-      if (cache != null) cache.stop();
-      
-      super.lockedStop();
-   }
-
-   public StatefulCache getCache()
-   {
-      // Ensure initialized
-      try{
-         this.createAndStartCache();
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException(e);
-      }
-      
-      // Return
-      return cache;
-   }
-   
-   public CacheFactoryRegistry getCacheFactoryRegistry()
-   {
-      return this.getDeployment().getCacheFactoryRegistry();
-   }
-   
-   /**
-    * Returns the name under which the JNDI Registrar for this container is bound
-    * 
-    * @return
-    */
-   protected String getJndiRegistrarBindName()
-   {
-      return ObjectStoreBindings.OBJECTSTORE_BEAN_NAME_JNDI_REGISTRAR_SFSB;
-   }
-
-   /**
-    * Performs a synchronous local invocation
-    */
-   public Object localInvoke(Object id, Method method, Object[] args)
-           throws Throwable
-   {
-      return localInvoke(id, method, args, null);
-   }
-
-   /**
-    * Performs a synchronous or asynchronous local invocation
-    *
-    */
-   public Object localHomeInvoke(Method method, Object[] args) throws Throwable
-   {
-      ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
-      pushEnc();
-      try
-      {
-         long hash = MethodHashing.calculateHash(method);
-         MethodInfo info = getAdvisor().getMethodInfo(hash);
-         if (info == null)
-         {
-            throw new RuntimeException(
-                    "Could not resolve beanClass method from proxy call: "
-                            + method.toString());
-         }
-         return invokeLocalHomeMethod(info, args);
-      }
-      finally
-      {
-         Thread.currentThread().setContextClassLoader(oldLoader);
-         popEnc();
-      }
-   }
-
-   /**
-    * Performs a synchronous or asynchronous local invocation
-    *
-    * @param provider If null a synchronous invocation, otherwise an asynchronous
-    */
-   public Object localInvoke(Object id, Method method, Object[] args,
-         FutureHolder provider) throws Throwable
-   {
-      long start = System.currentTimeMillis();
-
-      ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
-      pushEnc();
-      try
-      {
-         long hash = MethodHashing.calculateHash(method);
-         MethodInfo info = getAdvisor().getMethodInfo(hash);
-         if (info == null)
-         {
-            throw new RuntimeException(
-                  "Could not resolve beanClass method from proxy call: "
-                  + method.toString());
-         }
-      
-         Method unadvisedMethod = info.getUnadvisedMethod();
-      
-         try
-         {
-            invokeStats.callIn();
-      
-            if (unadvisedMethod != null && isHomeMethod(unadvisedMethod))
-            {
-               return invokeLocalHomeMethod(info, args);
-            }
-            else if (unadvisedMethod != null
-                  && isEJBObjectMethod(unadvisedMethod))
-            {
-               return invokeEJBLocalObjectMethod(id, info, args);
-            }
-            
-            SerializableMethod invoked = new SerializableMethod(method, method.getClass());
-            
-            //StatefulContainerInvocation nextInvocation = new StatefulContainerInvocation(info, id);
-            StatefulSessionContainerMethodInvocation nextInvocation = new StatefulSessionContainerMethodInvocation(info);
-            nextInvocation.setSessionId(id);
-            nextInvocation.setAdvisor(getAdvisor());
-            nextInvocation.setArguments(args);
-            
-            ProxyUtils.addLocalAsynchronousInfo(nextInvocation, provider);
-            
-            //invokedMethod.push(invoked);
-            return nextInvocation.invokeNext();
-         }
-         finally
-         {
-            if (unadvisedMethod != null)
-            {
-               long end = System.currentTimeMillis();
-               long elapsed = end - start;
-               invokeStats.updateStats(unadvisedMethod, elapsed);
-            }
-         
-            invokeStats.callOut();
-            
-            //invokedMethod.pop();
-         }
-      }
-      finally
-      {
-         Thread.currentThread().setContextClassLoader(oldLoader);
-         popEnc();
-      }
-   }
-   
-   /**
-    * Create a stateful bean and return its oid.
-    *
-    * @return
-    */
-   public Serializable createSession(Class<?>[] initTypes, Object[] initValues)
-   {
-      ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
-      pushEnc();
-      try
-      {
-         Thread.currentThread().setContextClassLoader(classloader);
-         StatefulCache cache = this.getCache();
-         StatefulBeanContext ctx = cache.create(initTypes, initValues);
-         // Since we return the key here, the context is not in use.
-         cache.release(ctx);
-         Object id = ctx.getId();
-         assert id instanceof Serializable : "SFSB Session IDs must be " + Serializable.class.getSimpleName();
-         return (Serializable) id;
-      }
-      finally
-      {
-         Thread.currentThread().setContextClassLoader(oldLoader);
-         popEnc();
-      }
-   }
-
-   protected void destroySession(Object id)
-   {
-      getCache().remove(id);
-   }
-   
-   /**
-    * Remote Invocation entry point, as delegated from
-    * ClassProxyHack (Remoting Dispatcher)
-    */
-   //TODO
-   public InvocationResponse dynamicInvoke(Invocation invocation) throws Throwable
-   {
-      /*
-       * Initialize
-       */
-
-      // Mark the start time
-      long start = System.currentTimeMillis();
-
-      // Create a pointer to a new Invocation
-      StatefulContainerInvocation newSi = null;
-
-      // Create a pointer to the response we'll return
-      InvocationResponse response = null;
-
-      // Create a pointer to the Session ID
-      Serializable sessionId = null;
-
-      /*
-       * Setup Environment (Stack/Thread)
-       */
-
-      // Hold a reference to the existing TCL
-      ClassLoader originalLoader = Thread.currentThread().getContextClassLoader();
-
-      // Set the Container's CL as TCL, required to unmarshall methods from the bean impl class
-      Thread.currentThread().setContextClassLoader(this.getClassloader());
-
-      // Push the ENC onto the stack
-      pushEnc();
-
-      try
-      {
-
-         /*
-          * Obtain the target method (unmarshall from invocation)
-          */
-
-         // Cast
-         assert invocation instanceof StatefulRemoteInvocation : SessionContainer.class.getName()
-               + ".dynamicInoke supports only " + StatefulRemoteInvocation.class.getSimpleName()
-               + ", but has been passed: " + invocation;
-         StatefulRemoteInvocation si = (StatefulRemoteInvocation) invocation;
-
-         // Get the method hash
-         long methodHash = si.getMethodHash();
-         log.debug("Received dynamic invocation for method with hash: " + methodHash);
-
-         // Get the Method via MethodInfo from the Advisor
-         Advisor advisor = this.getAdvisor();
-         MethodInfo info = advisor.getMethodInfo(methodHash);
-         Method unadvisedMethod = info.getMethod();
-         SerializableMethod unadvisedMethodSerializable = new SerializableMethod(unadvisedMethod);
-         
-         // Get the invoked method from invocation metadata
-         Object objInvokedMethod = si.getMetaData(SessionSpecRemotingMetadata.TAG_SESSION_INVOCATION,
-               SessionSpecRemotingMetadata.KEY_INVOKED_METHOD);
-         assert objInvokedMethod != null : "Invoked Method must be set on invocation metadata";
-         assert objInvokedMethod instanceof SerializableMethod : "Invoked Method set on invocation metadata is not of type "
-               + SerializableMethod.class.getName() + ", instead: " + objInvokedMethod;
-         SerializableMethod invokedMethod = (SerializableMethod) objInvokedMethod;
-         
-         /*
-          * Set the invoked method
-          */
-         //TODO Remove when CurrentInvocation is ironed out
-         
-         // Set onto stack
-         SessionSpecContainer.invokedMethod.push(invokedMethod);
-
-         try
-         {
-
-            // Increment invocation statistics
-            invokeStats.callIn();
-
-            /*
-             * Obtain Session ID
-             */
-
-            // Obtain the Session ID
-            Object objSessionId = si.getMetaData(StatefulSessionRemotingMetadata.TAG_SFSB_INVOCATION,
-                  StatefulSessionRemotingMetadata.KEY_SESSION_ID);
-            if (objSessionId != null)
-            {
-               assert objSessionId instanceof Serializable : "Session IDs must be "
-                     + Serializable.class.getSimpleName();
-               sessionId = (Serializable) objSessionId;
-            }
-
-            if (info != null && unadvisedMethod != null && isHomeMethod(unadvisedMethodSerializable))
-            {
-               response = invokeHomeMethod(info, si);
-            }
-            else if (info != null && unadvisedMethod != null && isEjbObjectMethod(unadvisedMethodSerializable))
-            {
-               response = invokeEJBObjectMethod(invokedMethod, si);
-            }
-            else
-            {
-               if (unadvisedMethod.isBridge())
-               {
-                  unadvisedMethod = this.getNonBridgeMethod(unadvisedMethod);
-                  info = super.getMethodInfo(unadvisedMethod);
-               }
-
-               if (sessionId == null)
-               {
-                  StatefulBeanContext ctx = getCache().create(null, null);
-                  Object objNewId = ctx.getId();
-                  assert objNewId instanceof Serializable : "Obtained new Session ID from cache, " + objNewId
-                        + ", which is not " + Serializable.class.getSimpleName();
-                  sessionId = (Serializable) objNewId;
-               }
-               
-               /*
-                * Build a new Invocation
-                */
-
-               // Construct the invocation
-               newSi = new StatefulContainerInvocation(info, sessionId);
-               //newSi = new StatefulContainerInvocation(info.getInterceptors(), long methodHash, Method advisedMethod, Method unadvisedMethod, Advisor advisor, Object id);
-               newSi.setArguments(si.getArguments());
-               newSi.setMetaData(si.getMetaData());
-               newSi.getMetaData().addMetaData(SessionSpecRemotingMetadata.TAG_SESSION_INVOCATION,
-                     SessionSpecRemotingMetadata.KEY_INVOKED_METHOD, invokedMethod, PayloadKey.AS_IS);
-               
-               //newSi.setAdvisor(getAdvisor());
-               
-               /*
-                * Ensure ID exists (useful for catching problems while we have context as
-                * to the caller, whereas in Interceptors we do not)
-                */
-               try
-               {
-                  this.getCache().get(sessionId);
-               }
-               catch(NoSuchEJBException nsee)
-               {
-                  throw this.constructProperNoSuchEjbException(nsee, invokedMethod.getActualClassName()); 
-               }
-
-               /*
-                * Perform Invocation
-                */
-               
-               // Create an object to hold the return value
-               Object returnValue = null;
-
-               // Invoke
-               returnValue = newSi.invokeNext();
-
-               // Marshall the response
-               response = marshallResponse(invocation, returnValue, newSi.getResponseContextInfo());
-               if (sessionId != null)
-               {
-                  response.addAttachment(StatefulConstants.NEW_ID, sessionId);
-               }
-               
-//               response = marshallResponse(invocation, rtn, newSi.getResponseContextInfo());
-//               if (newId != null) response.addAttachment(StatefulConstants.NEW_ID, newId);
-               
-               // Create a Response
-//             response = new InvocationResponse(returnValue);
-//             Map<Object, Object> responseContext = newSi.getResponseContextInfo();
-//             response.setContextInfo(responseContext);
-            }
-         }
-         catch (Throwable t)
-         {
-            Throwable exception = t;
-//            if (sessionId != null)
-//            {
-//               exception = new ForwardId(t, sessionId);
-//            }
-            Map<Object, Object> responseContext = null;
-            if (newSi != null)
-            {
-               responseContext = newSi.getResponseContextInfo();
-            }
-            response = marshallException(invocation, exception, responseContext);
-            return response;
-         }
-         finally
-         {
-            /*
-             * Update Invocation Statistics
-             */
-            if (unadvisedMethod != null)
-            {
-               // Mark end time
-               long end = System.currentTimeMillis();
-
-               // Calculate elapsed time
-               long elapsed = end - start;
-
-               // Update statistics with elapsed time
-               invokeStats.updateStats(unadvisedMethod, elapsed);
-            }
-
-            // Complete call to increment statistics
-            invokeStats.callOut();
-
-         }
-
-         // Return
-         return response;
-      }
-      finally
-      {
-         
-         // Pop invoked method off the stack
-         //TODO Remove when CurrentInvocation handles this
-         SessionSpecContainer.invokedMethod.pop();
-         
-         // Reset the TCL to original
-         Thread.currentThread().setContextClassLoader(originalLoader);
-
-         // Pop the ENC off the stack
-         this.popEnc();
-      }
-   }
-   
-   @Deprecated
-   public InvocationResponse dynamicInvoke(Object target, Invocation invocation) throws Throwable
-   {
-      throw new NotImplementedException("Should be using dynamicInvoke(Invocation invocation)");
-   }
-//   /**
-//    * This should be a remote invocation call
-//    *
-//    * @param invocation
-//    * @return
-//    * @throws Throwable
-//    * @deprecated Use dynamicInvoke(Invocation invocation)
-//    */
-//   @Deprecated
-//   public InvocationResponse dynamicInvoke(Object target, Invocation invocation) throws Throwable
-//   {
-//      long start = System.currentTimeMillis();
-//      
-//      ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
-//      EJBContainerInvocation newSi = null;
-//      pushEnc();
-//      try
-//      {
-//         Thread.currentThread().setContextClassLoader(classloader);
-//         MethodInvocation mi = (MethodInvocation)invocation;
-//         
-//         MethodInfo info = getAdvisor().getMethodInfo(mi.getMethodHash());
-//         if (info == null)
-//         {
-//            throw new RuntimeException("Could not resolve beanClass method from proxy call " + invocation);
-//         }
-//         Method unadvisedMethod = info.getUnadvisedMethod();
-//         
-//         
-//         StatefulRemoteInvocation si = (StatefulRemoteInvocation) invocation;
-//         
-//
-//         InvocationResponse response = null;
-//         
-//         Object newId = null;
-//         
-//         try
-//         {
-//            invokeStats.callIn();
-//            
-//            if (info != null && unadvisedMethod != null && isHomeMethod(unadvisedMethod))
-//            {
-//               response = invokeHomeMethod(info, si);
-//            }
-//            else if (info != null && unadvisedMethod != null && isEJBObjectMethod(unadvisedMethod))
-//            {
-//               response = invokeEJBObjectMethod(info, si);
-//            }
-//            else
-//            {
-//               if (unadvisedMethod.isBridge())
-//               {
-//                  unadvisedMethod = this.getNonBridgeMethod(unadvisedMethod);
-//                  info = super.getMethodInfo(unadvisedMethod);
-//               }
-//               
-//               if (si.getId() == null)
-//               {
-//                  StatefulBeanContext ctx = getCache().create(null, null);
-//                  newId = ctx.getId();
-//               }
-//               else
-//               {
-//                  newId = si.getId();
-//               }
-//               newSi = new StatefulContainerInvocation(info, newId);
-//               newSi.setArguments(si.getArguments());
-//               newSi.setMetaData(si.getMetaData());
-//               newSi.setAdvisor(getAdvisor());
-//   
-//               Object rtn = null;
-//                 
-//
-//               rtn = newSi.invokeNext();
-//
-//               response = marshallResponse(invocation, rtn, newSi.getResponseContextInfo());
-//               if (newId != null) response.addAttachment(StatefulConstants.NEW_ID, newId);
-//            }
-//         }
-//         catch (Throwable throwable)
-//         {
-//            Throwable exception = throwable;
-//            if (newId != null)
-//            {
-//               exception = new ForwardId(throwable, newId);
-//            }
-//            Map responseContext = null;
-//            if (newSi != null) newSi.getResponseContextInfo();
-//            response = marshallException(invocation, exception, responseContext);
-//            return response;
-//         }
-//         finally
-//         {
-//            if (unadvisedMethod != null)
-//            {
-//               long end = System.currentTimeMillis();
-//               long elapsed = end - start;
-//               invokeStats.updateStats(unadvisedMethod, elapsed);
-//            }
-//            
-//            invokeStats.callOut();
-//         }
-//
-//         return response;
-//      }
-//      finally
-//      {
-//         Thread.currentThread().setContextClassLoader(oldLoader);
-//         popEnc();
-//      }
-//   }
-
-
-   public TimerService getTimerService()
-   {
-      throw new UnsupportedOperationException("stateful bean doesn't support TimerService (EJB3 18.2#2)");
-   }
-
-   public TimerService getTimerService(Object pKey)
-   {
-      return getTimerService();
-   }
-   
-   @Override
-   public void invokePostActivate(BeanContext beanContext)
-   {
-      for (Injector injector : injectors)
-      {
-         if (injector instanceof JndiPropertyInjector)
-         {
-            AccessibleObject field = ((JndiPropertyInjector) injector).getAccessibleObject();
-            
-            if (field.isAnnotationPresent(javax.ejb.EJB.class))
-            {
-               continue; // skip nested EJB injection since the local proxy will be (de)serialized correctly
-            }
-            
-            if (field instanceof Field)
-            {
-               // reinject transient fields
-               if ((((Field)field).getModifiers() & Modifier.TRANSIENT) > 0)
-                  injector.inject(beanContext);
-            }
-         }
-      }
-      
-      this.invokeCallback(beanContext, PostActivate.class);
-   }
-
-   @Override
-   public void invokePrePassivate(BeanContext beanContext)
-   {
-      this.invokeCallback(beanContext, PrePassivate.class);
-   }
-
-   /*
-   @Override
-   protected Class[] getHandledCallbacks()
-   {
-      return new Class[]
-              {PostConstruct.class, PreDestroy.class, PostActivate.class,
-                      PrePassivate.class};
-   }
-   */
-
-   public void invokeInit(Object bean, Class[] initParameterTypes,
-                          Object[] initParameterValues)
-   {
-      int numParameters = 0;
-      if(initParameterTypes != null)
-         numParameters = initParameterTypes.length;
-      try
-      {
-         for(Method method : bean.getClass().getDeclaredMethods())
-         {
-            if(numParameters != method.getParameterTypes().length)
-               continue;
-            
-            if ((method.getAnnotation(Init.class) != null)
-                    || (resolveAnnotation(method, Init.class) != null))
-            {
-               if(initParameterTypes != null)
-               {
-                  Object[] parameters = getInitParameters(method,
-                          initParameterTypes, initParameterValues);
-   
-                  if (parameters != null)
-                     method.invoke(bean, parameters);
-               }
-               else
-               {
-                  method.invoke(bean);
-               }
-            }
-         }
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException(e);
-      }
-   }
-
-   protected Object[] getInitParameters(Method method,
-                                        Class[] initParameterTypes, Object[] initParameterValues)
-   {
-      if (method.getParameterTypes().length == initParameterTypes.length)
-      {
-         for (int i = 0; i < initParameterTypes.length; ++i)
-         {
-            Class formal = method.getParameterTypes()[i];
-            Class actual = initParameterTypes[i];
-            if (!isMethodInvocationConvertible(formal, actual == null ? null
-                    : actual))
-               return null;
-         }
-         return initParameterValues;
-      }
-      return null;
-   }
-
-   /**
-    * Determines whether a type represented by a class object is convertible to
-    * another type represented by a class object using a method invocation
-    * conversion, treating object types of primitive types as if they were
-    * primitive types (that is, a Boolean actual parameter type matches boolean
-    * primitive formal type). This behavior is because this method is used to
-    * determine applicable methods for an actual parameter list, and primitive
-    * types are represented by their object duals in reflective method calls.
-    *
-    * @param formal the formal parameter type to which the actual parameter type
-    *               should be convertible
-    * @param actual the actual parameter type.
-    * @return true if either formal type is assignable from actual type, or
-    *         formal is a primitive type and actual is its corresponding object
-    *         type or an object type of a primitive type that can be converted
-    *         to the formal type.
-    */
-   private static boolean isMethodInvocationConvertible(Class formal,
-                                                        Class actual)
-   {
-      /*
-       * if it's a null, it means the arg was null
-       */
-      if (actual == null && !formal.isPrimitive())
-      {
-         return true;
-      }
-      /*
-       * Check for identity or widening reference conversion
-       */
-      if (actual != null && formal.isAssignableFrom(actual))
-      {
-         return true;
-      }
-      /*
-       * Check for boxing with widening primitive conversion. Note that actual
-       * parameters are never primitives.
-       */
-      if (formal.isPrimitive())
-      {
-         if (formal == Boolean.TYPE && actual == Boolean.class)
-            return true;
-         if (formal == Character.TYPE && actual == Character.class)
-            return true;
-         if (formal == Byte.TYPE && actual == Byte.class)
-            return true;
-         if (formal == Short.TYPE
-                 && (actual == Short.class || actual == Byte.class))
-            return true;
-         if (formal == Integer.TYPE
-                 && (actual == Integer.class || actual == Short.class || actual == Byte.class))
-            return true;
-         if (formal == Long.TYPE
-                 && (actual == Long.class || actual == Integer.class
-                 || actual == Short.class || actual == Byte.class))
-            return true;
-         if (formal == Float.TYPE
-                 && (actual == Float.class || actual == Long.class
-                 || actual == Integer.class || actual == Short.class || actual == Byte.class))
-            return true;
-         if (formal == Double.TYPE
-                 && (actual == Double.class || actual == Float.class
-                 || actual == Long.class || actual == Integer.class
-                 || actual == Short.class || actual == Byte.class))
-            return true;
-      }
-      return false;
-   }
-
-   private Object invokeEJBLocalObjectMethod(Object id, MethodInfo info,
-                                             Object[] args) throws Exception
-   {
-      Method unadvisedMethod = info.getUnadvisedMethod();
-      if (unadvisedMethod.getName().equals("remove"))
-      {
-         try
-         {
-            destroySession(id);
-         }
-         catch(NoSuchEJBException e)
-         {
-            throw new NoSuchObjectLocalException(e.getMessage(), e);
-         }
-
-         return null;
-      }
-      else if (unadvisedMethod.getName().equals("getEJBLocalHome"))
-      {
-         Object bean = getCache().get(id).getInstance();
-
-         return bean;
-      }
-      else if (unadvisedMethod.getName().equals("getPrimaryKey"))
-      {
-         return id;
-      }
-      else if (unadvisedMethod.getName().equals("isIdentical"))
-      {
-         EJBObject bean = (EJBObject) args[0];
-
-         Object primaryKey = bean.getPrimaryKey();
-
-         boolean isIdentical = id.equals(primaryKey);
-
-         return isIdentical;
-      }
-      else
-      {
-         return null;
-      }
-   }
-
-   private Object invokeLocalHomeMethod(MethodInfo info, Object[] args)
-           throws Exception
-   {
-      Method unadvisedMethod = info.getUnadvisedMethod();
-      if (unadvisedMethod.getName().startsWith("create"))
-      {
-         Class<?>[] initParameterTypes =
-                 {};
-         Object[] initParameterValues =
-                 {};
-         if (unadvisedMethod.getParameterTypes().length > 0)
-         {
-            initParameterTypes = unadvisedMethod.getParameterTypes();
-            initParameterValues = args;
-         }
-
-         LocalBinding binding = this.getAnnotation(LocalBinding.class);
-
-         StatefulLocalProxyFactory factory = new StatefulLocalProxyFactory(this, binding);
-         factory.init();
-
-         Object proxy = factory.createProxyEjb21(initParameterTypes,
-                 initParameterValues, unadvisedMethod.getReturnType().getName());
-
-         return proxy;
-      }
-      else if (unadvisedMethod.getName().equals("remove"))
-      {
-         remove(args[0]);
-
-         return null;
-      }
-      else
-      {
-         return null;
-      }
-   }
-   
-   public Object createLocalProxy(Object id) throws Exception
-   {
-      return this.createLocalProxy(id, this.getAnnotation(LocalBinding.class));
-   }
-   
-   public Object createLocalProxy(Object id, LocalBinding binding) throws Exception
-   {
-      StatefulLocalProxyFactory factory = new StatefulLocalProxyFactory(this, binding);
-      factory.init();
-
-      return factory.createProxyBusiness(id);
-   }
-   
-   public Object createRemoteProxy(Object id, RemoteBinding binding) throws Exception
-   {
-      StatefulRemoteProxyFactory factory = new StatefulRemoteProxyFactory(this, binding);
-      factory.init();
-
-      if (id != null)
-         return factory.createProxyBusiness(id,null);
-      else
-         return factory.createProxyBusiness();
-   }
-   
-   public boolean isClustered()
-   {
-      return isAnnotationPresent(Clustered.class);
-   }
-
-   protected InvocationResponse invokeHomeMethod(MethodInfo info,
-         StatefulRemoteInvocation statefulInvocation) throws Throwable
-   {
-      Method unadvisedMethod = info.getUnadvisedMethod();
-      if (unadvisedMethod.getName().startsWith("create"))
-      {
-         Class<?>[] initParameterTypes =
-                 {};
-         Object[] initParameterValues =
-                 {};
-         if (unadvisedMethod.getParameterTypes().length > 0)
-         {
-            initParameterTypes = unadvisedMethod.getParameterTypes();
-            initParameterValues = statefulInvocation.getArguments();
-         }
-
-         StatefulSessionContainerMethodInvocation newStatefulInvocation = buildNewInvocation(
-                 info, statefulInvocation, initParameterTypes,
-                 initParameterValues);
-
-         // Get JNDI Registrar
-         JndiSessionRegistrarBase sfsbJndiRegistrar = this.getJndiRegistrar();
-         
-         // Determine if local/remote
-         boolean isLocal = EJBLocalObject.class.isAssignableFrom(unadvisedMethod.getDeclaringClass());
-         
-         // Find the Proxy Factory Key for this SFSB
-         String proxyFactoryKey = sfsbJndiRegistrar.getProxyFactoryRegistryKey(this.getMetaData(), isLocal);
-
-         // Lookup the Proxy Factory in the Object Store
-         StatefulSessionProxyFactory proxyFactory = Ejb3RegistrarLocator.locateRegistrar().lookup(proxyFactoryKey,
-               StatefulSessionProxyFactory.class);
-         
-         // Create a new EJB2.x Proxy
-         Object proxy = proxyFactory.createProxyEjb2x((Serializable)newStatefulInvocation.getSessionId());
-         
-         InvocationResponse response = marshallResponse(statefulInvocation, proxy, newStatefulInvocation.getResponseContextInfo());
-         if (newStatefulInvocation.getSessionId() != null)
-            response.addAttachment(StatefulConstants.NEW_ID,
-                    newStatefulInvocation.getSessionId());
-         return response;
-      }
-      else if (unadvisedMethod.getName().equals("remove"))
-      {
-         Object argument = statefulInvocation.getArguments()[0];
-         remove(argument);
-
-         InvocationResponse response = new InvocationResponse(null);
-         response.setContextInfo(statefulInvocation.getResponseContextInfo());
-         return response;
-      }
-      else if (unadvisedMethod.getName().equals("getEJBMetaData"))
-      {
-         Class<?> remote = null;
-         Class<?> home = null;
-         Class<?> pkClass = Object.class;
-         HomeHandleImpl homeHandle = null;
-
-         Class<?>[] remotes = ProxyFactoryHelper.getRemoteInterfaces(this);
-         if (remotes != null && remotes.length > 0)
-         {
-            remote = remotes[0];
-         }
-         RemoteHome homeAnnotation = this.getAnnotation(RemoteHome.class);
-         if (homeAnnotation != null)
-            home = homeAnnotation.value();
-         RemoteBinding remoteBindingAnnotation = this.getAnnotation(RemoteBinding.class);
-         if (remoteBindingAnnotation != null)
-            homeHandle = new HomeHandleImpl(remoteBindingAnnotation
-                    .jndiBinding());
-
-         EJBMetaDataImpl metadata = new EJBMetaDataImpl(remote, home, pkClass,
-                 true, false, homeHandle);
-
-         InvocationResponse response = marshallResponse(statefulInvocation, metadata, null);
-         return response;
-      }
-      else if (unadvisedMethod.getName().equals("getHomeHandle"))
-      {
-         HomeHandleImpl homeHandle = null;
-
-         RemoteBinding remoteBindingAnnotation = this.getAnnotation(RemoteBinding.class);
-         if (remoteBindingAnnotation != null)
-            homeHandle = new HomeHandleImpl(remoteBindingAnnotation
-                    .jndiBinding());
-
-
-         InvocationResponse response = marshallResponse(statefulInvocation, homeHandle, null);
-         return response;
-      }
-      else
-      {
-         return null;
-      }
-   }
-
-   protected InvocationResponse invokeEJBObjectMethod(SerializableMethod method,
-         StatefulRemoteInvocation statefulInvocation) throws Throwable
-   {
-      // Initialize
-      ClassLoader cl = this.getClassloader();
-      
-      // Obtain actual method
-      Method actualMethod = method.toMethod(cl);
-      long hash = MethodHashing.calculateHash(actualMethod);
-      MethodInfo info = this.getAdvisor().getMethodInfo(hash);
-      Method unadvisedMethod = info.getUnadvisedMethod();
-      
-      if (unadvisedMethod.getName().equals("getHandle"))
-      {
-         StatefulContainerInvocation newStatefulInvocation = buildInvocation(
-                 info, statefulInvocation);
-         
-         // Get JNDI Registrar
-         JndiSessionRegistrarBase sfsbJndiRegistrar = this.getJndiRegistrar();
-
-         // Determine if local/remote
-         boolean isLocal = EJBLocalObject.class.isAssignableFrom(unadvisedMethod.getDeclaringClass());
-         
-         // Find the Proxy Factory Key for this SFSB
-         String proxyFactoryKey = sfsbJndiRegistrar.getProxyFactoryRegistryKey(this.getMetaData(), isLocal);
-
-         // Lookup the Proxy Factory in the Object Store
-         StatefulSessionProxyFactory proxyFactory = Ejb3RegistrarLocator.locateRegistrar().lookup(proxyFactoryKey,
-               StatefulSessionProxyFactory.class);
-         
-         // Create a new EJB2.x Proxy
-         EJBObject proxy = (EJBObject)proxyFactory.createProxyEjb2x((Serializable)newStatefulInvocation.getId());
-         
-         StatefulHandleRemoteImpl handle = new StatefulHandleRemoteImpl(proxy);
-         InvocationResponse response = marshallResponse(statefulInvocation, handle, null);
-         return response;
-      }
-      
-      // SFSB remove()
-      else if (unadvisedMethod.getName().equals(Ejb2xMethodNames.METHOD_NAME_HOME_REMOVE))
-      {
-         try
-         {
-            // Attempt to remove the bean
-            destroySession(statefulInvocation.getId());
-         }
-         catch (NoSuchEJBException e)
-         {
-            String invokingClassName = method.getActualClassName();
-            Throwable newException = this.constructProperNoSuchEjbException(e, invokingClassName);
-            throw newException;
-         }
-
-         InvocationResponse response = new InvocationResponse(null);
-         return response;
-      }
-      else if (unadvisedMethod.getName().equals("getEJBHome"))
-      {
-         HomeHandleImpl homeHandle = null;
-
-         RemoteBinding remoteBindingAnnotation = this.getAnnotation(RemoteBinding.class);
-         if (remoteBindingAnnotation != null)
-            homeHandle = new HomeHandleImpl(ProxyFactoryHelper.getHomeJndiName(this));
-
-         EJBHome ejbHome = homeHandle.getEJBHome();
-
-         InvocationResponse response = marshallResponse(statefulInvocation, ejbHome, null);
-         return response;
-      }
-      else if (unadvisedMethod.getName().equals("getPrimaryKey"))
-      {
-         Object id = statefulInvocation.getId();
-
-         InvocationResponse response = marshallResponse(statefulInvocation, id, null);
-         return response;
-      }
-      else if (unadvisedMethod.getName().equals("isIdentical"))
-      {
-         Object id = statefulInvocation.getId();
-         EJBObject bean = (EJBObject) statefulInvocation.getArguments()[0];
-
-         Object primaryKey = bean.getPrimaryKey();
-
-         boolean isIdentical = id.equals(primaryKey);
-
-         InvocationResponse response = marshallResponse(statefulInvocation, isIdentical, null);
-         return response;
-      }
-      else
-      {
-         return null;
-      }
-   }
-
-   private StatefulSessionContainerMethodInvocation buildNewInvocation(MethodInfo info,
-         StatefulRemoteInvocation statefulInvocation, Class<?>[] initParameterTypes,
-         Object[] initParameterValues)
-   {
-      StatefulSessionContainerMethodInvocation newStatefulInvocation = null;
-
-      StatefulBeanContext ctx = null;
-      if (initParameterTypes.length > 0)
-         ctx = getCache().create(initParameterTypes, initParameterValues);
-      else
-         ctx = getCache().create(null, null);
-
-      Object newId = ctx.getId();
-      newStatefulInvocation = new StatefulSessionContainerMethodInvocation(info);
-      newStatefulInvocation.setSessionId(newId);
-
-      newStatefulInvocation.setArguments(statefulInvocation.getArguments());
-      newStatefulInvocation.setMetaData(statefulInvocation.getMetaData());
-      newStatefulInvocation.setAdvisor(getAdvisor());
-      
-      SerializableMethod invokedMethod = new SerializableMethod(info.getUnadvisedMethod());
-      newStatefulInvocation.getMetaData().addMetaData(SessionSpecRemotingMetadata.TAG_SESSION_INVOCATION,
-            SessionSpecRemotingMetadata.KEY_INVOKED_METHOD, invokedMethod, PayloadKey.AS_IS);
-
-      return newStatefulInvocation;
-   }
-
-   private StatefulContainerInvocation buildInvocation(MethodInfo info,
-                                                       StatefulRemoteInvocation statefulInvocation)
-   {
-      StatefulContainerInvocation newStatefulInvocation = null;
-      Object newId = null;
-      if (statefulInvocation.getId() == null)
-      {
-         StatefulBeanContext ctx = getCache().create(null, null);
-         newId = ctx.getId();
-         newStatefulInvocation = new StatefulContainerInvocation(info, newId);
-      }
-      else
-      {
-         newStatefulInvocation = new StatefulContainerInvocation(info, statefulInvocation.getId());
-      }
-
-      newStatefulInvocation.setArguments(statefulInvocation.getArguments());
-      newStatefulInvocation.setMetaData(statefulInvocation.getMetaData());
-      newStatefulInvocation.setAdvisor(getAdvisor());
-      
-      SerializableMethod invokedMethod = new SerializableMethod(info.getUnadvisedMethod());
-      newStatefulInvocation.getMetaData().addMetaData(SessionSpecRemotingMetadata.TAG_SESSION_INVOCATION,
-            SessionSpecRemotingMetadata.KEY_INVOKED_METHOD, invokedMethod, PayloadKey.AS_IS);
-
-      return newStatefulInvocation;
-   }
-
-   @Override
-   public Object getBusinessObject(BeanContext beanContext, Class businessInterface) throws IllegalStateException
-   {
-      assert beanContext != null : "beanContext is null";
-      assert businessInterface != null : "businessInterface is null";
-      
-      StatefulBeanContext ctx = (StatefulBeanContext) beanContext;
-      
-      SessionContainer container = ctx.getContainer();
-      assert container == this : "beanContext not of this container (" + container + " != " + this + ")";
-      
-      boolean isRemote = false;
-      boolean found = false;
-      Class<?>[] remoteInterfaces = ProxyFactoryHelper.getRemoteAndBusinessRemoteInterfaces(this);
-      for (Class<?> intf : remoteInterfaces)
-      {
-         if (intf.getName().equals(businessInterface.getName()))
-         {
-            isRemote = true;
-            found = true;
-            break;
-         }
-      }
-      if (found == false)
-      {
-         Class<?>[] localInterfaces = ProxyFactoryHelper.getLocalAndBusinessLocalInterfaces(this);
-         for (Class<?> intf : localInterfaces)
-         {
-            if (intf.getName().equals(businessInterface.getName()))
-            {
-               found = true;
-               break;
-            }
-         }
-      }
-      if (found == false) throw new IllegalStateException(businessInterface.getName() + " is not a business interface for container " + this);
-      
-      // Obtain SFSB JNDI Registrar
-      String sfsbJndiRegistrarObjectStoreBindName = this.getJndiRegistrarBindName();
-      JndiStatefulSessionRegistrar sfsbJndiRegistrar = Ejb3RegistrarLocator
-            .locateRegistrar().lookup(sfsbJndiRegistrarObjectStoreBindName,JndiStatefulSessionRegistrar.class);
-      
-      // Find the Proxy Factory Key for this SFSB
-      String proxyFactoryKey = sfsbJndiRegistrar.getProxyFactoryRegistryKey(this.getMetaData(), !isRemote);
-      
-      // Lookup the Proxy Factory in the Object Store
-      StatefulSessionProxyFactory proxyFactory = Ejb3RegistrarLocator.locateRegistrar().lookup(proxyFactoryKey,
-            StatefulSessionProxyFactory.class);
-      
-      // Create a new business proxy
-      Object proxy = proxyFactory.createProxyBusiness((Serializable) ctx.getId(), businessInterface.getName());
-      
-      // Return the Proxy
-      return proxy;
-
-//      Collection<ProxyFactory> proxyFactories = this.proxyDeployer.getProxyFactories().values();
-//      for (ProxyFactory factory : proxyFactories)
-//      {
-//         if (isRemote && factory instanceof StatefulRemoteProxyFactory)
-//         {
-//            return ((StatefulRemoteProxyFactory) factory).createProxyBusiness(ctx.getId(),null);
-//         }
-//         else if (!isRemote && factory instanceof StatefulLocalProxyFactory)
-//         {
-//            return ((StatefulLocalProxyFactory) factory).createProxyBusiness(ctx.getId(),null);
-//         }
-//      }
-//      throw new IllegalStateException("Unable to create proxy for getBusinessObject as a proxy factory was not found");
-   }
-
-   /**
-    * Remove the given object. Called when remove on Home is invoked.
-    * 
-    * @param target             either a Handle or a primaryKey
-    * @throws RemoveException   if it's not allowed to be removed
-    */
-   private void remove(Object target) throws RemoveException
-   {
-      // EJBTHREE-1217: EJBHome.remove(Object primaryKey) must throw RemoveException
-      if(!(target instanceof Handle))
-         throw new RemoveException("EJB 3 3.6.2.2: Session beans do not have a primary key");
-      
-      StatefulHandleRemoteImpl handle = (StatefulHandleRemoteImpl) target;
-
-      try
-      {
-         handle.getEJBObject().remove();
-      }
-      catch(RemoteException re)
-      {
-         throw new RemoveException(re.getMessage());
-      }
-   }
-   
-   protected void removeHandle(Handle arg) throws Exception
-   {
-      /*
-      StatefulHandleImpl handle = (StatefulHandleImpl) arg;
-
-      destroySession(handle.id);
-      */
-      arg.getEJBObject().remove();
-   }
-}

Copied: projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java (from rev 77399, projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java)
===================================================================
--- projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java	                        (rev 0)
+++ projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java	2008-08-25 05:28:04 UTC (rev 77405)
@@ -0,0 +1,1483 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.stateful;
+
+import java.io.Serializable;
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.rmi.NoSuchObjectException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.util.Hashtable;
+import java.util.Map;
+
+import javax.ejb.EJBHome;
+import javax.ejb.EJBLocalHome;
+import javax.ejb.EJBLocalObject;
+import javax.ejb.EJBObject;
+import javax.ejb.Handle;
+import javax.ejb.Init;
+import javax.ejb.NoSuchEJBException;
+import javax.ejb.NoSuchObjectLocalException;
+import javax.ejb.PostActivate;
+import javax.ejb.PrePassivate;
+import javax.ejb.RemoteHome;
+import javax.ejb.RemoveException;
+import javax.ejb.TimerService;
+
+import org.jboss.aop.Advisor;
+import org.jboss.aop.Domain;
+import org.jboss.aop.MethodInfo;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.InvocationResponse;
+import org.jboss.aop.util.MethodHashing;
+import org.jboss.aop.util.PayloadKey;
+import org.jboss.aspects.asynch.FutureHolder;
+import org.jboss.ejb3.BeanContext;
+import org.jboss.ejb3.EJBContainerInvocation;
+import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.ejb3.annotation.Cache;
+import org.jboss.ejb3.annotation.CacheConfig;
+import org.jboss.ejb3.annotation.Clustered;
+import org.jboss.ejb3.annotation.LocalBinding;
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.ejb3.annotation.RemoteBindings;
+import org.jboss.ejb3.cache.CacheFactoryRegistry;
+import org.jboss.ejb3.cache.Ejb3CacheFactory;
+import org.jboss.ejb3.cache.StatefulCache;
+import org.jboss.ejb3.cache.StatefulObjectFactory;
+import org.jboss.ejb3.common.lang.SerializableMethod;
+import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
+import org.jboss.ejb3.interceptors.container.StatefulSessionContainerMethodInvocation;
+import org.jboss.ejb3.proxy.ProxyFactory;
+import org.jboss.ejb3.proxy.ProxyUtils;
+import org.jboss.ejb3.proxy.clustered.objectstore.ClusteredObjectStoreBindings;
+import org.jboss.ejb3.proxy.container.StatefulSessionInvokableContext;
+import org.jboss.ejb3.proxy.factory.ProxyFactoryHelper;
+import org.jboss.ejb3.proxy.factory.session.stateful.StatefulSessionProxyFactory;
+import org.jboss.ejb3.proxy.factory.stateful.BaseStatefulRemoteProxyFactory;
+import org.jboss.ejb3.proxy.factory.stateful.StatefulClusterProxyFactory;
+import org.jboss.ejb3.proxy.factory.stateful.StatefulLocalProxyFactory;
+import org.jboss.ejb3.proxy.factory.stateful.StatefulRemoteProxyFactory;
+import org.jboss.ejb3.proxy.impl.EJBMetaDataImpl;
+import org.jboss.ejb3.proxy.impl.HomeHandleImpl;
+import org.jboss.ejb3.proxy.jndiregistrar.JndiSessionRegistrarBase;
+import org.jboss.ejb3.proxy.jndiregistrar.JndiStatefulSessionRegistrar;
+import org.jboss.ejb3.proxy.objectstore.ObjectStoreBindings;
+import org.jboss.ejb3.proxy.remoting.SessionSpecRemotingMetadata;
+import org.jboss.ejb3.proxy.remoting.StatefulSessionRemotingMetadata;
+import org.jboss.ejb3.session.Ejb2xMethodNames;
+import org.jboss.ejb3.session.SessionContainer;
+import org.jboss.ejb3.session.SessionSpecContainer;
+import org.jboss.injection.Injector;
+import org.jboss.injection.JndiPropertyInjector;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.util.NotImplementedException;
+
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision$
+ */
+public class StatefulContainer extends SessionSpecContainer
+      implements
+         StatefulObjectFactory<StatefulBeanContext>,
+         StatefulSessionInvokableContext
+{
+   private static final Logger log = Logger.getLogger(StatefulContainer.class);
+
+   protected StatefulCache cache;
+   private StatefulDelegateWrapper mbean = new StatefulDelegateWrapper(this);
+
+   public StatefulContainer(ClassLoader cl, String beanClassName, String ejbName, Domain domain,
+                            Hashtable ctxProperties, Ejb3Deployment deployment, JBossSessionBeanMetaData beanMetaData) throws ClassNotFoundException
+   {
+      super(cl, beanClassName, ejbName, domain, ctxProperties, deployment, beanMetaData);
+   }
+
+   public StatefulBeanContext create(Class<?>[] initTypes, Object[] initValues)
+   {
+      StatefulBeanContext sfctx = (StatefulBeanContext) createBeanContext();
+      // Tell context how to handle replication
+      CacheConfig config = getAnnotation(CacheConfig.class);
+      if (config != null)
+      {
+         sfctx.setReplicationIsPassivation(config.replicationIsPassivation());
+      }
+
+      // this is for propagated extended PC's
+      sfctx = sfctx.pushContainedIn();
+      
+      pushContext(sfctx);
+      try
+      {
+         if (injectors != null)
+         {
+            for (Injector injector : injectors)
+            {
+               injector.inject(sfctx);
+            }
+         }
+
+         sfctx.initialiseInterceptorInstances();
+
+      }
+      finally
+      {
+         popContext();
+         // this is for propagated extended PC's
+         sfctx.popContainedIn();
+      }
+      
+      invokePostConstruct(sfctx, initValues);
+      
+      //TODO This needs to be reimplemented as replacement for create() on home interface
+      invokeInit(sfctx.getInstance(), initTypes, initValues);
+      
+      return sfctx;
+   }
+   
+   @Override
+   public BeanContext<?> createBeanContext()
+   {
+      return new StatefulBeanContext(this, construct());
+   }
+   
+   @Override
+   protected StatefulLocalProxyFactory getProxyFactory(LocalBinding binding)
+   {
+      StatefulLocalProxyFactory factory = (StatefulLocalProxyFactory) this.proxyDeployer.getProxyFactory(binding);
+
+      if (factory == null)
+      {
+         factory = new StatefulLocalProxyFactory(this, binding);
+
+         try
+         {
+            factory.init();
+         }
+         catch (Exception e)
+         {
+            throw new RuntimeException(e);
+         }
+      }
+      
+      return factory;
+   }
+   
+   public Object createProxyLocalEjb21(Object id, LocalBinding binding, String businessInterfaceType) throws Exception
+   {
+      StatefulLocalProxyFactory proxyFactory = this.getProxyFactory(binding);
+      return proxyFactory.createProxyEjb21(id,businessInterfaceType);
+   }
+   
+   public Object createProxyRemoteEjb21(Object id, String businessInterfaceType) throws Exception
+   {
+      RemoteBinding binding = this.getRemoteBinding();
+      return this.createProxyRemoteEjb21(id,binding, businessInterfaceType);
+   }
+
+   public Object createProxyRemoteEjb21(Object id, RemoteBinding binding, String businessInterfaceType) throws Exception
+   { 
+      BaseStatefulRemoteProxyFactory proxyFactory = this.getProxyFactory(binding);
+      return proxyFactory.createProxyEjb21(id, businessInterfaceType);
+   }
+   
+   public Object createProxyLocalEjb21(Object id, String businessInterfaceType) throws Exception
+   {
+      LocalBinding binding = this.getAnnotation(LocalBinding.class);
+      return this.createProxyLocalEjb21(id,binding, businessInterfaceType);
+   }
+   
+   @Override
+   public Object createProxyLocalEjb21(LocalBinding binding, String businessInterfaceType) throws Exception
+   {
+      Object id = this.createSession();
+      return this.createProxyLocalEjb21(id,binding, businessInterfaceType);
+   }
+
+   @Override
+   public Object createProxyRemoteEjb21(RemoteBinding binding, String businessInterfaceType) throws Exception
+   {
+      Object id = this.createSession();
+      return this.createProxyRemoteEjb21(id, binding, businessInterfaceType);
+   }
+   
+   @Override
+   protected BaseStatefulRemoteProxyFactory getProxyFactory(RemoteBinding binding)
+   {
+      BaseStatefulRemoteProxyFactory factory = (BaseStatefulRemoteProxyFactory) this.proxyDeployer
+            .getProxyFactory(binding);
+
+      if (factory == null)
+      {
+
+         Clustered clustered = getAnnotation(Clustered.class);
+         if (clustered != null)
+         {
+            factory = new StatefulClusterProxyFactory(this, binding, clustered);
+         }
+         else
+         {
+            factory = new StatefulRemoteProxyFactory(this, binding);
+         }
+         
+         try
+         {
+            factory.init();
+         }
+         catch(Exception e)
+         {
+            throw new RuntimeException(e);
+         }
+      }
+
+      return factory;
+   }
+   
+   public void destroy(StatefulBeanContext ctx)
+   {
+      try
+      {
+         invokePreDestroy(ctx);
+      }
+      finally
+      {
+         ctx.remove();
+      }
+   }
+   
+   public Object getMBean()
+   {
+      return mbean;
+   }
+   
+   /**
+    * Creates and starts the configured cache, if not
+    * started already
+    * 
+    * @throws Exception
+    */
+   protected void createAndStartCache() throws Exception {
+      
+      // If Cache is initialized, exit
+      if(this.cache!=null && this.cache.isStarted())
+      {
+         return;
+      }
+      
+      Cache cacheConfig = getAnnotation(Cache.class);
+      CacheFactoryRegistry registry = getCacheFactoryRegistry();
+      Ejb3CacheFactory factory = registry.getCacheFactory(cacheConfig.value());
+      this.cache = factory.createCache();
+      this.cache.initialize(this);
+      this.cache.start();
+   }
+   
+   @Override
+   protected void lockedStart() throws Exception
+   {
+      try
+      {
+         super.lockedStart();
+         this.createAndStartCache();
+      }
+      catch (Exception e)
+      {
+         try
+         {
+            this.lockedStop();
+         }
+         catch (Exception ignore)
+         {
+            log.debug("Failed to cleanup after start() failure", ignore);
+         }
+         throw e;
+      }
+
+   }
+
+   @Override
+   protected void lockedStop() throws Exception
+   {
+      if (cache != null) cache.stop();
+      
+      super.lockedStop();
+   }
+
+   public StatefulCache getCache()
+   {
+      // Ensure initialized
+      try{
+         this.createAndStartCache();
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException(e);
+      }
+      
+      // Return
+      return cache;
+   }
+   
+   public CacheFactoryRegistry getCacheFactoryRegistry()
+   {
+      return this.getDeployment().getCacheFactoryRegistry();
+   }
+   
+   /**
+    * Returns the name under which the JNDI Registrar for this container is bound
+    * 
+    * @return
+    */
+   protected String getJndiRegistrarBindName()
+   {
+      return isClustered() ? ClusteredObjectStoreBindings.CLUSTERED_OBJECTSTORE_BEAN_NAME_JNDI_REGISTRAR_SFSB
+                           : ObjectStoreBindings.OBJECTSTORE_BEAN_NAME_JNDI_REGISTRAR_SFSB;
+   }
+
+   /**
+    * Performs a synchronous local invocation
+    */
+   public Object localInvoke(Object id, Method method, Object[] args)
+           throws Throwable
+   {
+      return localInvoke(id, method, args, null);
+   }
+
+   /**
+    * Performs a synchronous or asynchronous local invocation
+    *
+    */
+   public Object localHomeInvoke(Method method, Object[] args) throws Throwable
+   {
+      ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
+      pushEnc();
+      try
+      {
+         long hash = MethodHashing.calculateHash(method);
+         MethodInfo info = getAdvisor().getMethodInfo(hash);
+         if (info == null)
+         {
+            throw new RuntimeException(
+                    "Could not resolve beanClass method from proxy call: "
+                            + method.toString());
+         }
+         return invokeLocalHomeMethod(info, args);
+      }
+      finally
+      {
+         Thread.currentThread().setContextClassLoader(oldLoader);
+         popEnc();
+      }
+   }
+
+   /**
+    * Performs a synchronous or asynchronous local invocation
+    *
+    * @param provider If null a synchronous invocation, otherwise an asynchronous
+    */
+   public Object localInvoke(Object id, Method method, Object[] args,
+         FutureHolder provider) throws Throwable
+   {
+      long start = System.currentTimeMillis();
+
+      ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
+      pushEnc();
+      try
+      {
+         long hash = MethodHashing.calculateHash(method);
+         MethodInfo info = getAdvisor().getMethodInfo(hash);
+         if (info == null)
+         {
+            throw new RuntimeException(
+                  "Could not resolve beanClass method from proxy call: "
+                  + method.toString());
+         }
+      
+         Method unadvisedMethod = info.getUnadvisedMethod();
+      
+         try
+         {
+            invokeStats.callIn();
+      
+            if (unadvisedMethod != null && isHomeMethod(unadvisedMethod))
+            {
+               return invokeLocalHomeMethod(info, args);
+            }
+            else if (unadvisedMethod != null
+                  && isEJBObjectMethod(unadvisedMethod))
+            {
+               return invokeEJBLocalObjectMethod(id, info, args);
+            }
+            
+            SerializableMethod invoked = new SerializableMethod(method, method.getClass());
+            
+            //StatefulContainerInvocation nextInvocation = new StatefulContainerInvocation(info, id);
+            StatefulSessionContainerMethodInvocation nextInvocation = new StatefulSessionContainerMethodInvocation(info);
+            nextInvocation.setSessionId(id);
+            nextInvocation.setAdvisor(getAdvisor());
+            nextInvocation.setArguments(args);
+            
+            ProxyUtils.addLocalAsynchronousInfo(nextInvocation, provider);
+            
+            //invokedMethod.push(invoked);
+            return nextInvocation.invokeNext();
+         }
+         finally
+         {
+            if (unadvisedMethod != null)
+            {
+               long end = System.currentTimeMillis();
+               long elapsed = end - start;
+               invokeStats.updateStats(unadvisedMethod, elapsed);
+            }
+         
+            invokeStats.callOut();
+            
+            //invokedMethod.pop();
+         }
+      }
+      finally
+      {
+         Thread.currentThread().setContextClassLoader(oldLoader);
+         popEnc();
+      }
+   }
+   
+   /**
+    * Create a stateful bean and return its oid.
+    *
+    * @return
+    */
+   public Serializable createSession(Class<?>[] initTypes, Object[] initValues)
+   {
+      ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
+      pushEnc();
+      try
+      {
+         Thread.currentThread().setContextClassLoader(classloader);
+         StatefulCache cache = this.getCache();
+         StatefulBeanContext ctx = cache.create(initTypes, initValues);
+         // Since we return the key here, the context is not in use.
+         cache.release(ctx);
+         Object id = ctx.getId();
+         assert id instanceof Serializable : "SFSB Session IDs must be " + Serializable.class.getSimpleName();
+         return (Serializable) id;
+      }
+      finally
+      {
+         Thread.currentThread().setContextClassLoader(oldLoader);
+         popEnc();
+      }
+   }
+
+   protected void destroySession(Object id)
+   {
+      getCache().remove(id);
+   }
+   
+   /**
+    * Remote Invocation entry point, as delegated from
+    * ClassProxyHack (Remoting Dispatcher)
+    */
+   //TODO
+   public InvocationResponse dynamicInvoke(Invocation invocation) throws Throwable
+   {
+      /*
+       * Initialize
+       */
+
+      // Mark the start time
+      long start = System.currentTimeMillis();
+
+      // Create a pointer to a new Invocation
+      StatefulContainerInvocation newSi = null;
+
+      // Create a pointer to the response we'll return
+      InvocationResponse response = null;
+
+      // Create a pointer to the Session ID
+      Serializable sessionId = null;
+
+      /*
+       * Setup Environment (Stack/Thread)
+       */
+
+      // Hold a reference to the existing TCL
+      ClassLoader originalLoader = Thread.currentThread().getContextClassLoader();
+
+      // Set the Container's CL as TCL, required to unmarshall methods from the bean impl class
+      Thread.currentThread().setContextClassLoader(this.getClassloader());
+
+      // Push the ENC onto the stack
+      pushEnc();
+
+      try
+      {
+
+         /*
+          * Obtain the target method (unmarshall from invocation)
+          */
+
+         // Cast
+         assert invocation instanceof StatefulRemoteInvocation : SessionContainer.class.getName()
+               + ".dynamicInoke supports only " + StatefulRemoteInvocation.class.getSimpleName()
+               + ", but has been passed: " + invocation;
+         StatefulRemoteInvocation si = (StatefulRemoteInvocation) invocation;
+
+         // Get the method hash
+         long methodHash = si.getMethodHash();
+         log.debug("Received dynamic invocation for method with hash: " + methodHash);
+
+         // Get the Method via MethodInfo from the Advisor
+         Advisor advisor = this.getAdvisor();
+         MethodInfo info = advisor.getMethodInfo(methodHash);
+         Method unadvisedMethod = info.getMethod();
+         SerializableMethod unadvisedMethodSerializable = new SerializableMethod(unadvisedMethod);
+         
+         // Get the invoked method from invocation metadata
+         Object objInvokedMethod = si.getMetaData(SessionSpecRemotingMetadata.TAG_SESSION_INVOCATION,
+               SessionSpecRemotingMetadata.KEY_INVOKED_METHOD);
+         assert objInvokedMethod != null : "Invoked Method must be set on invocation metadata";
+         assert objInvokedMethod instanceof SerializableMethod : "Invoked Method set on invocation metadata is not of type "
+               + SerializableMethod.class.getName() + ", instead: " + objInvokedMethod;
+         SerializableMethod invokedMethod = (SerializableMethod) objInvokedMethod;
+         
+         /*
+          * Set the invoked method
+          */
+         //TODO Remove when CurrentInvocation is ironed out
+         
+         // Set onto stack
+         SessionSpecContainer.invokedMethod.push(invokedMethod);
+
+         try
+         {
+
+            // Increment invocation statistics
+            invokeStats.callIn();
+
+            /*
+             * Obtain Session ID
+             */
+
+            // Obtain the Session ID
+            Object objSessionId = si.getMetaData(StatefulSessionRemotingMetadata.TAG_SFSB_INVOCATION,
+                  StatefulSessionRemotingMetadata.KEY_SESSION_ID);
+            if (objSessionId != null)
+            {
+               assert objSessionId instanceof Serializable : "Session IDs must be "
+                     + Serializable.class.getSimpleName();
+               sessionId = (Serializable) objSessionId;
+            }
+
+            if (info != null && unadvisedMethod != null && isHomeMethod(unadvisedMethodSerializable))
+            {
+               response = invokeHomeMethod(info, si);
+            }
+            else if (info != null && unadvisedMethod != null && isEjbObjectMethod(unadvisedMethodSerializable))
+            {
+               response = invokeEJBObjectMethod(invokedMethod, si);
+            }
+            else
+            {
+               if (unadvisedMethod.isBridge())
+               {
+                  unadvisedMethod = this.getNonBridgeMethod(unadvisedMethod);
+                  info = super.getMethodInfo(unadvisedMethod);
+               }
+
+               if (sessionId == null)
+               {
+                  StatefulBeanContext ctx = getCache().create(null, null);
+                  Object objNewId = ctx.getId();
+                  assert objNewId instanceof Serializable : "Obtained new Session ID from cache, " + objNewId
+                        + ", which is not " + Serializable.class.getSimpleName();
+                  sessionId = (Serializable) objNewId;
+               }
+               
+               /*
+                * Build a new Invocation
+                */
+
+               // Construct the invocation
+               newSi = new StatefulContainerInvocation(info, sessionId);
+               //newSi = new StatefulContainerInvocation(info.getInterceptors(), long methodHash, Method advisedMethod, Method unadvisedMethod, Advisor advisor, Object id);
+               newSi.setArguments(si.getArguments());
+               newSi.setMetaData(si.getMetaData());
+               newSi.getMetaData().addMetaData(SessionSpecRemotingMetadata.TAG_SESSION_INVOCATION,
+                     SessionSpecRemotingMetadata.KEY_INVOKED_METHOD, invokedMethod, PayloadKey.AS_IS);
+               
+               //newSi.setAdvisor(getAdvisor());
+               
+               /*
+                * Ensure ID exists (useful for catching problems while we have context as
+                * to the caller, whereas in Interceptors we do not)
+                */
+               try
+               {
+                  this.getCache().get(sessionId);
+               }
+               catch(NoSuchEJBException nsee)
+               {
+                  throw this.constructProperNoSuchEjbException(nsee, invokedMethod.getActualClassName()); 
+               }
+
+               /*
+                * Perform Invocation
+                */
+               
+               // Create an object to hold the return value
+               Object returnValue = null;
+
+               // Invoke
+               returnValue = newSi.invokeNext();
+
+               // Marshall the response
+               response = marshallResponse(invocation, returnValue, newSi.getResponseContextInfo());
+               if (sessionId != null)
+               {
+                  response.addAttachment(StatefulConstants.NEW_ID, sessionId);
+               }
+               
+//               response = marshallResponse(invocation, rtn, newSi.getResponseContextInfo());
+//               if (newId != null) response.addAttachment(StatefulConstants.NEW_ID, newId);
+               
+               // Create a Response
+//             response = new InvocationResponse(returnValue);
+//             Map<Object, Object> responseContext = newSi.getResponseContextInfo();
+//             response.setContextInfo(responseContext);
+            }
+         }
+         catch (Throwable t)
+         {
+            Throwable exception = t;
+//            if (sessionId != null)
+//            {
+//               exception = new ForwardId(t, sessionId);
+//            }
+            Map<Object, Object> responseContext = null;
+            if (newSi != null)
+            {
+               responseContext = newSi.getResponseContextInfo();
+            }
+            response = marshallException(invocation, exception, responseContext);
+            return response;
+         }
+         finally
+         {
+            /*
+             * Update Invocation Statistics
+             */
+            if (unadvisedMethod != null)
+            {
+               // Mark end time
+               long end = System.currentTimeMillis();
+
+               // Calculate elapsed time
+               long elapsed = end - start;
+
+               // Update statistics with elapsed time
+               invokeStats.updateStats(unadvisedMethod, elapsed);
+            }
+
+            // Complete call to increment statistics
+            invokeStats.callOut();
+
+         }
+
+         // Return
+         return response;
+      }
+      finally
+      {
+         
+         // Pop invoked method off the stack
+         //TODO Remove when CurrentInvocation handles this
+         SessionSpecContainer.invokedMethod.pop();
+         
+         // Reset the TCL to original
+         Thread.currentThread().setContextClassLoader(originalLoader);
+
+         // Pop the ENC off the stack
+         this.popEnc();
+      }
+   }
+   
+   @Deprecated
+   public InvocationResponse dynamicInvoke(Object target, Invocation invocation) throws Throwable
+   {
+      throw new NotImplementedException("Should be using dynamicInvoke(Invocation invocation)");
+   }
+//   /**
+//    * This should be a remote invocation call
+//    *
+//    * @param invocation
+//    * @return
+//    * @throws Throwable
+//    * @deprecated Use dynamicInvoke(Invocation invocation)
+//    */
+//   @Deprecated
+//   public InvocationResponse dynamicInvoke(Object target, Invocation invocation) throws Throwable
+//   {
+//      long start = System.currentTimeMillis();
+//      
+//      ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
+//      EJBContainerInvocation newSi = null;
+//      pushEnc();
+//      try
+//      {
+//         Thread.currentThread().setContextClassLoader(classloader);
+//         MethodInvocation mi = (MethodInvocation)invocation;
+//         
+//         MethodInfo info = getAdvisor().getMethodInfo(mi.getMethodHash());
+//         if (info == null)
+//         {
+//            throw new RuntimeException("Could not resolve beanClass method from proxy call " + invocation);
+//         }
+//         Method unadvisedMethod = info.getUnadvisedMethod();
+//         
+//         
+//         StatefulRemoteInvocation si = (StatefulRemoteInvocation) invocation;
+//         
+//
+//         InvocationResponse response = null;
+//         
+//         Object newId = null;
+//         
+//         try
+//         {
+//            invokeStats.callIn();
+//            
+//            if (info != null && unadvisedMethod != null && isHomeMethod(unadvisedMethod))
+//            {
+//               response = invokeHomeMethod(info, si);
+//            }
+//            else if (info != null && unadvisedMethod != null && isEJBObjectMethod(unadvisedMethod))
+//            {
+//               response = invokeEJBObjectMethod(info, si);
+//            }
+//            else
+//            {
+//               if (unadvisedMethod.isBridge())
+//               {
+//                  unadvisedMethod = this.getNonBridgeMethod(unadvisedMethod);
+//                  info = super.getMethodInfo(unadvisedMethod);
+//               }
+//               
+//               if (si.getId() == null)
+//               {
+//                  StatefulBeanContext ctx = getCache().create(null, null);
+//                  newId = ctx.getId();
+//               }
+//               else
+//               {
+//                  newId = si.getId();
+//               }
+//               newSi = new StatefulContainerInvocation(info, newId);
+//               newSi.setArguments(si.getArguments());
+//               newSi.setMetaData(si.getMetaData());
+//               newSi.setAdvisor(getAdvisor());
+//   
+//               Object rtn = null;
+//                 
+//
+//               rtn = newSi.invokeNext();
+//
+//               response = marshallResponse(invocation, rtn, newSi.getResponseContextInfo());
+//               if (newId != null) response.addAttachment(StatefulConstants.NEW_ID, newId);
+//            }
+//         }
+//         catch (Throwable throwable)
+//         {
+//            Throwable exception = throwable;
+//            if (newId != null)
+//            {
+//               exception = new ForwardId(throwable, newId);
+//            }
+//            Map responseContext = null;
+//            if (newSi != null) newSi.getResponseContextInfo();
+//            response = marshallException(invocation, exception, responseContext);
+//            return response;
+//         }
+//         finally
+//         {
+//            if (unadvisedMethod != null)
+//            {
+//               long end = System.currentTimeMillis();
+//               long elapsed = end - start;
+//               invokeStats.updateStats(unadvisedMethod, elapsed);
+//            }
+//            
+//            invokeStats.callOut();
+//         }
+//
+//         return response;
+//      }
+//      finally
+//      {
+//         Thread.currentThread().setContextClassLoader(oldLoader);
+//         popEnc();
+//      }
+//   }
+
+
+   public TimerService getTimerService()
+   {
+      throw new UnsupportedOperationException("stateful bean doesn't support TimerService (EJB3 18.2#2)");
+   }
+
+   public TimerService getTimerService(Object pKey)
+   {
+      return getTimerService();
+   }
+   
+   @Override
+   public void invokePostActivate(BeanContext beanContext)
+   {
+      for (Injector injector : injectors)
+      {
+         if (injector instanceof JndiPropertyInjector)
+         {
+            AccessibleObject field = ((JndiPropertyInjector) injector).getAccessibleObject();
+            
+            if (field.isAnnotationPresent(javax.ejb.EJB.class))
+            {
+               continue; // skip nested EJB injection since the local proxy will be (de)serialized correctly
+            }
+            
+            if (field instanceof Field)
+            {
+               // reinject transient fields
+               if ((((Field)field).getModifiers() & Modifier.TRANSIENT) > 0)
+                  injector.inject(beanContext);
+            }
+         }
+      }
+      
+      this.invokeCallback(beanContext, PostActivate.class);
+   }
+
+   @Override
+   public void invokePrePassivate(BeanContext beanContext)
+   {
+      this.invokeCallback(beanContext, PrePassivate.class);
+   }
+
+   /*
+   @Override
+   protected Class[] getHandledCallbacks()
+   {
+      return new Class[]
+              {PostConstruct.class, PreDestroy.class, PostActivate.class,
+                      PrePassivate.class};
+   }
+   */
+
+   public void invokeInit(Object bean, Class[] initParameterTypes,
+                          Object[] initParameterValues)
+   {
+      int numParameters = 0;
+      if(initParameterTypes != null)
+         numParameters = initParameterTypes.length;
+      try
+      {
+         for(Method method : bean.getClass().getDeclaredMethods())
+         {
+            if(numParameters != method.getParameterTypes().length)
+               continue;
+            
+            if ((method.getAnnotation(Init.class) != null)
+                    || (resolveAnnotation(method, Init.class) != null))
+            {
+               if(initParameterTypes != null)
+               {
+                  Object[] parameters = getInitParameters(method,
+                          initParameterTypes, initParameterValues);
+   
+                  if (parameters != null)
+                     method.invoke(bean, parameters);
+               }
+               else
+               {
+                  method.invoke(bean);
+               }
+            }
+         }
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+
+   protected Object[] getInitParameters(Method method,
+                                        Class[] initParameterTypes, Object[] initParameterValues)
+   {
+      if (method.getParameterTypes().length == initParameterTypes.length)
+      {
+         for (int i = 0; i < initParameterTypes.length; ++i)
+         {
+            Class formal = method.getParameterTypes()[i];
+            Class actual = initParameterTypes[i];
+            if (!isMethodInvocationConvertible(formal, actual == null ? null
+                    : actual))
+               return null;
+         }
+         return initParameterValues;
+      }
+      return null;
+   }
+
+   /**
+    * Determines whether a type represented by a class object is convertible to
+    * another type represented by a class object using a method invocation
+    * conversion, treating object types of primitive types as if they were
+    * primitive types (that is, a Boolean actual parameter type matches boolean
+    * primitive formal type). This behavior is because this method is used to
+    * determine applicable methods for an actual parameter list, and primitive
+    * types are represented by their object duals in reflective method calls.
+    *
+    * @param formal the formal parameter type to which the actual parameter type
+    *               should be convertible
+    * @param actual the actual parameter type.
+    * @return true if either formal type is assignable from actual type, or
+    *         formal is a primitive type and actual is its corresponding object
+    *         type or an object type of a primitive type that can be converted
+    *         to the formal type.
+    */
+   private static boolean isMethodInvocationConvertible(Class formal,
+                                                        Class actual)
+   {
+      /*
+       * if it's a null, it means the arg was null
+       */
+      if (actual == null && !formal.isPrimitive())
+      {
+         return true;
+      }
+      /*
+       * Check for identity or widening reference conversion
+       */
+      if (actual != null && formal.isAssignableFrom(actual))
+      {
+         return true;
+      }
+      /*
+       * Check for boxing with widening primitive conversion. Note that actual
+       * parameters are never primitives.
+       */
+      if (formal.isPrimitive())
+      {
+         if (formal == Boolean.TYPE && actual == Boolean.class)
+            return true;
+         if (formal == Character.TYPE && actual == Character.class)
+            return true;
+         if (formal == Byte.TYPE && actual == Byte.class)
+            return true;
+         if (formal == Short.TYPE
+                 && (actual == Short.class || actual == Byte.class))
+            return true;
+         if (formal == Integer.TYPE
+                 && (actual == Integer.class || actual == Short.class || actual == Byte.class))
+            return true;
+         if (formal == Long.TYPE
+                 && (actual == Long.class || actual == Integer.class
+                 || actual == Short.class || actual == Byte.class))
+            return true;
+         if (formal == Float.TYPE
+                 && (actual == Float.class || actual == Long.class
+                 || actual == Integer.class || actual == Short.class || actual == Byte.class))
+            return true;
+         if (formal == Double.TYPE
+                 && (actual == Double.class || actual == Float.class
+                 || actual == Long.class || actual == Integer.class
+                 || actual == Short.class || actual == Byte.class))
+            return true;
+      }
+      return false;
+   }
+
+   private Object invokeEJBLocalObjectMethod(Object id, MethodInfo info,
+                                             Object[] args) throws Exception
+   {
+      Method unadvisedMethod = info.getUnadvisedMethod();
+      if (unadvisedMethod.getName().equals("remove"))
+      {
+         try
+         {
+            destroySession(id);
+         }
+         catch(NoSuchEJBException e)
+         {
+            throw new NoSuchObjectLocalException(e.getMessage(), e);
+         }
+
+         return null;
+      }
+      else if (unadvisedMethod.getName().equals("getEJBLocalHome"))
+      {
+         Object bean = getCache().get(id).getInstance();
+
+         return bean;
+      }
+      else if (unadvisedMethod.getName().equals("getPrimaryKey"))
+      {
+         return id;
+      }
+      else if (unadvisedMethod.getName().equals("isIdentical"))
+      {
+         EJBObject bean = (EJBObject) args[0];
+
+         Object primaryKey = bean.getPrimaryKey();
+
+         boolean isIdentical = id.equals(primaryKey);
+
+         return isIdentical;
+      }
+      else
+      {
+         return null;
+      }
+   }
+
+   private Object invokeLocalHomeMethod(MethodInfo info, Object[] args)
+           throws Exception
+   {
+      Method unadvisedMethod = info.getUnadvisedMethod();
+      if (unadvisedMethod.getName().startsWith("create"))
+      {
+         Class<?>[] initParameterTypes =
+                 {};
+         Object[] initParameterValues =
+                 {};
+         if (unadvisedMethod.getParameterTypes().length > 0)
+         {
+            initParameterTypes = unadvisedMethod.getParameterTypes();
+            initParameterValues = args;
+         }
+
+         LocalBinding binding = this.getAnnotation(LocalBinding.class);
+
+         StatefulLocalProxyFactory factory = new StatefulLocalProxyFactory(this, binding);
+         factory.init();
+
+         Object proxy = factory.createProxyEjb21(initParameterTypes,
+                 initParameterValues, unadvisedMethod.getReturnType().getName());
+
+         return proxy;
+      }
+      else if (unadvisedMethod.getName().equals("remove"))
+      {
+         remove(args[0]);
+
+         return null;
+      }
+      else
+      {
+         return null;
+      }
+   }
+   
+   public Object createLocalProxy(Object id) throws Exception
+   {
+      return this.createLocalProxy(id, this.getAnnotation(LocalBinding.class));
+   }
+   
+   public Object createLocalProxy(Object id, LocalBinding binding) throws Exception
+   {
+      StatefulLocalProxyFactory factory = new StatefulLocalProxyFactory(this, binding);
+      factory.init();
+
+      return factory.createProxyBusiness(id);
+   }
+   
+   public Object createRemoteProxy(Object id, RemoteBinding binding) throws Exception
+   {
+      StatefulRemoteProxyFactory factory = new StatefulRemoteProxyFactory(this, binding);
+      factory.init();
+
+      if (id != null)
+         return factory.createProxyBusiness(id,null);
+      else
+         return factory.createProxyBusiness();
+   }
+   
+   public boolean isClustered()
+   {
+      return isAnnotationPresent(Clustered.class);
+   }
+
+   protected InvocationResponse invokeHomeMethod(MethodInfo info,
+         StatefulRemoteInvocation statefulInvocation) throws Throwable
+   {
+      Method unadvisedMethod = info.getUnadvisedMethod();
+      if (unadvisedMethod.getName().startsWith("create"))
+      {
+         Class<?>[] initParameterTypes =
+                 {};
+         Object[] initParameterValues =
+                 {};
+         if (unadvisedMethod.getParameterTypes().length > 0)
+         {
+            initParameterTypes = unadvisedMethod.getParameterTypes();
+            initParameterValues = statefulInvocation.getArguments();
+         }
+
+         StatefulSessionContainerMethodInvocation newStatefulInvocation = buildNewInvocation(
+                 info, statefulInvocation, initParameterTypes,
+                 initParameterValues);
+
+         // Get JNDI Registrar
+         JndiSessionRegistrarBase sfsbJndiRegistrar = this.getJndiRegistrar();
+         
+         // Determine if local/remote
+         boolean isLocal = EJBLocalObject.class.isAssignableFrom(unadvisedMethod.getDeclaringClass());
+         
+         // Find the Proxy Factory Key for this SFSB
+         String proxyFactoryKey = sfsbJndiRegistrar.getProxyFactoryRegistryKey(this.getMetaData(), isLocal);
+
+         // Lookup the Proxy Factory in the Object Store
+         StatefulSessionProxyFactory proxyFactory = Ejb3RegistrarLocator.locateRegistrar().lookup(proxyFactoryKey,
+               StatefulSessionProxyFactory.class);
+         
+         // Create a new EJB2.x Proxy
+         Object proxy = proxyFactory.createProxyEjb2x((Serializable)newStatefulInvocation.getSessionId());
+         
+         InvocationResponse response = marshallResponse(statefulInvocation, proxy, newStatefulInvocation.getResponseContextInfo());
+         if (newStatefulInvocation.getSessionId() != null)
+            response.addAttachment(StatefulConstants.NEW_ID,
+                    newStatefulInvocation.getSessionId());
+         return response;
+      }
+      else if (unadvisedMethod.getName().equals("remove"))
+      {
+         Object argument = statefulInvocation.getArguments()[0];
+         remove(argument);
+
+         InvocationResponse response = new InvocationResponse(null);
+         response.setContextInfo(statefulInvocation.getResponseContextInfo());
+         return response;
+      }
+      else if (unadvisedMethod.getName().equals("getEJBMetaData"))
+      {
+         Class<?> remote = null;
+         Class<?> home = null;
+         Class<?> pkClass = Object.class;
+         HomeHandleImpl homeHandle = null;
+
+         Class<?>[] remotes = ProxyFactoryHelper.getRemoteInterfaces(this);
+         if (remotes != null && remotes.length > 0)
+         {
+            remote = remotes[0];
+         }
+         RemoteHome homeAnnotation = this.getAnnotation(RemoteHome.class);
+         if (homeAnnotation != null)
+            home = homeAnnotation.value();
+         RemoteBinding remoteBindingAnnotation = this.getAnnotation(RemoteBinding.class);
+         if (remoteBindingAnnotation != null)
+            homeHandle = new HomeHandleImpl(remoteBindingAnnotation
+                    .jndiBinding());
+
+         EJBMetaDataImpl metadata = new EJBMetaDataImpl(remote, home, pkClass,
+                 true, false, homeHandle);
+
+         InvocationResponse response = marshallResponse(statefulInvocation, metadata, null);
+         return response;
+      }
+      else if (unadvisedMethod.getName().equals("getHomeHandle"))
+      {
+         HomeHandleImpl homeHandle = null;
+
+         RemoteBinding remoteBindingAnnotation = this.getAnnotation(RemoteBinding.class);
+         if (remoteBindingAnnotation != null)
+            homeHandle = new HomeHandleImpl(remoteBindingAnnotation
+                    .jndiBinding());
+
+
+         InvocationResponse response = marshallResponse(statefulInvocation, homeHandle, null);
+         return response;
+      }
+      else
+      {
+         return null;
+      }
+   }
+
+   protected InvocationResponse invokeEJBObjectMethod(SerializableMethod method,
+         StatefulRemoteInvocation statefulInvocation) throws Throwable
+   {
+      // Initialize
+      ClassLoader cl = this.getClassloader();
+      
+      // Obtain actual method
+      Method actualMethod = method.toMethod(cl);
+      long hash = MethodHashing.calculateHash(actualMethod);
+      MethodInfo info = this.getAdvisor().getMethodInfo(hash);
+      Method unadvisedMethod = info.getUnadvisedMethod();
+      
+      if (unadvisedMethod.getName().equals("getHandle"))
+      {
+         StatefulContainerInvocation newStatefulInvocation = buildInvocation(
+                 info, statefulInvocation);
+         
+         // Get JNDI Registrar
+         JndiSessionRegistrarBase sfsbJndiRegistrar = this.getJndiRegistrar();
+
+         // Determine if local/remote
+         boolean isLocal = EJBLocalObject.class.isAssignableFrom(unadvisedMethod.getDeclaringClass());
+         
+         // Find the Proxy Factory Key for this SFSB
+         String proxyFactoryKey = sfsbJndiRegistrar.getProxyFactoryRegistryKey(this.getMetaData(), isLocal);
+
+         // Lookup the Proxy Factory in the Object Store
+         StatefulSessionProxyFactory proxyFactory = Ejb3RegistrarLocator.locateRegistrar().lookup(proxyFactoryKey,
+               StatefulSessionProxyFactory.class);
+         
+         // Create a new EJB2.x Proxy
+         EJBObject proxy = (EJBObject)proxyFactory.createProxyEjb2x((Serializable)newStatefulInvocation.getId());
+         
+         StatefulHandleRemoteImpl handle = new StatefulHandleRemoteImpl(proxy);
+         InvocationResponse response = marshallResponse(statefulInvocation, handle, null);
+         return response;
+      }
+      
+      // SFSB remove()
+      else if (unadvisedMethod.getName().equals(Ejb2xMethodNames.METHOD_NAME_HOME_REMOVE))
+      {
+         try
+         {
+            // Attempt to remove the bean
+            destroySession(statefulInvocation.getId());
+         }
+         catch (NoSuchEJBException e)
+         {
+            String invokingClassName = method.getActualClassName();
+            Throwable newException = this.constructProperNoSuchEjbException(e, invokingClassName);
+            throw newException;
+         }
+
+         InvocationResponse response = new InvocationResponse(null);
+         return response;
+      }
+      else if (unadvisedMethod.getName().equals("getEJBHome"))
+      {
+         HomeHandleImpl homeHandle = null;
+
+         RemoteBinding remoteBindingAnnotation = this.getAnnotation(RemoteBinding.class);
+         if (remoteBindingAnnotation != null)
+            homeHandle = new HomeHandleImpl(ProxyFactoryHelper.getHomeJndiName(this));
+
+         EJBHome ejbHome = homeHandle.getEJBHome();
+
+         InvocationResponse response = marshallResponse(statefulInvocation, ejbHome, null);
+         return response;
+      }
+      else if (unadvisedMethod.getName().equals("getPrimaryKey"))
+      {
+         Object id = statefulInvocation.getId();
+
+         InvocationResponse response = marshallResponse(statefulInvocation, id, null);
+         return response;
+      }
+      else if (unadvisedMethod.getName().equals("isIdentical"))
+      {
+         Object id = statefulInvocation.getId();
+         EJBObject bean = (EJBObject) statefulInvocation.getArguments()[0];
+
+         Object primaryKey = bean.getPrimaryKey();
+
+         boolean isIdentical = id.equals(primaryKey);
+
+         InvocationResponse response = marshallResponse(statefulInvocation, isIdentical, null);
+         return response;
+      }
+      else
+      {
+         return null;
+      }
+   }
+
+   private StatefulSessionContainerMethodInvocation buildNewInvocation(MethodInfo info,
+         StatefulRemoteInvocation statefulInvocation, Class<?>[] initParameterTypes,
+         Object[] initParameterValues)
+   {
+      StatefulSessionContainerMethodInvocation newStatefulInvocation = null;
+
+      StatefulBeanContext ctx = null;
+      if (initParameterTypes.length > 0)
+         ctx = getCache().create(initParameterTypes, initParameterValues);
+      else
+         ctx = getCache().create(null, null);
+
+      Object newId = ctx.getId();
+      newStatefulInvocation = new StatefulSessionContainerMethodInvocation(info);
+      newStatefulInvocation.setSessionId(newId);
+
+      newStatefulInvocation.setArguments(statefulInvocation.getArguments());
+      newStatefulInvocation.setMetaData(statefulInvocation.getMetaData());
+      newStatefulInvocation.setAdvisor(getAdvisor());
+      
+      SerializableMethod invokedMethod = new SerializableMethod(info.getUnadvisedMethod());
+      newStatefulInvocation.getMetaData().addMetaData(SessionSpecRemotingMetadata.TAG_SESSION_INVOCATION,
+            SessionSpecRemotingMetadata.KEY_INVOKED_METHOD, invokedMethod, PayloadKey.AS_IS);
+
+      return newStatefulInvocation;
+   }
+
+   private StatefulContainerInvocation buildInvocation(MethodInfo info,
+                                                       StatefulRemoteInvocation statefulInvocation)
+   {
+      StatefulContainerInvocation newStatefulInvocation = null;
+      Object newId = null;
+      if (statefulInvocation.getId() == null)
+      {
+         StatefulBeanContext ctx = getCache().create(null, null);
+         newId = ctx.getId();
+         newStatefulInvocation = new StatefulContainerInvocation(info, newId);
+      }
+      else
+      {
+         newStatefulInvocation = new StatefulContainerInvocation(info, statefulInvocation.getId());
+      }
+
+      newStatefulInvocation.setArguments(statefulInvocation.getArguments());
+      newStatefulInvocation.setMetaData(statefulInvocation.getMetaData());
+      newStatefulInvocation.setAdvisor(getAdvisor());
+      
+      SerializableMethod invokedMethod = new SerializableMethod(info.getUnadvisedMethod());
+      newStatefulInvocation.getMetaData().addMetaData(SessionSpecRemotingMetadata.TAG_SESSION_INVOCATION,
+            SessionSpecRemotingMetadata.KEY_INVOKED_METHOD, invokedMethod, PayloadKey.AS_IS);
+
+      return newStatefulInvocation;
+   }
+
+   @Override
+   public Object getBusinessObject(BeanContext beanContext, Class businessInterface) throws IllegalStateException
+   {
+      assert beanContext != null : "beanContext is null";
+      assert businessInterface != null : "businessInterface is null";
+      
+      StatefulBeanContext ctx = (StatefulBeanContext) beanContext;
+      
+      SessionContainer container = ctx.getContainer();
+      assert container == this : "beanContext not of this container (" + container + " != " + this + ")";
+      
+      boolean isRemote = false;
+      boolean found = false;
+      Class<?>[] remoteInterfaces = ProxyFactoryHelper.getRemoteAndBusinessRemoteInterfaces(this);
+      for (Class<?> intf : remoteInterfaces)
+      {
+         if (intf.getName().equals(businessInterface.getName()))
+         {
+            isRemote = true;
+            found = true;
+            break;
+         }
+      }
+      if (found == false)
+      {
+         Class<?>[] localInterfaces = ProxyFactoryHelper.getLocalAndBusinessLocalInterfaces(this);
+         for (Class<?> intf : localInterfaces)
+         {
+            if (intf.getName().equals(businessInterface.getName()))
+            {
+               found = true;
+               break;
+            }
+         }
+      }
+      if (found == false) throw new IllegalStateException(businessInterface.getName() + " is not a business interface for container " + this);
+      
+      // Obtain SFSB JNDI Registrar
+      String sfsbJndiRegistrarObjectStoreBindName = this.getJndiRegistrarBindName();
+      JndiStatefulSessionRegistrar sfsbJndiRegistrar = Ejb3RegistrarLocator
+            .locateRegistrar().lookup(sfsbJndiRegistrarObjectStoreBindName,JndiStatefulSessionRegistrar.class);
+      
+      // Find the Proxy Factory Key for this SFSB
+      String proxyFactoryKey = sfsbJndiRegistrar.getProxyFactoryRegistryKey(this.getMetaData(), !isRemote);
+      
+      // Lookup the Proxy Factory in the Object Store
+      StatefulSessionProxyFactory proxyFactory = Ejb3RegistrarLocator.locateRegistrar().lookup(proxyFactoryKey,
+            StatefulSessionProxyFactory.class);
+      
+      // Create a new business proxy
+      Object proxy = proxyFactory.createProxyBusiness((Serializable) ctx.getId(), businessInterface.getName());
+      
+      // Return the Proxy
+      return proxy;
+
+//      Collection<ProxyFactory> proxyFactories = this.proxyDeployer.getProxyFactories().values();
+//      for (ProxyFactory factory : proxyFactories)
+//      {
+//         if (isRemote && factory instanceof StatefulRemoteProxyFactory)
+//         {
+//            return ((StatefulRemoteProxyFactory) factory).createProxyBusiness(ctx.getId(),null);
+//         }
+//         else if (!isRemote && factory instanceof StatefulLocalProxyFactory)
+//         {
+//            return ((StatefulLocalProxyFactory) factory).createProxyBusiness(ctx.getId(),null);
+//         }
+//      }
+//      throw new IllegalStateException("Unable to create proxy for getBusinessObject as a proxy factory was not found");
+   }
+
+   /**
+    * Remove the given object. Called when remove on Home is invoked.
+    * 
+    * @param target             either a Handle or a primaryKey
+    * @throws RemoveException   if it's not allowed to be removed
+    */
+   private void remove(Object target) throws RemoveException
+   {
+      // EJBTHREE-1217: EJBHome.remove(Object primaryKey) must throw RemoveException
+      if(!(target instanceof Handle))
+         throw new RemoveException("EJB 3 3.6.2.2: Session beans do not have a primary key");
+      
+      StatefulHandleRemoteImpl handle = (StatefulHandleRemoteImpl) target;
+
+      try
+      {
+         handle.getEJBObject().remove();
+      }
+      catch(RemoteException re)
+      {
+         throw new RemoveException(re.getMessage());
+      }
+   }
+   
+   protected void removeHandle(Handle arg) throws Exception
+   {
+      /*
+      StatefulHandleImpl handle = (StatefulHandleImpl) arg;
+
+      destroySession(handle.id);
+      */
+      arg.getEJBObject().remove();
+   }
+}

Deleted: projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java	2008-08-25 02:13:51 UTC (rev 77394)
+++ projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java	2008-08-25 05:28:04 UTC (rev 77405)
@@ -1,783 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, 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.stateless;
-
-
-import java.io.Serializable;
-import java.lang.reflect.Method;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Map;
-import java.util.Set;
-
-import javax.ejb.EJBContext;
-import javax.ejb.EJBException;
-import javax.ejb.EJBObject;
-import javax.ejb.Handle;
-import javax.ejb.Timer;
-import javax.ejb.TimerService;
-import javax.naming.NamingException;
-
-import org.jboss.aop.Advisor;
-import org.jboss.aop.Domain;
-import org.jboss.aop.MethodInfo;
-import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.aop.joinpoint.InvocationResponse;
-import org.jboss.aop.joinpoint.MethodInvocation;
-import org.jboss.aspects.asynch.FutureHolder;
-import org.jboss.ejb.AllowedOperationsAssociation;
-import org.jboss.ejb.AllowedOperationsFlags;
-import org.jboss.ejb3.BeanContext;
-import org.jboss.ejb3.BeanContextLifecycleCallback;
-import org.jboss.ejb3.EJBContainerInvocation;
-import org.jboss.ejb3.Ejb3Deployment;
-import org.jboss.ejb3.annotation.Clustered;
-import org.jboss.ejb3.annotation.LocalBinding;
-import org.jboss.ejb3.annotation.RemoteBinding;
-import org.jboss.ejb3.common.lang.SerializableMethod;
-import org.jboss.ejb3.proxy.ProxyUtils;
-import org.jboss.ejb3.proxy.container.InvokableContext;
-import org.jboss.ejb3.proxy.factory.ProxyFactoryHelper;
-import org.jboss.ejb3.proxy.factory.SessionProxyFactory;
-import org.jboss.ejb3.proxy.factory.stateless.BaseStatelessRemoteProxyFactory;
-import org.jboss.ejb3.proxy.factory.stateless.StatelessClusterProxyFactory;
-import org.jboss.ejb3.proxy.factory.stateless.StatelessLocalProxyFactory;
-import org.jboss.ejb3.proxy.factory.stateless.StatelessRemoteProxyFactory;
-import org.jboss.ejb3.proxy.objectstore.ObjectStoreBindings;
-import org.jboss.ejb3.proxy.remoting.SessionSpecRemotingMetadata;
-import org.jboss.ejb3.session.SessionContainer;
-import org.jboss.ejb3.session.SessionSpecContainer;
-import org.jboss.ejb3.stateful.StatefulRemoteInvocation;
-import org.jboss.ejb3.timerservice.TimedObjectInvoker;
-import org.jboss.ejb3.timerservice.TimerServiceFactory;
-import org.jboss.injection.WebServiceContextProxy;
-import org.jboss.injection.lang.reflect.BeanProperty;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
-import org.jboss.metadata.ejb.spec.NamedMethodMetaData;
-import org.jboss.proxy.ejb.handle.HomeHandleImpl;
-import org.jboss.wsf.spi.SPIProvider;
-import org.jboss.wsf.spi.SPIProviderResolver;
-import org.jboss.wsf.spi.invocation.ExtensibleWebServiceContext;
-import org.jboss.wsf.spi.invocation.InvocationType;
-import org.jboss.wsf.spi.invocation.WebServiceContextFactory;
-import org.jboss.wsf.spi.invocation.integration.InvocationContextCallback;
-import org.jboss.wsf.spi.invocation.integration.ServiceEndpointContainer;
-
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class StatelessContainer extends SessionSpecContainer
-  implements TimedObjectInvoker, ServiceEndpointContainer, InvokableContext
-{
-   private static final Logger log = Logger.getLogger(StatelessContainer.class);
-
-   protected TimerService timerService;
-   private Method timeout;
-   private StatelessDelegateWrapper mbean = new StatelessDelegateWrapper(this);
-
-   public StatelessContainer(ClassLoader cl, String beanClassName, String ejbName, Domain domain,
-                             Hashtable ctxProperties, Ejb3Deployment deployment, JBossSessionBeanMetaData beanMetaData) throws ClassNotFoundException
-   {
-      super(cl, beanClassName, ejbName, domain, ctxProperties, deployment, beanMetaData);
-      
-      initializeTimeout();
-   }
-
-   @Override
-   public BeanContext<?> createBeanContext()
-   {
-      return new StatelessBeanContext(this, construct());
-   }
-   
-   @Override
-   protected StatelessLocalProxyFactory getProxyFactory(LocalBinding binding)
-   {
-      StatelessLocalProxyFactory factory = (StatelessLocalProxyFactory) this.proxyDeployer.getProxyFactory(binding);
-
-      if (factory == null)
-      {
-         factory = new StatelessLocalProxyFactory(this, binding);
-         try
-         {
-            factory.init();
-         }
-         catch (Exception e)
-         {
-            throw new RuntimeException(e);
-         }
-      }
-
-      return factory;
-   }
-   
-   @Override
-   protected BaseStatelessRemoteProxyFactory getProxyFactory(RemoteBinding binding)
-   {
-      BaseStatelessRemoteProxyFactory factory = (BaseStatelessRemoteProxyFactory) this.proxyDeployer
-            .getProxyFactory(binding);
-
-      if (factory == null)
-      {
-         Clustered clustered = getAnnotation(Clustered.class);
-         if (clustered != null)
-            factory = new StatelessClusterProxyFactory(this, binding, clustered);
-         else
-            factory = new StatelessRemoteProxyFactory(this, binding);
-         
-         try
-         {
-            factory.init();
-         }
-         catch (Exception e)
-         {
-            throw new RuntimeException(e);
-         }
-      }
-
-      return factory;
-   }
-   
-   /**
-    * Create a local proxy (EJBLocalObject) for an enterprise bean identified by id, with
-    * the specified LocalBinding
-    * 
-    * @param id
-    * @return
-    * @throws Exception
-    */
-   @Override
-   public Object createProxyLocalEjb21(LocalBinding binding, String businessInterfaceType) throws Exception
-   {
-      StatelessLocalProxyFactory proxyFactory = this.getProxyFactory(binding);
-      return proxyFactory.createProxyEjb21(businessInterfaceType);
-   }
-   
-   @Override
-   public Object createProxyRemoteEjb21(RemoteBinding binding, String businessInterfaceType) throws Exception
-   {
-      BaseStatelessRemoteProxyFactory proxyFactory = this.getProxyFactory(binding);
-      return proxyFactory.createProxyEjb21(businessInterfaceType);
-   }
-   
-   public Serializable createSession(Class<?> initTypes[], Object initArgs[])
-   {
-      if((initTypes != null && initTypes.length > 0) || (initArgs != null && initArgs.length > 0))
-         throw new IllegalArgumentException("stateless bean create method must take no arguments (EJB3 4.5)");
-      // a stateless bean has no sessions
-      // TODO: pool stuff
-      return null;
-   }
-   
-   public boolean isClustered()
-   {
-      return isAnnotationPresent(Clustered.class);
-   }
-   
-   public Object getMBean()
-   {
-      return mbean;
-   }
-   
-   private void initializeTimeout()
-   {
-      JBossSessionBeanMetaData metaData = getMetaData();
-      NamedMethodMetaData timeoutMethodMetaData = null;
-      if(metaData != null)
-         timeoutMethodMetaData = metaData.getTimeoutMethod();
-      this.timeout = getTimeoutCallback(timeoutMethodMetaData, getBeanClass());
-   }
-   
-   @Override
-   protected void lockedStart() throws Exception
-   {
-      try
-      {
-         super.lockedStart();
-         
-         timerService = TimerServiceFactory.getInstance().createTimerService(this, this);
-         
-         TimerServiceFactory.getInstance().restoreTimerService(timerService);
-      }
-      catch (Exception e)
-      {
-         try
-         {
-            this.lockedStop();
-         }
-         catch (Exception ignore)
-         {
-            log.debug("Failed to cleanup after start() failure", ignore);
-         }
-         throw e;
-      }
-   }
-
-   @Override
-   protected void lockedStop() throws Exception
-   {
-      if (timerService != null)
-      {
-         TimerServiceFactory.getInstance().removeTimerService(timerService);
-         timerService = null;
-      }
-      
-      super.lockedStop();
-   }
-
-   public TimerService getTimerService()
-   {
-      return timerService;
-   }
-
-   public TimerService getTimerService(Object pKey)
-   {
-      assert timerService != null : "Timer Service not yet initialized";
-      return timerService;
-   }
-   
-   public void callTimeout(Timer timer) throws Exception
-   {
-      if (timeout == null) throw new EJBException("No method has been annotated with @Timeout");
-      Object[] args = {timer};
-      ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
-      try
-      {
-         AllowedOperationsAssociation.pushInMethodFlag(AllowedOperationsFlags.IN_EJB_TIMEOUT);
-         try
-         {
-            MethodInfo info = super.getMethodInfo(timeout);
-            EJBContainerInvocation nextInvocation = new EJBContainerInvocation(info);
-            nextInvocation.setAdvisor(getAdvisor());
-            nextInvocation.setArguments(args);
-            nextInvocation.invokeNext();
-         }
-         catch (Throwable throwable)
-         {
-            if (throwable instanceof Exception) throw (Exception) throwable;
-            throw new RuntimeException(throwable);
-         }
-         finally
-         {
-            AllowedOperationsAssociation.popInMethodFlag();
-         }
-      }
-      finally
-      {
-         Thread.currentThread().setContextClassLoader(oldLoader);
-      }
-   }
-
-   /**
-    * Performs a synchronous local invocation
-    */
-   public Object localInvoke(Method method, Object[] args) throws Throwable
-   {
-      return localInvoke(method, args, null);
-   }
-
-   /**
-    * Performs a synchronous or asynchronous local invocation
-    *
-    * @param provider If null a synchronous invocation, otherwise an asynchronous
-    */
-   public Object localInvoke(Method method, Object[] args, FutureHolder provider) throws Throwable
-   {
-      return localInvoke(method, args, provider, null);
-   }
-   
-   public Object localInvoke(Object id, Method method, Object[] args, FutureHolder provider) throws Throwable
-   {
-      return localInvoke(method, args, provider);
-   }
-   
-   public Object localInvoke(Method method, Object[] args, FutureHolder provider, BeanContextLifecycleCallback<StatelessBeanContext> callback) throws Throwable
-   {
-      long start = System.currentTimeMillis();
-      
-      ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
-      try
-      {
-         MethodInfo info = getMethodInfo(method);
-         Method unadvisedMethod = info.getUnadvisedMethod();
-
-         try
-         {
-            invokeStats.callIn();
-            
-            //invokedMethod.push(new SerializableMethod(unadvisedMethod, unadvisedMethod.getClass()));
-
-            if (unadvisedMethod != null && isHomeMethod(unadvisedMethod))
-            {
-               return localHomeInvoke(unadvisedMethod, args);
-            }
-
-            EJBContainerInvocation<StatelessContainer, StatelessBeanContext> nextInvocation = new EJBContainerInvocation<StatelessContainer, StatelessBeanContext>(info);
-            nextInvocation.setAdvisor(getAdvisor());
-            nextInvocation.setArguments(args);
-            nextInvocation.setContextCallback(callback);
-
-            ProxyUtils.addLocalAsynchronousInfo(nextInvocation, provider);
-            return nextInvocation.invokeNext();
-         }
-         finally
-         {
-            if (unadvisedMethod != null)
-            {
-               long end = System.currentTimeMillis();
-               long elapsed = end - start;
-               invokeStats.updateStats(unadvisedMethod, elapsed);
-            }
-            
-            invokeStats.callOut();
-            
-            //invokedMethod.pop();
-         }
-      }
-      finally
-      {
-         Thread.currentThread().setContextClassLoader(oldLoader);
-      }
-   }
-   
-   /**
-    * Remote Invocation entry point, as delegated from
-    * ClassProxyHack (Remoting Dispatcher)
-    */
-   public InvocationResponse dynamicInvoke(Invocation invocation) throws Throwable
-   {
-      /*
-       * Initialize
-       */
-
-      // Mark the start time
-      long start = System.currentTimeMillis();
-
-      // Create a pointer to a new Invocation
-      EJBContainerInvocation newSi = null;
-
-      // Create a pointer to the response we'll return
-      InvocationResponse response = null;
-      
-
-      /*
-       * Setup Environment (Stack/Thread)
-       */
-
-      // Hold a reference to the existing TCL
-      ClassLoader originalLoader = Thread.currentThread().getContextClassLoader();
-
-      // Set the Container's CL as TCL, required to unmarshall methods from the bean impl class
-      Thread.currentThread().setContextClassLoader(this.getClassloader());
-
-      // Push the ENC onto the stack
-      pushEnc();
-      
-      try
-      {
-         
-         /*
-          * Obtain the target method (unmarshall from invocation)
-          */
-
-         // Cast
-         assert invocation instanceof StatefulRemoteInvocation : SessionContainer.class.getName()
-               + ".dynamicInoke supports only " + StatefulRemoteInvocation.class.getSimpleName()
-               + ", but has been passed: " + invocation;
-         MethodInvocation si = (MethodInvocation) invocation;
-
-         // Get the method hash
-         long methodHash = si.getMethodHash();
-         log.debug("Received dynamic invocation for method with hash: " + methodHash);
-
-         // Get the Method via MethodInfo from the Advisor
-         Advisor advisor = this.getAdvisor();
-         MethodInfo info = advisor.getMethodInfo(methodHash);
-         Method unadvisedMethod = info.getMethod();
-         SerializableMethod unadvisedMethodSerializable = new SerializableMethod(unadvisedMethod);
-         
-         try
-         {
-            invokeStats.callIn();
-            
-            /*
-             * Set the invoked method
-             */
-            //TODO Remove when CurrentInvocation is ironed out
-            
-            // Get the invoked method from invocation metadata
-            Object objInvokedMethod = si.getMetaData(SessionSpecRemotingMetadata.TAG_SESSION_INVOCATION,SessionSpecRemotingMetadata.KEY_INVOKED_METHOD);
-            assert objInvokedMethod !=null : "Invoked Method must be set on invocation metadata";
-            assert objInvokedMethod instanceof SerializableMethod : "Invoked Method set on invocation metadata is not of type " + SerializableMethod.class.getName() + ", instead: " + objInvokedMethod;
-            SerializableMethod invokedMethod = (SerializableMethod)objInvokedMethod;
-            
-            // Set onto stack
-            SessionSpecContainer.invokedMethod.push(invokedMethod);
-
-            //invokedMethod.push(new SerializableMethod(unadvisedMethod, unadvisedMethod.getClass()));
-            Map responseContext = null;
-            Object rtn = null;
-            if (unadvisedMethod != null && isHomeMethod(unadvisedMethodSerializable))
-            {
-               rtn = invokeHomeMethod(info, si);
-            }
-            else if (info != null && unadvisedMethod != null && isEjbObjectMethod(unadvisedMethodSerializable))
-            {
-               rtn = invokeEJBObjectMethod(info, si);
-            }
-            else
-            {
-
-               newSi = new EJBContainerInvocation<StatelessContainer, StatelessBeanContext>(info);
-               newSi.setArguments(si.getArguments());
-               newSi.setMetaData(si.getMetaData());
-               //newSi.setAdvisor(getAdvisor());               
-               
-               try
-               {
-                  rtn = newSi.invokeNext();
-                  responseContext = newSi.getResponseContextInfo();
-               }
-               catch (Throwable throwable)
-               {
-                  responseContext = newSi.getResponseContextInfo();
-                  return marshallException(invocation, throwable, responseContext);
-               }
-               finally
-               {
-                  SessionSpecContainer.invokedMethod.pop();
-               }
-            }
-
-            response = marshallResponse(invocation, rtn, responseContext);
-            return response;
-         }
-         finally
-         {
-            if (unadvisedMethod != null)
-            {
-               long end = System.currentTimeMillis();
-               long elapsed = end - start;
-               invokeStats.updateStats(unadvisedMethod, elapsed);
-            }
-
-            invokeStats.callOut();
-
-            //invokedMethod.pop();
-         }
-      }
-      finally
-      {
-         Thread.currentThread().setContextClassLoader(originalLoader);
-      }
-   }
-
-   @Deprecated
-   public InvocationResponse dynamicInvoke(Object target, Invocation invocation) throws Throwable
-   {
-      long start = System.currentTimeMillis();
-      
-      ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
-      try
-      {
-         Thread.currentThread().setContextClassLoader(classloader);
-         MethodInvocation si = (MethodInvocation) invocation;
-         MethodInfo info = getAdvisor().getMethodInfo(si.getMethodHash());
-         if (info == null)
-         {
-            throw new RuntimeException("Could not resolve beanClass method from proxy call " + invocation);
-         }
-
-         Method unadvisedMethod = info.getUnadvisedMethod();
-         try
-         {
-            invokeStats.callIn();
-            
-            //invokedMethod.push(new SerializableMethod(unadvisedMethod, unadvisedMethod.getClass()));
-            Map responseContext = null;
-            Object rtn = null;
-            if (unadvisedMethod != null && isHomeMethod(unadvisedMethod))
-            {
-               rtn = invokeHomeMethod(info, si);
-            }
-            else if (info != null && unadvisedMethod != null && isEJBObjectMethod(unadvisedMethod))
-            {
-               rtn = invokeEJBObjectMethod(info, si);
-            }
-            else
-            {
-
-               EJBContainerInvocation newSi = null;
-
-               newSi = new EJBContainerInvocation<StatelessContainer, StatelessBeanContext>(info);
-               newSi.setArguments(si.getArguments());
-               newSi.setMetaData(si.getMetaData());
-               newSi.setAdvisor(getAdvisor());
-               try
-               {
-                  rtn = newSi.invokeNext();
-                  responseContext = newSi.getResponseContextInfo();
-               }
-               catch (Throwable throwable)
-               {
-                  responseContext = newSi.getResponseContextInfo();
-                  return marshallException(invocation, throwable, responseContext);
-               }
-            }
-
-            InvocationResponse response = marshallResponse(invocation, rtn, responseContext);
-            return response;
-         }
-         finally
-         {
-            if (unadvisedMethod != null)
-            {
-               long end = System.currentTimeMillis();
-               long elapsed = end - start;
-               invokeStats.updateStats(unadvisedMethod, elapsed);
-            }
-            
-            invokeStats.callOut();
-            
-            //invokedMethod.pop();
-         }
-      }
-      finally
-      {
-         Thread.currentThread().setContextClassLoader(oldLoader);
-      }
-   }
-
-
-   protected Object invokeEJBObjectMethod(MethodInfo info, MethodInvocation invocation) throws Throwable
-   {
-      Method unadvisedMethod = info.getUnadvisedMethod();
-      if (unadvisedMethod.getName().equals("getHandle"))
-      {
-         
-         StatelessHandleRemoteImpl handle = null;
-         RemoteBinding binding = this.getAnnotation(RemoteBinding.class);
-         BaseStatelessRemoteProxyFactory factory = this.getProxyFactory(binding);
-         handle = factory.createHandle();
-
-         return handle;
-      }
-      else if (unadvisedMethod.getName().equals("remove"))
-      {
-         return null;
-      }
-      else if (unadvisedMethod.getName().equals("getEJBHome"))
-      {
-         HomeHandleImpl homeHandle = null;
-
-         RemoteBinding remoteBindingAnnotation = this.getAnnotation(RemoteBinding.class);
-         if (remoteBindingAnnotation != null)
-            homeHandle = new HomeHandleImpl(ProxyFactoryHelper.getHomeJndiName(this));
-
-         return homeHandle.getEJBHome();
-      }
-      else if (unadvisedMethod.getName().equals("getPrimaryKey"))
-      {
-         return null;
-      }
-      else if (unadvisedMethod.getName().equals("isIdentical"))
-      {
-         return false;
-      }
-      else
-      {
-         return null;
-      }
-   }
-
-   public Object localHomeInvoke(Method method, Object[] args) throws Throwable
-   {
-      if (method.getName().equals("create"))
-      {
-         LocalBinding binding = this.getAnnotation(LocalBinding.class);
-
-         // FIXME: why this binding? Could be another one. (there is only one local binding, but that's another bug)
-
-         StatelessLocalProxyFactory factory = this.getProxyFactory(binding);
-
-         Object proxy = factory.createProxyEjb21(method.getReturnType().getName());
-
-         return proxy;
-      }
-      else
-      // remove
-      {
-         return null;
-      }
-   }
-
-   protected Object invokeHomeMethod(MethodInfo info, MethodInvocation invocation) throws Throwable
-   {
-      Method unadvisedMethod = info.getUnadvisedMethod();
-      if (unadvisedMethod.getName().equals("create"))
-      {
-         RemoteBinding binding = this.getRemoteBinding();
-
-         BaseStatelessRemoteProxyFactory factory = this.getProxyFactory(binding);
-
-         return factory.createProxyEjb21(unadvisedMethod.getReturnType().getName());
-      }
-      else
-      // remove
-      {
-         return null;
-      }
-   }
-
-   @Override
-   public Object getBusinessObject(BeanContext ctx, Class intf)
-   {
-      assert intf != null : "intf is null";
-      
-      try
-      {
-         
-         /*
-          * Get all business interfaces
-          */
-         Set<String> businessInterfaceNames = new HashSet<String>();
-         JBossSessionBeanMetaData smd= (JBossSessionBeanMetaData)this.getXml();
-         businessInterfaceNames.addAll(smd.getBusinessRemotes());
-         businessInterfaceNames.addAll(smd.getBusinessLocals());
-         
-         String interfaceName = intf.getName();
-         
-         if (!businessInterfaceNames.contains(interfaceName))
-            throw new IllegalStateException("Cannot find BusinessObject for interface: " + interfaceName);
-         
-         String jndiName = this.getXml().determineResolvedJndiName(interfaceName);
-         return getInitialContext().lookup(jndiName);
-      }
-      catch (NamingException e)
-      {
-         throw new RuntimeException("failed to invoke getBusinessObject", e);
-      }
-   }
-
-   protected void removeHandle(Handle handle)
-   {
-      throw new RuntimeException("NYI");
-   }
-
-   /**
-    * WS integration
-    * @return
-    */
-   public Class getServiceImplementationClass()
-   {
-      return this.getBeanClass();
-   }
-
-   /**
-    * WS Integration
-    * @param method
-    * @param args
-    * @param invCtxCallback
-    * @return
-    * @throws Throwable
-    */
-   public Object invokeEndpoint(Method method, Object[] args, InvocationContextCallback invCtxCallback) throws Throwable
-   {
-      // JAX-RPC message context
-      javax.xml.rpc.handler.MessageContext jaxrpcContext = invCtxCallback.get(javax.xml.rpc.handler.MessageContext.class);
-
-      // JAX-WS webservice context
-      SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
-      WebServiceContextFactory contextFactory = spiProvider.getSPI(WebServiceContextFactory.class);
-      ExtensibleWebServiceContext jaxwsContext = contextFactory.newWebServiceContext(
-        InvocationType.JAXWS_EJB3,
-        invCtxCallback.get(javax.xml.ws.handler.MessageContext.class)
-      );
-
-      // ThreadLocal association
-      WebServiceContextProxy.associateMessageContext(jaxwsContext);
-
-      // EJB3 Injection Callbacks
-      WSCallbackImpl ejb3Callback = new WSCallbackImpl( jaxrpcContext, jaxwsContext );
-
-      // Actual invocation
-      return this.localInvoke(method, args, null, ejb3Callback);
-   }
-
-   public String getContainerName()
-   {
-      String name = this.getObjectName() != null ? this.getObjectName().getCanonicalName() : null;
-      return name;
-   }
-   
-   /**
-    * Returns the name under which the JNDI Registrar for this container is bound
-    * 
-    * @return
-    */
-   protected String getJndiRegistrarBindName()
-   {
-      return ObjectStoreBindings.OBJECTSTORE_BEAN_NAME_JNDI_REGISTRAR_SLSB;
-   }
-   
-   static class WSCallbackImpl implements BeanContextLifecycleCallback
-   {
-      private ExtensibleWebServiceContext jaxwsContext;
-      private javax.xml.rpc.handler.MessageContext jaxrpcMessageContext;
-
-      public WSCallbackImpl(javax.xml.rpc.handler.MessageContext jaxrpc, ExtensibleWebServiceContext jaxws)
-      {
-         jaxrpcMessageContext = jaxrpc;
-         jaxwsContext = jaxws;
-      }
-
-      public void attached(BeanContext beanCtx)
-      {
-         // JAX-RPC MessageContext
-         StatelessBeanContext sbc = (StatelessBeanContext)beanCtx;
-         sbc.setMessageContextJAXRPC(jaxrpcMessageContext);
-
-         // JAX-WS MessageContext
-         BeanProperty beanProp = sbc.getWebServiceContextProperty();
-         if (beanProp != null)
-         {
-            EJBContext ejbCtx = beanCtx.getEJBContext();            
-            jaxwsContext.addAttachment(EJBContext.class, ejbCtx);
-            beanProp.set(beanCtx.getInstance(), jaxwsContext);
-         }
-      }
-
-      public void released(BeanContext beanCtx)
-      {
-         StatelessBeanContext sbc = (StatelessBeanContext)beanCtx;
-         sbc.setMessageContextJAXRPC(null);
-
-         BeanProperty beanProp = sbc.getWebServiceContextProperty();
-         if (beanProp != null)
-            beanProp.set(beanCtx.getInstance(), null);
-      }      
-   }
-}

Copied: projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java (from rev 77399, projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java)
===================================================================
--- projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java	                        (rev 0)
+++ projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java	2008-08-25 05:28:04 UTC (rev 77405)
@@ -0,0 +1,785 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.stateless;
+
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.Set;
+
+import javax.ejb.EJBContext;
+import javax.ejb.EJBException;
+import javax.ejb.EJBObject;
+import javax.ejb.Handle;
+import javax.ejb.Timer;
+import javax.ejb.TimerService;
+import javax.naming.NamingException;
+
+import org.jboss.aop.Advisor;
+import org.jboss.aop.Domain;
+import org.jboss.aop.MethodInfo;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.InvocationResponse;
+import org.jboss.aop.joinpoint.MethodInvocation;
+import org.jboss.aspects.asynch.FutureHolder;
+import org.jboss.ejb.AllowedOperationsAssociation;
+import org.jboss.ejb.AllowedOperationsFlags;
+import org.jboss.ejb3.BeanContext;
+import org.jboss.ejb3.BeanContextLifecycleCallback;
+import org.jboss.ejb3.EJBContainerInvocation;
+import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.ejb3.annotation.Clustered;
+import org.jboss.ejb3.annotation.LocalBinding;
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.ejb3.common.lang.SerializableMethod;
+import org.jboss.ejb3.proxy.ProxyUtils;
+import org.jboss.ejb3.proxy.clustered.objectstore.ClusteredObjectStoreBindings;
+import org.jboss.ejb3.proxy.container.InvokableContext;
+import org.jboss.ejb3.proxy.factory.ProxyFactoryHelper;
+import org.jboss.ejb3.proxy.factory.SessionProxyFactory;
+import org.jboss.ejb3.proxy.factory.stateless.BaseStatelessRemoteProxyFactory;
+import org.jboss.ejb3.proxy.factory.stateless.StatelessClusterProxyFactory;
+import org.jboss.ejb3.proxy.factory.stateless.StatelessLocalProxyFactory;
+import org.jboss.ejb3.proxy.factory.stateless.StatelessRemoteProxyFactory;
+import org.jboss.ejb3.proxy.objectstore.ObjectStoreBindings;
+import org.jboss.ejb3.proxy.remoting.SessionSpecRemotingMetadata;
+import org.jboss.ejb3.session.SessionContainer;
+import org.jboss.ejb3.session.SessionSpecContainer;
+import org.jboss.ejb3.stateful.StatefulRemoteInvocation;
+import org.jboss.ejb3.timerservice.TimedObjectInvoker;
+import org.jboss.ejb3.timerservice.TimerServiceFactory;
+import org.jboss.injection.WebServiceContextProxy;
+import org.jboss.injection.lang.reflect.BeanProperty;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.ejb.spec.NamedMethodMetaData;
+import org.jboss.proxy.ejb.handle.HomeHandleImpl;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.invocation.ExtensibleWebServiceContext;
+import org.jboss.wsf.spi.invocation.InvocationType;
+import org.jboss.wsf.spi.invocation.WebServiceContextFactory;
+import org.jboss.wsf.spi.invocation.integration.InvocationContextCallback;
+import org.jboss.wsf.spi.invocation.integration.ServiceEndpointContainer;
+
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision$
+ */
+public class StatelessContainer extends SessionSpecContainer
+  implements TimedObjectInvoker, ServiceEndpointContainer, InvokableContext
+{
+   private static final Logger log = Logger.getLogger(StatelessContainer.class);
+
+   protected TimerService timerService;
+   private Method timeout;
+   private StatelessDelegateWrapper mbean = new StatelessDelegateWrapper(this);
+
+   public StatelessContainer(ClassLoader cl, String beanClassName, String ejbName, Domain domain,
+                             Hashtable ctxProperties, Ejb3Deployment deployment, JBossSessionBeanMetaData beanMetaData) throws ClassNotFoundException
+   {
+      super(cl, beanClassName, ejbName, domain, ctxProperties, deployment, beanMetaData);
+      
+      initializeTimeout();
+   }
+
+   @Override
+   public BeanContext<?> createBeanContext()
+   {
+      return new StatelessBeanContext(this, construct());
+   }
+   
+   @Override
+   protected StatelessLocalProxyFactory getProxyFactory(LocalBinding binding)
+   {
+      StatelessLocalProxyFactory factory = (StatelessLocalProxyFactory) this.proxyDeployer.getProxyFactory(binding);
+
+      if (factory == null)
+      {
+         factory = new StatelessLocalProxyFactory(this, binding);
+         try
+         {
+            factory.init();
+         }
+         catch (Exception e)
+         {
+            throw new RuntimeException(e);
+         }
+      }
+
+      return factory;
+   }
+   
+   @Override
+   protected BaseStatelessRemoteProxyFactory getProxyFactory(RemoteBinding binding)
+   {
+      BaseStatelessRemoteProxyFactory factory = (BaseStatelessRemoteProxyFactory) this.proxyDeployer
+            .getProxyFactory(binding);
+
+      if (factory == null)
+      {
+         Clustered clustered = getAnnotation(Clustered.class);
+         if (clustered != null)
+            factory = new StatelessClusterProxyFactory(this, binding, clustered);
+         else
+            factory = new StatelessRemoteProxyFactory(this, binding);
+         
+         try
+         {
+            factory.init();
+         }
+         catch (Exception e)
+         {
+            throw new RuntimeException(e);
+         }
+      }
+
+      return factory;
+   }
+   
+   /**
+    * Create a local proxy (EJBLocalObject) for an enterprise bean identified by id, with
+    * the specified LocalBinding
+    * 
+    * @param id
+    * @return
+    * @throws Exception
+    */
+   @Override
+   public Object createProxyLocalEjb21(LocalBinding binding, String businessInterfaceType) throws Exception
+   {
+      StatelessLocalProxyFactory proxyFactory = this.getProxyFactory(binding);
+      return proxyFactory.createProxyEjb21(businessInterfaceType);
+   }
+   
+   @Override
+   public Object createProxyRemoteEjb21(RemoteBinding binding, String businessInterfaceType) throws Exception
+   {
+      BaseStatelessRemoteProxyFactory proxyFactory = this.getProxyFactory(binding);
+      return proxyFactory.createProxyEjb21(businessInterfaceType);
+   }
+   
+   public Serializable createSession(Class<?> initTypes[], Object initArgs[])
+   {
+      if((initTypes != null && initTypes.length > 0) || (initArgs != null && initArgs.length > 0))
+         throw new IllegalArgumentException("stateless bean create method must take no arguments (EJB3 4.5)");
+      // a stateless bean has no sessions
+      // TODO: pool stuff
+      return null;
+   }
+   
+   public boolean isClustered()
+   {
+      return isAnnotationPresent(Clustered.class);
+   }
+   
+   public Object getMBean()
+   {
+      return mbean;
+   }
+   
+   private void initializeTimeout()
+   {
+      JBossSessionBeanMetaData metaData = getMetaData();
+      NamedMethodMetaData timeoutMethodMetaData = null;
+      if(metaData != null)
+         timeoutMethodMetaData = metaData.getTimeoutMethod();
+      this.timeout = getTimeoutCallback(timeoutMethodMetaData, getBeanClass());
+   }
+   
+   @Override
+   protected void lockedStart() throws Exception
+   {
+      try
+      {
+         super.lockedStart();
+         
+         timerService = TimerServiceFactory.getInstance().createTimerService(this, this);
+         
+         TimerServiceFactory.getInstance().restoreTimerService(timerService);
+      }
+      catch (Exception e)
+      {
+         try
+         {
+            this.lockedStop();
+         }
+         catch (Exception ignore)
+         {
+            log.debug("Failed to cleanup after start() failure", ignore);
+         }
+         throw e;
+      }
+   }
+
+   @Override
+   protected void lockedStop() throws Exception
+   {
+      if (timerService != null)
+      {
+         TimerServiceFactory.getInstance().removeTimerService(timerService);
+         timerService = null;
+      }
+      
+      super.lockedStop();
+   }
+
+   public TimerService getTimerService()
+   {
+      return timerService;
+   }
+
+   public TimerService getTimerService(Object pKey)
+   {
+      assert timerService != null : "Timer Service not yet initialized";
+      return timerService;
+   }
+   
+   public void callTimeout(Timer timer) throws Exception
+   {
+      if (timeout == null) throw new EJBException("No method has been annotated with @Timeout");
+      Object[] args = {timer};
+      ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
+      try
+      {
+         AllowedOperationsAssociation.pushInMethodFlag(AllowedOperationsFlags.IN_EJB_TIMEOUT);
+         try
+         {
+            MethodInfo info = super.getMethodInfo(timeout);
+            EJBContainerInvocation nextInvocation = new EJBContainerInvocation(info);
+            nextInvocation.setAdvisor(getAdvisor());
+            nextInvocation.setArguments(args);
+            nextInvocation.invokeNext();
+         }
+         catch (Throwable throwable)
+         {
+            if (throwable instanceof Exception) throw (Exception) throwable;
+            throw new RuntimeException(throwable);
+         }
+         finally
+         {
+            AllowedOperationsAssociation.popInMethodFlag();
+         }
+      }
+      finally
+      {
+         Thread.currentThread().setContextClassLoader(oldLoader);
+      }
+   }
+
+   /**
+    * Performs a synchronous local invocation
+    */
+   public Object localInvoke(Method method, Object[] args) throws Throwable
+   {
+      return localInvoke(method, args, null);
+   }
+
+   /**
+    * Performs a synchronous or asynchronous local invocation
+    *
+    * @param provider If null a synchronous invocation, otherwise an asynchronous
+    */
+   public Object localInvoke(Method method, Object[] args, FutureHolder provider) throws Throwable
+   {
+      return localInvoke(method, args, provider, null);
+   }
+   
+   public Object localInvoke(Object id, Method method, Object[] args, FutureHolder provider) throws Throwable
+   {
+      return localInvoke(method, args, provider);
+   }
+   
+   public Object localInvoke(Method method, Object[] args, FutureHolder provider, BeanContextLifecycleCallback<StatelessBeanContext> callback) throws Throwable
+   {
+      long start = System.currentTimeMillis();
+      
+      ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
+      try
+      {
+         MethodInfo info = getMethodInfo(method);
+         Method unadvisedMethod = info.getUnadvisedMethod();
+
+         try
+         {
+            invokeStats.callIn();
+            
+            //invokedMethod.push(new SerializableMethod(unadvisedMethod, unadvisedMethod.getClass()));
+
+            if (unadvisedMethod != null && isHomeMethod(unadvisedMethod))
+            {
+               return localHomeInvoke(unadvisedMethod, args);
+            }
+
+            EJBContainerInvocation<StatelessContainer, StatelessBeanContext> nextInvocation = new EJBContainerInvocation<StatelessContainer, StatelessBeanContext>(info);
+            nextInvocation.setAdvisor(getAdvisor());
+            nextInvocation.setArguments(args);
+            nextInvocation.setContextCallback(callback);
+
+            ProxyUtils.addLocalAsynchronousInfo(nextInvocation, provider);
+            return nextInvocation.invokeNext();
+         }
+         finally
+         {
+            if (unadvisedMethod != null)
+            {
+               long end = System.currentTimeMillis();
+               long elapsed = end - start;
+               invokeStats.updateStats(unadvisedMethod, elapsed);
+            }
+            
+            invokeStats.callOut();
+            
+            //invokedMethod.pop();
+         }
+      }
+      finally
+      {
+         Thread.currentThread().setContextClassLoader(oldLoader);
+      }
+   }
+   
+   /**
+    * Remote Invocation entry point, as delegated from
+    * ClassProxyHack (Remoting Dispatcher)
+    */
+   public InvocationResponse dynamicInvoke(Invocation invocation) throws Throwable
+   {
+      /*
+       * Initialize
+       */
+
+      // Mark the start time
+      long start = System.currentTimeMillis();
+
+      // Create a pointer to a new Invocation
+      EJBContainerInvocation newSi = null;
+
+      // Create a pointer to the response we'll return
+      InvocationResponse response = null;
+      
+
+      /*
+       * Setup Environment (Stack/Thread)
+       */
+
+      // Hold a reference to the existing TCL
+      ClassLoader originalLoader = Thread.currentThread().getContextClassLoader();
+
+      // Set the Container's CL as TCL, required to unmarshall methods from the bean impl class
+      Thread.currentThread().setContextClassLoader(this.getClassloader());
+
+      // Push the ENC onto the stack
+      pushEnc();
+      
+      try
+      {
+         
+         /*
+          * Obtain the target method (unmarshall from invocation)
+          */
+
+         // Cast
+         assert invocation instanceof StatefulRemoteInvocation : SessionContainer.class.getName()
+               + ".dynamicInoke supports only " + StatefulRemoteInvocation.class.getSimpleName()
+               + ", but has been passed: " + invocation;
+         MethodInvocation si = (MethodInvocation) invocation;
+
+         // Get the method hash
+         long methodHash = si.getMethodHash();
+         log.debug("Received dynamic invocation for method with hash: " + methodHash);
+
+         // Get the Method via MethodInfo from the Advisor
+         Advisor advisor = this.getAdvisor();
+         MethodInfo info = advisor.getMethodInfo(methodHash);
+         Method unadvisedMethod = info.getMethod();
+         SerializableMethod unadvisedMethodSerializable = new SerializableMethod(unadvisedMethod);
+         
+         try
+         {
+            invokeStats.callIn();
+            
+            /*
+             * Set the invoked method
+             */
+            //TODO Remove when CurrentInvocation is ironed out
+            
+            // Get the invoked method from invocation metadata
+            Object objInvokedMethod = si.getMetaData(SessionSpecRemotingMetadata.TAG_SESSION_INVOCATION,SessionSpecRemotingMetadata.KEY_INVOKED_METHOD);
+            assert objInvokedMethod !=null : "Invoked Method must be set on invocation metadata";
+            assert objInvokedMethod instanceof SerializableMethod : "Invoked Method set on invocation metadata is not of type " + SerializableMethod.class.getName() + ", instead: " + objInvokedMethod;
+            SerializableMethod invokedMethod = (SerializableMethod)objInvokedMethod;
+            
+            // Set onto stack
+            SessionSpecContainer.invokedMethod.push(invokedMethod);
+
+            //invokedMethod.push(new SerializableMethod(unadvisedMethod, unadvisedMethod.getClass()));
+            Map responseContext = null;
+            Object rtn = null;
+            if (unadvisedMethod != null && isHomeMethod(unadvisedMethodSerializable))
+            {
+               rtn = invokeHomeMethod(info, si);
+            }
+            else if (info != null && unadvisedMethod != null && isEjbObjectMethod(unadvisedMethodSerializable))
+            {
+               rtn = invokeEJBObjectMethod(info, si);
+            }
+            else
+            {
+
+               newSi = new EJBContainerInvocation<StatelessContainer, StatelessBeanContext>(info);
+               newSi.setArguments(si.getArguments());
+               newSi.setMetaData(si.getMetaData());
+               //newSi.setAdvisor(getAdvisor());               
+               
+               try
+               {
+                  rtn = newSi.invokeNext();
+                  responseContext = newSi.getResponseContextInfo();
+               }
+               catch (Throwable throwable)
+               {
+                  responseContext = newSi.getResponseContextInfo();
+                  return marshallException(invocation, throwable, responseContext);
+               }
+               finally
+               {
+                  SessionSpecContainer.invokedMethod.pop();
+               }
+            }
+
+            response = marshallResponse(invocation, rtn, responseContext);
+            return response;
+         }
+         finally
+         {
+            if (unadvisedMethod != null)
+            {
+               long end = System.currentTimeMillis();
+               long elapsed = end - start;
+               invokeStats.updateStats(unadvisedMethod, elapsed);
+            }
+
+            invokeStats.callOut();
+
+            //invokedMethod.pop();
+         }
+      }
+      finally
+      {
+         Thread.currentThread().setContextClassLoader(originalLoader);
+      }
+   }
+
+   @Deprecated
+   public InvocationResponse dynamicInvoke(Object target, Invocation invocation) throws Throwable
+   {
+      long start = System.currentTimeMillis();
+      
+      ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
+      try
+      {
+         Thread.currentThread().setContextClassLoader(classloader);
+         MethodInvocation si = (MethodInvocation) invocation;
+         MethodInfo info = getAdvisor().getMethodInfo(si.getMethodHash());
+         if (info == null)
+         {
+            throw new RuntimeException("Could not resolve beanClass method from proxy call " + invocation);
+         }
+
+         Method unadvisedMethod = info.getUnadvisedMethod();
+         try
+         {
+            invokeStats.callIn();
+            
+            //invokedMethod.push(new SerializableMethod(unadvisedMethod, unadvisedMethod.getClass()));
+            Map responseContext = null;
+            Object rtn = null;
+            if (unadvisedMethod != null && isHomeMethod(unadvisedMethod))
+            {
+               rtn = invokeHomeMethod(info, si);
+            }
+            else if (info != null && unadvisedMethod != null && isEJBObjectMethod(unadvisedMethod))
+            {
+               rtn = invokeEJBObjectMethod(info, si);
+            }
+            else
+            {
+
+               EJBContainerInvocation newSi = null;
+
+               newSi = new EJBContainerInvocation<StatelessContainer, StatelessBeanContext>(info);
+               newSi.setArguments(si.getArguments());
+               newSi.setMetaData(si.getMetaData());
+               newSi.setAdvisor(getAdvisor());
+               try
+               {
+                  rtn = newSi.invokeNext();
+                  responseContext = newSi.getResponseContextInfo();
+               }
+               catch (Throwable throwable)
+               {
+                  responseContext = newSi.getResponseContextInfo();
+                  return marshallException(invocation, throwable, responseContext);
+               }
+            }
+
+            InvocationResponse response = marshallResponse(invocation, rtn, responseContext);
+            return response;
+         }
+         finally
+         {
+            if (unadvisedMethod != null)
+            {
+               long end = System.currentTimeMillis();
+               long elapsed = end - start;
+               invokeStats.updateStats(unadvisedMethod, elapsed);
+            }
+            
+            invokeStats.callOut();
+            
+            //invokedMethod.pop();
+         }
+      }
+      finally
+      {
+         Thread.currentThread().setContextClassLoader(oldLoader);
+      }
+   }
+
+
+   protected Object invokeEJBObjectMethod(MethodInfo info, MethodInvocation invocation) throws Throwable
+   {
+      Method unadvisedMethod = info.getUnadvisedMethod();
+      if (unadvisedMethod.getName().equals("getHandle"))
+      {
+         
+         StatelessHandleRemoteImpl handle = null;
+         RemoteBinding binding = this.getAnnotation(RemoteBinding.class);
+         BaseStatelessRemoteProxyFactory factory = this.getProxyFactory(binding);
+         handle = factory.createHandle();
+
+         return handle;
+      }
+      else if (unadvisedMethod.getName().equals("remove"))
+      {
+         return null;
+      }
+      else if (unadvisedMethod.getName().equals("getEJBHome"))
+      {
+         HomeHandleImpl homeHandle = null;
+
+         RemoteBinding remoteBindingAnnotation = this.getAnnotation(RemoteBinding.class);
+         if (remoteBindingAnnotation != null)
+            homeHandle = new HomeHandleImpl(ProxyFactoryHelper.getHomeJndiName(this));
+
+         return homeHandle.getEJBHome();
+      }
+      else if (unadvisedMethod.getName().equals("getPrimaryKey"))
+      {
+         return null;
+      }
+      else if (unadvisedMethod.getName().equals("isIdentical"))
+      {
+         return false;
+      }
+      else
+      {
+         return null;
+      }
+   }
+
+   public Object localHomeInvoke(Method method, Object[] args) throws Throwable
+   {
+      if (method.getName().equals("create"))
+      {
+         LocalBinding binding = this.getAnnotation(LocalBinding.class);
+
+         // FIXME: why this binding? Could be another one. (there is only one local binding, but that's another bug)
+
+         StatelessLocalProxyFactory factory = this.getProxyFactory(binding);
+
+         Object proxy = factory.createProxyEjb21(method.getReturnType().getName());
+
+         return proxy;
+      }
+      else
+      // remove
+      {
+         return null;
+      }
+   }
+
+   protected Object invokeHomeMethod(MethodInfo info, MethodInvocation invocation) throws Throwable
+   {
+      Method unadvisedMethod = info.getUnadvisedMethod();
+      if (unadvisedMethod.getName().equals("create"))
+      {
+         RemoteBinding binding = this.getRemoteBinding();
+
+         BaseStatelessRemoteProxyFactory factory = this.getProxyFactory(binding);
+
+         return factory.createProxyEjb21(unadvisedMethod.getReturnType().getName());
+      }
+      else
+      // remove
+      {
+         return null;
+      }
+   }
+
+   @Override
+   public Object getBusinessObject(BeanContext ctx, Class intf)
+   {
+      assert intf != null : "intf is null";
+      
+      try
+      {
+         
+         /*
+          * Get all business interfaces
+          */
+         Set<String> businessInterfaceNames = new HashSet<String>();
+         JBossSessionBeanMetaData smd= (JBossSessionBeanMetaData)this.getXml();
+         businessInterfaceNames.addAll(smd.getBusinessRemotes());
+         businessInterfaceNames.addAll(smd.getBusinessLocals());
+         
+         String interfaceName = intf.getName();
+         
+         if (!businessInterfaceNames.contains(interfaceName))
+            throw new IllegalStateException("Cannot find BusinessObject for interface: " + interfaceName);
+         
+         String jndiName = this.getXml().determineResolvedJndiName(interfaceName);
+         return getInitialContext().lookup(jndiName);
+      }
+      catch (NamingException e)
+      {
+         throw new RuntimeException("failed to invoke getBusinessObject", e);
+      }
+   }
+
+   protected void removeHandle(Handle handle)
+   {
+      throw new RuntimeException("NYI");
+   }
+
+   /**
+    * WS integration
+    * @return
+    */
+   public Class getServiceImplementationClass()
+   {
+      return this.getBeanClass();
+   }
+
+   /**
+    * WS Integration
+    * @param method
+    * @param args
+    * @param invCtxCallback
+    * @return
+    * @throws Throwable
+    */
+   public Object invokeEndpoint(Method method, Object[] args, InvocationContextCallback invCtxCallback) throws Throwable
+   {
+      // JAX-RPC message context
+      javax.xml.rpc.handler.MessageContext jaxrpcContext = invCtxCallback.get(javax.xml.rpc.handler.MessageContext.class);
+
+      // JAX-WS webservice context
+      SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+      WebServiceContextFactory contextFactory = spiProvider.getSPI(WebServiceContextFactory.class);
+      ExtensibleWebServiceContext jaxwsContext = contextFactory.newWebServiceContext(
+        InvocationType.JAXWS_EJB3,
+        invCtxCallback.get(javax.xml.ws.handler.MessageContext.class)
+      );
+
+      // ThreadLocal association
+      WebServiceContextProxy.associateMessageContext(jaxwsContext);
+
+      // EJB3 Injection Callbacks
+      WSCallbackImpl ejb3Callback = new WSCallbackImpl( jaxrpcContext, jaxwsContext );
+
+      // Actual invocation
+      return this.localInvoke(method, args, null, ejb3Callback);
+   }
+
+   public String getContainerName()
+   {
+      String name = this.getObjectName() != null ? this.getObjectName().getCanonicalName() : null;
+      return name;
+   }
+   
+   /**
+    * Returns the name under which the JNDI Registrar for this container is bound
+    * 
+    * @return
+    */
+   protected String getJndiRegistrarBindName()
+   {
+      return isClustered() ? ClusteredObjectStoreBindings.CLUSTERED_OBJECTSTORE_BEAN_NAME_JNDI_REGISTRAR_SLSB
+                           : ObjectStoreBindings.OBJECTSTORE_BEAN_NAME_JNDI_REGISTRAR_SLSB;
+   }
+   
+   static class WSCallbackImpl implements BeanContextLifecycleCallback
+   {
+      private ExtensibleWebServiceContext jaxwsContext;
+      private javax.xml.rpc.handler.MessageContext jaxrpcMessageContext;
+
+      public WSCallbackImpl(javax.xml.rpc.handler.MessageContext jaxrpc, ExtensibleWebServiceContext jaxws)
+      {
+         jaxrpcMessageContext = jaxrpc;
+         jaxwsContext = jaxws;
+      }
+
+      public void attached(BeanContext beanCtx)
+      {
+         // JAX-RPC MessageContext
+         StatelessBeanContext sbc = (StatelessBeanContext)beanCtx;
+         sbc.setMessageContextJAXRPC(jaxrpcMessageContext);
+
+         // JAX-WS MessageContext
+         BeanProperty beanProp = sbc.getWebServiceContextProperty();
+         if (beanProp != null)
+         {
+            EJBContext ejbCtx = beanCtx.getEJBContext();            
+            jaxwsContext.addAttachment(EJBContext.class, ejbCtx);
+            beanProp.set(beanCtx.getInstance(), jaxwsContext);
+         }
+      }
+
+      public void released(BeanContext beanCtx)
+      {
+         StatelessBeanContext sbc = (StatelessBeanContext)beanCtx;
+         sbc.setMessageContextJAXRPC(null);
+
+         BeanProperty beanProp = sbc.getWebServiceContextProperty();
+         if (beanProp != null)
+            beanProp.set(beanCtx.getInstance(), null);
+      }      
+   }
+}

Deleted: projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/resources/META-INF/ejb3-deployers-jboss-beans.xml
===================================================================
--- projects/ejb3/trunk/core/src/main/resources/META-INF/ejb3-deployers-jboss-beans.xml	2008-08-25 02:13:51 UTC (rev 77394)
+++ projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/resources/META-INF/ejb3-deployers-jboss-beans.xml	2008-08-25 05:28:04 UTC (rev 77405)
@@ -1,310 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-    EJB3 Deployers
--->
-<deployment xmlns="urn:jboss:bean-deployer:2.0">
-
-   <bean name="DefaultPersistenceProperties" class="org.jboss.ejb3.DefaultPersistenceProperties"/>
-
-   <bean name="Ejb3Deployer" class="org.jboss.ejb3.deployers.Ejb3Deployer">
-      <property name="type">ejb3x</property>
-      <property name="kernel"><inject bean="jboss.kernel:service=Kernel"/></property>
-      <property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
-      <property name="defaultPersistenceProperties"><inject bean="DefaultPersistenceProperties" property="properties"/></property>
-      <property name="cacheFactoryRegistry"><inject bean="EJB3CacheFactoryRegistry" /></property>
-      <property name="poolFactoryRegistry"><inject bean="EJB3PoolFactoryRegistry" /></property>
-      <property name="remoteProxyFactoryRegistry"><inject bean="EJB3RemoteProxyFactoryRegistry" /></property>
-      <property name="persistenceManagerFactoryRegistry"><inject bean="EJB3PersistenceManagerFactoryRegistry" /></property>
-      
-      <!-- 
-   
-      Configure the deployer to optionally require a deployment 
-      descriptor for deployable units.  By turning this switch to "true", 
-      "META-INF/jboss.xml" or the EJB3 Deployment Descriptor "META-INF/ejb-jar.xml" 
-      will be required for deployment, enabling a performance increace in deployment by
-      not scanning for annotations in non-deployable EJB3 JARs.
-      
-      Default for this value is "false".
-      
-      -->
-      <property name="deploymentDescriptorRequired">false</property>
-      
-      <property name="ignoredJarsSet">
-         <set elementClass="java.lang.String">
-            <value>snmp-adaptor.jar</value>
-            <value>otherimages.jar</value>
-            <value>applet.jar</value>
-            <value>jcommon.jar</value>
-            <value>console-mgr-classes.jar</value>
-            <value>jfreechart.jar</value>
-            <value>juddi-service.jar</value>
-            <value>wsdl4j.jar</value>
-            <value>commons-collections.jar</value>
-            <value>commons-pool.jar</value>
-            <value>juddi.jar</value>
-            <value>commons-discovery.jar</value>
-            <value>uddi4j.jar</value>
-            <value>axis.jar</value>
-            <value>commons-dbcp.jar</value>
-            <value>jboss-juddiaxis.jar</value>
-            <value>trove.jar</value>
-            <value>javassist.jar</value>
-            <value>jboss-aop-jdk50.jar</value>
-            <value>jboss-aspect-library-jdk50.jar</value>
-            <value>ejb3-persistence.jar</value>
-            <value>commons-validator-1.1.3.jar</value>
-            <value>commons-collections.jar</value>
-            <value>commons-fileupload.jar</value>
-            <value>commons-pool.jar</value>
-            <value>hibernate-entitymanager.jar</value>
-            <value>jboss-ejb3x.jar</value>
-            <value>commons-digester-1.6.jar</value>
-            <value>cglib-2.1.1.jar</value>
-            <value>commons-discovery.jar</value>
-            <value>jboss-annotations-ejb3.jar</value>
-            <value>jaxen-1.1-beta-4.jar</value>
-            <value>hibernate-annotations.jar</value>
-            <value>commons-httpclient.jar</value>
-            <value>commons-logging.jar</value>
-            <value>commons-vfs.jar</value>
-            <value>hibernate3.jar</value>
-            <value>commons-logging-api.jar</value>
-            <value>asm.jar</value>
-            <value>asm-attrs.jar</value>
-            <value>commons-lang-2.0.jar</value>
-            <value>commons-beanutils.jar</value>
-            <value>jboss-ejb3.jar</value>
-            <value>dom4j.jar</value>
-            <value>commons-codec-1.2.jar</value>
-            <value>wsdl4j.jar</value>
-            <value>xmlsec.jar</value>
-            <value>jbossws.jar</value>
-            <value>jboss-bean-deployer.jar</value>
-            <value>jboss-microcontainer.jar</value>
-            <value>jboss-dependency.jar</value>
-            <value>jboss-container.jar</value>
-            <value>tomcat-coyote.jar</value>
-            <value>commons-collections.jar</value>
-            <value>myfaces.jar</value>
-            <value>jstl.jar</value>
-            <value>commons-digester-1.6.jar</value>
-            <value>myfaces-impl.jar</value>
-            <value>commons-beanutils.jar</value>
-            <value>myfaces-jsf-api.jar</value>
-            <value>commons-codec-1.2.jar</value>
-            <value>catalina-optional.jar</value>
-            <value>tomcat-util.jar</value>
-            <value>jasper-compiler.jar</value>
-            <value>commons-el.jar</value>
-            <value>jasper-compiler-jdt.jar</value>
-            <value>tomcat-http.jar</value>
-            <value>catalina-manager.jar</value>
-            <value>jasper-runtime.jar</value>
-            <value>tomcat55-service.jar</value>
-            <value>servlets-invoker.jar</value>
-            <value>catalina.jar</value>
-            <value>naming-resources.jar</value>
-            <value>servlets-default.jar</value>
-            <value>tomcat-ajp.jar</value>
-            <value>commons-modeler.jar</value>
-            <value>tomcat-apr.jar</value>
-            <value>servlets-webdav.jar</value>
-         </set>
-      </property>
-      <depends>AspectLibrary</depends>
-   </bean>
-   
-   <bean name="AppClientParsingDeployer" class="org.jboss.ejb3.deployers.AppClientParsingDeployer">
-      <property name="type">car</property>
-      <!-- TODO: check depends -->
-      <depends>AspectLibrary</depends>
-   </bean>
-   
-   <bean name="JBossClientParsingDeployer" class="org.jboss.ejb3.deployers.JBossClientParsingDeployer">
-      <property name="type">car</property>
-      <depends>AppClientParsingDeployer</depends>
-   </bean>
-   
-   <bean name="AppClientScanningDeployer" class="org.jboss.ejb3.deployers.AppClientScanningDeployer">
-      <depends>JBossClientParsingDeployer</depends>
-   </bean>
-   
-   <bean name="Ejb3ClientDeployer" class="org.jboss.ejb3.deployers.Ejb3ClientDeployer">
-      <property name="type">car</property>
-      <property name="kernel"><inject bean="jboss.kernel:service=Kernel"/></property>
-      <property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
-      <!-- TODO: check depends -->
-      <depends>AspectLibrary</depends>
-      <depends>AppClientScanningDeployer</depends>
-   </bean>
-   
-   <!-- EJB3 Cache Factory Registry -->
-   <bean name="EJB3CacheFactoryRegistry" class="org.jboss.ejb3.cache.CacheFactoryRegistry">
-      <property name="factories">
-         <!-- Define each of the registered factories -->
-         <map class="java.util.HashMap" keyClass="java.lang.String"
-            valueClass="java.lang.Class">
-            <!-- NoPassivationCache -->
-            <entry>
-               <key>NoPassivationCache</key>
-               <value>org.jboss.ejb3.cache.NoPassivationCacheFactory</value>
-            </entry>
-            <!-- SimpleStatefulCache -->
-            <entry>
-               <key>SimpleStatefulCache</key>
-               <value>org.jboss.ejb3.cache.simple.SimpleStatefulCacheFactory</value>
-            </entry>
-            <!-- StatefulTreeCache -->
-            <entry>
-               <key>StatefulTreeCache</key>
-               <value>org.jboss.ejb3.cache.tree.StatefulTreeCacheFactory</value>
-            </entry>
-         </map>
-      </property>
-   </bean>
-   
-   <!-- EJB3 Pool Factory Registry -->
-   <bean name="EJB3PoolFactoryRegistry" class="org.jboss.ejb3.pool.PoolFactoryRegistry">
-      <property name="factories">
-         <!-- Define each of the registered factories -->
-         <map class="java.util.HashMap" keyClass="java.lang.String"
-            valueClass="java.lang.Class">
-            <!-- ThreadlocalPool -->
-            <entry>
-               <key>ThreadlocalPool</key>
-               <value>org.jboss.ejb3.pool.ThreadlocalPoolFactory</value>
-            </entry>
-            <!-- StrictMaxPool -->
-            <entry>
-               <key>StrictMaxPool</key>
-               <value>org.jboss.ejb3.pool.StrictMaxPoolFactory</value>
-            </entry>
-         </map>
-      </property>
-   </bean>
-   
-   <!-- Remoting Proxy Factory Registry -->
-   <bean name="EJB3RemoteProxyFactoryRegistry" class="org.jboss.ejb3.proxy.factory.RemoteProxyFactoryRegistry">
-      <property name="factories">
-         <!-- Define each of the registered factories -->
-         <map class="java.util.HashMap" keyClass="java.lang.String"
-            valueClass="java.lang.Class">
-            <!-- RemoteProxyFactory -->
-            <entry>
-               <key>RemoteProxyFactory</key>
-               <value>org.jboss.ejb3.proxy.factory.RemoteProxyFactory</value>
-            </entry>
-            <!-- IORFactory -->
-            <entry>
-               <key>IORFactory</key>
-               <value>org.jboss.ejb3.iiop.IORFactory</value>
-            </entry>
-            <!-- ServiceRemoteProxyFactory -->
-            <entry>
-               <key>ServiceRemoteProxyFactory</key>
-               <value>org.jboss.ejb3.proxy.factory.service.ServiceRemoteProxyFactory</value>
-            </entry>
-            <!-- StatefulClusterProxyFactory -->
-            <entry>
-               <key>StatefulClusterProxyFactory</key>
-               <value>org.jboss.ejb3.proxy.factory.stateful.StatefulClusterProxyFactory</value>
-            </entry>
-            <!-- StatefulRemoteProxyFactory -->
-            <entry>
-               <key>StatefulRemoteProxyFactory</key>
-               <value>org.jboss.ejb3.proxy.factory.stateful.StatefulRemoteProxyFactory</value>
-            </entry>
-            <!-- StatelessClusterProxyFactory -->
-            <entry>
-               <key>StatelessClusterProxyFactory</key>
-               <value>org.jboss.ejb3.proxy.factory.stateless.StatelessClusterProxyFactory</value>
-            </entry>
-            <!-- StatelessRemoteProxyFactory -->
-            <entry>
-               <key>StatelessRemoteProxyFactory</key>
-               <value>org.jboss.ejb3.proxy.factory.stateless.StatelessRemoteProxyFactory</value>
-            </entry>            
-         </map>
-      </property>
-      <property name="loadBalancePolicies">
-         <!-- Define each of the registered factories -->
-         <map class="java.util.HashMap" keyClass="java.lang.String"
-            valueClass="java.lang.Class">
-            <!-- RoundRobin -->
-            <entry>
-               <key>RoundRobin</key>
-               <value>org.jboss.ha.client.loadbalance.RoundRobin</value>
-            </entry>
-            <!-- RandomRobin -->
-            <entry>
-               <key>RandomRobin</key>
-               <value>org.jboss.ha.client.loadbalance.RandomRobin</value>
-            </entry>
-            <!-- FirstAvailable -->
-            <entry>
-               <key>FirstAvailable</key>
-               <value>org.jboss.ha.client.loadbalance.FirstAvailable</value>
-            </entry>
-         </map>
-      </property>
-   </bean>
-   
-   <!-- EJB3 Persistence Manager Factory Registry -->
-   <bean name="EJB3PersistenceManagerFactoryRegistry" class="org.jboss.ejb3.cache.persistence.PersistenceManagerFactoryRegistry">
-      <property name="factories">
-         <!-- Define each of the registered factories -->
-         <map class="java.util.HashMap" keyClass="java.lang.String"
-            valueClass="java.lang.Class">
-            <!-- StatefulSessionFilePersistenceManager -->
-            <entry>
-               <key>StatefulSessionFilePersistenceManager</key>
-               <value>org.jboss.ejb3.cache.simple.StatefulSessionFilePersistenceManagerFactory</value>
-            </entry>
-         </map>
-      </property>
-   </bean>
-   
-   <bean name="JNDIKernelRegistryPlugin" class="org.jboss.ejb3.kernel.JNDIKernelRegistryPlugin"/>
-   
-   <!-- Persistence Unit deployers -->
-   <bean name="PersistenceUnitParsingDeployer" class="org.jboss.ejb3.deployers.PersistenceUnitParsingDeployer">
-      <property name="type">car</property>
-   </bean>
-   
-   <!-- 
-    
-    JNDI Registrars
-    
-    
-    The JNDI Registrar is responsible for all JNDI Bindings for
-    an EJB.  Its constructor takes the following arguments, in order:
-    
-    javax.naming.Context (JNDI Context into which to bind objects)
-    org.jboss.ejb3.proxy.spi.registry.ProxyFactoryRegistry (Implementation of ProxyFactoryRegistry)
-    String statelessSessionProxyObjectFactoryType The JNDI ObjectFactory implementation to use for SLSB
-    ...more later when SFSB, @Service, MDB Implemented
-    
-  -->
-
-  <!-- SLSB JNDI Registrar -->
-  <bean name="org.jboss.ejb3.JndiRegistrar.Session.SLSBJndiRegistrar"
-    class="org.jboss.ejb3.proxy.jndiregistrar.JndiStatelessSessionRegistrar">
-    <constructor>
-      <parameter>
-        org.jboss.ejb3.proxy.objectfactory.session.stateless.StatelessSessionProxyObjectFactory
-      </parameter>
-    </constructor>
-  </bean>
-
-  <!-- SFSB JNDI Registrar -->
-  <bean name="org.jboss.ejb3.JndiRegistrar.Session.SFSBJndiRegistrar"
-    class="org.jboss.ejb3.proxy.jndiregistrar.JndiStatefulSessionRegistrar">
-    <constructor>
-      <parameter>
-        org.jboss.ejb3.proxy.objectfactory.session.stateful.StatefulSessionProxyObjectFactory
-      </parameter>
-    </constructor>
-  </bean>
-   
-</deployment>

Copied: projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/resources/META-INF/ejb3-deployers-jboss-beans.xml (from rev 77399, projects/ejb3/trunk/core/src/main/resources/META-INF/ejb3-deployers-jboss-beans.xml)
===================================================================
--- projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/resources/META-INF/ejb3-deployers-jboss-beans.xml	                        (rev 0)
+++ projects/ejb3/tags/jboss-ejb3-core-0.1.15/src/main/resources/META-INF/ejb3-deployers-jboss-beans.xml	2008-08-25 05:28:04 UTC (rev 77405)
@@ -0,0 +1,329 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+    EJB3 Deployers
+-->
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <bean name="DefaultPersistenceProperties" class="org.jboss.ejb3.DefaultPersistenceProperties"/>
+
+   <bean name="Ejb3Deployer" class="org.jboss.ejb3.deployers.Ejb3Deployer">
+      <property name="type">ejb3x</property>
+      <property name="kernel"><inject bean="jboss.kernel:service=Kernel"/></property>
+      <property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
+      <property name="defaultPersistenceProperties"><inject bean="DefaultPersistenceProperties" property="properties"/></property>
+      <property name="cacheFactoryRegistry"><inject bean="EJB3CacheFactoryRegistry" /></property>
+      <property name="poolFactoryRegistry"><inject bean="EJB3PoolFactoryRegistry" /></property>
+      <property name="remoteProxyFactoryRegistry"><inject bean="EJB3RemoteProxyFactoryRegistry" /></property>
+      <property name="persistenceManagerFactoryRegistry"><inject bean="EJB3PersistenceManagerFactoryRegistry" /></property>
+      
+      <!-- 
+   
+      Configure the deployer to optionally require a deployment 
+      descriptor for deployable units.  By turning this switch to "true", 
+      "META-INF/jboss.xml" or the EJB3 Deployment Descriptor "META-INF/ejb-jar.xml" 
+      will be required for deployment, enabling a performance increace in deployment by
+      not scanning for annotations in non-deployable EJB3 JARs.
+      
+      Default for this value is "false".
+      
+      -->
+      <property name="deploymentDescriptorRequired">false</property>
+      
+      <property name="ignoredJarsSet">
+         <set elementClass="java.lang.String">
+            <value>snmp-adaptor.jar</value>
+            <value>otherimages.jar</value>
+            <value>applet.jar</value>
+            <value>jcommon.jar</value>
+            <value>console-mgr-classes.jar</value>
+            <value>jfreechart.jar</value>
+            <value>juddi-service.jar</value>
+            <value>wsdl4j.jar</value>
+            <value>commons-collections.jar</value>
+            <value>commons-pool.jar</value>
+            <value>juddi.jar</value>
+            <value>commons-discovery.jar</value>
+            <value>uddi4j.jar</value>
+            <value>axis.jar</value>
+            <value>commons-dbcp.jar</value>
+            <value>jboss-juddiaxis.jar</value>
+            <value>trove.jar</value>
+            <value>javassist.jar</value>
+            <value>jboss-aop-jdk50.jar</value>
+            <value>jboss-aspect-library-jdk50.jar</value>
+            <value>ejb3-persistence.jar</value>
+            <value>commons-validator-1.1.3.jar</value>
+            <value>commons-collections.jar</value>
+            <value>commons-fileupload.jar</value>
+            <value>commons-pool.jar</value>
+            <value>hibernate-entitymanager.jar</value>
+            <value>jboss-ejb3x.jar</value>
+            <value>commons-digester-1.6.jar</value>
+            <value>cglib-2.1.1.jar</value>
+            <value>commons-discovery.jar</value>
+            <value>jboss-annotations-ejb3.jar</value>
+            <value>jaxen-1.1-beta-4.jar</value>
+            <value>hibernate-annotations.jar</value>
+            <value>commons-httpclient.jar</value>
+            <value>commons-logging.jar</value>
+            <value>commons-vfs.jar</value>
+            <value>hibernate3.jar</value>
+            <value>commons-logging-api.jar</value>
+            <value>asm.jar</value>
+            <value>asm-attrs.jar</value>
+            <value>commons-lang-2.0.jar</value>
+            <value>commons-beanutils.jar</value>
+            <value>jboss-ejb3.jar</value>
+            <value>dom4j.jar</value>
+            <value>commons-codec-1.2.jar</value>
+            <value>wsdl4j.jar</value>
+            <value>xmlsec.jar</value>
+            <value>jbossws.jar</value>
+            <value>jboss-bean-deployer.jar</value>
+            <value>jboss-microcontainer.jar</value>
+            <value>jboss-dependency.jar</value>
+            <value>jboss-container.jar</value>
+            <value>tomcat-coyote.jar</value>
+            <value>commons-collections.jar</value>
+            <value>myfaces.jar</value>
+            <value>jstl.jar</value>
+            <value>commons-digester-1.6.jar</value>
+            <value>myfaces-impl.jar</value>
+            <value>commons-beanutils.jar</value>
+            <value>myfaces-jsf-api.jar</value>
+            <value>commons-codec-1.2.jar</value>
+            <value>catalina-optional.jar</value>
+            <value>tomcat-util.jar</value>
+            <value>jasper-compiler.jar</value>
+            <value>commons-el.jar</value>
+            <value>jasper-compiler-jdt.jar</value>
+            <value>tomcat-http.jar</value>
+            <value>catalina-manager.jar</value>
+            <value>jasper-runtime.jar</value>
+            <value>tomcat55-service.jar</value>
+            <value>servlets-invoker.jar</value>
+            <value>catalina.jar</value>
+            <value>naming-resources.jar</value>
+            <value>servlets-default.jar</value>
+            <value>tomcat-ajp.jar</value>
+            <value>commons-modeler.jar</value>
+            <value>tomcat-apr.jar</value>
+            <value>servlets-webdav.jar</value>
+         </set>
+      </property>
+      <depends>AspectLibrary</depends>
+   </bean>
+   
+   <bean name="AppClientParsingDeployer" class="org.jboss.ejb3.deployers.AppClientParsingDeployer">
+      <property name="type">car</property>
+      <!-- TODO: check depends -->
+      <depends>AspectLibrary</depends>
+   </bean>
+   
+   <bean name="JBossClientParsingDeployer" class="org.jboss.ejb3.deployers.JBossClientParsingDeployer">
+      <property name="type">car</property>
+      <depends>AppClientParsingDeployer</depends>
+   </bean>
+   
+   <bean name="AppClientScanningDeployer" class="org.jboss.ejb3.deployers.AppClientScanningDeployer">
+      <depends>JBossClientParsingDeployer</depends>
+   </bean>
+   
+   <bean name="Ejb3ClientDeployer" class="org.jboss.ejb3.deployers.Ejb3ClientDeployer">
+      <property name="type">car</property>
+      <property name="kernel"><inject bean="jboss.kernel:service=Kernel"/></property>
+      <property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
+      <!-- TODO: check depends -->
+      <depends>AspectLibrary</depends>
+      <depends>AppClientScanningDeployer</depends>
+   </bean>
+   
+   <!-- EJB3 Cache Factory Registry -->
+   <bean name="EJB3CacheFactoryRegistry" class="org.jboss.ejb3.cache.CacheFactoryRegistry">
+      <property name="factories">
+         <!-- Define each of the registered factories -->
+         <map class="java.util.HashMap" keyClass="java.lang.String"
+            valueClass="java.lang.Class">
+            <!-- NoPassivationCache -->
+            <entry>
+               <key>NoPassivationCache</key>
+               <value>org.jboss.ejb3.cache.NoPassivationCacheFactory</value>
+            </entry>
+            <!-- SimpleStatefulCache -->
+            <entry>
+               <key>SimpleStatefulCache</key>
+               <value>org.jboss.ejb3.cache.simple.SimpleStatefulCacheFactory</value>
+            </entry>
+            <!-- StatefulTreeCache -->
+            <entry>
+               <key>StatefulTreeCache</key>
+               <value>org.jboss.ejb3.cache.tree.StatefulTreeCacheFactory</value>
+            </entry>
+         </map>
+      </property>
+   </bean>
+   
+   <!-- EJB3 Pool Factory Registry -->
+   <bean name="EJB3PoolFactoryRegistry" class="org.jboss.ejb3.pool.PoolFactoryRegistry">
+      <property name="factories">
+         <!-- Define each of the registered factories -->
+         <map class="java.util.HashMap" keyClass="java.lang.String"
+            valueClass="java.lang.Class">
+            <!-- ThreadlocalPool -->
+            <entry>
+               <key>ThreadlocalPool</key>
+               <value>org.jboss.ejb3.pool.ThreadlocalPoolFactory</value>
+            </entry>
+            <!-- StrictMaxPool -->
+            <entry>
+               <key>StrictMaxPool</key>
+               <value>org.jboss.ejb3.pool.StrictMaxPoolFactory</value>
+            </entry>
+         </map>
+      </property>
+   </bean>
+   
+   <!-- Remoting Proxy Factory Registry -->
+   <bean name="EJB3RemoteProxyFactoryRegistry" class="org.jboss.ejb3.proxy.factory.RemoteProxyFactoryRegistry">
+      <property name="factories">
+         <!-- Define each of the registered factories -->
+         <map class="java.util.HashMap" keyClass="java.lang.String"
+            valueClass="java.lang.Class">
+            <!-- RemoteProxyFactory -->
+            <entry>
+               <key>RemoteProxyFactory</key>
+               <value>org.jboss.ejb3.proxy.factory.RemoteProxyFactory</value>
+            </entry>
+            <!-- IORFactory -->
+            <entry>
+               <key>IORFactory</key>
+               <value>org.jboss.ejb3.iiop.IORFactory</value>
+            </entry>
+            <!-- ServiceRemoteProxyFactory -->
+            <entry>
+               <key>ServiceRemoteProxyFactory</key>
+               <value>org.jboss.ejb3.proxy.factory.service.ServiceRemoteProxyFactory</value>
+            </entry>
+            <!-- StatefulClusterProxyFactory -->
+            <entry>
+               <key>StatefulClusterProxyFactory</key>
+               <value>org.jboss.ejb3.proxy.factory.stateful.StatefulClusterProxyFactory</value>
+            </entry>
+            <!-- StatefulRemoteProxyFactory -->
+            <entry>
+               <key>StatefulRemoteProxyFactory</key>
+               <value>org.jboss.ejb3.proxy.factory.stateful.StatefulRemoteProxyFactory</value>
+            </entry>
+            <!-- StatelessClusterProxyFactory -->
+            <entry>
+               <key>StatelessClusterProxyFactory</key>
+               <value>org.jboss.ejb3.proxy.factory.stateless.StatelessClusterProxyFactory</value>
+            </entry>
+            <!-- StatelessRemoteProxyFactory -->
+            <entry>
+               <key>StatelessRemoteProxyFactory</key>
+               <value>org.jboss.ejb3.proxy.factory.stateless.StatelessRemoteProxyFactory</value>
+            </entry>            
+         </map>
+      </property>
+      <property name="loadBalancePolicies">
+         <!-- Define each of the registered factories -->
+         <map class="java.util.HashMap" keyClass="java.lang.String"
+            valueClass="java.lang.Class">
+            <!-- RoundRobin -->
+            <entry>
+               <key>RoundRobin</key>
+               <value>org.jboss.ha.client.loadbalance.RoundRobin</value>
+            </entry>
+            <!-- RandomRobin -->
+            <entry>
+               <key>RandomRobin</key>
+               <value>org.jboss.ha.client.loadbalance.RandomRobin</value>
+            </entry>
+            <!-- FirstAvailable -->
+            <entry>
+               <key>FirstAvailable</key>
+               <value>org.jboss.ha.client.loadbalance.FirstAvailable</value>
+            </entry>
+         </map>
+      </property>
+   </bean>
+   
+   <!-- EJB3 Persistence Manager Factory Registry -->
+   <bean name="EJB3PersistenceManagerFactoryRegistry" class="org.jboss.ejb3.cache.persistence.PersistenceManagerFactoryRegistry">
+      <property name="factories">
+         <!-- Define each of the registered factories -->
+         <map class="java.util.HashMap" keyClass="java.lang.String"
+            valueClass="java.lang.Class">
+            <!-- StatefulSessionFilePersistenceManager -->
+            <entry>
+               <key>StatefulSessionFilePersistenceManager</key>
+               <value>org.jboss.ejb3.cache.simple.StatefulSessionFilePersistenceManagerFactory</value>
+            </entry>
+         </map>
+      </property>
+   </bean>
+   
+   <bean name="JNDIKernelRegistryPlugin" class="org.jboss.ejb3.kernel.JNDIKernelRegistryPlugin"/>
+   
+   <!-- Persistence Unit deployers -->
+   <bean name="PersistenceUnitParsingDeployer" class="org.jboss.ejb3.deployers.PersistenceUnitParsingDeployer">
+      <property name="type">car</property>
+   </bean>
+   
+   <!-- 
+    
+    JNDI Registrars   
+    
+    The JNDI Registrar is responsible for all JNDI Bindings for
+    an EJB.
+    
+  -->
+
+  <!-- SLSB JNDI Registrar -->
+  <bean name="org.jboss.ejb3.JndiRegistrar.Session.SLSBJndiRegistrar"
+    class="org.jboss.ejb3.proxy.jndiregistrar.JndiStatelessSessionRegistrar">
+    <constructor>
+      <parameter>
+        org.jboss.ejb3.proxy.objectfactory.session.stateless.StatelessSessionProxyObjectFactory
+      </parameter>
+    </constructor>
+  </bean>
+
+  <!-- SFSB JNDI Registrar -->
+  <bean name="org.jboss.ejb3.JndiRegistrar.Session.SFSBJndiRegistrar"
+    class="org.jboss.ejb3.proxy.jndiregistrar.JndiStatefulSessionRegistrar">
+    <constructor>
+      <parameter>
+        org.jboss.ejb3.proxy.objectfactory.session.stateful.StatefulSessionProxyObjectFactory
+      </parameter>
+    </constructor>
+  </bean>
+
+  <bean name="org.jboss.ejb3.ProxyClusteringRegistry"
+        class="org.jboss.ejb3.proxy.clustered.registry.ProxyClusteringRegistry"/>
+
+  <!-- Clustered SLSB JNDI Registrar -->
+  <bean name="org.jboss.ejb3.JndiRegistrar.Session.ClusteredSLSBJndiRegistrar"
+    class="org.jboss.ejb3.proxy.clustered.jndiregistrar.JndiClusteredStatelessSessionRegistrar">
+    <constructor>
+      <parameter>
+        org.jboss.ejb3.proxy.clustered.objectfactory.session.stateless.StatelessSessionClusteredProxyObjectFactory
+      </parameter>
+      <parameter><inject bean="org.jboss.ejb3.ProxyClusteringRegistry"/></parameter>
+    </constructor>
+  </bean>
+
+  <!-- Clustered SFSB JNDI Registrar -->
+  <bean name="org.jboss.ejb3.JndiRegistrar.Session.ClusteredSFSBJndiRegistrar"
+    class="org.jboss.ejb3.proxy.clustered.jndiregistrar.JndiClusteredStatefulSessionRegistrar">
+    <constructor>
+      <parameter>
+        org.jboss.ejb3.proxy.clustered.objectfactory.session.stateful.StatefulSessionClusteredProxyObjectFactory
+      </parameter>
+      <parameter><inject bean="org.jboss.ejb3.ProxyClusteringRegistry"/></parameter>
+    </constructor>
+  </bean>
+   
+</deployment>




More information about the jboss-cvs-commits mailing list