Index: .classpath
===================================================================
--- .classpath	(.../trunk/ejb3)	(revision 97484)
+++ .classpath	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -1,8 +1,34 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-	<classpathentry kind="src" output="target/classes" path="src/main/java"/>
-	<classpathentry excluding="**" kind="src" output="target/classes" path="src/resources"/>
+	<classpathentry kind="src" path="src/main"/>
+	<classpathentry exported="true" kind="src" path="/aspects"/>
+	<classpathentry exported="true" kind="src" path="/connector"/>
+	<classpathentry exported="true" kind="src" path="/iiop"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
-	<classpathentry kind="output" path="target/classes"/>
+	<classpathentry exported="true" kind="lib" path="/thirdparty/hibernate-annotations/lib/hibernate-annotations.jar"/>
+	<classpathentry exported="true" kind="lib" path="/thirdparty/hibernate-entitymanager/lib/hibernate-entitymanager.jar" sourcepath="/thirdparty/hibernate-entitymanager/lib/hibernate-entitymanager-sources.jar"/>
+	<classpathentry exported="true" kind="lib" path="/thirdparty/jboss/serialization/lib/jboss-serialization.jar"/>
+	<classpathentry exported="true" kind="lib" path="/thirdparty/jboss/jboss-ejb3-cache/lib/jboss-ejb3-cache.jar" sourcepath="/thirdparty/jboss/jboss-ejb3-cache/lib/jboss-ejb3-cache-sources.jar"/>
+	<classpathentry exported="true" kind="lib" path="/thirdparty/jboss/jboss-ejb3-ext-api/lib/jboss-ejb3-ext-api.jar" sourcepath="/thirdparty/jboss/jboss-ejb3-ext-api/lib/jboss-ejb3-ext-api-sources.jar"/>
+	<classpathentry exported="true" kind="lib" path="/thirdparty/jboss/web/lib/jbossweb.jar" sourcepath="/thirdparty/jboss/web/lib/jbossweb-sources.jar"/>
+	<classpathentry exported="true" kind="lib" path="/thirdparty/jboss/jboss-ejb3-interceptors/lib/jboss-ejb3-interceptors.jar" sourcepath="/thirdparty/jboss/jboss-ejb3-interceptors/lib/jboss-ejb3-interceptors-sources.jar"/>
+	<classpathentry exported="true" kind="lib" path="/thirdparty/jboss/jboss-ejb3-metadata/lib/jboss-ejb3-metadata.jar" sourcepath="/thirdparty/jboss/jboss-ejb3-metadata/lib/jboss-ejb3-metadata-sources.jar"/>
+	<classpathentry exported="true" kind="lib" path="/thirdparty/jboss/jboss-ejb3-ext-api-impl/lib/jboss-ejb3-ext-api-impl.jar" sourcepath="/thirdparty/jboss/jboss-ejb3-ext-api-impl/lib/jboss-ejb3-ext-api-impl-sources.jar"/>
+	<classpathentry exported="true" kind="lib" path="/thirdparty/jboss/jboss-ejb3-core/lib/jboss-ejb3-core.jar" sourcepath="/thirdparty/jboss/jboss-ejb3-core/lib/jboss-ejb3-core-sources.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/junit/lib/junit.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/test/lib/jboss-test.jar" sourcepath="/thirdparty/jboss/test/lib/jboss-test-src.zip"/>
+	<classpathentry kind="lib" path="/thirdparty/org/jboss/ws/lib/jbossws-spi.jar" sourcepath="/thirdparty/org/jboss/ws/lib/jbossws-spi-sources.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/hibernate/lib/hibernate-core.jar" sourcepath="/thirdparty/hibernate/lib/hibernate-core-sources.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-jpa-deployers/lib/jboss-jpa-deployers.jar" sourcepath="/thirdparty/jboss/jboss-jpa-deployers/lib/jboss-jpa-deployers-sources.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-ejb3-transactions/lib/jboss-ejb3-transactions.jar" sourcepath="/thirdparty/jboss/jboss-ejb3-transactions/lib/jboss-ejb3-transactions-sources.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-ejb3-common/lib/jboss-ejb3-common.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-ejb3-timerservice-spi/lib/jboss-ejb3-timerservice-spi.jar" sourcepath="/thirdparty/jboss/jboss-ejb3-timerservice-spi/lib/jboss-ejb3-timerservice-spi-sources.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/microcontainer/lib/jboss-dependency.jar" sourcepath="/thirdparty/jboss/microcontainer/lib/jboss-dependency-sources.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-mdr/lib/jboss-mdr.jar" sourcepath="/thirdparty/jboss/jboss-mdr/lib/jboss-mdr-sources.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-reflect/lib/jboss-reflect.jar" sourcepath="/thirdparty/jboss/jboss-reflect/lib/jboss-reflect-sources.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/microcontainer/lib/jboss-kernel.jar" sourcepath="/thirdparty/jboss/microcontainer/lib/jboss-kernel-sources.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-jpa-impl/lib/jboss-jpa-impl.jar" sourcepath="/thirdparty/jboss/jboss-jpa-impl/lib/jboss-jpa-impl-sources.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-jpa-spi/lib/jboss-jpa-spi.jar" sourcepath="/thirdparty/jboss/jboss-jpa-spi/lib/jboss-jpa-spi-sources.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/validation-api/lib/validation-api.jar" sourcepath="/thirdparty/validation-api/lib/validation-api-sources.jar"/>
+	<classpathentry kind="output" path="output/eclipse-classes"/>
 </classpath>
Index: .project
===================================================================
--- .project	(.../trunk/ejb3)	(revision 97484)
+++ .project	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -1,16 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <projectDescription>
-	<name>jboss-as-ejb3</name>
-	<comment>JBoss Application Server (ejb3 module)</comment>
+	<name>ejb3</name>
+	<comment></comment>
 	<projects>
-		<project>jboss-as-connector</project>
-		<project>jboss-as-deployment</project>
-		<project>jboss-as-iiop</project>
-		<project>jboss-as-main</project>
-		<project>jboss-as-security</project>
-		<project>jboss-as-server</project>
-		<project>jboss-as-system</project>
-		<project>jboss-as-system-jmx</project>
 	</projects>
 	<buildSpec>
 		<buildCommand>
@@ -18,14 +10,8 @@
 			<arguments>
 			</arguments>
 		</buildCommand>
-		<buildCommand>
-			<name>org.maven.ide.eclipse.maven2Builder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
 	</buildSpec>
 	<natures>
-		<nature>org.maven.ide.eclipse.maven2Nature</nature>
 		<nature>org.eclipse.jdt.core.javanature</nature>
 	</natures>
 </projectDescription>
Index: build.bat
===================================================================
--- build.bat	(.../trunk/ejb3)	(revision 97484)
+++ build.bat	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -3,7 +3,7 @@
 REM
 REM  This is the main entry point for the build system.
 REM
-REM  Users should be sure to execute this file rather than 'mvn' to ensure
+REM  Users should be sure to execute this file rather than 'ant' to ensure
 REM  the correct version is being used with the correct configuration.
 REM
 REM  ======================================================================
@@ -16,8 +16,8 @@
 REM
 
 REM ******************************************************
-REM Ignore the MAVEN_HOME variable: we want to use *our*
-REM Maven version and associated JARs.
+REM Ignore the ANT_HOME variable: we want to use *our*
+REM ANT version and associated JARs.
 REM ******************************************************
 REM Ignore the users classpath, cause it might mess
 REM things up
@@ -26,14 +26,15 @@
 SETLOCAL
 
 set CLASSPATH=
-set MAVEN_HOME=
+set ANT_HOME=
+set ANT_OPTS=-Djava.protocol.handler.pkgs=org.jboss.net.protocol -Dbuild.script=build.bat
 
 REM ******************************************************
 REM - "for" loops have been unrolled for compatibility
 REM   with some WIN32 systems.
 REM ******************************************************
 
-set NAMES=tools;tools\maven;tools\apache\maven
+set NAMES=tools;tools\ant;tools\apache\ant
 set SUBFOLDERS=..;..\..;..\..\..;..\..\..\..
 
 REM ******************************************************
@@ -50,13 +51,13 @@
 REM ******************************************************
 
 :subLoop
-for %%j in (%SUBFOLDERS%) do call :testIfExists %%j\%1\bin\mvn.bat %2 %3 %4 %5 %6 %7
+for %%j in (%SUBFOLDERS%) do call :testIfExists %%j\%1\bin\ant.bat %2 %3 %4 %5 %6 %7
 
 goto :EOF
 
 
 REM ******************************************************
-REM ************ Test if Maven Batch file exists ***********
+REM ************ Test if ANT Batch file exists ***********
 REM ******************************************************
 
 :testIfExists
@@ -81,9 +82,7 @@
 
 :ExecuteBatch
 echo Calling %1 %2 %3 %4 %5 %6 %7 %8
-set GOAL=%2
-if "%GOAL%"=="" set GOAL=install
-call %1 %GOAL% %3 %4 %5 %6 %7 %8
+call %1 %2 %3 %4 %5 %6 %7 %8
 
 :end
 

Property changes on: .gitignore
___________________________________________________________________
Deleted: svn:keywords
   - Author Date Id Revision
Deleted: svn:eol-style
   - native

Index: src/test/org/jboss/ejb3/test/appclient/unit/SimpleResourceEarUnitTestCase.java
===================================================================
--- src/test/org/jboss/ejb3/test/appclient/unit/SimpleResourceEarUnitTestCase.java	(.../trunk/ejb3)	(revision 0)
+++ src/test/org/jboss/ejb3/test/appclient/unit/SimpleResourceEarUnitTestCase.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.appclient.unit;
+
+import java.net.URL;
+
+import javax.naming.Context;
+import javax.naming.NameNotFoundException;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.client.ClientLauncher;
+import org.jboss.ejb3.metamodel.ApplicationClientDD;
+import org.jboss.ejb3.test.appclient.client.SimpleResourceClient;
+import org.jboss.metadata.client.jboss.JBossClientMetaData;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public class SimpleResourceEarUnitTestCase extends JBossTestCase
+{
+
+   public SimpleResourceEarUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   /**
+    * Test to see if the client deployer has setup enc env correctly.
+    * 
+    * @throws Exception
+    */
+   public void testJNDI() throws Exception
+   {
+      String clientName = "appclient-simpleresource-client";
+      Context ctx = getInitialContext();
+      try
+      {
+         ctx = (Context) ctx.lookup(clientName);
+      }
+      catch(NameNotFoundException e)
+      {
+         fail(clientName + " not bound");
+      }
+      
+      try
+      {
+         String value = (String) ctx.lookup("env/msg");
+         assertEquals("Hello world", value);
+      }
+      catch(NameNotFoundException e)
+      {
+         fail("env/msg not bound");
+      }
+      
+      // TODO: shouldn't org.jboss.ejb3.test.appclient.client.SimpleResourceClient/msg be bound?
+      
+//      NamingEnumeration<NameClassPair> e = ctx.list("env");
+//      while(e.hasMore())
+//      {
+//         NameClassPair ncp = e.next();
+//         System.out.println(ncp.getName());
+//      }
+//      try
+//      {
+//         
+//      }
+//      catch(NameNotFoundException e)
+//      {
+//         
+//      }
+   }
+   
+   public void testClientLauncher() throws Throwable
+   {
+      String mainClassName = SimpleResourceClient.class.getName();
+      String applicationClientName = "appclient-simpleresource-client"; // must match JNDI name in jboss-client.xml or display-name in application-client.xml
+      String args[] = { };
+      
+      ClientLauncher launcher = new ClientLauncher();
+      launcher.launch(mainClassName, applicationClientName, args);
+   }
+   
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(SimpleResourceEarUnitTestCase.class, "appclient-simpleresource.ear");
+   }
+
+}

Property changes on: src/test/org/jboss/ejb3/test/appclient/unit/SimpleResourceEarUnitTestCase.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/test/org/jboss/ejb3/test/appclient/unit/AppClientUnitTestCase.java
===================================================================
--- src/test/org/jboss/ejb3/test/appclient/unit/AppClientUnitTestCase.java	(.../trunk/ejb3)	(revision 0)
+++ src/test/org/jboss/ejb3/test/appclient/unit/AppClientUnitTestCase.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,76 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2006, Red Hat Middleware LLC, and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.test.appclient.unit;
+
+import java.net.URL;
+import java.util.Date;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.client.ClientLauncher;
+import org.jboss.ejb3.metamodel.ApplicationClientDD;
+import org.jboss.ejb3.test.appclient.client.HelloWorldClient;
+import org.jboss.metadata.client.jboss.JBossClientMetaData;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public class AppClientUnitTestCase extends JBossTestCase
+{
+   public AppClientUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void test1() throws Throwable
+   {
+      String mainClassName = HelloWorldClient.class.getName();
+      String applicationClientName = "applicationclient_test"; // must match JNDI name in jboss-client.xml or display-name in application-client.xml
+      String name = new Date().toString();
+      String args[] = { name };
+      
+      ClientLauncher launcher = new ClientLauncher();
+      launcher.launch(mainClassName, applicationClientName, args);
+      
+      {
+         String actual = HelloWorldClient.getResult();
+         String expected = "Hi " + name + ", how are you?";
+         assertEquals(expected, actual);
+      }
+      
+      {
+         int actual = HelloWorldClient.getPostConstructCalls();
+         int expected = 1;
+         assertEquals("postConstruct should be called once", expected, actual);
+      }
+   }
+   
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(AppClientUnitTestCase.class, "appclient-jms-service.xml,appclient-test.ear");
+      //return getDeploySetup(AppClientUnitTestCase.class, "appclient-test.jar,appclient-test-client.jar");
+   }
+}

Property changes on: src/test/org/jboss/ejb3/test/appclient/unit/AppClientUnitTestCase.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/test/org/jboss/ejb3/test/appclient/unit/SimpleResourceUnitTestCase.java
===================================================================
--- src/test/org/jboss/ejb3/test/appclient/unit/SimpleResourceUnitTestCase.java	(.../trunk/ejb3)	(revision 0)
+++ src/test/org/jboss/ejb3/test/appclient/unit/SimpleResourceUnitTestCase.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.appclient.unit;
+
+import java.net.URL;
+
+import javax.naming.Context;
+import javax.naming.NameNotFoundException;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.client.ClientLauncher;
+import org.jboss.ejb3.metamodel.ApplicationClientDD;
+import org.jboss.ejb3.test.appclient.client.SimpleResourceClient;
+import org.jboss.metadata.client.jboss.JBossClientMetaData;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public class SimpleResourceUnitTestCase extends JBossTestCase
+{
+
+   public SimpleResourceUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   /**
+    * Test to see if the client deployer has setup enc env correctly.
+    * 
+    * @throws Exception
+    */
+   public void testJNDI() throws Exception
+   {
+      String clientName = "appclient-simpleresource-client";
+      Context ctx = getInitialContext();
+      try
+      {
+         ctx = (Context) ctx.lookup(clientName);
+      }
+      catch(NameNotFoundException e)
+      {
+         fail(clientName + " not bound");
+      }
+      
+      try
+      {
+         String value = (String) ctx.lookup("env/msg");
+         assertEquals("Hello world", value);
+      }
+      catch(NameNotFoundException e)
+      {
+         fail("env/msg not bound");
+      }
+      
+      // TODO: shouldn't org.jboss.ejb3.test.appclient.client.SimpleResourceClient/msg be bound?
+      
+//      NamingEnumeration<NameClassPair> e = ctx.list("env");
+//      while(e.hasMore())
+//      {
+//         NameClassPair ncp = e.next();
+//         System.out.println(ncp.getName());
+//      }
+//      try
+//      {
+//         
+//      }
+//      catch(NameNotFoundException e)
+//      {
+//         
+//      }
+   }
+   
+   public void testClientLauncher() throws Throwable
+   {
+      String mainClassName = SimpleResourceClient.class.getName();
+      String applicationClientName = "appclient-simpleresource-client"; // must match JNDI name in jboss-client.xml or display-name in application-client.xml
+      String args[] = { };
+
+      ClientLauncher launcher = new ClientLauncher();
+      launcher.launch(mainClassName, applicationClientName, args);
+   }
+   
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(SimpleResourceUnitTestCase.class, "appclient-simpleresource-client.jar");
+   }
+
+}

Property changes on: src/test/org/jboss/ejb3/test/appclient/unit/SimpleResourceUnitTestCase.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/test/org/jboss/ejb3/test/appclient/HelloWorldBean.java
===================================================================
--- src/test/org/jboss/ejb3/test/appclient/HelloWorldBean.java	(.../trunk/ejb3)	(revision 0)
+++ src/test/org/jboss/ejb3/test/appclient/HelloWorldBean.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,41 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2006, Red Hat Middleware LLC, and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.test.appclient;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+@Stateless
+@Remote(HelloWorldService.class)
+public class HelloWorldBean implements HelloWorldService
+{
+   public String sayHelloTo(String name)
+   {
+      return "Hi " + name;
+   }
+}

Property changes on: src/test/org/jboss/ejb3/test/appclient/HelloWorldBean.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/test/org/jboss/ejb3/test/appclient/HelloWorldService.java
===================================================================
--- src/test/org/jboss/ejb3/test/appclient/HelloWorldService.java	(.../trunk/ejb3)	(revision 0)
+++ src/test/org/jboss/ejb3/test/appclient/HelloWorldService.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,33 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2006, Red Hat Middleware LLC, and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.test.appclient;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public interface HelloWorldService
+{
+   String sayHelloTo(String name);
+}

Property changes on: src/test/org/jboss/ejb3/test/appclient/HelloWorldService.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/test/org/jboss/ejb3/test/appclient/MessageReplierBean.java
===================================================================
--- src/test/org/jboss/ejb3/test/appclient/MessageReplierBean.java	(.../trunk/ejb3)	(revision 0)
+++ src/test/org/jboss/ejb3/test/appclient/MessageReplierBean.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,86 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2006, Red Hat Middleware LLC, and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.test.appclient;
+
+import javax.annotation.Resource;
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.EJBException;
+import javax.ejb.MessageDriven;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+
+import org.jboss.logging.Logger;
+
+/**
+ * This message bean will just reply the message.
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+@MessageDriven(activationConfig = {
+   @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
+   @ActivationConfigProperty(propertyName="destination", propertyValue="queue/messageReplier")
+})
+public class MessageReplierBean implements MessageListener
+{
+   private static final Logger log = Logger.getLogger(MessageReplierBean.class);
+   
+   @Resource(mappedName="java:ConnectionFactory")
+   private ConnectionFactory connectionFactory;
+   
+   public void onMessage(Message message)
+   {
+      try
+      {
+         if(message.getJMSReplyTo() != null)
+         {
+            Destination destination = message.getJMSReplyTo();
+            
+            Connection conn = connectionFactory.createConnection();
+            try
+            {
+               Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+               MessageProducer producer = session.createProducer(destination);
+               producer.send(destination, message);
+               producer.close();
+               session.close();
+            }
+            finally
+            {
+               conn.close();
+            }
+         }
+         else
+            log.info("no reply to specified");
+      }
+      catch(JMSException e)
+      {
+         throw new EJBException(e);
+      }
+   }
+}

Property changes on: src/test/org/jboss/ejb3/test/appclient/MessageReplierBean.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/test/org/jboss/ejb3/test/appclient/client/SimpleResourceClient.java
===================================================================
--- src/test/org/jboss/ejb3/test/appclient/client/SimpleResourceClient.java	(.../trunk/ejb3)	(revision 0)
+++ src/test/org/jboss/ejb3/test/appclient/client/SimpleResourceClient.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.appclient.client;
+
+import javax.annotation.Resource;
+
+/**
+ * This client only uses a simple resource.
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public class SimpleResourceClient
+{
+   @Resource(name="msg")
+   private static String msg;
+   
+   /**
+    * @param args
+    */
+   public static void main(String[] args)
+   {
+      if(msg == null)
+         throw new NullPointerException("msg is null");
+      
+      System.out.println("msg = " + msg);
+   }
+
+}

Property changes on: src/test/org/jboss/ejb3/test/appclient/client/SimpleResourceClient.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/test/org/jboss/ejb3/test/appclient/client/HelloWorldClient.java
===================================================================
--- src/test/org/jboss/ejb3/test/appclient/client/HelloWorldClient.java	(.../trunk/ejb3)	(revision 0)
+++ src/test/org/jboss/ejb3/test/appclient/client/HelloWorldClient.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,129 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2006, Red Hat Middleware LLC, and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.test.appclient.client;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.jboss.ejb3.test.appclient.HelloWorldService;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public class HelloWorldClient
+{
+   @EJB
+   private static HelloWorldService helloWorldService;
+   
+   @Resource(name="msg")
+   private static String msg;
+   
+   private static String result;
+   
+   @Resource(mappedName="ConnectionFactory")
+   private static ConnectionFactory connectionFactory;
+   
+   @Resource(name="messageReplier")
+   private static Destination destination;
+   
+   private static int postConstructCalls = 0;
+   
+   public static int getPostConstructCalls()
+   {
+      return postConstructCalls;
+   }
+   
+   public static String getResult()
+   {
+      return result;
+   }
+   
+   public static void main(String args[])
+   {
+      String name = "unspecified";
+      if(args.length > 0)
+         name = args[0];
+      
+      if(helloWorldService == null)
+         throw new NullPointerException("helloWorldService is null");
+      
+      if(msg == null)
+         throw new NullPointerException("msg is null");
+      
+      result = helloWorldService.sayHelloTo(name) + ", " + msg;
+      
+      testMDB();
+   }
+   
+   public static void testMDB()
+   {
+      if(connectionFactory == null)
+         throw new NullPointerException("connectionFactory is null");
+      
+      if(destination == null)
+         throw new NullPointerException("destination is null");
+      
+      try
+      {
+         Connection conn = connectionFactory.createConnection();
+         Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+         
+         Queue replyTo = session.createTemporaryQueue();
+         TextMessage msg = session.createTextMessage("Hello world");
+         msg.setJMSReplyTo(replyTo);
+         
+         MessageConsumer consumer = session.createConsumer(replyTo);
+         conn.start();
+         
+         MessageProducer producer = session.createProducer(destination);
+         producer.send(destination, msg);
+         
+         TextMessage reply = (TextMessage) consumer.receive(2000);
+         System.out.println("reply = " + reply.getText());
+         
+         producer.close();
+         conn.stop();
+         consumer.close();
+         session.close();
+      }
+      catch(Exception e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+   
+   public static void postConstruct()
+   {
+      postConstructCalls++;
+   }
+}

Property changes on: src/test/org/jboss/ejb3/test/appclient/client/HelloWorldClient.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/test/org/jboss/ejb3/test/iiop/MySessionBean.java
===================================================================
--- src/test/org/jboss/ejb3/test/iiop/MySessionBean.java	(.../trunk/ejb3)	(revision 0)
+++ src/test/org/jboss/ejb3/test/iiop/MySessionBean.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,60 @@
+/*
+ * 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.test.iiop;
+
+import javax.annotation.Resource;
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.Remote;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateless;
+
+import org.jboss.ejb3.annotation.IIOP;
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.ejb3.annotation.SecurityDomain;
+import org.jboss.ejb3.annotation.defaults.RemoteBindingDefaults;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+@Stateless
+@Remote(MySession.class)
+@RemoteBinding(factory=RemoteBindingDefaults.PROXY_FACTORY_IMPLEMENTATION_IOR)
+@IIOP(interfaceRepositorySupported=false)
+@SecurityDomain("other")
+public class MySessionBean
+{
+   @Resource SessionContext ctx;
+   
+   @RolesAllowed({"allowed"})
+   public String getWhoAmI()
+   {
+      return ctx.getCallerPrincipal().getName();
+   }
+   
+   public String sayHelloTo(String name)
+   {
+      return "Hi " + name;
+   }
+}

Property changes on: src/test/org/jboss/ejb3/test/iiop/MySessionBean.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/test/org/jboss/ejb3/test/iiop/unit/IiopRemoteUnitTestCase.java
===================================================================
--- src/test/org/jboss/ejb3/test/iiop/unit/IiopRemoteUnitTestCase.java	(.../trunk/ejb3)	(revision 0)
+++ src/test/org/jboss/ejb3/test/iiop/unit/IiopRemoteUnitTestCase.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,316 @@
+/*
+ * 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.test.iiop.unit;
+
+import java.rmi.MarshalledObject;
+import java.util.Date;
+import java.util.Properties;
+
+import javax.ejb.Handle;
+import javax.ejb.HomeHandle;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+import javax.rmi.PortableRemoteObject;
+import javax.transaction.UserTransaction;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.CustomJNDIJBossTestCase;
+import org.jboss.ejb3.test.iiop.HomedStatelessHome;
+import org.jboss.ejb3.test.iiop.MySession;
+import org.jboss.ejb3.test.iiop.MyStateful;
+import org.jboss.ejb3.test.iiop.MyStatefulHome;
+import org.jboss.ejb3.test.iiop.TxTester;
+import org.jboss.security.SecurityAssociation;
+import org.jboss.security.SimplePrincipal;
+
+/**
+ * TODO: use JBossIIOPTestCase
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public class IiopRemoteUnitTestCase extends CustomJNDIJBossTestCase
+{
+
+   public IiopRemoteUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   @Override
+   public InitialContext getInitialContext() throws NamingException
+   {
+      return new InitialContext(getJndiProperties());
+   }
+   
+   private Properties getJndiProperties()
+   {
+      Properties props = new Properties();
+      props.put("java.naming.factory.initial", "com.sun.jndi.cosnaming.CNCtxFactory");
+      props.put("java.naming.provider.url", "corbaloc::localhost:3528/NameService");
+      props.put("java.naming.factory.object", "org.jboss.tm.iiop.client.IIOPClientUserTransactionObjectFactory");
+      props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming.client:org.jnp.interfaces");
+      props.put("j2ee.clientName", "iiop-unit-test");
+      
+//      props.put(InitialContext.SECURITY_PRINCIPAL, "somebody");
+//      props.put(InitialContext.SECURITY_CREDENTIALS, "password");
+      
+      return props;
+//      return null;
+   }
+   
+   @Override
+   protected void tearDown() throws Exception
+   {
+      super.tearDown();
+      
+      SecurityAssociation.clear();
+   }
+   
+   public void test0() throws Exception
+   {
+      System.out.println("java: " + getInitialContext().lookup("java:comp/HandleDelegate"));
+   }
+   
+   public void test1() throws Exception
+   {
+      SimplePrincipal principal = new SimplePrincipal("somebody");
+      SecurityAssociation.setPrincipal(principal);
+      SecurityAssociation.setCredential("password".toCharArray());
+      
+      InitialContext ctx = getInitialContext();
+      Object obj = ctx.lookup("MySessionBean/remote");
+      System.err.println(obj.getClass());
+      MySession session = (MySession) PortableRemoteObject.narrow(obj, MySession.class);
+      assertNotNull(session);
+      String me = new Date().toString();
+      String response = session.sayHelloTo(me);
+      assertEquals("Hi " + me, response);
+   }
+   
+   public void test2() throws Exception
+   {
+      InitialContext ctx = getInitialContext();
+      Object obj = ctx.lookup("MyStatefulBean/home");
+      MyStatefulHome home = (MyStatefulHome) PortableRemoteObject.narrow(obj, MyStatefulHome.class);
+      //MyStateful bean1 = (MyStateful) PortableRemoteObject.narrow(obj, MyStateful.class);
+      MyStateful bean1 = home.create();
+      bean1.setName("bean1");
+      String response = bean1.sayHello();
+      assertEquals("Hello bean1", response);
+      bean1.remove();
+   }
+   
+   public void testGetEJBHome() throws Exception
+   {
+      InitialContext ctx = getInitialContext();
+      Object obj = ctx.lookup("HomedStatelessBean/home");
+      HomedStatelessHome home = (HomedStatelessHome) PortableRemoteObject.narrow(obj, HomedStatelessHome.class);
+      MySession session = home.create();
+      Object o = session.getEJBHome();
+      HomedStatelessHome home2 = (HomedStatelessHome) PortableRemoteObject.narrow(o, HomedStatelessHome.class);
+      // TODO: check home2
+   }
+   
+   public void testGetHandle() throws Exception
+   {
+      InitialContext ctx = getInitialContext();
+      Object obj = ctx.lookup("HomedStatelessBean/home");
+      HomedStatelessHome home = (HomedStatelessHome) PortableRemoteObject.narrow(obj, HomedStatelessHome.class);
+      MySession session = home.create();
+      Handle h = session.getHandle();
+      MarshalledObject mo = new MarshalledObject(h);
+      Handle h2 = (Handle) mo.get();
+      Object o = h2.getEJBObject();
+      MySession session2 = (MySession) PortableRemoteObject.narrow(o, MySession.class);
+      String me = new Date().toString();
+      String response = session2.sayHelloTo(me);
+      assertEquals("Hi " + me, response);
+   }
+   
+   public void testGetHomeHandle() throws Exception
+   {
+      InitialContext ctx = getInitialContext();
+      Object obj = ctx.lookup("HomedStatelessBean/home");
+      HomedStatelessHome home = (HomedStatelessHome) PortableRemoteObject.narrow(obj, HomedStatelessHome.class);
+      HomeHandle h = home.getHomeHandle();
+      MarshalledObject mo = new MarshalledObject(h);
+      HomeHandle h2 = (HomeHandle) mo.get();
+      Object o = h2.getEJBHome();
+      HomedStatelessHome home2 = (HomedStatelessHome) PortableRemoteObject.narrow(o, HomedStatelessHome.class);
+      // TODO: check home2
+   }
+   
+   public void testGetPrimaryKeyAndRemove() throws Exception
+   {
+      InitialContext ctx = getInitialContext();
+      Object obj = ctx.lookup("MyStatefulBean/home");
+      MyStatefulHome home = (MyStatefulHome) PortableRemoteObject.narrow(obj, MyStatefulHome.class);
+      MyStateful session = home.create();
+      Object primaryKey = session.getPrimaryKey();
+      assertNotNull(primaryKey);
+      
+      home.remove(primaryKey);
+      try
+      {
+         session.sayHello();
+         fail("should throw an exception");
+      }
+      catch(Exception e)
+      {
+         // TODO: check exception (NoSuchEJBException)
+      }
+   }
+   
+   public void testHomedStateless() throws Exception
+   {
+      InitialContext ctx = getInitialContext();
+      Object obj = ctx.lookup("HomedStatelessBean/home");
+      HomedStatelessHome home = (HomedStatelessHome) PortableRemoteObject.narrow(obj, HomedStatelessHome.class);
+      MySession session = home.create();
+      String me = new Date().toString();
+      String response = session.sayHelloTo(me);
+      assertEquals("Hi " + me, response);
+   }
+   
+   public void testIsIdentical() throws Exception
+   {
+      InitialContext ctx = getInitialContext();
+      Object obj = ctx.lookup("MyStatefulBean/home");
+      MyStatefulHome home = (MyStatefulHome) PortableRemoteObject.narrow(obj, MyStatefulHome.class);
+      MyStateful session = home.create();
+      Handle h = session.getHandle();
+      MarshalledObject mo = new MarshalledObject(h);
+      Handle h2 = (Handle) mo.get();
+      Object o = h2.getEJBObject();
+      MyStateful session2 = (MyStateful) PortableRemoteObject.narrow(o, MyStateful.class);
+      assertTrue(session.isIdentical(session2));
+   }
+   
+   public void testRemoveByHandle() throws Exception
+   {
+      InitialContext ctx = getInitialContext();
+      Object obj = ctx.lookup("MyStatefulBean/home");
+      MyStatefulHome home = (MyStatefulHome) PortableRemoteObject.narrow(obj, MyStatefulHome.class);
+      MyStateful session = home.create();
+      session.setName("Me");
+      home.remove(session.getHandle());
+      try
+      {
+         session.sayHello();
+         fail("should throw an exception");
+      }
+      catch(Exception e)
+      {
+         // TODO: check exception (NoSuchEJBException)
+      }
+   }
+   
+   public void testSecurity() throws Exception
+   {
+      SimplePrincipal principal = new SimplePrincipal("somebody");
+      SecurityAssociation.setPrincipal(principal);
+      SecurityAssociation.setCredential("password".toCharArray());
+      
+      InitialContext ctx = getInitialContext();
+      Object obj = ctx.lookup("MySessionBean/remote");
+      System.err.println(obj.getClass());
+      MySession session = (MySession) PortableRemoteObject.narrow(obj, MySession.class);
+      assertNotNull(session);
+      String actual = session.getWhoAmI();
+      System.err.println("whoAmI = " + actual);
+      assertEquals(actual, "somebody");
+   }
+   
+   public void testService() throws Exception
+   {
+      InitialContext ctx = getInitialContext();
+      Object obj = ctx.lookup("MyServiceBean/remote");
+      MyStateful bean1 = (MyStateful) PortableRemoteObject.narrow(obj, MyStateful.class);
+      bean1.setName("bean1");
+      String response = bean1.sayHello();
+      assertEquals("Hello bean1", response);
+   }
+   
+   public void testTxPropegation() throws Exception
+   {
+      InitialContext ctx = getInitialContext();
+      Object obj = ctx.lookup("TxTesterBean/remote");
+      TxTester session = (TxTester) PortableRemoteObject.narrow(obj, TxTester.class);
+      assertNotNull(session);
+      UserTransaction tx;
+      try
+      {
+         tx = (UserTransaction) PortableRemoteObject.narrow(ctx.lookup("UserTransaction"), UserTransaction.class);
+      }
+      catch(NameNotFoundException e)
+      {
+         log.warn("Corba Transaction Service is not installed (not available with Arjuna, only with JBossTS)");
+         return;
+      }
+      tx.begin();
+      try
+      {
+         session.txMandatoryMethod();
+      }
+      finally
+      {
+         tx.rollback();
+      }
+      // If it doesn't throw an exception everything is fine.
+   }
+
+   public void testTxRequired() throws Exception
+   {
+      InitialContext ctx = getInitialContext();
+      Object obj = ctx.lookup("TxTesterBean/remote");
+      TxTester session = (TxTester) PortableRemoteObject.narrow(obj, TxTester.class);
+      assertNotNull(session);
+      try
+      {
+         session.txMandatoryMethod();
+         fail("Expected an exception");
+      }
+      catch(Exception e)
+      {
+         //fail("TODO: check exception");
+      }
+      // TODO: throws an ugly exception, needs assertions to check
+   }
+   
+   public static Test suite() throws Exception
+   {
+      try
+      {
+         System.err.println(IiopRemoteUnitTestCase.class.getClassLoader().getResource("jacorb.properties"));
+      }
+      catch(Throwable t)
+      {
+         t.printStackTrace();
+      }
+      return getDeploySetup(IiopRemoteUnitTestCase.class, "iiop.jar");
+   }
+
+}

Property changes on: src/test/org/jboss/ejb3/test/iiop/unit/IiopRemoteUnitTestCase.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/test/org/jboss/ejb3/test/iiop/TxTester.java
===================================================================
--- src/test/org/jboss/ejb3/test/iiop/TxTester.java	(.../trunk/ejb3)	(revision 0)
+++ src/test/org/jboss/ejb3/test/iiop/TxTester.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,37 @@
+/*
+ * 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.test.iiop;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.EJBObject;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public interface TxTester extends EJBObject
+{
+   void txMandatoryMethod() throws RemoteException;
+}

Property changes on: src/test/org/jboss/ejb3/test/iiop/TxTester.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/test/org/jboss/ejb3/test/iiop/MyStatefulBean.java
===================================================================
--- src/test/org/jboss/ejb3/test/iiop/MyStatefulBean.java	(.../trunk/ejb3)	(revision 0)
+++ src/test/org/jboss/ejb3/test/iiop/MyStatefulBean.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,93 @@
+/*
+ * 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.test.iiop;
+
+import java.rmi.RemoteException;
+
+import javax.annotation.PreDestroy;
+import javax.ejb.CreateException;
+import javax.ejb.Init;
+import javax.ejb.Remote;
+import javax.ejb.RemoteHome;
+import javax.ejb.Remove;
+import javax.ejb.RemoveException;
+import javax.ejb.Stateful;
+
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.ejb3.annotation.defaults.RemoteBindingDefaults;
+import org.jboss.logging.Logger;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+@Stateful
+@Remote(MyStateful.class)
+@RemoteHome(MyStatefulHome.class)
+@RemoteBinding(factory=RemoteBindingDefaults.PROXY_FACTORY_IMPLEMENTATION_IOR)
+public class MyStatefulBean
+{
+   private static final Logger log = Logger.getLogger(MyStatefulBean.class);
+   
+   private String name;
+   
+   @Init
+   public void ejbCreate() throws CreateException, RemoteException
+   {
+      name = "anonymous";
+   }
+   
+   @Init
+   public void ejbCreate(String name) throws CreateException, RemoteException
+   {
+      this.name = name;
+   }
+   
+   @Remove
+   public void ejbRemove() throws RemoveException, RemoteException
+   {
+      log.info("remove bean");
+   }
+   
+   public String getName() throws RemoteException
+   {
+      return name;
+   }
+   
+   @PreDestroy
+   public void preDestroy()
+   {
+      log.info("pre destroy");
+   }
+   
+   public String sayHello() throws RemoteException
+   {
+      return "Hello " + name;
+   }
+   
+   public void setName(String name) throws RemoteException
+   {
+      this.name = name;
+   }
+}

Property changes on: src/test/org/jboss/ejb3/test/iiop/MyStatefulBean.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/test/org/jboss/ejb3/test/iiop/MyStatefulHome.java
===================================================================
--- src/test/org/jboss/ejb3/test/iiop/MyStatefulHome.java	(.../trunk/ejb3)	(revision 0)
+++ src/test/org/jboss/ejb3/test/iiop/MyStatefulHome.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,39 @@
+/*
+ * 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.test.iiop;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBHome;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public interface MyStatefulHome extends EJBHome
+{
+   MyStateful create() throws CreateException, RemoteException;
+   MyStateful create(String name) throws CreateException, RemoteException;
+}

Property changes on: src/test/org/jboss/ejb3/test/iiop/MyStatefulHome.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/test/org/jboss/ejb3/test/iiop/TxTesterBean.java
===================================================================
--- src/test/org/jboss/ejb3/test/iiop/TxTesterBean.java	(.../trunk/ejb3)	(revision 0)
+++ src/test/org/jboss/ejb3/test/iiop/TxTesterBean.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,78 @@
+/*
+ * 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.test.iiop;
+
+import javax.ejb.EJBException;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import org.jboss.ejb3.annotation.JndiInject;
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.ejb3.annotation.defaults.RemoteBindingDefaults;
+import org.jboss.logging.Logger;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+@Stateless
+@Remote(TxTester.class)
+@RemoteBinding(factory=RemoteBindingDefaults.PROXY_FACTORY_IMPLEMENTATION_IOR)
+@TransactionManagement(TransactionManagementType.CONTAINER)
+public class TxTesterBean
+{
+   private static final Logger log = Logger.getLogger(TxTesterBean.class);
+   
+   @JndiInject(jndiName="java:/TransactionManager") TransactionManager tm;
+   
+   @TransactionAttribute(TransactionAttributeType.MANDATORY)
+   public void txMandatoryMethod()
+   {
+      try
+      {
+         log.info("currentThread = " + Thread.currentThread());
+         log.info("currentTransaction = " + tm.getTransaction());
+         log.info("tm = " + tm);
+         
+         Transaction tx = tm.getTransaction();
+         if(tx == null)
+            throw new EJBException("no tx");
+         
+         if(tx.getStatus() != Status.STATUS_ACTIVE)
+            throw new EJBException("tx not active");
+      }
+      catch(SystemException e)
+      {
+         throw new EJBException(e);
+      }
+   }
+}

Property changes on: src/test/org/jboss/ejb3/test/iiop/TxTesterBean.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/test/org/jboss/ejb3/test/iiop/MySession.java
===================================================================
--- src/test/org/jboss/ejb3/test/iiop/MySession.java	(.../trunk/ejb3)	(revision 0)
+++ src/test/org/jboss/ejb3/test/iiop/MySession.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,40 @@
+/*
+ * 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.test.iiop;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.EJBObject;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+//@Remote
+public interface MySession extends EJBObject
+{
+   String getWhoAmI() throws RemoteException;
+   
+   String sayHelloTo(String name) throws RemoteException;
+}

Property changes on: src/test/org/jboss/ejb3/test/iiop/MySession.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/test/org/jboss/ejb3/test/iiop/HomedStatelessBean.java
===================================================================
--- src/test/org/jboss/ejb3/test/iiop/HomedStatelessBean.java	(.../trunk/ejb3)	(revision 0)
+++ src/test/org/jboss/ejb3/test/iiop/HomedStatelessBean.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,58 @@
+/*
+ * 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.test.iiop;
+
+import javax.annotation.Resource;
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.Remote;
+import javax.ejb.RemoteHome;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateless;
+
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.ejb3.annotation.defaults.RemoteBindingDefaults;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+@Stateless
+@Remote(MySession.class)
+@RemoteHome(HomedStatelessHome.class)
+@RemoteBinding(factory=RemoteBindingDefaults.PROXY_FACTORY_IMPLEMENTATION_IOR)
+public class HomedStatelessBean
+{
+   @Resource SessionContext ctx;
+   
+   @RolesAllowed({"user"})
+   public String getWhoAmI()
+   {
+      return ctx.getCallerPrincipal().getName();
+   }
+   
+   public String sayHelloTo(String name)
+   {
+      return "Hi " + name;
+   }
+}

Property changes on: src/test/org/jboss/ejb3/test/iiop/HomedStatelessBean.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/test/org/jboss/ejb3/test/iiop/MyServiceBean.java
===================================================================
--- src/test/org/jboss/ejb3/test/iiop/MyServiceBean.java	(.../trunk/ejb3)	(revision 0)
+++ src/test/org/jboss/ejb3/test/iiop/MyServiceBean.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,61 @@
+/*
+ * 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.test.iiop;
+
+import javax.ejb.Remote;
+
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.ejb3.annotation.Service;
+import org.jboss.ejb3.annotation.defaults.RemoteBindingDefaults;
+import org.jboss.logging.Logger;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+@Service
+@Remote(MyStateful.class)
+@RemoteBinding(factory=RemoteBindingDefaults.PROXY_FACTORY_IMPLEMENTATION_IOR)
+public class MyServiceBean
+{
+   @SuppressWarnings("unused")
+   private static final Logger log = Logger.getLogger(MyServiceBean.class);
+   
+   private String name;
+   
+   public String getName()
+   {
+      return name;
+   }
+   
+   public String sayHello()
+   {
+      return "Hello " + name;
+   }
+   
+   public void setName(String name)
+   {
+      this.name = name;
+   }
+}

Property changes on: src/test/org/jboss/ejb3/test/iiop/MyServiceBean.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/test/org/jboss/ejb3/test/iiop/HomedStatelessHome.java
===================================================================
--- src/test/org/jboss/ejb3/test/iiop/HomedStatelessHome.java	(.../trunk/ejb3)	(revision 0)
+++ src/test/org/jboss/ejb3/test/iiop/HomedStatelessHome.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,38 @@
+/*
+ * 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.test.iiop;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBHome;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public interface HomedStatelessHome extends EJBHome
+{
+   MySession create() throws CreateException, RemoteException;
+}

Property changes on: src/test/org/jboss/ejb3/test/iiop/HomedStatelessHome.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/test/org/jboss/ejb3/test/iiop/MyStateful.java
===================================================================
--- src/test/org/jboss/ejb3/test/iiop/MyStateful.java	(.../trunk/ejb3)	(revision 0)
+++ src/test/org/jboss/ejb3/test/iiop/MyStateful.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,41 @@
+/*
+ * 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.test.iiop;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.EJBObject;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public interface MyStateful extends EJBObject
+{
+   String getName() throws RemoteException;
+   
+   String sayHello() throws RemoteException;
+   
+   void setName(String name) throws RemoteException;
+}

Property changes on: src/test/org/jboss/ejb3/test/iiop/MyStateful.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/test/org/jboss/ejb3/test/CustomJNDIJBossTestSetup.java
===================================================================
--- src/test/org/jboss/ejb3/test/CustomJNDIJBossTestSetup.java	(.../trunk/ejb3)	(revision 0)
+++ src/test/org/jboss/ejb3/test/CustomJNDIJBossTestSetup.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,56 @@
+/*
+ * 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.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossTestServices;
+import org.jboss.test.JBossTestSetup;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public class CustomJNDIJBossTestSetup extends JBossTestSetup
+{
+
+   public CustomJNDIJBossTestSetup(Test test) throws Exception
+   {
+      super(test);
+   }
+   
+   protected CustomJNDIJBossTestServices getDelegate()
+   {
+      return (CustomJNDIJBossTestServices) this.delegate;
+   }
+   
+   @Override
+   protected void setUp() throws Exception
+   {
+      // override so we get the right delegate
+      
+      delegate = (JBossTestServices) CustomJNDIJBossTestCase.getDelegate(clazz);
+      delegate.setUp();
+   }
+}

Property changes on: src/test/org/jboss/ejb3/test/CustomJNDIJBossTestSetup.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/test/org/jboss/ejb3/test/CustomJNDIJBossTestServices.java
===================================================================
--- src/test/org/jboss/ejb3/test/CustomJNDIJBossTestServices.java	(.../trunk/ejb3)	(revision 0)
+++ src/test/org/jboss/ejb3/test/CustomJNDIJBossTestServices.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,83 @@
+/*
+ * 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.test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import javax.naming.InitialContext;
+
+import org.jboss.test.JBossTestServices;
+
+/**
+ * This class provides services for JBoss unit tests.
+ * If found it uses custom.jndi.properties to establish a connection with
+ * the Main Deployer.
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public class CustomJNDIJBossTestServices extends JBossTestServices
+{
+
+   public CustomJNDIJBossTestServices(Class clazz)
+   {
+      super(clazz);
+   }
+   public CustomJNDIJBossTestServices(String className)
+   {
+      super(className);
+   }
+
+   protected Properties getCustomJNDIProperties() throws IOException
+   {
+      InputStream in = getClass().getClassLoader().getResourceAsStream("custom.jndi.properties");
+      if(in == null)
+      {
+         log.debug("no custom.jndi.properties found using defaults");
+         return null;
+      }
+      Properties props = new Properties();
+      props.load(in);
+      in.close();
+      return props;
+   }
+   
+   @Override
+   public void init() throws Exception
+   {
+      if(initialContext == null)
+      {
+         initialContext = new InitialContext(getCustomJNDIProperties());
+         log.debug("initialContext.getEnvironment()=" + initialContext.getEnvironment());
+         jndiEnv = initialContext.getEnvironment();
+         
+         log.debug("server = " + getServer());
+      }
+   }
+      
+   protected boolean isSecureTest()
+   {
+      return Boolean.getBoolean("jbosstest.secure");
+   }
+}

Property changes on: src/test/org/jboss/ejb3/test/CustomJNDIJBossTestServices.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/test/org/jboss/ejb3/test/common/unit/DBSetup.java
===================================================================
--- src/test/org/jboss/ejb3/test/common/unit/DBSetup.java	(.../trunk/ejb3)	(revision 0)
+++ src/test/org/jboss/ejb3/test/common/unit/DBSetup.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,156 @@
+/*
+ * 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.test.common.unit;
+
+import java.sql.DriverManager;
+import java.sql.Connection;
+import java.sql.Statement;
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Method;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+
+/** A TestSetup that starts hypersonic before the testcase with a tcp
+ * listening port at 1701.
+ * 
+ * @author Scott.Stark@jboss.org
+ * @version $Revison:$
+ */
+public class DBSetup extends TestSetup
+{
+   public DBSetup(Test test)
+   {
+      super(test);
+   }
+
+   protected void setUp() throws Exception
+   {
+         File hypersoniDir = new File("output/hypersonic");
+         if (!hypersoniDir.exists())
+         {
+            hypersoniDir.mkdirs();
+         }
+
+         if (!hypersoniDir.isDirectory())
+         {
+            throw new IOException("Failed to create directory: " + hypersoniDir);
+         }
+      
+         File dbPath = new File(hypersoniDir, "clusteredentity-db");
+
+         // Start DB in new thread, or else it will block us
+         DBThread serverThread = new DBThread(dbPath);
+         serverThread.start();
+         
+         int elapsed = 0;
+         while (!serverThread.isStarted() && elapsed < 15000)
+         {
+            try 
+            {
+               Thread.sleep(100);
+               elapsed += 100;
+            }
+            catch (InterruptedException ie)
+            {
+               System.out.println("Interrupted while waiting for Hypersonic");
+            }
+         }
+         
+         if (!serverThread.isStarted())
+            System.out.println("Hypersonic failed to start in a timely fashion");
+   }
+
+   protected void tearDown() throws Exception
+   {
+      Class.forName("org.hsqldb.jdbcDriver");
+      String dbURL = "jdbc:hsqldb:hsql://" + System.getProperty("jbosstest.server.host", "localhost") + ":1701";
+      Connection conn = DriverManager.getConnection(dbURL, "sa", "");
+      Statement statement = conn.createStatement();      
+      statement.executeQuery("SHUTDOWN COMPACT");
+      
+   }
+
+   public static void main(String[] args) throws Exception
+   {
+      DBSetup setup = new DBSetup(null);
+      setup.setUp();
+      Thread.sleep(120*1000);
+      setup.tearDown();
+   }
+   
+   class DBThread extends Thread
+   {
+      boolean started;
+      File dbPath;
+      
+      DBThread(File dbPath)
+      {
+         super("hypersonic");
+         this.dbPath = dbPath;
+      }
+      
+      boolean isStarted()
+      {
+         return started;
+      }
+      
+      public void run()
+      {
+         try
+         {
+            // Create startup arguments
+            // BES 2007/09/25 We use -silent true to avoid 
+            // http://sourceforge.net/tracker/index.php?func=detail&aid=1673747&group_id=23316&atid=378131
+            String[] args = {
+                  "-database",
+                  dbPath.toString(),
+                  "-port",
+                  String.valueOf(1701),
+                  "-silent",
+                  "true",
+                  "-trace",
+                  "false",
+                  "-no_system_exit",
+                  "true",
+             };
+            System.out.println("Starting hsqldb");
+            // HACK Do this by reflection for now until we determine how 
+            // we want to handle this in EJB3
+            Class clazz = Thread.currentThread().getContextClassLoader().loadClass("org.hsqldb.Server");
+            Method main = clazz.getDeclaredMethod("main", new Class[] { String[].class });
+            main.invoke(null, new Object[] { args });
+//            org.hsqldb.Server.main(args);
+            System.out.println("Done");
+         }
+         catch (Exception e)
+         {
+            e.printStackTrace();
+         }
+         finally
+         {
+            started = true;
+         }
+      }
+   }
+}

Property changes on: src/test/org/jboss/ejb3/test/common/unit/DBSetup.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/test/org/jboss/ejb3/test/CustomJNDIJBossTestCase.java
===================================================================
--- src/test/org/jboss/ejb3/test/CustomJNDIJBossTestCase.java	(.../trunk/ejb3)	(revision 0)
+++ src/test/org/jboss/ejb3/test/CustomJNDIJBossTestCase.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,126 @@
+/*
+ * 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.test;
+
+import java.util.StringTokenizer;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.test.AbstractTestDelegate;
+import org.jboss.test.JBossTestCase;
+import org.jboss.test.JBossTestServices;
+
+/**
+ * This test case will use custom.jndi.properties to find the deployer.
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public class CustomJNDIJBossTestCase extends JBossTestCase
+{
+
+   public CustomJNDIJBossTestCase(String name)
+   {
+      super(name);
+   }
+
+   /**
+    * Overriden to return CustomJNDIJBossTestServices as the test delegate.
+    */
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      AbstractTestDelegate delegate = new CustomJNDIJBossTestServices(clazz);
+      return delegate;
+   }
+
+   /**
+    * Get a JBossTestSetup that does login and deployment in setUp/tearDown
+    *
+    * @param test a Test
+    * @param jarNames is a comma seperated list of deployments
+    */
+   public static Test getDeploySetup(final Test test, final String jarNames)
+      throws Exception
+   {
+      CustomJNDIJBossTestSetup wrapper = new CustomJNDIJBossTestSetup(test)
+      {
+         protected void setUp() throws Exception
+         {
+            super.setUp();
+            deploymentException = null;
+            try
+            {
+               this.delegate.init();
+
+               if (this.getDelegate().isSecureTest())
+                  this.delegate.login();
+
+               if (jarNames == null) return;
+
+               // deploy the comma seperated list of jars
+               StringTokenizer st = new StringTokenizer(jarNames, ", ");
+               while (st != null && st.hasMoreTokens())
+               {
+                  String jarName = st.nextToken();
+                  this.redeploy(jarName);
+                  this.getLog().debug("deployed package: " + jarName);
+               }
+            }
+            catch (Exception ex)
+            {
+               // Throw this in testServerFound() instead.
+               deploymentException = ex;
+            }
+         }
+
+         protected void tearDown() throws Exception
+         {
+            if (jarNames == null) return; //Nothing to Undeploy
+             
+            // undeploy the comma seperated list of jars
+            StringTokenizer st = new StringTokenizer(jarNames, ", ");
+            String[] depoyments = new String[st.countTokens()];
+            for (int i = depoyments.length - 1; i >= 0; i--)
+               depoyments[i] = st.nextToken();
+            for (int i = 0; i < depoyments.length; i++)
+            {
+               String jarName = depoyments[i];
+               this.undeploy(jarName);
+               this.getLog().debug("undeployed package: " + jarName);
+            }
+
+            if (this.getDelegate().isSecureTest())
+               this.delegate.logout();
+         }
+      };
+      return wrapper;
+   }
+
+   public static Test getDeploySetup(final Class clazz, final String jarName)
+      throws Exception
+   {
+      TestSuite suite = new TestSuite();
+      suite.addTest(new TestSuite(clazz));
+      return getDeploySetup(suite, jarName);
+   }
+}

Property changes on: src/test/org/jboss/ejb3/test/CustomJNDIJBossTestCase.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/as/ejb3/timerservice/TimedObjectInvokerBridge.java
===================================================================
--- src/main/org/jboss/as/ejb3/timerservice/TimedObjectInvokerBridge.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/as/ejb3/timerservice/TimedObjectInvokerBridge.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.as.ejb3.timerservice;
+
+import javax.ejb.Timer;
+
+import org.jboss.ejb.txtimer.TimedObjectInvoker;
+
+/**
+ * @author <a href="mailto:cdewolf@redhat.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public class TimedObjectInvokerBridge implements TimedObjectInvoker
+{
+   private org.jboss.ejb3.timerservice.spi.TimedObjectInvoker delegate;
+
+   protected TimedObjectInvokerBridge(org.jboss.ejb3.timerservice.spi.TimedObjectInvoker delegate)
+   {
+      assert delegate != null : "delegate is null";
+      this.delegate = delegate;
+   }
+   
+   public void callTimeout(Timer timer) throws Exception
+   {
+      delegate.callTimeout(timer);
+   }
+}

Property changes on: src/main/org/jboss/as/ejb3/timerservice/TimedObjectInvokerBridge.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision

Index: src/main/org/jboss/as/ejb3/timerservice/TimerServiceFacade.java
===================================================================
--- src/main/org/jboss/as/ejb3/timerservice/TimerServiceFacade.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/as/ejb3/timerservice/TimerServiceFacade.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,101 @@
+/*
+ * 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.as.ejb3.timerservice;
+
+import static org.jboss.ejb.AllowedOperationsFlags.IN_BUSINESS_METHOD;
+import static org.jboss.ejb.AllowedOperationsFlags.IN_EJB_TIMEOUT;
+import static org.jboss.ejb.AllowedOperationsFlags.IN_SERVICE_ENDPOINT_METHOD;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Date;
+
+import javax.ejb.EJBException;
+import javax.ejb.Timer;
+import javax.ejb.TimerService;
+import javax.management.ObjectName;
+
+import org.jboss.ejb.AllowedOperationsAssociation;
+
+/**
+ * Holds the association with the container, without exposing it.
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public class TimerServiceFacade implements TimerService
+{
+   private ObjectName objectName;
+   private TimerService delegate;
+   
+   protected TimerServiceFacade(ObjectName objectName, TimerService delegate)
+   {
+      this.objectName = objectName;
+      this.delegate = delegate;
+   }
+
+   private void assertAllowedIn(String timerMethod)
+   {
+      // TODO: This isn't handled by the AS timer service itself
+      AllowedOperationsAssociation.assertAllowedIn(timerMethod, IN_BUSINESS_METHOD | IN_EJB_TIMEOUT | IN_SERVICE_ENDPOINT_METHOD);
+   }
+   
+   public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException
+   {
+      assertAllowedIn("TimerService.createTimer");
+      return delegate.createTimer(initialExpiration, intervalDuration, info);
+   }
+
+   public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException
+   {
+      assertAllowedIn("TimerService.createTimer");
+      return delegate.createTimer(expiration, info);
+   }
+
+   public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException
+   {
+      assertAllowedIn("TimerService.createTimer");
+      return delegate.createTimer(initialDuration, intervalDuration, info);
+   }
+
+   public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException
+   {
+      assertAllowedIn("TimerService.createTimer");
+      return delegate.createTimer(duration, info);
+   }
+
+//   protected EJBContainer getContainer()
+//   {
+//      return (EJBContainer) container;
+//   }
+   
+   protected ObjectName getContainerId()
+   {
+      return objectName;
+   }
+   
+   public Collection<?> getTimers() throws IllegalStateException, EJBException
+   {
+      assertAllowedIn("TimerService.getTimers");
+      return delegate.getTimers();
+   }
+}

Property changes on: src/main/org/jboss/as/ejb3/timerservice/TimerServiceFacade.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision

Index: src/main/org/jboss/as/ejb3/timerservice/JBossTimerServiceFactory.java
===================================================================
--- src/main/org/jboss/as/ejb3/timerservice/JBossTimerServiceFactory.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/as/ejb3/timerservice/JBossTimerServiceFactory.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,130 @@
+/*
+ * 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.as.ejb3.timerservice;
+
+import javax.ejb.TimerService;
+import javax.management.ObjectName;
+
+import org.jboss.ejb.AllowedOperationsAssociation;
+import org.jboss.ejb.txtimer.EJBTimerService;
+import org.jboss.ejb3.timerservice.spi.TimedObjectInvoker;
+import org.jboss.ejb3.timerservice.spi.TimerServiceFactory;
+import org.jboss.logging.Logger;
+import org.jboss.mx.util.MBeanProxyExt;
+import org.jboss.mx.util.MBeanServerLocator;
+
+/**
+ * Factory to create timer services which use the JBoss EJB Timer Service.
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public class JBossTimerServiceFactory implements TimerServiceFactory
+{
+   private static Logger log = Logger.getLogger(JBossTimerServiceFactory.class);
+   
+   public TimerService createTimerService(TimedObjectInvoker invoker)
+   {
+      TimerService timerService = null;
+      try
+      {
+         EJBTimerService service = getEJBTimerService();
+         ObjectName objectName = new ObjectName(invoker.getTimedObjectId());
+         org.jboss.ejb.txtimer.TimedObjectInvoker bridge = new TimedObjectInvokerBridge(invoker);
+         TimerService delegate = service.createTimerService(objectName, null, bridge);
+         timerService = new TimerServiceFacade(objectName, delegate);
+      }
+      catch (Exception e)
+      {
+         //throw new EJBException("Could not create timer service", e);
+         if (log.isTraceEnabled())
+         {
+            log.trace("Unable to initialize timer service", e);
+         }
+         else
+         {
+            log.trace("Unable to initialize timer service");
+         }
+      }
+      return timerService;
+   }
+
+   protected EJBTimerService getEJBTimerService()
+   {
+      return (EJBTimerService) MBeanProxyExt.create(EJBTimerService.class, EJBTimerService.OBJECT_NAME, MBeanServerLocator.locateJBoss());
+   }
+   
+   public void removeTimerService(TimerService timerService)
+   {
+      removeTimerService(((TimerServiceFacade) timerService).getContainerId());
+   }
+
+   protected void removeTimerService(ObjectName containerId)
+   {
+      try
+      {
+         EJBTimerService service = getEJBTimerService();
+         service.removeTimerService(containerId, true);
+      }
+      catch (Exception e)
+      {
+         //throw new EJBException("Could not remove timer service", e);
+         if (log.isTraceEnabled())
+         {
+            log.trace("Unable to initialize timer service", e);
+         }
+         else
+         {
+            log.trace("Unable to initialize timer service");
+         }
+      }
+   }
+   
+   public void restoreTimerService(TimerService aTimerService)
+   {
+      if (aTimerService == null)
+      {
+         log.warn("TIMER SERVICE IS NOT INSTALLED");
+         return;
+      }
+      TimerServiceFacade timerService = (TimerServiceFacade) aTimerService;
+      ClassLoader loader = null;
+      
+      // FIXME: A hack to circumvent the check in TimerServiceFacade
+      // In AS itself (/EJB2) the container has an unsecured timer service association
+      // see org.jboss.ejb.Container.getTimerService(Object pKey)
+      AllowedOperationsAssociation.pushInMethodFlag(AllowedOperationsAssociation.IN_BUSINESS_METHOD);
+      try
+      {
+         getEJBTimerService().restoreTimers(timerService.getContainerId(), loader);
+      }
+      finally
+      {
+         AllowedOperationsAssociation.popInMethodFlag();
+      }
+   }
+   
+   public void suspendTimerService(TimerService timerService)
+   {
+      removeTimerService(timerService);
+   }
+}

Property changes on: src/main/org/jboss/as/ejb3/timerservice/JBossTimerServiceFactory.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision

Index: src/main/org/jboss/as/jpa/resolvers/JBossASDataSourceDependencyResolver.java
===================================================================
--- src/main/org/jboss/as/jpa/resolvers/JBossASDataSourceDependencyResolver.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/as/jpa/resolvers/JBossASDataSourceDependencyResolver.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.as.jpa.resolvers;
+
+import org.jboss.ejb3.deployers.JBossASDepdencyPolicy;
+import org.jboss.jpa.resolvers.DataSourceDependencyResolver;
+
+/**
+ * @author <a href="mailto:cdewolf@redhat.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public class JBossASDataSourceDependencyResolver implements DataSourceDependencyResolver
+{
+   public String resolveDataSourceSupplier(String jndiName)
+   {
+      return JBossASDepdencyPolicy.createDataSourceKernelName(jndiName);
+   }
+}

Property changes on: src/main/org/jboss/as/jpa/resolvers/JBossASDataSourceDependencyResolver.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/as/jpa/builder/JPA2CEMFBuilder.java
===================================================================
--- src/main/org/jboss/as/jpa/builder/JPA2CEMFBuilder.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/as/jpa/builder/JPA2CEMFBuilder.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.as.jpa.builder;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.spi.PersistenceProvider;
+import javax.persistence.spi.PersistenceUnitInfo;
+import javax.validation.Validation;
+import javax.validation.ValidatorFactory;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.jpa.builder.CEMFBuilder;
+import org.jboss.jpa.impl.JPAConstants;
+
+/**
+ * Create a container managed entity manager factory with bean validation enabled.
+ * 
+ * @author <a href="mailto:cdewolf@redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class JPA2CEMFBuilder implements CEMFBuilder
+{
+   public EntityManagerFactory build(DeploymentUnit deploymentUnit, PersistenceUnitInfo persistenceUnitInfo)
+   {
+      try
+      {
+         Class<?> providerClass = Thread.currentThread().getContextClassLoader().loadClass(persistenceUnitInfo.getPersistenceProviderClassName());
+         
+         PersistenceProvider pp = (PersistenceProvider) providerClass.newInstance();
+         Map<Object, Object> properties = new HashMap<Object, Object>(1);
+         // FIXME: get it from JNDI or the deployer
+         ValidatorFactory beanValidationFactory = Validation.buildDefaultValidatorFactory();
+         properties.put(JPAConstants.BEAN_VALIDATION_FACTORY, beanValidationFactory);
+         EntityManagerFactory cemf = pp.createContainerEntityManagerFactory(persistenceUnitInfo, properties);
+         return cemf;
+      }
+      catch(ClassNotFoundException e)
+      {
+         throw new RuntimeException(e);
+      }
+      catch (InstantiationException e)
+      {
+         throw new RuntimeException(e);
+      }
+      catch (IllegalAccessException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+}
Index: src/main/org/jboss/as/javaee/SimpleJavaEEModuleInformer.java
===================================================================
--- src/main/org/jboss/as/javaee/SimpleJavaEEModuleInformer.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/as/javaee/SimpleJavaEEModuleInformer.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.as.javaee;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.jpa.javaee.JavaEEModuleInformer;
+import org.jboss.metadata.client.jboss.JBossClientMetaData;
+import org.jboss.metadata.ear.jboss.JBossAppMetaData;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossEntityBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+
+/**
+ * @author <a href="mailto:cdewolf@redhat.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public class SimpleJavaEEModuleInformer implements JavaEEModuleInformer
+{
+   public String getApplicationName(DeploymentUnit unit)
+   {
+      DeploymentUnit topLevel = unit.getTopLevel();
+      if(topLevel.isAttachmentPresent(JBossAppMetaData.class))
+         return topLevel.getSimpleName();
+      return null;
+   }
+
+   public String getModulePath(DeploymentUnit unit)
+   {
+      return unit.getRelativePath();
+   }
+
+   public ModuleType getModuleType(DeploymentUnit unit)
+   {
+      if(unit.isAttachmentPresent(JBossClientMetaData.class))
+         return ModuleType.APP_CLIENT;
+      if(unit.isAttachmentPresent(JBossMetaData.class) && isReallyAnEjbDeployment(unit))
+         return ModuleType.EJB;
+      if(unit.isAttachmentPresent(JBossWebMetaData.class))
+         return ModuleType.WEB;
+      return ModuleType.JAVA;
+   }
+
+   /*
+    * Some hacks to counter problems.
+    */
+   private boolean isReallyAnEjbDeployment(DeploymentUnit unit)
+   {
+      JBossMetaData metaData = unit.getAttachment(JBossMetaData.class);
+      // JBMETA-69
+      if(metaData.getEnterpriseBeans() == null || metaData.getEnterpriseBeans().size() == 0)
+         return false;
+      // JBMETA-70
+      // The chance of a persistence unit being defined with couple of EJB entity beans is
+      // pretty slim.
+      for(JBossEnterpriseBeanMetaData bean : metaData.getEnterpriseBeans())
+      {
+         if(!(bean instanceof JBossEntityBeanMetaData))
+            return true;
+      }
+      return false;
+   }
+}

Property changes on: src/main/org/jboss/as/javaee/SimpleJavaEEModuleInformer.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/clientmodule/ClientEjbResolver.java
===================================================================
--- src/main/org/jboss/ejb3/clientmodule/ClientEjbResolver.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/clientmodule/ClientEjbResolver.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,57 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2006, Red Hat Middleware LLC, and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.clientmodule;
+
+import javax.naming.NameNotFoundException;
+
+import org.jboss.ejb3.DeploymentScope;
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.ejb3.enc.DeploymentEjbResolver;
+
+// based on WarEjbResolver
+/**
+ * Resolves ejb references within an application client.
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public class ClientEjbResolver extends DeploymentEjbResolver
+{
+
+   protected ClientEjbResolver(DeploymentScope ear, String errorName)
+   {
+      super(ear, errorName);
+   }
+
+   @Override
+   protected EJBContainer searchDeploymentInternally(String ejbLink, Class businessIntf)
+   {
+      return null;
+   }
+
+   @Override
+   protected EJBContainer searchForEjbContainerInternally(Class businessIntf) throws NameNotFoundException
+   {
+      return null;
+   }
+
+}

Property changes on: src/main/org/jboss/ejb3/clientmodule/ClientEjbResolver.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/clientmodule/RemotePuEncInjector.java
===================================================================
--- src/main/org/jboss/ejb3/clientmodule/RemotePuEncInjector.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/clientmodule/RemotePuEncInjector.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.clientmodule;
+
+import javax.naming.NamingException;
+
+import org.jboss.injection.EncInjector;
+import org.jboss.injection.ExtendedInjectionContainer;
+import org.jboss.injection.InjectionContainer;
+import org.jboss.jpa.deployment.PersistenceUnitDeployment;
+import org.jboss.jpa.remote.RemotelyInjectEntityManagerFactory;
+import org.jboss.jpa.spi.PersistenceUnitRegistry;
+import org.jboss.util.naming.Util;
+
+/**
+ * EXPERIMENTAL
+ * 
+ * Setup a remote entity manager factory.
+ * 
+ * @author <a href="mailto:cdewolf@redhat.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public class RemotePuEncInjector implements EncInjector
+{
+   private String encName;
+   private String unitName;
+   
+   public RemotePuEncInjector(String encName, Class<?> injectionType, String unitName, String error)
+   {
+      assert encName != null : "encName is null";
+      this.encName = encName;
+      this.unitName = unitName;
+   }
+   
+   public void inject(InjectionContainer c)
+   {
+      if(!(c instanceof ExtendedInjectionContainer))
+         throw new UnsupportedOperationException("RemotePuEncInjector only works for ExtendedInjectionContainer");
+      ExtendedInjectionContainer container = (ExtendedInjectionContainer) c;
+      
+      String name = container.resolvePersistenceUnitSupplier(unitName);
+      PersistenceUnitDeployment deployment = ((PersistenceUnitDeployment) PersistenceUnitRegistry.getPersistenceUnit(name));
+      RemotelyInjectEntityManagerFactory factory = new RemotelyInjectEntityManagerFactory(deployment.getXml(), "FIXME");
+      
+      try
+      {
+         Util.rebind(container.getEnc(), encName, factory);
+      }
+      catch (NamingException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+}

Property changes on: src/main/org/jboss/ejb3/clientmodule/RemotePuEncInjector.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/clientmodule/ResourceHandler.java
===================================================================
--- src/main/org/jboss/ejb3/clientmodule/ResourceHandler.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/clientmodule/ResourceHandler.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,631 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.clientmodule;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Map;
+
+import javax.annotation.Resource;
+import javax.annotation.Resources;
+import javax.ejb.EJBContext;
+import javax.ejb.EJBException;
+import javax.ejb.TimerService;
+import javax.transaction.UserTransaction;
+
+import org.jboss.ejb3.Container;
+import org.jboss.injection.EJBContextPropertyInjector;
+import org.jboss.injection.EnvEntryEncInjector;
+import org.jboss.injection.InjectionContainer;
+import org.jboss.injection.InjectionHandler;
+import org.jboss.injection.InjectionUtil;
+import org.jboss.injection.Injector;
+import org.jboss.injection.InjectorFactory;
+import org.jboss.injection.JndiPropertyInjector;
+import org.jboss.injection.LinkRefEncInjector;
+import org.jboss.injection.TimerServicePropertyInjector;
+import org.jboss.injection.UserTransactionPropertyInjector;
+import org.jboss.injection.ValueEncInjector;
+import org.jboss.injection.lang.reflect.BeanProperty;
+import org.jboss.injection.lang.reflect.FieldBeanProperty;
+import org.jboss.injection.lang.reflect.MethodBeanProperty;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.javaee.spec.EnvironmentEntryMetaData;
+import org.jboss.metadata.javaee.spec.MessageDestinationReferenceMetaData;
+import org.jboss.metadata.javaee.spec.RemoteEnvironment;
+import org.jboss.metadata.javaee.spec.ResourceEnvironmentReferenceMetaData;
+import org.jboss.metadata.javaee.spec.ResourceReferenceMetaData;
+import org.jboss.reflect.plugins.ValueConvertor;
+import org.omg.CORBA.ORB;
+
+/**
+ * Handling of resources in the server side setup of the client container.
+ * 
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ * @author Scott.Stark@jboss.org
+ * @version $Revision$
+ */
+public class ResourceHandler<X extends RemoteEnvironment> implements InjectionHandler<X>
+{
+   private static final Logger log = Logger.getLogger(ResourceHandler.class);
+   
+   private boolean checkEncInjectors;
+
+   public ResourceHandler()
+   {
+      this(true);
+   }
+   
+   public ResourceHandler(boolean checkEncInjectors)
+   {
+      this.checkEncInjectors = checkEncInjectors;
+   }
+   
+   private void createURLInjector(String encName, String mappedName, InjectionContainer container)
+   {
+      assert encName.length() > 0 : "encName is empty";
+      assert mappedName.length() > 0 : "mappedName is empty";
+      
+      // Create a URL from the mappedName
+      try
+      {
+         URL url = new URL(mappedName.trim());
+         container.getEncInjectors().put(encName, new ValueEncInjector(encName, url, "@Resource"));
+      }
+      catch (MalformedURLException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+   
+   private static void loadEnvEntry(InjectionContainer container, Collection<EnvironmentEntryMetaData> envEntries)
+   {
+      for (EnvironmentEntryMetaData envEntry : envEntries)
+      {
+         String encName = "env/" + envEntry.getEnvEntryName();
+         // 16.4.1.3: If the env-entry-value is not specified, no value will be injected and it
+         // will not be initialized into the naming context.
+         if(envEntry.getValue() == null)
+         {
+            log.debug("ignoring env-entry " + envEntry);
+            continue;
+         }
+         InjectionUtil.injectionTarget(encName, envEntry, container, container.getEncInjections());
+         if (container.getEncInjectors().containsKey(encName)) continue;
+         log.trace("adding env-entry injector " + encName);
+         container.getEncInjectors().put(encName, new EnvEntryEncInjector(encName, envEntry.getType(), envEntry.getValue()));
+      }
+   }
+
+   private static void loadXmlResourceRefs(InjectionContainer container, Collection<ResourceReferenceMetaData> refs)
+   {
+      for (ResourceReferenceMetaData envRef : refs)
+      {
+         String encName = "env/" + envRef.getResourceRefName();
+         if (container.getEncInjectors().containsKey(encName))
+            continue;
+
+         if (envRef.getMappedName() == null || envRef.getMappedName().equals(""))
+         {
+            if (envRef.getResUrl() != null)
+            {
+               try
+               {
+                  container.getEncInjectors().put(encName, new ValueEncInjector(encName, new URL(envRef.getResUrl().trim()), "<resource-ref>"));
+               }
+               catch (MalformedURLException e)
+               {
+                  throw new RuntimeException(e);
+               }
+            }
+            else if (UserTransaction.class.getName().equals(envRef.getType()))
+            {
+               final InjectionContainer ic = container;
+               InjectorFactory<?> factory = new InjectorFactory<UserTransactionPropertyInjector>()
+               {
+                  public UserTransactionPropertyInjector create(BeanProperty property)
+                  {
+                     return new UserTransactionPropertyInjector(property, ic);
+                  }
+               };
+               if(envRef.getInjectionTargets() != null)
+               {
+                  InjectionUtil.createInjectors(container.getInjectors(), container.getClassloader(), factory, envRef.getInjectionTargets());
+                  continue;
+               }
+               else
+               {
+                  encName = "java:comp/UserTransaction";
+               }
+            }
+            else if (ORB.class.getName().equals(envRef.getType()))
+            {
+               encName = "java:comp/ORB";
+            }
+            else
+            {
+               throw new RuntimeException("mapped-name is required for " + envRef.getResourceRefName() + " of deployment " + container.getIdentifier());
+            }
+         }
+         else
+         {
+            container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, envRef.getMappedName(), "<resource-ref>"));
+         }
+         InjectionUtil.injectionTarget(encName, envRef, container, container.getEncInjections());
+      }
+   }
+
+   private static void loadXmlResourceEnvRefs(InjectionContainer container, Collection<ResourceEnvironmentReferenceMetaData> refs)
+   {
+      for (ResourceEnvironmentReferenceMetaData envRef : refs)
+      {
+         // EJBTHREE-712
+         // TODO: refactor with handlePropertyAnnotation
+         String resTypeName = envRef.getType();
+         String mappedName = envRef.getMappedName();
+         try
+         {
+            if(resTypeName != null)
+            {
+               Class<?> resType = Class.forName(resTypeName);
+               if(EJBContext.class.isAssignableFrom(resType))
+               {
+                  InjectorFactory<?> factory = new InjectorFactory<EJBContextPropertyInjector>()
+                  {
+                     public EJBContextPropertyInjector create(BeanProperty property)
+                     {
+                        return new EJBContextPropertyInjector(property);
+                     }
+                  };
+                  InjectionUtil.createInjectors(container.getInjectors(), container.getClassloader(), factory, envRef.getInjectionTargets());
+                  continue;
+               }
+               else if (resType.equals(UserTransaction.class))
+               {
+                  final InjectionContainer ic = container;
+                  InjectorFactory<?> factory = new InjectorFactory<UserTransactionPropertyInjector>()
+                  {
+                     public UserTransactionPropertyInjector create(BeanProperty property)
+                     {
+                        return new UserTransactionPropertyInjector(property, ic);
+                     }
+                  };
+                  if(envRef.getInjectionTargets() != null)
+                  {
+                     InjectionUtil.createInjectors(container.getInjectors(), container.getClassloader(), factory, envRef.getInjectionTargets());
+                     continue;
+                  }
+                  else
+                  {
+                     mappedName = "java:comp/UserTransaction";
+                  }
+               }
+               else if (resType.equals(ORB.class))
+               {
+                  mappedName = "java:comp/ORB";
+               }
+            }
+         }
+         catch(ClassNotFoundException e)
+         {
+            throw new EJBException(e);
+         }
+         
+         String encName = "env/" + envRef.getResourceEnvRefName();
+         if (container.getEncInjectors().containsKey(encName)) continue;
+         if (mappedName == null || mappedName.equals(""))
+         {
+            throw new RuntimeException("mapped-name is required for " + envRef.getResourceEnvRefName() + " of deployment " + container.getIdentifier());
+         }
+         container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, mappedName, "<resource-ref>"));
+         InjectionUtil.injectionTarget(encName, envRef, container, container.getEncInjections());
+      }
+   }
+
+   private static void loadXmlMessageDestinationRefs(InjectionContainer container, Collection<MessageDestinationReferenceMetaData> refs)
+   {
+      for (MessageDestinationReferenceMetaData envRef : refs)
+      {
+         String encName = "env/" + envRef.getMessageDestinationRefName();
+         if (container.getEncInjectors().containsKey(encName)) continue;
+         String jndiName = envRef.getMappedName();
+         if (jndiName == null || jndiName.equals(""))
+         {
+            // Look for a message-destination-link
+            jndiName = envRef.getResolvedJndiName();
+            if (jndiName == null)
+            {
+               throw new RuntimeException("message-destination has no jndi-name/resolved-jndi-name " + envRef);
+               // TODO: add dependency
+            }
+         }
+         container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, jndiName, "<message-destination-ref>"));
+         InjectionUtil.injectionTarget(encName, envRef, container, container.getEncInjections());
+      }
+   }
+
+   public void loadXml(X xml, InjectionContainer container)
+   {
+      if (xml == null)
+         return;
+      if (xml.getMessageDestinationReferences() != null)
+         loadXmlMessageDestinationRefs(container, xml.getMessageDestinationReferences());
+      if (xml.getResourceEnvironmentReferences() != null)
+         loadXmlResourceEnvRefs(container, xml.getResourceEnvironmentReferences());
+      if (xml.getResourceReferences() != null)
+         loadXmlResourceRefs(container, xml.getResourceReferences());
+      if (xml.getEnvironmentEntries() != null)
+         loadEnvEntry(container, xml.getEnvironmentEntries());
+   }
+
+   public void handleClassAnnotations(Class<?> clazz, InjectionContainer container)
+   {
+      Resources resources = container.getAnnotation(Resources.class, clazz);
+      if (resources != null)
+      {
+      for (Resource ref : resources.value())
+      {
+         handleClassAnnotation(ref, container, clazz);
+      }
+      }
+      Resource res = container.getAnnotation(Resource.class, clazz);
+      if (res != null) handleClassAnnotation(res, container, clazz);
+   }
+
+   private void handleClassAnnotation(Resource ref, InjectionContainer container, Class<?> clazz)
+   {
+      String encName = ref.name();
+      if (encName == null || encName.equals(""))
+      {
+         throw new RuntimeException("JBoss requires name() for class level @Resource");
+      }
+      encName = "env/" + ref.name();
+      if (container.getEncInjectors().containsKey(encName)) return;
+
+      String mappedName = ref.mappedName();
+      if (mappedName == null || mappedName.equals(""))
+      {
+         // Handle class level @Resource(type=ORB.class)
+         if(ORB.class.isAssignableFrom(ref.type()))
+         {
+            mappedName = "java:comp/ORB";
+         }
+         else if(UserTransaction.class.isAssignableFrom(ref.type()))
+         {
+            mappedName = "java:comp/UserTransaction";
+         }
+         else
+         {
+            throw new RuntimeException("You did not specify a @Resource.mappedName() for name: "
+                  +ref.name()+", class: " + clazz.getName() + " and there is no binding for that enc name in XML");
+         }
+      }
+
+      if (ref.type() == URL.class)
+      {
+         createURLInjector(encName, mappedName, container);
+      }
+      else
+      {
+         container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, ref.mappedName(), "@Resource"));
+      }
+   }
+
+   public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+   {
+      Resource ref = container.getAnnotation(Resource.class, method);
+      if (ref == null) return;
+
+      log.trace("method " + method + " has @Resource");
+      
+      handlePropertyAnnotation(ref, new MethodBeanProperty(method), container, injectors);
+      /*
+      String encName = ref.name();
+      if (encName == null || encName.equals(""))
+      {
+         encName = InjectionUtil.getEncName(method);
+      }
+      else
+      {
+         encName = "env/" + encName;
+      }
+
+      method.setAccessible(true);
+
+      if (!method.getName().startsWith("set"))
+         throw new RuntimeException("@Resource can only be used with a set method: " + method);
+      if (method.getParameterTypes().length != 1)
+         throw new RuntimeException("@Resource can only be used with a set method of one parameter: " + method);
+
+      Class type = method.getParameterTypes()[0];
+      if (!ref.type().equals(Object.class))
+      {
+         type = ref.type();
+      }
+      if (type.equals(UserTransaction.class))
+      {
+         injectors.put(method, new UserTransactionMethodInjector(method, container));
+      }
+      else if (type.equals(TimerService.class))
+      {
+         injectors.put(method, new TimerServiceMethodInjector(method, (Container) container)); // only EJBs
+      }
+      else if (EJBContext.class.isAssignableFrom(type))
+      {
+         injectors.put(method, new EJBContextMethodInjector(method));
+      }
+      else if (type.equals(WebServiceContext.class))
+      {
+         // FIXME: For now we skip it, and rely on the WS stack to perform the injection
+      }
+      else if (type.equals(String.class)
+              || type.equals(Character.class)
+              || type.equals(Byte.class)
+              || type.equals(Short.class)
+              || type.equals(Integer.class)
+              || type.equals(Long.class)
+              || type.equals(Boolean.class)
+              || type.equals(Double.class)
+              || type.equals(Float.class)
+              || type.isPrimitive()
+              )
+      {
+
+         // don't add an injector if no XML <env-entry is present as there will be no value to inject
+         if (container.getEncInjectors().containsKey(encName))
+         {
+            injectors.put(method, new JndiMethodInjector(method, encName, container.getEnc()));
+         }
+         else if (ref.mappedName() != null && ref.mappedName().length() > 0)
+         {
+            // Use the mappedName as the string value
+            String s = ref.mappedName().trim();
+            try
+            {
+               Object value = ValueConvertor.convertValue(type, s);
+               container.getEncInjectors().put(encName, new ValueEncInjector(encName, value, "@Resource"));
+               injectors.put(method, new JndiMethodInjector(method, encName, container.getEnc()));
+            }
+            catch(Throwable t)
+            {
+               throw new RuntimeException("Failed to convert: "+ref.mappedName()+" to type:"+type, t);
+            }
+         }
+      }
+      else
+      {
+         if (!container.getEncInjectors().containsKey(encName))
+         {
+            String mappedName = ref.mappedName();
+            if (mappedName == null || mappedName.equals(""))
+            {
+              throw new RuntimeException("You did not specify a @Resource.mappedName() on " + method + " and there is no binding for that enc name in XML");
+            }
+            container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, ref.mappedName(), "@Resource"));
+         }
+         injectors.put(method, new JndiMethodInjector(method, encName, container.getEnc()));
+      }
+      */
+   }
+   
+   public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+   {
+      Resource ref = container.getAnnotation(Resource.class, field);
+      if (ref == null) return;
+
+      log.trace("field " + field + " has @Resource");
+      
+      handlePropertyAnnotation(ref, new FieldBeanProperty(field), container, injectors);
+      /*
+      String encName = ref.name();
+      if (encName == null || encName.equals(""))
+      {
+         encName = InjectionUtil.getEncName(field);
+      }
+      else
+      {
+         encName = "env/" + encName;
+      }
+
+      field.setAccessible(true);
+
+      Class type = field.getType();
+      if (!ref.type().equals(Object.class))
+      {
+         type = ref.type();
+      }
+      if (type.equals(UserTransaction.class))
+      {
+         injectors.put(field, new UserTransactionFieldInjector(field, container));
+      }
+      else if (type.equals(TimerService.class))
+      {
+         injectors.put(field, new TimerServiceFieldInjector(field, (Container) container)); // only EJBs
+      }
+      else if (EJBContext.class.isAssignableFrom(type))
+      {
+         injectors.put(field, new EJBContextFieldInjector(field));
+      }
+      else if (type.equals(WebServiceContext.class))
+      {
+         // FIXME: For now we skip it, and rely on the WS stack to perform the injection
+      }
+      else if (type.equals(String.class)
+              || type.equals(Character.class)
+              || type.equals(Byte.class)
+              || type.equals(Short.class)
+              || type.equals(Integer.class)
+              || type.equals(Long.class)
+              || type.equals(Boolean.class)
+              || type.equals(Double.class)
+              || type.equals(Float.class)
+              || type.isPrimitive()
+              )
+      {
+         // don't add an injector if no XML <env-entry is present as there will be no value to inject
+         if (container.getEncInjectors().containsKey(encName))
+         {
+            injectors.put(field, new JndiFieldInjector(field, encName, container.getEnc()));
+         }
+         else if (ref.mappedName() != null && ref.mappedName().length() > 0)
+         {
+            // Use the mappedName as the string value
+            String s = ref.mappedName().trim();
+            try
+            {
+               Object value = ValueConvertor.convertValue(type, s);
+               container.getEncInjectors().put(encName, new ValueEncInjector(encName, value, "@Resource"));
+               injectors.put(field, new JndiFieldInjector(field, encName, container.getEnc()));
+            }
+            catch(Throwable t)
+            {
+               throw new RuntimeException("Failed to convert: "+ref.mappedName()+" to type:"+type, t);
+            }
+         }
+         else
+         {
+            log.warn("Not injecting " + field.getName() + ", no matching enc injector " + encName + " found");
+         }
+      }
+      else
+      {
+         if (!container.getEncInjectors().containsKey(encName))
+         {
+            String mappedName = ref.mappedName();
+            if (mappedName == null || mappedName.equals(""))
+            {
+              throw new RuntimeException("You did not specify a @Resource.mappedName() on " + field + " and there is no binding for enc name " + encName + " in XML");
+            }
+            container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, ref.mappedName(), "@Resource"));
+         }
+         injectors.put(field, new JndiFieldInjector(field, encName, container.getEnc()));
+      }
+      */
+   }
+
+   private void handlePropertyAnnotation(Resource ref, BeanProperty property, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+   {
+      assert ref != null;
+      assert property != null;
+      assert container != null;
+      assert injectors != null;
+      
+      String encName = ref.name();
+      if (encName == null || encName.equals(""))
+      {
+         //encName = InjectionUtil.getEncName(field);
+         encName = property.getDeclaringClass().getName() + "/" + property.getName();
+      }
+      if (!encName.startsWith("env/"))
+      {
+         encName = "env/" + encName;
+      }
+
+      AccessibleObject accObj = property.getAccessibleObject();
+      
+      Class<?> type = property.getType();
+      if (!ref.type().equals(Object.class))
+      {
+         type = ref.type();
+      }
+      
+      if (type.equals(UserTransaction.class))
+      {
+         injectors.put(accObj, new UserTransactionPropertyInjector(property, container));
+      }
+      else if (type.equals(TimerService.class))
+      {
+         injectors.put(accObj, new TimerServicePropertyInjector(property, (Container) container)); // only EJBs
+      }
+      else if(type.equals(URL.class) && ref.mappedName() != null && ref.mappedName().length() > 0)
+      {
+         createURLInjector(encName, ref.mappedName(), container);
+         injectors.put(accObj, new JndiPropertyInjector(property, encName, container.getEnc()));
+      }
+      else if (type.equals(String.class)
+              || type.equals(Character.class)
+              || type.equals(Byte.class)
+              || type.equals(Short.class)
+              || type.equals(Integer.class)
+              || type.equals(Long.class)
+              || type.equals(Boolean.class)
+              || type.equals(Double.class)
+              || type.equals(Float.class)
+              || type.isPrimitive()
+              )
+      {
+         // don't add an injector if no XML <env-entry is present as there will be no value to inject
+         if (container.getEncInjectors().containsKey(encName))
+         {
+            injectors.put(accObj, new JndiPropertyInjector(property, encName, container.getEnc()));
+         }
+         else if (ref.mappedName() != null && ref.mappedName().length() > 0)
+         {
+            // Use the mappedName as the string value
+            String s = ref.mappedName().trim();
+            try
+            {
+               Object value = ValueConvertor.convertValue(type, s);
+               container.getEncInjectors().put(encName, new ValueEncInjector(encName, value, "@Resource"));
+               injectors.put(accObj, new JndiPropertyInjector(property, encName, container.getEnc()));
+            }
+            catch(Throwable t)
+            {
+               throw new RuntimeException("Failed to convert: "+ref.mappedName()+" to type:"+type, t);
+            }
+         }
+         else
+         {
+            log.warn("Not injecting " + property.getName() + ", no matching enc injector " + encName + " found");
+         }
+      }
+      else
+      {
+         if (checkEncInjectors && !container.getEncInjectors().containsKey(encName))
+         {
+            String mappedName = ref.mappedName();
+            if (mappedName == null || mappedName.equals(""))
+            {
+               // TODO: is this a nice trick?
+//               if(ConnectionFactory.class.isAssignableFrom(type))
+//               {
+//                  // neat little trick
+//                  mappedName = "java:/ConnectionFactory";
+//               }
+//               else
+               if(ORB.class.isAssignableFrom(type))
+                  mappedName = "java:comp/ORB";
+               else if(EJBContext.class.isAssignableFrom(type))
+                  mappedName = "java:comp/EJBContext";
+               else
+                  throw new RuntimeException("You did not specify a @Resource.mappedName() on " + accObj + " and there is no binding for enc name " + encName + " in XML");
+            }
+            container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, mappedName, "@Resource"));
+         }
+         injectors.put(accObj, new JndiPropertyInjector(property, encName, container.getEnc()));
+      }      
+   }
+}

Property changes on: src/main/org/jboss/ejb3/clientmodule/ResourceHandler.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java
===================================================================
--- src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,438 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.clientmodule;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.naming.Context;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+
+import org.jboss.beans.metadata.api.annotations.Start;
+import org.jboss.beans.metadata.api.annotations.Stop;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.ejb3.Container;
+import org.jboss.ejb3.DependencyPolicy;
+import org.jboss.ejb3.DeploymentScope;
+import org.jboss.ejb3.DeploymentUnit;
+import org.jboss.ejb3.Ejb3Module;
+import org.jboss.ejb3.deployers.JBoss5DeploymentScope;
+import org.jboss.ejb3.deployers.JBoss5DeploymentUnit;
+import org.jboss.ejb3.deployers.JBossASDepdencyPolicy;
+import org.jboss.ejb3.enc.DeploymentEjbResolver;
+import org.jboss.ejb3.enc.MessageDestinationResolver;
+import org.jboss.ejb3.javaee.AbstractJavaEEComponent;
+import org.jboss.ejb3.javaee.SimpleJavaEEModule;
+import org.jboss.injection.DependsHandler;
+import org.jboss.injection.EncInjector;
+import org.jboss.injection.ExtendedInjectionContainer;
+import org.jboss.injection.InjectionHandler;
+import org.jboss.injection.Injector;
+import org.jboss.injection.WebServiceRefHandler;
+import org.jboss.jpa.resolvers.PersistenceUnitDependencyResolver;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.client.jboss.JBossClientMetaData;
+import org.jboss.metadata.javaee.spec.RemoteEnvironment;
+import org.jboss.metadata.javaee.spec.ServiceReferenceMetaData;
+import org.jboss.metadata.javaee.spec.ServiceReferencesMetaData;
+import org.jboss.metadata.serviceref.ServiceReferenceHandler;
+import org.jboss.metadata.serviceref.VirtualFileAdaptor;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+
+/**
+ * This class builds up the java:comp namespace for JavaEE 5 application clients.
+ * It uses the existing injection framework to get this done.
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @author adrian@jboss.org
+ * @version $Revision$
+ */
+public class ClientENCInjectionContainer extends AbstractJavaEEComponent implements ExtendedInjectionContainer
+{
+   private static final Logger log = Logger.getLogger(ClientENCInjectionContainer.class);
+
+   private VFSDeploymentUnit deploymentUnit;
+   private DeploymentUnit ejb3Unit;
+   private JBossClientMetaData clientMetaData;
+   private Class<?> mainClass;
+   private String applicationClientName;
+   private ClassLoader classLoader;
+
+   // TODO: remove injectors, these are not supported
+   private List<Injector> injectors = new ArrayList<Injector>();
+   private Map<String, Map<AccessibleObject, Injector>> encInjections = new HashMap<String, Map<AccessibleObject, Injector>>();
+   private Map<String, EncInjector> encInjectors = new HashMap<String, EncInjector>();
+
+   private Context enc;
+
+   private DeploymentEjbResolver ejbResolver;
+   private DeploymentScope deploymentScope;
+   private ObjectName objectName;
+   private DependencyPolicy dependencyPolicy = new JBossASDepdencyPolicy(this);
+
+   private MessageDestinationResolver messageDestinationResolver;
+   
+   private PersistenceUnitDependencyResolver persistenceUnitDependencyResolver;
+
+   public ClientENCInjectionContainer(VFSDeploymentUnit unit, JBossClientMetaData xml, Class<?> mainClass, String applicationClientName, ClassLoader classLoader,
+         Context encCtx, PersistenceUnitDependencyResolver persistenceUnitDependencyResolver) throws NamingException
+   {
+      super(new SimpleJavaEEModule((unit.getParent() != null ? unit.getParent().getSimpleName() : null), unit.getSimpleName()));
+      if (mainClass == null)
+         throw new NullPointerException("mainClass is mandatory");
+      if (applicationClientName == null)
+         throw new NullPointerException("applicationClientName is mandatory");
+      if (classLoader == null)
+         throw new NullPointerException("classLoader is mandatory");
+
+      this.deploymentUnit = unit;
+      this.ejb3Unit = new JBoss5DeploymentUnit(unit);
+      this.clientMetaData = xml;
+      this.mainClass = mainClass;
+      this.applicationClientName = applicationClientName;
+      this.classLoader = classLoader;
+
+      this.enc = encCtx;
+
+      /*
+       EAR ear = null;
+
+       if (di.parent != null)
+       {
+       if (di.parent.shortName.endsWith(".ear") || di.parent.shortName.endsWith(".ear/"))
+       {
+       synchronized (di.parent.context)
+       {
+       ear = (EAR) di.parent.context.get("EJB3_EAR_METADATA");
+       if (ear == null)
+       {
+       ear = new JmxEARImpl(di.parent.shortName);
+       di.parent.context.put("EJB3_EAR_METADATA", ear);
+       }
+       }
+       }
+       }
+       */
+
+      //DeploymentScope scope = null;
+      if (unit.getParent() != null)
+      {
+         boolean isEar = unit != unit.getTopLevel();
+         this.deploymentScope = new JBoss5DeploymentScope(unit.getParent(), isEar);
+      }
+
+      ejbResolver = new ClientEjbResolver(deploymentScope, unit.getSimpleName());
+      messageDestinationResolver = new MessageDestinationResolver(deploymentScope, xml.getMessageDestinations());
+
+      String on = Ejb3Module.BASE_EJB3_JMX_NAME + createScopeKernelName(unit, deploymentScope) + ",name=" + applicationClientName;
+      try
+      {
+         this.objectName = new ObjectName(on);
+      }
+      catch (MalformedObjectNameException e)
+      {
+         // should not happen
+         throw new RuntimeException("Malformed object name " + on, e);
+      }
+      
+      this.persistenceUnitDependencyResolver = persistenceUnitDependencyResolver;
+      
+      // The resolvers must be set by here.
+      assert this.persistenceUnitDependencyResolver != null : "no persistenceUnitDependencyResolver specified";
+      
+      // Process meta data, so we have the right dependencies.
+      processMetaData();
+   }
+
+   private String createScopeKernelName(VFSDeploymentUnit unit, DeploymentScope ear)
+   {
+      String scopedKernelName = "";
+      if (ear != null)
+         scopedKernelName += ",ear=" + ear.getShortName();
+      scopedKernelName += ",jar=" + unit.getSimpleName();
+      return scopedKernelName;
+   }
+
+   public <T extends Annotation> T getAnnotation(Class<T> annotationType, Class<?> clazz)
+   {
+      return clazz.getAnnotation(annotationType);
+   }
+
+   public <T extends Annotation> T getAnnotation(Class<T> annotationType, Class<?> clazz, Method method)
+   {
+      return method.getAnnotation(annotationType);
+   }
+
+   public <T extends Annotation> T getAnnotation(Class<T> annotationType, Method method)
+   {
+      return method.getAnnotation(annotationType);
+   }
+
+   public <T extends Annotation> T getAnnotation(Class<T> annotationType, Class<?> clazz, Field field)
+   {
+      return field.getAnnotation(annotationType);
+   }
+
+   public <T extends Annotation> T getAnnotation(Class<T> annotationType, Field field)
+   {
+      return field.getAnnotation(annotationType);
+   }
+
+   public VirtualFile getRootFile()
+   {
+      return ejb3Unit.getRootFile();
+   }
+
+   public ClassLoader getClassloader()
+   {
+      return classLoader;
+   }
+
+   public DependencyPolicy getDependencyPolicy()
+   {
+      return dependencyPolicy;
+   }
+
+   public String getDeploymentDescriptorType()
+   {
+      return "application-client.xml";
+   }
+
+   public String getEjbJndiName(Class businessInterface) throws NameNotFoundException
+   {
+      return ejbResolver.getEjbJndiName(businessInterface);
+   }
+
+   public String getEjbJndiName(String link, Class businessInterface)
+   {
+      return ejbResolver.getEjbJndiName(link, businessInterface);
+   }
+
+   public Context getEnc()
+   {
+      return enc;
+   }
+
+   public Map<String, Map<AccessibleObject, Injector>> getEncInjections()
+   {
+      return encInjections;
+   }
+
+   public Map<String, EncInjector> getEncInjectors()
+   {
+      return encInjectors;
+   }
+
+   public RemoteEnvironment getEnvironmentRefGroup()
+   {
+      return clientMetaData;
+   }
+
+   public String getIdentifier()
+   {
+      return applicationClientName;
+   }
+
+   /**
+    * A client enc injection container doesn't support injectors, because
+    * these must be run client side.
+    */
+   public List<Injector> getInjectors()
+   {
+      //throw new RuntimeException("not supported");
+      return injectors;
+   }
+
+   public Class<?> getMainClass()
+   {
+      return mainClass;
+   }
+
+   public ObjectName getObjectName()
+   {
+      return objectName;
+   }
+
+   public boolean hasJNDIBinding(String jndiName)
+   {
+      return false;
+   }
+
+   private void populateEnc()
+   {
+      for (EncInjector injector : encInjectors.values())
+      {
+         log.trace("encInjector: " + injector);
+         injector.inject(this);
+      }
+   }
+
+   private void processMetaData()
+   {
+      if (clientMetaData.getDepends() != null)
+         for (String dependency : clientMetaData.getDepends())
+         {
+            getDependencyPolicy().addDependency(dependency);
+         }
+
+      // TODO: check which handlers an application client should support
+      Collection<InjectionHandler<JBossClientMetaData>> handlers = new ArrayList<InjectionHandler<JBossClientMetaData>>();
+      handlers.add(new EJBRemoteHandler<JBossClientMetaData>());
+      handlers.add(new DependsHandler<JBossClientMetaData>());
+      //handlers.add(new JndiInjectHandler<JBossClientMetaData>());
+      //handlers.add(new PersistenceContextHandler<JBossClientMetaData>());
+      handlers.add(new RemotePersistenceUnitHandler<JBossClientMetaData>());
+      handlers.add(new ResourceHandler<JBossClientMetaData>());
+      handlers.add(new WebServiceRefHandler<JBossClientMetaData>());
+
+      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<JBossClientMetaData> handler : handlers)
+            handler.loadXml(clientMetaData, this);
+/*
+         Map<AccessibleObject, Injector> tmp = InjectionUtil.processAnnotations(this, handlers, getMainClass());
+         injectors.addAll(tmp.values());
+*/
+
+         //         initialiseInterceptors();
+         //         for (InterceptorInfo interceptorInfo : applicableInterceptors)
+         //         {
+         //            for (InjectionHandler handler : handlers)
+         //            {
+         //               handler.loadXml(interceptorInfo.getXml(), this);
+         //            }
+         //         }
+         //         for (InterceptorInfo interceptorInfo : applicableInterceptors)
+         //         {
+         //            Map<AccessibleObject, Injector> tmpInterceptor = InjectionUtil.processAnnotations(this, handlers, interceptorInfo.getClazz());
+         //            InterceptorInjector injector = new InterceptorInjector(this, interceptorInfo, tmpInterceptor);
+         //            interceptorInjectors.put(interceptorInfo.getClazz(), injector);
+         //         }
+
+         // When @WebServiceRef is not used service-ref won't be processed
+         // In this case we process them late
+         if (clientMetaData != null)
+         {
+            ServiceReferencesMetaData serviceRefs = clientMetaData.getServiceReferences();
+            if (serviceRefs != null)
+            {
+               Iterator<ServiceReferenceMetaData> itRefs = serviceRefs.iterator();
+               while (itRefs.hasNext())
+               {
+                  ServiceReferenceMetaData sref = itRefs.next();
+                  try
+                  {
+                     String name = sref.getServiceRefName();
+                     String encName = "env/" + name;
+                     Context encCtx = getEnc();
+
+                     UnifiedVirtualFile vfsRoot = new VirtualFileAdaptor(getRootFile());
+                     new ServiceReferenceHandler().bindServiceRef(encCtx, encName, vfsRoot, getClassloader(), sref);
+
+                  }
+                  catch (Exception e)
+                  {
+                     log.error("Failed to bind service-ref", e);
+                  }
+               }
+            }
+         }
+      }
+      finally
+      {
+         Thread.currentThread().setContextClassLoader(old);
+      }
+   }
+
+   public Container resolveEjbContainer(String link, Class businessIntf)
+   {
+      return ejbResolver.getEjbContainer(link, businessIntf);
+   }
+
+   public Container resolveEjbContainer(Class businessIntf) throws NameNotFoundException
+   {
+      return ejbResolver.getEjbContainer(businessIntf);
+   }
+
+   public String resolveMessageDestination(String link)
+   {
+      //      // FIXME: this is a copy of DeploymentEjbResolver & Ejb3Deployment.resolveMessageDestination
+      //      int hashIndex = link.indexOf('#');
+      //      if (hashIndex != -1)
+      //      {
+      //         if (deploymentScope == null)
+      //         {
+      //            log.warn("ejb link '" + link + "' is relative, but no deployment scope found");
+      //            return null;
+      //         }
+      //         String relativePath = link.substring(0, hashIndex);
+      //         Ejb3Deployment dep = deploymentScope.findRelativeDeployment(relativePath);
+      //         if (dep == null)
+      //         {
+      //            log.warn("can't find a deployment for path '" + relativePath + "' of ejb link '" + link + "'");
+      //            return null;
+      //         }
+      //         String name = link.substring(hashIndex + 1);
+      //         // call resolve, because get is private (and should stay that way)
+      //         return dep.resolveMessageDestination(name);
+      //      }
+      //      return getMessageDestination(link);
+      return messageDestinationResolver.resolveMessageDestination(link);
+   }
+
+   public String resolvePersistenceUnitSupplier(String persistenceUnitName)
+   {
+      assert persistenceUnitDependencyResolver != null : "persistenceUnitDependencyResolver has not been injected";
+      return persistenceUnitDependencyResolver.resolvePersistenceUnitSupplier(deploymentUnit, persistenceUnitName);
+   }
+   
+   @Start
+   public void start()
+   {
+      populateEnc();
+
+      // Don't run any injectors, they must be run client side
+
+      log.info("STARTED CLIENT ENC CONTAINER: " + applicationClientName);
+   }
+
+   @Stop
+   public void stop()
+   {
+      log.info("STOPPED CLIENT ENC CONTAINER: " + applicationClientName);
+   }
+}

Property changes on: src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/clientmodule/EJBRemoteHandler.java
===================================================================
--- src/main/org/jboss/ejb3/clientmodule/EJBRemoteHandler.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/clientmodule/EJBRemoteHandler.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,338 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.clientmodule;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Map;
+
+import javax.ejb.EJB;
+import javax.ejb.EJBs;
+import javax.naming.NameNotFoundException;
+
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.ejb3.annotation.IgnoreDependency;
+import org.jboss.injection.EJBInjectionHandler;
+import org.jboss.injection.EjbEncInjector;
+import org.jboss.injection.EncInjector;
+import org.jboss.injection.InjectionContainer;
+import org.jboss.injection.InjectionUtil;
+import org.jboss.injection.Injector;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.javaee.spec.AbstractEJBReferenceMetaData;
+import org.jboss.metadata.javaee.spec.AnnotatedEJBReferenceMetaData;
+import org.jboss.metadata.javaee.spec.AnnotatedEJBReferencesMetaData;
+import org.jboss.metadata.javaee.spec.EJBReferenceMetaData;
+import org.jboss.metadata.javaee.spec.RemoteEnvironment;
+
+/**
+ * Local override until the ejb3 code is released for EJBTHREE-1289.
+ * 
+ * Searches bean class for all @Inject and create Injectors
+ * for a remote environment.
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ * @author Scott.Stark@jboss.org
+ * @version $Revision$
+ */
+public class EJBRemoteHandler<X extends RemoteEnvironment> extends EJBInjectionHandler<X>
+{
+   private static final Logger log = Logger.getLogger(EJBRemoteHandler.class);
+
+   public void loadXml(X xml, InjectionContainer container)
+   {
+      if (xml != null)
+      {
+         log.trace("ejbRefs = " + xml.getEjbReferences());
+         if (xml.getAnnotatedEjbReferences() != null)
+            loadEjbRefXml(xml.getAnnotatedEjbReferences(), container);
+         if (xml.getEjbReferences() != null)
+            loadEjbRefXml(xml.getEjbReferences(), container);
+      }
+   }
+
+   protected void loadEjbRefXml(AnnotatedEJBReferencesMetaData refs,
+         InjectionContainer container)
+   {
+      for (AnnotatedEJBReferenceMetaData ref : refs)
+      {
+         String interfaceName = ref.getBeanInterface().getName();
+         String errorType = "@EJB";
+
+         ejbRefXml(ref, interfaceName, container, errorType);
+      }      
+   }
+
+   protected void loadEjbRefXml(Collection<EJBReferenceMetaData> refs, InjectionContainer container)
+   {
+      for (EJBReferenceMetaData ref : refs)
+      {
+         String interfaceName = ref.getRemote();
+         String errorType = "<ejb-ref>";
+
+         ejbRefXml(ref, interfaceName, container, errorType);
+      }
+   }
+
+   protected void ejbRefXml(AbstractEJBReferenceMetaData ref, String interfaceName, InjectionContainer container, String errorType)
+   {
+      String encName = "env/" + ref.getEjbRefName();
+      InjectionUtil.injectionTarget(encName, ref, container, container.getEncInjections());
+      if (container.getEncInjectors().containsKey(encName))
+         return;
+
+      String mappedName = ref.getMappedName();
+      if (mappedName != null && mappedName.equals(""))
+         mappedName = null;
+      if(mappedName == null && ref.getResolvedJndiName() != null)
+         mappedName = ref.getResolvedJndiName();
+
+      String link = ref.getLink();
+      if (link != null && link.trim().equals("")) link = null;
+
+      Class<?> refClass = null;
+
+      if (interfaceName != null)
+      {
+         try
+         {
+            refClass = container.getClassloader().loadClass(interfaceName);
+         }
+         catch (ClassNotFoundException e)
+         {
+            throw new RuntimeException("could not find " + errorType + "'s local interface " + interfaceName + " in " + container.getDeploymentDescriptorType() + " of " + container.getIdentifier());
+         }
+      }
+      
+      //----- injectors
+
+      if (mappedName == null && refClass == null && link == null)
+      {
+         // must be jboss.xml only with @EJB used to define reference.  jboss.xml used to tag for ignore dependency
+         // i think it is ok to assume this because the ejb-jar.xml schema should handle any missing elements
+      }
+      else
+      {
+         ejbRefEncInjector(mappedName, encName, null, refClass, link, errorType, container);
+         if (ref.getIgnoreDependency() != null)
+         {
+            log.debug("IGNORING <ejb-ref> DEPENDENCY: " + encName);
+            return;
+         }
+
+         ejbRefDependency(mappedName, link, container, refClass, errorType, encName);
+      }
+   }
+
+   protected void ejbRefDependency(String mappedName, String link, InjectionContainer container, Class<?> refClass, String errorType, String encName)
+   {
+      if(mappedName != null && mappedName.length() == 0) mappedName = null;
+      if (refClass != null && (refClass.equals(Object.class) || refClass.equals(void.class))) refClass = null;
+      
+      if(mappedName != null)
+      {
+         addJNDIDependency(container, mappedName);
+         return;
+      }
+      
+      if (refClass != null)
+      {
+         if (link != null && !link.trim().equals(""))
+         {
+            addDependency(container, link, refClass);
+         }
+         else
+         {
+            addDependency(container, refClass);
+         }
+      }
+      
+      else
+      {
+         String msg = "IGNORING DEPENDENCY: unable to resolve dependency of EJB, there is too little information";
+         log.warn(msg);
+      }
+   }
+
+   protected void ejbRefEncInjector(String mappedName, String encName, String fieldName, Class refClass, String link, String errorType, InjectionContainer container)
+   {
+      if (refClass != null && (refClass.equals(Object.class) || refClass.equals(void.class)))
+         refClass = null;
+      if (mappedName != null && mappedName.trim().equals(""))
+         mappedName = null;
+      if (mappedName == null)
+      {
+         //
+         AnnotatedEJBReferencesMetaData amds = container.getEnvironmentRefGroup().getAnnotatedEjbReferences();
+         if(amds != null)
+         {
+            AnnotatedEJBReferenceMetaData amd = amds.get(encName);
+            if(amd == null && fieldName != null)
+               amd = amds.get(fieldName);
+            if(amd != null)
+            {
+               mappedName = amd.getMappedName();
+               if(mappedName == null)
+                  mappedName = amd.getResolvedJndiName();
+            }
+         }
+      }
+
+      EncInjector injector = null;
+      
+      if (mappedName == null)
+      {
+         injector = new EjbEncInjector(encName, refClass, link, errorType);
+      }
+      else
+      {
+         injector = new EjbEncInjector(encName, mappedName, errorType);
+      }
+
+      container.getEncInjectors().put(encName, injector);
+   }
+
+   public static EJBContainer getEjbContainer(EJB ref, InjectionContainer container, Class<?> memberType)
+   {
+      EJBContainer rtn = null;
+
+      if (ref.mappedName() != null && !"".equals(ref.mappedName()))
+      {
+         return null;
+      }
+
+      if (ref.beanName().equals("") && memberType == null)
+         throw new RuntimeException("For deployment " + container.getIdentifier() + "not enough information for @EJB.  Please fill out the beanName and/or businessInterface attributes");
+
+      Class<?> businessInterface = memberType;
+      if (!ref.beanInterface().getName().equals(Object.class.getName()))
+      {
+         businessInterface = ref.beanInterface();
+      }
+
+      if (ref.beanName().equals(""))
+      {
+         try
+         {
+            rtn = (EJBContainer) container.resolveEjbContainer(businessInterface);
+         }
+         catch (NameNotFoundException e)
+         {
+            log.warn("For deployment " + container.getIdentifier() + " could not find jndi binding based on interface only for @EJB(" + businessInterface.getName() + ") " + e.getMessage());
+         }
+      }
+      else
+      {
+         rtn = (EJBContainer) container.resolveEjbContainer(ref.beanName(), businessInterface);
+      }
+
+      return rtn;
+   }
+
+   public static String getJndiName(EJB ref, InjectionContainer container, Class<?> memberType)
+   {
+      String jndiName;
+
+      if (ref.mappedName() != null && !"".equals(ref.mappedName()))
+      {
+         return ref.mappedName();
+      }
+
+      if (ref.beanName().equals("") && memberType == null)
+         throw new RuntimeException("For deployment " + container.getIdentifier() + "not enough information for @EJB.  Please fill out the beanName and/or businessInterface attributes");
+
+      Class<?> businessInterface = memberType;
+      if (!ref.beanInterface().getName().equals(Object.class.getName()))
+      {
+         businessInterface = ref.beanInterface();
+      }
+
+      if (ref.beanName().equals(""))
+      {
+         try
+         {
+            jndiName = container.getEjbJndiName(businessInterface);
+         }
+         catch (NameNotFoundException e)
+         {
+            throw new RuntimeException("For deployment " + container.getIdentifier() + " could not find jndi binding based on interface only for @EJB(" + businessInterface.getName() + ") " + e.getMessage());
+         }
+         if (jndiName == null)
+         {
+            throw new RuntimeException("For deployment " + container.getIdentifier() + " could not find jndi binding based on interface only for @EJB(" + businessInterface.getName() + ")");
+         }
+      }
+      else
+      {
+         jndiName = container.getEjbJndiName(ref.beanName(), businessInterface);
+         if (jndiName == null)
+         {
+            throw new RuntimeException("For EJB " + container.getIdentifier() + "could not find jndi binding based on beanName and business interface for @EJB(" + ref.beanName() + ", " + businessInterface.getName() + ")");
+         }
+      }
+
+      return jndiName;
+   }
+
+   public void handleClassAnnotations(Class<?> clazz, InjectionContainer container)
+   {
+      throw new IllegalStateException("handleClassAnnotation cannot be used in a client");
+   }
+
+   protected void handleClassAnnotation(EJB ejb, Class<?> clazz, InjectionContainer container)
+   {
+      throw new IllegalStateException("handleClassAnnotation cannot be used in a client");
+   }
+
+   public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+   {
+      throw new IllegalStateException("handleMethodAnnotations cannot be used in a client");
+   }
+
+   public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+   {
+      throw new IllegalStateException("handleFieldAnnotations cannot be used in a client");
+   }
+
+   protected boolean isIgnoreDependency(InjectionContainer container, EJB ref)
+   {
+      RemoteEnvironment refGroup =  container.getEnvironmentRefGroup();
+      
+      if (refGroup != null)
+      {
+         if(refGroup.getEjbReferences() != null)
+         for(EJBReferenceMetaData ejbRef : refGroup.getEjbReferences())
+         {
+            if (ejbRef.getEjbRefName().equals(ref.name()))
+            {
+               return ejbRef.getIgnoreDependency() != null;
+            }
+         }
+      }
+      
+      // TODO: shouldn't we scan local ejb refs as well?
+      
+      return false;
+   }
+}
\ No newline at end of file

Property changes on: src/main/org/jboss/ejb3/clientmodule/EJBRemoteHandler.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/clientmodule/RemotePersistenceUnitHandler.java
===================================================================
--- src/main/org/jboss/ejb3/clientmodule/RemotePersistenceUnitHandler.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/clientmodule/RemotePersistenceUnitHandler.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.clientmodule;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Map;
+
+import javax.naming.NameNotFoundException;
+
+import org.jboss.injection.InjectionContainer;
+import org.jboss.injection.InjectionHandler;
+import org.jboss.injection.InjectionUtil;
+import org.jboss.injection.Injector;
+import org.jboss.injection.PersistenceUnitHandler;
+import org.jboss.metadata.javaee.spec.PersistenceUnitReferenceMetaData;
+import org.jboss.metadata.javaee.spec.RemoteEnvironment;
+
+/**
+ * EXPERIMENTAL
+ * 
+ * Allow injection of a persistence unit into a component running outside
+ * the VM where the peristence unit is deployed.
+ * 
+ * Currently this only runs for application client which does do any
+ * annotation processing by itself. This is delegated to the AnnotationDeployer.
+ * 
+ * @author <a href="mailto:cdewolf@redhat.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public class RemotePersistenceUnitHandler<X extends RemoteEnvironment> implements InjectionHandler<X>
+{
+   public void handleClassAnnotations(Class<?> clazz, InjectionContainer container)
+   {
+      throw new UnsupportedOperationException("metadata should have been complete");
+   }
+
+   public void handleFieldAnnotations(Field field, InjectionContainer container,
+         Map<AccessibleObject, Injector> injectors)
+   {
+      throw new UnsupportedOperationException("metadata should have been complete");
+   }
+
+   public void handleMethodAnnotations(Method method, InjectionContainer container,
+         Map<AccessibleObject, Injector> injectors)
+   {
+      throw new UnsupportedOperationException("metadata should have been complete");
+   }
+
+   public void loadXml(X xml, InjectionContainer container)
+   {
+      if (xml == null) return;
+      if (xml.getPersistenceUnitRefs() == null) return;
+
+      for (PersistenceUnitReferenceMetaData ref : xml.getPersistenceUnitRefs())
+      {
+         String encName = "env/" + ref.getPersistenceUnitRefName();
+         // we add injection target no matter what.  enc injection might be overridden but
+         // XML injection cannot be overriden
+         Class<?> injectionType = InjectionUtil.injectionTarget(encName, ref, container, container.getEncInjections());
+         if (container.getEncInjectors().containsKey(encName))
+            return;
+         container.getEncInjectors().put(encName, new RemotePuEncInjector(encName, injectionType, ref.getPersistenceUnitName(), "<persistence-unit-ref>"));
+         try
+         {
+            PersistenceUnitHandler.addPUDependency(ref.getPersistenceUnitName(), container);
+         }
+         catch (NameNotFoundException e)
+         {
+            throw new RuntimeException("Illegal <persistence-unit-ref> of " + ref.getPersistenceUnitRefName() + " :" + e.getMessage());
+         }
+      }
+   }
+
+}

Property changes on: src/main/org/jboss/ejb3/clientmodule/RemotePersistenceUnitHandler.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/deployers/EJBRegistrationDeployer.java
===================================================================
--- src/main/org/jboss/ejb3/deployers/EJBRegistrationDeployer.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/deployers/EJBRegistrationDeployer.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,312 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, Red Hat Middleware LLC., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.ejb3.deployers;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+
+import javax.management.MBeanServer;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.vfs.spi.deployer.AbstractVFSRealDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.deployment.security.JaccPolicyUtil;
+import org.jboss.deployment.spi.DeploymentEndpointResolver;
+import org.jboss.ejb3.DeploymentScope;
+import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.kernel.Kernel;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ear.jboss.JBossAppMetaData;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Creates initial EJB deployments and initializes only basic metadata.
+ * A registration process is required so that
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ * @author adrian@jboss.org
+ * @version $Revision$
+ * @deprecated use Ejb3Deployer
+ */
+@Deprecated
+public class EJBRegistrationDeployer extends AbstractVFSRealDeployer
+{
+   private static final Logger log = Logger.getLogger(EJBRegistrationDeployer.class);
+
+   private HashSet ignoredJarsSet;
+   private MBeanServer mbeanServer;
+   private Kernel kernel;
+   private Properties defaultPersistenceProperties;
+   private List<String> allowedSuffixes;
+   private boolean requireDeploymentDescriptor;
+
+   public static boolean has30EjbJarXml(InputStream ddStream)
+   {
+      try
+      {
+         // look for version="3.0" in the file
+         byte[] stringToFind = "version=\"3.0\"".getBytes();
+         InputStreamReader reader = new InputStreamReader(ddStream);
+         try
+         {
+            int idx = 0;
+            int len = stringToFind.length;
+            while (reader.ready())
+            {
+               int read = reader.read();
+               if (read == stringToFind[idx])
+               {
+                  idx++;
+                  if (idx == len)
+                  {
+                     return true;
+                  }
+               }
+               else
+               {
+                  idx = 0;
+               }
+            }
+
+         }
+         finally
+         {
+            try
+            {
+               reader.close();
+               ddStream.close();
+            }
+            catch (IOException ignored)
+            {
+            }
+         }
+      }
+      catch (Exception ignore)
+      {
+      }
+      return false;
+   }
+
+   /**
+    * Create a new EJBRegistrationDeployer.
+    */
+   public EJBRegistrationDeployer()
+   {
+      setOutputs(Ejb3Deployment.class.getName(), JaccPolicyUtil.IGNORE_ME_NAME);
+   }
+   
+   public List<String> getAllowedSuffixes()
+   {
+      return allowedSuffixes;
+   }
+
+   public void setAllowedSuffixes(List<String> allowedSuffixes)
+   {
+      this.allowedSuffixes = allowedSuffixes;
+   }
+
+   public HashSet getIgnoredJarsSet()
+   {
+      return ignoredJarsSet;
+   }
+
+   public void setIgnoredJarsSet(HashSet ignoredJarsSet)
+   {
+      this.ignoredJarsSet = ignoredJarsSet;
+   }
+
+   public MBeanServer getMbeanServer()
+   {
+      return mbeanServer;
+   }
+
+   public void setMbeanServer(MBeanServer mbeanServer)
+   {
+      this.mbeanServer = mbeanServer;
+   }
+
+   public Kernel getKernel()
+   {
+      return kernel;
+   }
+
+   public void setKernel(Kernel kernel)
+   {
+      this.kernel = kernel;
+   }
+
+   public Properties getDefaultPersistenceProperties()
+   {
+      return defaultPersistenceProperties;
+   }
+
+   public void setDefaultPersistenceProperties(Properties defaultPersistenceProperties)
+   {
+      this.defaultPersistenceProperties = defaultPersistenceProperties;
+   }
+
+   public boolean getRequireDeploymentDescriptor()
+   {
+      return requireDeploymentDescriptor;
+   }
+
+   public void setRequireDeploymentDescriptor(boolean requireDeploymentDescriptor)
+   {
+      this.requireDeploymentDescriptor = requireDeploymentDescriptor;
+   }
+
+   public void deploy(VFSDeploymentUnit unit) throws DeploymentException
+   {
+      try
+      {
+         // Initialize
+         boolean hasEjbDd = false;
+         boolean hasJbossDd = false;
+         
+         VirtualFile jar = unit.getRoot();
+         if (jar.isLeaf() || ignoredJarsSet.contains(jar.getName()))
+         {
+            log.trace("EJBRegistrationDeployer ignoring: " + jar.getName());
+            return;
+         }
+         if(!hasAllowedSuffix(jar.getName()))
+         {
+            log.trace("EJBRegistrationDeployer suffix not allowed: " + jar.getName());
+            return;
+         }
+         
+         VirtualFile ejbjar = unit.getMetaDataFile("ejb-jar.xml");
+         if (ejbjar != null)
+         {
+            InputStream is = ejbjar.openStream();
+            boolean has30EjbJarXml = has30EjbJarXml(is);
+            is.close();
+            if (!has30EjbJarXml) {
+               return;
+            }
+            else {
+               hasEjbDd = true;
+            }
+         }
+         
+         // Determine if jboss.xml is specified
+         hasJbossDd = unit.getMetaDataFile("jboss.xml")!=null;
+         
+         // If DDs are required and none are present, skip deployment
+         // EJBTHREE-1040
+         if (this.getRequireDeploymentDescriptor() && !(hasJbossDd || hasEjbDd))
+         {
+            log.trace(EJBRegistrationDeployer.class.getSimpleName() + " skipping deployment \"" + unit.getSimpleName()
+                  + "\", jar: \"" + jar.getName()
+                  + "\" - either EJB3 Deployment Descriptor or \"jboss.xml\" is required and neither were found.");
+            return;
+         }
+            
+         log.debug("********* EJBRegistrationDepoyer Begin Unit: " + unit.getSimpleName() + " jar: " + jar.getName());
+         JBoss5DeploymentScope scope = null;
+         VFSDeploymentUnit parent = unit.getParent();
+         boolean initScopeDeployment = false;
+         if (parent != null && parent.isAttachmentPresent(JBossAppMetaData.class))
+         {
+            // An ear parent
+            scope = (JBoss5DeploymentScope) parent.getAttachment(DeploymentScope.class);
+            if (scope == null)
+            {
+               boolean isEar = unit != unit.getTopLevel();
+               if(parent.isAttachmentPresent(DeploymentEndpointResolver.class) == true)
+                  scope = new JBoss5DeploymentScope(parent, isEar);
+               else
+               {
+                  // EJBTHREE-1291
+                  scope = new JBoss5DeploymentScope(parent, isEar, unit.getSimpleName());
+                  initScopeDeployment = true;
+               }
+               parent.addAttachment(DeploymentScope.class, scope);
+            }
+         }
+         JBoss5DeploymentUnit du = new JBoss5DeploymentUnit(unit);
+         du.setDefaultPersistenceProperties(defaultPersistenceProperties);
+         Ejb3JBoss5Deployment deployment = new Ejb3JBoss5Deployment(du, kernel, mbeanServer, unit, scope, null);
+         if (scope != null)
+            scope.register(deployment);
+         if(initScopeDeployment)
+         {
+            scope.setDeployment(deployment);
+         }
+         // create() creates initial EJB containers and initializes metadata.
+         deployment.create();
+         if (deployment.getEjbContainers().size() == 0)
+         {
+            log.trace("EJBRegistrationDeployer no containers in scanned jar, consider adding it to the ignore list: " + jar.getName() + " url: " + jar.toURL() + " unit: " + unit.getSimpleName());
+            return;
+         }
+         unit.addAttachment(Ejb3Deployment.class, deployment);
+         // TODO: temporarily disable the security deployment
+         unit.addAttachment(JaccPolicyUtil.IGNORE_ME_NAME, true, Boolean.class);
+      }
+      catch (Exception e)
+      {
+         throw new DeploymentException(e);
+      }
+   }
+
+   private boolean hasAllowedSuffix(String name)
+   {
+      if(allowedSuffixes == null)
+         return true;
+      
+      for (String suffix : allowedSuffixes)
+      {
+         if (name.endsWith(suffix))
+         {
+            return true;
+         }
+      }
+      return false;
+   }
+   
+   public void undeploy(VFSDeploymentUnit unit)
+   {
+      Ejb3Deployment deployment = unit.getAttachment(Ejb3Deployment.class);
+      if (deployment == null) return;
+      try
+      {
+         deployment.stop();
+      }
+      catch (Exception e)
+      {
+         log.error("failed to stop deployment", e);
+      }
+      try
+      {
+         deployment.destroy();
+      }
+      catch (Exception e)
+      {
+         log.error("failed to destroy deployment", e);
+      }
+   }
+}

Property changes on: src/main/org/jboss/ejb3/deployers/EJBRegistrationDeployer.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/deployers/JBossASDepdencyPolicy.java
===================================================================
--- src/main/org/jboss/ejb3/deployers/JBossASDepdencyPolicy.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/deployers/JBossASDepdencyPolicy.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,157 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.deployers;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.beans.metadata.plugins.AbstractDemandMetaData;
+import org.jboss.beans.metadata.plugins.AbstractSupplyMetaData;
+import org.jboss.beans.metadata.spi.DemandMetaData;
+import org.jboss.beans.metadata.spi.DependencyMetaData;
+import org.jboss.beans.metadata.spi.SupplyMetaData;
+import org.jboss.ejb3.DependencyPolicy;
+import org.jboss.ejb3.javaee.JavaEEComponent;
+import org.jboss.ejb3.kernel.JNDIKernelRegistryPlugin;
+
+/**
+ * The implementation of the DependencyPolicy used by the jbossas ejb3
+ * related deployers.
+ * 
+ * @author Scott.Stark@jboss.org
+ * @version $Revision$
+ */
+public class JBossASDepdencyPolicy extends JBoss5DependencyPolicy
+   implements DependencyPolicy
+{
+   private JavaEEComponent component;
+   private Set<DependencyMetaData> dependencies = new HashSet<DependencyMetaData>();
+   private Set<DemandMetaData> demands = new HashSet<DemandMetaData>();
+   private Set<SupplyMetaData> supplies = new HashSet<SupplyMetaData>();
+
+   public JBossASDepdencyPolicy(JavaEEComponent component)
+   {
+      super(component);
+      this.component = component;
+   }
+
+   public void addDependency(String dependency)
+   {
+      addDependency(new AbstractDemandMetaData(dependency));
+   }
+   public void addDependency(DemandMetaData dependency)
+   {
+      demands.add(dependency);      
+   }
+   public void addDependency(DependencyMetaData dependency)
+   {
+      dependencies.add(dependency);      
+   }
+
+   public void addDependency(Class<?> businessInterface)
+   {
+      addDependency("Class:" + businessInterface.getName());
+   }
+   
+   /**
+    * Add a dependency on an enterprise bean.
+    * 
+    * Optionally the ejb link is prefixed with the path name to
+    * another ejb-jar file separated with a '#' to the enterprise bean's name.
+    * 
+    * @param ejbLink        the name of the target enterprise bean
+    * @param businessInterface
+    */
+   public void addDependency(String ejbLink, Class<?> businessInterface)
+   {
+      assert ejbLink != null : "ejbLink is null"; 
+      
+      // Note that businessInterface is always ignored during resolving.
+      
+      // FIXME: less hacky
+      
+      int hashIndex = ejbLink.indexOf('#');
+      if (hashIndex != -1)
+      {
+         String unitName = ejbLink.substring(0, hashIndex);
+         String ejbName = ejbLink.substring(hashIndex + 1);
+         // Work around ejb2/3 container name mismatches by adding
+         String ejb3Name = component.createObjectName(unitName, ejbName);
+         String ejb2Name = "TODO...";
+         String demand = null;
+         AbstractDemandMetaData admd = new AbstractDemandMetaData(demand);
+         admd.setTransformer("");
+         //addDependency(admd);
+      }
+      else
+      {
+         //addDependency(new EjbLinkDemandMetaData(component, ejbLink));
+      }
+   }
+   
+   public void addJNDIName(String name)
+   {
+      assert name != null : "name is null";
+      assert name.length() > 0 : "name is empty";
+      
+      addDependency(JNDIKernelRegistryPlugin.JNDI_DEPENDENCY_PREFIX + name);
+   }
+   
+   public Set<DependencyMetaData> getDependencies()
+   {
+      return dependencies;
+   }
+   public Set<DemandMetaData> getDemands()
+   {
+      return demands;
+   }
+   
+   public void addSupply(Class<?> businessInterface)
+   {
+      supplies.add(new AbstractSupplyMetaData("Class:" + businessInterface.getName()));
+   }
+   
+   public Set<SupplyMetaData> getSupplies()
+   {
+      return supplies;
+   }
+   public void addDatasource(String jndiName)
+   {
+      addDependency(createDataSourceKernelName(jndiName));
+   }
+   
+   public static String createDataSourceKernelName(String jndiName)
+   {
+      String ds = jndiName;
+      if (ds.startsWith("java:/"))
+      {
+         ds = ds.substring(6);
+
+      }
+      else if (ds.startsWith("java:"))
+      {
+         ds = ds.substring(5);
+      }
+      String onStr = "jboss.jca:name=" + ds + ",service=DataSourceBinding";
+      return onStr;
+   }
+}

Property changes on: src/main/org/jboss/ejb3/deployers/JBossASDepdencyPolicy.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/deployers/JBoss5DeploymentScope.java
===================================================================
--- src/main/org/jboss/ejb3/deployers/JBoss5DeploymentScope.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/deployers/JBoss5DeploymentScope.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,262 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, Red Hat Middleware LLC., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.ejb3.deployers;
+
+import java.util.Collection;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.management.ObjectName;
+import javax.naming.NameNotFoundException;
+
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.deployment.spi.DeploymentEndpointResolver;
+import org.jboss.deployment.spi.EndpointInfo;
+import org.jboss.deployment.spi.EndpointType;
+import org.jboss.ejb3.DeploymentScope;
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.ejb3.deployers.tmp.EjbModuleEjbResolver;
+import org.jboss.ejb3.javaee.JavaEEComponentHelper;
+import org.jboss.logging.Logger;
+
+/**
+ * Abstraction for an EAR/WAR or anything that scopes EJB deployments
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ * @author adrian@jboss.org
+ * @author Scott.Stark@jboss.org
+ * @version $Revision$
+ */
+public class JBoss5DeploymentScope implements DeploymentScope
+{
+   public static final String ATTACHMENT_KEY = "org.jboss.ejb3.deployers.JBoss5DeploymentScope.deployments";
+   private static final Logger log = Logger.getLogger(JBoss5DeploymentScope.class);
+   /** The Map<String,Ejb3Deployment> of the deployment vfs path name to deployment */
+   private ConcurrentHashMap<String, Ejb3Deployment> deployments;
+   /** The deployment endpoint resolver implementation */
+   private DeploymentEndpointResolver endpointResolver;
+   private EjbModuleEjbResolver ejbRefResolver;
+   /** The parent deployment short name */
+   private String shortName;
+   /** The deployment short name minus any .suffix */
+   private String baseName;
+   
+   private boolean isEar;
+
+   @SuppressWarnings("unchecked")
+   public JBoss5DeploymentScope(VFSDeploymentUnit parent, boolean isEar)
+   {
+      this.isEar = isEar;
+      this.shortName = parent.getSimpleName();
+      baseName = null;
+      if(isEar)
+      {
+         this.baseName = shortName;
+         int idx = shortName.lastIndexOf('.');
+         if( idx > 0 )
+            baseName = shortName.substring(0, idx);
+      }
+
+      // Create the deployment map attachment if it does not exist
+      deployments = (ConcurrentHashMap<String, Ejb3Deployment>)parent.getAttachment(ATTACHMENT_KEY);
+      if (deployments == null)
+      {
+         deployments = new ConcurrentHashMap<String, Ejb3Deployment>();
+         parent.addAttachment(ATTACHMENT_KEY, deployments);
+      }
+      // MappedReferenceMetaDataResolverDeployer output, Look for the endpoint resolver
+      endpointResolver = parent.getAttachment(DeploymentEndpointResolver.class);
+      /*
+      if(endpointResolver == null)
+         throw new IllegalStateException("No DeploymentEndpointResolver found in deployment: "+parent);
+      */
+   }
+   /**
+    * Temp ctor until EJBTHREE-1291 is resolved
+    * @param parent
+    * @param shortName
+    */
+   public JBoss5DeploymentScope(VFSDeploymentUnit parent, boolean isEar, String shortName)
+   {
+      this(parent, isEar);
+      ejbRefResolver = new EjbModuleEjbResolver(this, shortName);
+   }
+   public void setDeployment(Ejb3Deployment deployment)
+   {
+      ejbRefResolver.setDeployment(deployment);
+   }
+
+   public DeploymentEndpointResolver getEndpointResolver()
+   {
+      return endpointResolver;
+   }
+   public void setEndpointResolver(DeploymentEndpointResolver endpointResolver)
+   {
+      this.endpointResolver = endpointResolver;
+   }
+
+   public Collection<Ejb3Deployment> getEjbDeployments()
+   {
+      return deployments.values();
+   }
+
+   public void register(Ejb3Deployment deployment)
+   {
+      // Create the path name relative to the root
+      String pathName = deployment.getDeploymentUnit().getRootFile().getPathName();
+      if(pathName.startsWith(shortName))
+      {
+         if(pathName.length() > shortName.length())
+            pathName = pathName.substring(shortName.length()+1);
+         else
+            pathName = "";
+      }
+      deployments.put(pathName, deployment);
+   }
+
+   public void unregister(Ejb3Deployment deployment)
+   {
+      String pathName = deployment.getDeploymentUnit().getRootFile().getPathName();
+      if(pathName.startsWith(shortName))
+         pathName = pathName.substring(shortName.length()+1);
+      deployments.remove(pathName);
+   }
+
+   public Ejb3Deployment findRelativeDeployment(String relativeName)
+   {
+      if (relativeName.startsWith("../"))
+      {
+         relativeName = relativeName.substring(3);
+      }
+      return deployments.get(relativeName);
+   }
+
+   @SuppressWarnings("unchecked")
+   public EJBContainer getEjbContainer(Class businessIntf, String vfsContext)
+      throws NameNotFoundException
+   {
+      // Get the deployment endpoint
+      if(ejbRefResolver != null)
+      {
+         // TODO: EJBTHREE-1291
+         return ejbRefResolver.getEjbContainer(businessIntf);
+      }
+
+      EJBContainer container = null;
+      EndpointInfo endpoint = endpointResolver.getEndpointInfo(businessIntf, EndpointType.EJB, vfsContext);
+      if(endpoint != null)
+      {
+         log.debug("Found endpoint for interface: "+businessIntf+", endpoint: "+endpoint);
+         Ejb3Deployment deployment = deployments.get(endpoint.getPathName());
+         // Note that this should never happen because the dependencies should have been
+         // resolved by the MappedReferenceMetaDataResolverDeployer
+         if(deployment == null)
+            throw new IllegalStateException("JBAS-5713: could not find an ejb3 deployment for " + endpoint.getPathName() + " (yet), try reordering the jars or adding explicit dependencies");
+         String ejbObjectName = JavaEEComponentHelper.createObjectName(deployment, endpoint.getName());
+         ObjectName ejbON;
+         try
+         {
+            ejbON = new ObjectName(ejbObjectName);
+         }
+         catch (Exception e)
+         {
+            throw new IllegalStateException("Failed to build ejb container ObjectName", e);
+         }
+         container = (EJBContainer) deployment.getContainer(ejbON);
+         // TODO: container = deployment.getEjbContainerForEjbName(endpoint.getName());
+      }
+      else
+      {
+         log.debug("Failed to find endpoint for interface: "+businessIntf);
+      }
+      return container;
+   }
+
+   @SuppressWarnings("unchecked")
+   public EJBContainer getEjbContainer(String ejbLink, Class businessIntf, String vfsContext)
+   {
+      if(ejbRefResolver != null)
+      {
+         // TODO: EJBTHREE-1291
+         return ejbRefResolver.getEjbContainer(ejbLink, businessIntf);
+      }
+
+      EJBContainer container = null;
+      // First try the ejbLink
+      EndpointInfo endpoint = endpointResolver.getEndpointInfo(ejbLink, EndpointType.EJB, vfsContext);
+      if(endpoint != null)
+      {
+         log.debug("Found endpoint for ejbLink: "+ejbLink+", endpoint: "+endpoint);
+         Ejb3Deployment deployment = deployments.get(endpoint.getPathName());
+         // Note that this should never happen because the dependencies should have been
+         // resolved by the MappedReferenceMetaDataResolverDeployer
+         if(deployment == null)
+            throw new IllegalStateException("JBAS-5713: could not find an ejb3 deployment for " + endpoint.getPathName() + " (yet), try reordering the jars or adding explicit dependencies");
+         String ejbObjectName = JavaEEComponentHelper.createObjectName(deployment, endpoint.getName());
+         ObjectName ejbON;
+         try
+         {
+            ejbON = new ObjectName(ejbObjectName);
+         }
+         catch (Exception e)
+         {
+            throw new IllegalStateException("Failed to build ejb container ObjectName", e);
+         }
+         container = (EJBContainer) deployment.getContainer(ejbON);
+         // TODO: container = deployment.getEjbContainerForEjbName(endpoint.getName());         container = deployment.getEjbContainerForEjbName(endpoint.getName());
+      }
+      else
+      {
+         log.debug("Failed to find endpoint for ejbLink: "+ejbLink);
+         // Try the business interface
+         try
+         {
+            container = getEjbContainer(businessIntf, vfsContext);
+         }
+         catch(NameNotFoundException e)
+         {
+            log.debug("Did not resolve container by interface: "+businessIntf, e);
+         }
+      }     
+      return container;
+   }
+
+   public String getName()
+   {
+      return shortName;
+   }
+   
+   public String getShortName()
+   {
+      return shortName;
+   }
+
+   public String getBaseName()
+   {
+      return baseName;
+   }
+
+   protected boolean isEar()
+   {
+      return isEar;
+   }
+}

Property changes on: src/main/org/jboss/ejb3/deployers/JBoss5DeploymentScope.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/deployers/AbstractOptionalVFSRealDeployer.java
===================================================================
--- src/main/org/jboss/ejb3/deployers/AbstractOptionalVFSRealDeployer.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/deployers/AbstractOptionalVFSRealDeployer.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.deployers;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+
+/**
+ * An abstract more complicated VFS real deployer where the input
+ * is optional instead of mandatory.
+ * 
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public abstract class AbstractOptionalVFSRealDeployer<T> extends AbstractRealDeployer
+{
+   private Class<T> optionalInput;
+   
+   public AbstractOptionalVFSRealDeployer(Class<T> optionalInput)
+   {
+      assert optionalInput != null : "optionalInput is null";
+      
+      this.optionalInput = optionalInput;
+      setInputs(optionalInput);
+   }
+   
+   public void internalDeploy(DeploymentUnit unit) throws DeploymentException
+   {
+      deploy(unit, unit.getAttachment(optionalInput));
+   }
+
+   public void deploy(DeploymentUnit unit, T deployment) throws DeploymentException
+   {
+      if (unit instanceof VFSDeploymentUnit == false)
+         return;
+      
+      VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit;
+      deploy(vfsDeploymentUnit, deployment);
+   }
+
+   /**
+    * Deploy a deployment
+    * 
+    * @param unit the unit
+    * @param deployment the attachment
+    * @throws DeploymentException for any error
+    */
+   public abstract void deploy(VFSDeploymentUnit unit, T deployment) throws DeploymentException;
+
+   @Override
+   public void internalUndeploy(DeploymentUnit unit)
+   {
+      undeploy(unit, unit.getAttachment(optionalInput));
+   }
+   
+   public void undeploy(DeploymentUnit unit, T deployment)
+   {
+      if (unit instanceof VFSDeploymentUnit == false)
+         return;
+      
+      VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit;
+      undeploy(vfsDeploymentUnit, deployment);
+   }
+   
+   /**
+    * Undeploy a deployment
+    * 
+    * @param unit the unit
+    * @param deployment the attachment
+    */
+   public void undeploy(VFSDeploymentUnit unit, T deployment)
+   {
+      // Nothing
+   }
+}

Property changes on: src/main/org/jboss/ejb3/deployers/AbstractOptionalVFSRealDeployer.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/deployers/AppClientScanningDeployer.java
===================================================================
--- src/main/org/jboss/ejb3/deployers/AppClientScanningDeployer.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/deployers/AppClientScanningDeployer.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,133 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.deployers;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.metadata.client.jboss.JBossClientMetaData;
+import org.jboss.virtual.VFSUtils;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Scan the main & super classes for annotations.
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @author adrian@jboss.org
+ * @version $Revision$
+ */
+public class AppClientScanningDeployer extends AbstractOptionalVFSRealDeployer<JBossClientMetaData>
+{
+
+   public AppClientScanningDeployer()
+   {
+      super(JBossClientMetaData.class);
+      setOutput(JBossClientMetaData.class);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.deployers.plugins.deployer.AbstractSimpleDeployer#deploy(org.jboss.deployers.spi.deployer.DeploymentUnit)
+    */
+   @Override
+   public void deploy(VFSDeploymentUnit unit, JBossClientMetaData dd) throws DeploymentException
+   {
+      // FIXME: implement metadata complete
+//      if(dd != null && dd.getMetaDataComplete())
+//         return;
+      // for now the EJB3 client deployer handles all
+      if(dd != null)
+         return;
+      
+      try
+      {
+         String mainClassName = getMainClassName(unit);
+         if(mainClassName == null)
+            return;
+         
+         Class<?> mainClass = unit.getClassLoader().loadClass(mainClassName);
+         
+         log.info("mainClass = " + mainClass);
+         
+         if(hasAnnotations(mainClass))
+         {
+            // add a dummy application client dd to fire up the ejb3 client deployer
+            dd = new JBossClientMetaData();
+            unit.addAttachment(JBossClientMetaData.class, dd);
+         }
+      }
+      catch(ClassNotFoundException e)
+      {
+         throw new DeploymentException(e);
+      }
+      catch(IOException e)
+      {
+         throw new DeploymentException(e);
+      }
+   }
+   
+   // TODO: integrate with Ejb3ClientDeployer.getMainClassName
+   private String getMainClassName(VFSDeploymentUnit unit) throws IOException
+   {
+      VirtualFile file = unit.getMetaDataFile("MANIFEST.MF");
+      log.trace("parsing " + file);
+
+      if(file == null)
+      {
+         return null;
+      }
+
+      try
+      {
+         Manifest mf = VFSUtils.readManifest(file);
+         Attributes attrs = mf.getMainAttributes();
+         String className = attrs.getValue(Attributes.Name.MAIN_CLASS);
+         return className;
+      }
+      finally
+      {
+         file.close();
+      }
+   }
+   
+   // TODO: should we check for type of annotations?
+   private boolean hasAnnotations(Class<?> cls)
+   {
+      if(cls == null)
+         return false;
+      
+      // Note: this also returns true if super class has annotations
+      if(cls.getAnnotations().length > 0)
+         return true;
+      
+      for(Field f : cls.getDeclaredFields())
+      {
+         if(f.getAnnotations().length > 0)
+            return true;
+      }
+      
+      return hasAnnotations(cls.getSuperclass());
+   }
+}

Property changes on: src/main/org/jboss/ejb3/deployers/AppClientScanningDeployer.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/deployers/JBossASKernel.java
===================================================================
--- src/main/org/jboss/ejb3/deployers/JBossASKernel.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/deployers/JBossASKernel.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,314 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.deployers;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanException;
+import javax.management.MBeanInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
+
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractConstructorMetaData;
+import org.jboss.beans.metadata.plugins.AbstractDemandMetaData;
+import org.jboss.beans.metadata.plugins.AbstractValueMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.beans.metadata.spi.DemandMetaData;
+import org.jboss.beans.metadata.spi.SupplyMetaData;
+import org.jboss.ejb3.DependencyPolicy;
+import org.jboss.ejb3.DeploymentUnit;
+import org.jboss.ejb3.KernelAbstraction;
+import org.jboss.ejb3.MCDependencyPolicy;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.kernel.spi.registry.KernelRegistryEntry;
+import org.jboss.logging.Logger;
+
+/**
+ * The JBossAS implementation of the ejb3 KernelAbstraction integration api
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ * @author Scott.Stark@jboss.org
+ * @version $Revision$
+ */
+public class JBossASKernel
+   implements KernelAbstraction
+{
+   private static Logger log = Logger.getLogger(JBossASKernel.class);
+   private MBeanServer mbeanServer;
+   private Kernel kernel;
+
+   public JBossASKernel(Kernel kernel)
+   {
+      this(kernel, null);
+   }
+   public JBossASKernel(Kernel kernel, MBeanServer mbeanServer)
+   {
+      this.kernel = kernel;
+      this.mbeanServer = mbeanServer;
+   }
+
+   public MBeanServer getMbeanServer()
+   {
+      return mbeanServer;
+   }
+   public void setMbeanServer(MBeanServer mbeanServer)
+   {
+      this.mbeanServer = mbeanServer;
+   }
+
+   public void install(String name, DependencyPolicy dependencies,
+         DeploymentUnit unit, Object service)
+   {
+      // Look for the kernel deployment
+      KernelDeployment deployment = null;
+      if(unit != null)
+      {
+         deployment = (KernelDeployment) unit.getAttachment(KernelDeployment.class.getName());
+         if(deployment == null)
+         {
+            AbstractKernelDeployment akd = new AbstractKernelDeployment();
+            akd.setBeanFactories(new ArrayList<BeanMetaDataFactory>());
+            deployment = akd;
+            String kdname = unit.getShortName();
+            deployment.setName(kdname);
+            unit.addAttachment(KernelDeployment.class.getName(), deployment);
+            log.info("Created KernelDeployment for: "+unit.getShortName());
+         }
+      }
+
+      // Create the metadata for the bean to install
+      AbstractBeanMetaData bean = new AbstractBeanMetaData(name, service.getClass().getName());
+      bean.setConstructor(new AlreadyInstantiated(service));
+      MCDependencyPolicy policy = (MCDependencyPolicy) dependencies;
+      bean.setDepends(policy.getDependencies());
+      bean.setDemands(policy.getDemands());
+      bean.setSupplies(policy.getSupplies());
+      log.info("installing bean: " + name);
+      log.info("  with dependencies:");
+      for (Object obj : policy.getDependencies())
+      {
+         Object msgObject = obj;
+         if (obj instanceof AbstractDemandMetaData)
+         {
+            msgObject = ((AbstractDemandMetaData)obj).getDemand();
+         }
+         log.info("\t" + msgObject);
+      }
+      log.info("  and demands:");
+      for(DemandMetaData dmd : policy.getDemands())
+      {
+         log.info("\t" + dmd.getDemand());
+      }
+      log.info("  and supplies:");
+      for(SupplyMetaData smd : policy.getSupplies())
+      {
+         log.info("\t" + smd.getSupply());
+      }
+
+      if(unit != null)
+      {
+         // Just add the mc bean metadata to the unit
+         deployment.getBeanFactories().add(bean);
+         log.info("Added bean("+name+") to KernelDeployment of: "+unit.getShortName());
+      }
+      else
+      {
+         // Install directly into the kernel
+         try
+         {
+            try 
+            {
+               kernel.getController().uninstall(name);
+            }
+            catch (IllegalStateException e){}
+                  
+            log.info("Installing bean("+name+") into kernel");
+            kernel.getController().install(bean);
+         }
+         catch (Throwable throwable)
+         {
+            throw new RuntimeException(throwable);
+         }
+      }
+   }
+
+   public void installMBean(ObjectName on, DependencyPolicy dependencies,
+         Object service)
+   {
+      if(mbeanServer == null)
+         throw new RuntimeException("No MBeanServer has been injected");
+
+      try
+      {
+         mbeanServer.registerMBean(service, on);
+         install(on.getCanonicalName(), dependencies, null, service);
+         
+         // EJBTHREE-606: emulate the ServiceController calls
+         MBeanInfo info = mbeanServer.getMBeanInfo(on); // redundant call for speed
+         invokeOptionalMethod(on, info, "create");
+         invokeOptionalMethod(on, info, "start");
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+
+   public void uninstall(String name)
+   {
+      
+      
+   }
+
+   public Object getAttribute(ObjectName objectName, String attribute) throws Exception
+   {
+      String name = objectName.getCanonicalName();
+      KernelRegistryEntry entry = kernel.getRegistry().getEntry(name);
+      if (entry != null)
+      {
+         Object target = entry.getTarget();
+         Field field = target.getClass().getField(attribute);
+         return field.get(target);
+      }
+      return null;
+   }
+   
+   public Set getMBeans(ObjectName query) throws Exception
+   {
+      Object target = kernel.getRegistry().getEntry(query);
+      Set set = new HashSet();
+      set.add(target);
+      return set;
+   }
+
+   public void uninstallMBean(ObjectName on)
+   {
+      try
+      {
+         // EJBTHREE-606: emulate the ServiceController calls
+         MBeanInfo info = mbeanServer.getMBeanInfo(on); // redundant call for speed
+         try
+         {
+            invokeOptionalMethod(on, info, "stop");
+         }
+         catch(Exception e)
+         {
+            log.warn("stop on " + on + " failed", e);
+         }
+         try
+         {
+            invokeOptionalMethod(on, info, "destroy");
+         }
+         catch(Exception e)
+         {
+            log.warn("destroy on " + on + " failed", e);
+         }
+         
+         mbeanServer.unregisterMBean(on);
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+
+   public Object invoke(ObjectName objectName, String operationName, Object[] params, String[] signature) throws Exception
+   {
+      String name = objectName.getCanonicalName();
+      KernelRegistryEntry entry = kernel.getRegistry().getEntry(name);
+      if (entry != null)
+      {
+         Object target = entry.getTarget();
+         Class[] types = new Class[signature.length];
+         for (int i = 0; i < signature.length; ++i)
+         {
+            types[i] = Thread.currentThread().getContextClassLoader().loadClass(signature[i]);
+         }
+         Method method = target.getClass().getMethod(operationName, types);
+         return method.invoke(target, params);
+      }
+      return null;
+   }
+
+   private boolean hasOperation(MBeanInfo info, String operationName)
+   {
+      for(MBeanOperationInfo operationInfo : info.getOperations())
+      {
+         if(operationInfo.getName().equals(operationName) == false)
+            continue;
+         
+         // void return type
+         if(operationInfo.getReturnType().equals("void") == false)
+            continue;
+         
+         // no parameters
+         if(operationInfo.getSignature().length != 0)
+            continue;
+         
+         return true;
+      }
+      
+      return false;
+   }
+   private void invokeOptionalMethod(ObjectName on, MBeanInfo info, String operationName)
+      throws InstanceNotFoundException, MBeanException, ReflectionException
+   {
+      Object params[] = { };
+      String signature[] = { };
+      if(hasOperation(info, operationName))
+         mbeanServer.invoke(on, operationName, params, signature);
+   }
+
+   public static class AlreadyInstantiated extends AbstractConstructorMetaData
+   {
+      private static final long serialVersionUID = 1L;
+      
+      private Object bean;
+
+      public class Factory
+      {
+
+         public Object create()
+         {
+            return bean;
+         }
+      }
+
+      public AlreadyInstantiated(Object bean)
+      {
+         this.bean = bean;
+         this.setFactory(new AbstractValueMetaData(new Factory()));
+         this.setFactoryClass(Factory.class.getName());
+         this.setFactoryMethod("create");
+      }
+   }
+ 
+}

Property changes on: src/main/org/jboss/ejb3/deployers/JBossASKernel.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/deployers/JBoss5DeploymentUnit.java
===================================================================
--- src/main/org/jboss/ejb3/deployers/JBoss5DeploymentUnit.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/deployers/JBoss5DeploymentUnit.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,233 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, Red Hat Middleware LLC., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.ejb3.deployers;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collections;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
+import org.jboss.virtual.VisitorAttributes;
+import org.jboss.virtual.plugins.context.jar.JarUtils;
+import org.jboss.virtual.plugins.vfs.helpers.FilterVirtualFileVisitor;
+import org.jboss.virtual.plugins.vfs.helpers.SuffixesExcludeFilter;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ * @version $Revision$
+ */
+public class JBoss5DeploymentUnit implements org.jboss.ejb3.DeploymentUnit
+{
+   private VFSDeploymentUnit unit;
+   private ClassLoader classLoader;
+   private InterceptorInfoRepository interceptorInfoRepository;
+   private Map defaultPersistenceProperties;
+
+   public JBoss5DeploymentUnit(VFSDeploymentUnit unit)
+   {
+      this(unit, unit.getClassLoader());
+   }
+   
+   public JBoss5DeploymentUnit(VFSDeploymentUnit unit, ClassLoader classLoader)
+   {
+      assert unit != null : "unit is null";
+      assert classLoader != null : "classLoader is null";
+      
+      this.unit = unit;
+      this.classLoader = classLoader;
+      this.interceptorInfoRepository = new InterceptorInfoRepository(classLoader);
+   }
+
+   public Object addAttachment(String name, Object attachment)
+   {
+      return unit.addAttachment(name, attachment);
+   }
+   public Object getAttachment(String name)
+   {
+      return unit.getAttachment(name);
+   }
+   public Object removeAttachment(String name)
+   {
+      return unit.removeAttachment(name);
+   }
+
+   public VirtualFile getRootFile()
+   {
+      return unit.getFile("");
+   }
+   
+   public String getRelativePath()
+   {
+      return unit.getRelativePath();
+   }
+
+   public URL getRelativeURL(String jar)
+   {
+      try
+      {
+         return new URL(jar);
+      }
+      catch (MalformedURLException e)
+      {
+         try
+         {
+            if (getUrl() == null)
+               throw new RuntimeException("relative <jar-file> not allowed when standalone deployment unit is used");
+            return new URL(getUrl(), jar);
+         }
+         catch (Exception e1)
+         {
+            throw new RuntimeException("could not find relative path: " + jar, e1);
+         }
+      }
+   }
+
+   URL extractDescriptorUrl(String resource)
+   {
+      try
+      {
+         VirtualFile vf = unit.getMetaDataFile(resource);
+         if (vf == null) return null;
+         return vf.toURL();
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+
+   public URL getPersistenceXml()
+   {
+      return extractDescriptorUrl("persistence.xml");
+   }
+
+   public URL getEjbJarXml()
+   {
+      return extractDescriptorUrl("ejb-jar.xml");
+   }
+
+   public URL getJbossXml()
+   {
+      return extractDescriptorUrl("jboss.xml");
+   }
+
+   public VirtualFile getMetaDataFile(String name)
+   {
+      return unit.getMetaDataFile(name);
+   }
+   
+   public List<Class> getClasses()
+   {
+      return null;
+   }
+
+   public ClassLoader getClassLoader()
+   {
+      return classLoader;
+   }
+
+   public ClassLoader getResourceLoader()
+   {
+      return getClassLoader();
+   }
+
+   public String getShortName()
+   {
+      return unit.getFile("").getName();
+   }
+
+   public URL getUrl()
+   {
+      try
+      {
+         return unit.getFile("").toURL();
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+
+   public String getDefaultEntityManagerName()
+   {
+      String url = getUrl().toString();
+      String name = url.substring(url.lastIndexOf('/') + 1, url.lastIndexOf('.'));
+      return name;
+   }
+
+   public Map getDefaultPersistenceProperties()
+   {
+      return defaultPersistenceProperties;
+   }
+
+   public void setDefaultPersistenceProperties(Map defaultPersistenceProperties)
+   {
+      this.defaultPersistenceProperties = defaultPersistenceProperties;
+   }
+
+   public Hashtable getJndiProperties()
+   {
+      return null;
+   }
+
+   public InterceptorInfoRepository getInterceptorInfoRepository()
+   {
+      return interceptorInfoRepository;
+   }
+
+   public List<VirtualFile> getResources(VirtualFileFilter filter)
+   {
+      List<VirtualFile> classPath = unit.getClassPath();
+      if(classPath == null || classPath.isEmpty())
+         return Collections.emptyList();
+
+      VisitorAttributes va = new VisitorAttributes();
+      va.setLeavesOnly(true);
+      SuffixesExcludeFilter noJars = new SuffixesExcludeFilter(JarUtils.getSuffixes());
+      va.setRecurseFilter(noJars);
+      FilterVirtualFileVisitor visitor = new FilterVirtualFileVisitor(filter, va);
+
+      for(VirtualFile root : classPath)
+      {
+         try
+         {
+            if( root.isLeaf() == false )
+               root.visit(visitor);
+         }
+         catch (IOException e)
+         {
+            throw new RuntimeException(e);
+         }
+      }
+      
+      return visitor.getMatched();
+   }
+}

Property changes on: src/main/org/jboss/ejb3/deployers/JBoss5DeploymentUnit.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/deployers/JBossClientParsingDeployer.java
===================================================================
--- src/main/org/jboss/ejb3/deployers/JBossClientParsingDeployer.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/deployers/JBossClientParsingDeployer.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.deployers;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer;
+import org.jboss.metadata.client.jboss.JBossClientMetaData;
+import org.jboss.metadata.client.spec.ApplicationClientMetaData;
+
+/**
+ * The jboss-client.xml javaee client parsing deployer
+ * 
+ * This deployer generates a merged JBossClientMetaData.
+ * For application-client.xml ApplicationClientMetaData is retrieved from
+ * the attachments. If there is a jboss-client.xml it will be parsed
+ * by the SchemaResolverDeployer.
+ * If either one is available a merged view will be created.
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @author adrian@jboss.org
+ * @author Scott.Stark@jboss.org
+ * @version $Revision$
+ */
+public class JBossClientParsingDeployer extends SchemaResolverDeployer<JBossClientMetaData>
+{
+   public JBossClientParsingDeployer()
+   {
+      super(JBossClientMetaData.class);
+      // If an ApplicationClientMetaData is available use it
+      setInputs(ApplicationClientMetaData.class);
+      setName("jboss-client.xml");
+   }
+
+   /**
+    * Override to create the merged JBossClientMetaData view
+    */
+   @Override
+   protected void createMetaData(DeploymentUnit unit, String name, String suffix) throws DeploymentException
+   {
+      super.createMetaData(unit, name, suffix);
+      JBossClientMetaData jbossMetaData = getMetaData(unit, JBossClientMetaData.class.getName());
+      ApplicationClientMetaData acmd = unit.getAttachment(ApplicationClientMetaData.class);
+      // If either one is available generate a merged view
+      if(jbossMetaData == null && acmd == null)
+         return;
+
+      // If there no JBossClientMetaData was created from a jboss-client.xml, create one
+      if (jbossMetaData == null)
+      {
+         jbossMetaData = new JBossClientMetaData();
+      }
+      // Create a merged view
+      JBossClientMetaData metaData = new JBossClientMetaData();
+      metaData.merge(jbossMetaData, acmd, true);
+      // Register the merged view as the output
+      unit.getTransientManagedObjects().addAttachment(JBossClientMetaData.class.getName(), metaData, getOutput());
+      // Keep the raw parsed as well
+      // TODO: Wolf: Why? (ProfileService?)
+      unit.getTransientManagedObjects().addAttachment("Raw"+JBossClientMetaData.class.getName(), jbossMetaData, getOutput());
+   }
+}

Property changes on: src/main/org/jboss/ejb3/deployers/JBossClientParsingDeployer.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/deployers/AppClientParsingDeployer.java
===================================================================
--- src/main/org/jboss/ejb3/deployers/AppClientParsingDeployer.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/deployers/AppClientParsingDeployer.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.deployers;
+
+import org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer;
+import org.jboss.metadata.client.spec.ApplicationClientMetaData;
+
+/**
+ * The javaee application client descriptor parsing deployer
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @author adrian@jboss.org
+ * @author Scott.Stark@jboss.org
+ * @version $Revision$
+ */
+public class AppClientParsingDeployer extends SchemaResolverDeployer<ApplicationClientMetaData>
+{
+   public AppClientParsingDeployer()
+   {
+      super(ApplicationClientMetaData.class);
+      setName("application-client.xml");
+   }
+   
+}

Property changes on: src/main/org/jboss/ejb3/deployers/AppClientParsingDeployer.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/deployers/MergedJBossClientMetaDataDeployer.java
===================================================================
--- src/main/org/jboss/ejb3/deployers/MergedJBossClientMetaDataDeployer.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/deployers/MergedJBossClientMetaDataDeployer.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.deployers;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployment.AnnotationMetaDataDeployer;
+import org.jboss.metadata.client.jboss.JBossClientMetaData;
+import org.jboss.metadata.client.spec.AnnotationMergedView;
+import org.jboss.metadata.client.spec.ApplicationClient5MetaData;
+import org.jboss.metadata.client.spec.ApplicationClientMetaData;
+
+
+/**
+ * A deployer that merges annotation metadata, xml metadata, and jboss metadata
+ * into a merged JBossClientMetaData.
+ * 
+ * @author Scott.Stark@jboss.org
+ * @version $Revision$
+ */
+public class MergedJBossClientMetaDataDeployer extends AbstractDeployer
+{
+   public static final String CLIENT_MERGED_ATTACHMENT_NAME = "merged."+JBossClientMetaData.class.getName();
+
+   /**
+    * Create a new JBossEjbParsingDeployer.
+    */
+   public MergedJBossClientMetaDataDeployer()
+   {
+      setStage(DeploymentStages.POST_CLASSLOADER);
+      // application.xml metadata
+      addInput(ApplicationClientMetaData.class);
+      // jboss-client.xml metadata
+      addInput(JBossClientMetaData.class);
+      // annotated metadata view
+      addInput(AnnotationMetaDataDeployer.CLIENT_ANNOTATED_ATTACHMENT_NAME);
+      // Output is the merge JBossMetaData view
+      setOutput(JBossClientMetaData.class);
+      // Specify a separate merged name to distiguish this output from JBossClientMetaData
+      addOutput(CLIENT_MERGED_ATTACHMENT_NAME);
+   }
+
+   public void deploy(DeploymentUnit unit) throws DeploymentException
+   {
+      ApplicationClientMetaData specMetaData = unit.getAttachment(ApplicationClientMetaData.class);
+      JBossClientMetaData metaData = unit.getAttachment(JBossClientMetaData.class);
+      // Check for an annotated view
+      String key = AnnotationMetaDataDeployer.CLIENT_ANNOTATED_ATTACHMENT_NAME;
+      ApplicationClient5MetaData annotatedMetaData = unit.getAttachment(key, ApplicationClient5MetaData.class);
+      if(specMetaData == null && metaData == null && annotatedMetaData == null)
+         return;
+
+      if(annotatedMetaData != null)
+      {
+         if(specMetaData != null)
+         {
+            ApplicationClient5MetaData specMerged = new ApplicationClient5MetaData();
+            AnnotationMergedView.merge(specMerged, specMetaData, annotatedMetaData);
+            specMetaData = specMerged;
+         }
+         else
+            specMetaData = annotatedMetaData;
+      }
+
+      // Create a merged view
+      JBossClientMetaData mergedMetaData = new JBossClientMetaData();
+      mergedMetaData.merge(metaData, specMetaData, false);
+
+      // Output the merged JBossMetaData
+      unit.getTransientManagedObjects().addAttachment(JBossClientMetaData.class, mergedMetaData);
+      unit.addAttachment(CLIENT_MERGED_ATTACHMENT_NAME, mergedMetaData, JBossClientMetaData.class);
+   }
+}

Property changes on: src/main/org/jboss/ejb3/deployers/MergedJBossClientMetaDataDeployer.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/deployers/Ejb3JBoss5Deployment.java
===================================================================
--- src/main/org/jboss/ejb3/deployers/Ejb3JBoss5Deployment.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/deployers/Ejb3JBoss5Deployment.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,168 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, Red Hat Middleware LLC., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.ejb3.deployers;
+
+import java.util.Map;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.security.jacc.PolicyConfiguration;
+
+import org.jboss.beans.metadata.plugins.AbstractSupplyMetaData;
+import org.jboss.deployment.MappedReferenceMetaDataResolverDeployer;
+import org.jboss.deployment.dependency.ContainerDependencyMetaData;
+import org.jboss.ejb3.Container;
+import org.jboss.ejb3.DependencyPolicy;
+import org.jboss.ejb3.DeploymentUnit;
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.ejb3.MCDependencyPolicy;
+import org.jboss.ejb3.javaee.JavaEEApplication;
+import org.jboss.ejb3.javaee.JavaEEComponent;
+import org.jboss.ejb3.kernel.JNDIKernelRegistryPlugin;
+import org.jboss.kernel.Kernel;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.EjbDeploymentSummary;
+
+/**
+ * JBoss 5.0 Microkernel specific implementation
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ * @author adrian@jboss.org
+ * @version $Revision$
+ */
+public class Ejb3JBoss5Deployment extends Ejb3Deployment
+{
+   private static Logger log = Logger.getLogger(Ejb3JBoss5Deployment.class);
+   private org.jboss.deployers.structure.spi.DeploymentUnit jbossUnit;
+   private Map<String, ContainerDependencyMetaData> endpoints;
+
+   public Ejb3JBoss5Deployment(DeploymentUnit ejb3Unit, Kernel kernel, MBeanServer mbeanServer, org.jboss.deployers.structure.spi.DeploymentUnit jbossUnit, JBoss5DeploymentScope deploymentScope, JBossMetaData metaData)
+   {
+      // Either call the old constructor and do process persistence units
+      //super(ejb3Unit, deploymentScope, metaData, persistenceUnitsMetaData);
+      // or call the new constructor and don't process persistence units
+      super(jbossUnit, ejb3Unit, deploymentScope, metaData);
+      
+      this.jbossUnit = jbossUnit;
+      kernelAbstraction = new JBossASKernel(kernel, mbeanServer);
+
+      // todo maybe mbeanServer should be injected?
+      this.mbeanServer = mbeanServer;
+      org.jboss.deployers.structure.spi.DeploymentUnit topUnit = jbossUnit.getTopLevel();
+      endpoints = (Map<String, ContainerDependencyMetaData>) topUnit.getAttachment(MappedReferenceMetaDataResolverDeployer.ENDPOINT_MAP_KEY);
+   }
+
+   protected PolicyConfiguration createPolicyConfiguration() throws Exception
+   {
+      return null;
+   }
+
+   protected void putJaccInService(PolicyConfiguration pc, DeploymentUnit ejb3Unit)
+   {
+      //Ignore
+   }
+
+   public DependencyPolicy createDependencyPolicy(JavaEEComponent component)
+   {
+      return new JBoss5DependencyPolicy(component);
+   }
+
+   @Override
+   public JavaEEApplication getApplication()
+   {
+      // getApplication must return null if there is no ear
+      JavaEEApplication app = super.getApplication();
+      if(((JBoss5DeploymentScope) app).isEar())
+         return app;
+      return null;
+   }
+   
+   @Override
+   protected void registerEJBContainer(Container container) throws Exception
+   {
+      // Add the jndi supplies
+      MCDependencyPolicy dependsPolicy = (MCDependencyPolicy) container.getDependencyPolicy();
+      EJBContainer ejbContainer = (EJBContainer) container;
+      JBossEnterpriseBeanMetaData beanMD = ejbContainer.getXml();
+
+      ContainerDependencyMetaData cdmd = null;
+      if(endpoints != null)
+      {
+         String ejbKey = "ejb/" + jbossUnit.getRelativePath() + "#" + container.getEjbName();
+         cdmd = endpoints.get(ejbKey);
+      }
+      else
+      {
+         log.warn(jbossUnit+" has no ContainerDependencyMetaData attachment");
+      }
+
+      if(cdmd != null)
+      {
+         for(String jndiName : cdmd.getJndiNames())
+         {
+         String supplyName = JNDIKernelRegistryPlugin.JNDI_DEPENDENCY_PREFIX + jndiName;
+         AbstractSupplyMetaData supply = new AbstractSupplyMetaData(supplyName);
+         dependsPolicy.getSupplies().add(supply);
+         }
+      }
+
+      // EJBTHREE-1335: container name in meta data
+      generateContainerName(container, beanMD);
+      
+      super.registerEJBContainer(container);
+   }
+
+   private void generateContainerName(Container container, JBossEnterpriseBeanMetaData beanMD)
+   {
+      ObjectName on = container.getObjectName();
+      assert on!=null : "ObjectName was null";
+
+      // Heiko: This should actually generate the name and assign it to ejb3 meta data
+      // Currently we stick to copying the values around until an EJB3 team member figures out a proper way      
+      beanMD.setGeneratedContainerName(on.getCanonicalName());
+   }
+
+   private static EjbDeploymentSummary getUnitSummary(DeploymentUnit unit, JBossEnterpriseBeanMetaData beanMD)
+   {
+      ClassLoader loader = unit.getClassLoader();
+      EjbDeploymentSummary summary = new EjbDeploymentSummary();
+      summary.setBeanMD(beanMD);
+      summary.setBeanClassName(beanMD.getEjbClass());
+      summary.setDeploymentName(unit.getShortName());
+      String baseName = unit.getRootFile().getName();
+      summary.setDeploymentScopeBaseName(baseName);
+      summary.setEjbName(beanMD.getEjbName());
+      summary.setLoader(loader);
+      summary.setLocal(beanMD.isMessageDriven());
+      if(beanMD instanceof JBossSessionBeanMetaData)
+      {
+         JBossSessionBeanMetaData sbeanMD = (JBossSessionBeanMetaData) beanMD;
+         summary.setStateful(sbeanMD.isStateful());
+      }
+      summary.setService(beanMD.isService());
+      return summary;
+   }   
+}

Property changes on: src/main/org/jboss/ejb3/deployers/Ejb3JBoss5Deployment.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/deployers/PersistenceUnitParsingDeployer.java
===================================================================
--- src/main/org/jboss/ejb3/deployers/PersistenceUnitParsingDeployer.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/deployers/PersistenceUnitParsingDeployer.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.deployers;
+
+import org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer;
+import org.jboss.metadata.jpa.spec.PersistenceMetaData;
+
+/**
+ * Find and parse persistence.xml.
+ * 
+ * In a jar:
+ * META-INF/persistence.xml
+ * 
+ * In a war (JPA 6.2):
+ * WEB-INF/classes/META-INF/persistence.xml
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @author <a href="mailto:ales.justin@jboss.com">Ales Justin</a>
+ * @version $Revision$
+ */
+public class PersistenceUnitParsingDeployer extends SchemaResolverDeployer<PersistenceMetaData>
+{
+   public PersistenceUnitParsingDeployer()
+   {
+      super(PersistenceMetaData.class);
+      setName("persistence.xml");
+      setRegisterWithJBossXB(true);
+   }
+}

Property changes on: src/main/org/jboss/ejb3/deployers/PersistenceUnitParsingDeployer.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/deployers/tmp/DeploymentEjbResolver.java
===================================================================
--- src/main/org/jboss/ejb3/deployers/tmp/DeploymentEjbResolver.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/deployers/tmp/DeploymentEjbResolver.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,183 @@
+/*
+ * 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.deployers.tmp;
+
+import java.util.Iterator;
+
+import javax.naming.NameNotFoundException;
+
+import org.jboss.ejb3.Container;
+import org.jboss.ejb3.DeploymentScope;
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.ejb3.Ejb3Registry;
+import org.jboss.ejb3.proxy.factory.ProxyFactoryHelper;
+import org.jboss.logging.Logger;
+
+/**
+ * Class to resolve EJB containers from ejb-ref or @EJB metadata
+ * This class is overriden for specific behaviors, specifically whether or not
+ * to resolve the EJB internally in a specific deployment or not.  There will be one for
+ * an EJB jar deployment and a WAR deployment and any other deployment package that needs to
+ * use @EJB.
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ * @version $Revision$
+ */
+public abstract class DeploymentEjbResolver
+{
+   private static final Logger log = Logger.getLogger(DeploymentEjbResolver.class);
+   
+   protected DeploymentScope deploymentScope;
+   protected String errorName;
+
+   protected DeploymentEjbResolver(DeploymentScope deploymentScope, String errorName)
+   {
+      this.deploymentScope = deploymentScope;
+      this.errorName = errorName;
+   }
+
+   protected abstract EJBContainer searchDeploymentInternally(String ejbLink, Class businessIntf);
+
+   public EJBContainer getEjbContainer(String ejbLink, Class businessIntf)
+   {
+      int hashIndex = ejbLink.indexOf('#');
+      if (hashIndex != -1)
+      {
+         if (deploymentScope == null)
+         {
+            log.warn("ejb link '" + ejbLink + "' is relative, but no deployment scope found");
+            return null;
+         }
+         String relativePath = ejbLink.substring(0, hashIndex);
+         Ejb3Deployment dep = deploymentScope.findRelativeDeployment(relativePath);
+         if (dep == null)
+         {
+            log.warn("can't find a deployment for path '" + relativePath + "' of ejb link '" + ejbLink + "'");
+            return null;
+         }
+         String ejbName = ejbLink.substring(hashIndex + 1);
+         return dep.getEjbContainer(ejbName, businessIntf);
+      }
+      // look internally
+      EJBContainer ejb = searchDeploymentInternally(ejbLink, businessIntf);
+      if (ejb != null) return ejb;
+      for (Object obj : Ejb3Registry.getContainers())
+      {
+         EJBContainer container = (EJBContainer) obj;
+         if (container.getEjbName().equals(ejbLink))
+         {
+            return container;
+         }
+      }
+      return null;
+   }
+
+   public String getEjbJndiName(String ejbLink, Class businessIntf)
+   {
+      EJBContainer container = getEjbContainer(ejbLink, businessIntf);
+      if (container == null)
+      {
+         return null;
+      }
+      return ProxyFactoryHelper.getJndiName(container, businessIntf);
+   }
+
+   public EJBContainer getEjbContainer(Ejb3Deployment deployment, Class businessIntf) throws NameNotFoundException
+   {
+      EJBContainer container = null;
+      // search in myself
+      for (Object obj : deployment.getEjbContainers().values())
+      {
+         EJBContainer newContainer = (EJBContainer) obj;
+         if (container == newContainer) continue;
+         if (ProxyFactoryHelper.publishesInterface(newContainer, businessIntf))
+         {
+            if (container != null) throw new NameNotFoundException("duplicated in " + errorName);
+            container = newContainer;
+         }
+      }
+      return container;
+   }
+
+   public EJBContainer getEjbContainer(Class businessIntf) throws NameNotFoundException
+   {
+      EJBContainer rtnContainer = null;
+      // search in deployment first
+      rtnContainer = searchForEjbContainerInternally(businessIntf);
+      if (rtnContainer != null) return rtnContainer;
+      // search in EAR
+      String jarName = null;
+      if (deploymentScope != null)
+      {
+         for (Ejb3Deployment deployment : deploymentScope.getEjbDeployments())
+         {
+            EJBContainer newContainer = getEjbContainer(deployment, businessIntf);
+            if (rtnContainer == newContainer) continue; // don't check self
+            if (rtnContainer != null && newContainer != null)
+            {
+               throw new NameNotFoundException("duplicated in .ear within " + jarName +
+                       " and " + deployment.getDeploymentUnit().getShortName());
+            }
+            if (newContainer != null)
+            {
+               rtnContainer = newContainer;
+               jarName = deployment.getDeploymentUnit().getShortName();
+            }
+         }
+      }
+      if (rtnContainer != null)
+      {
+         return rtnContainer;
+      }
+      // search everywhere
+      Iterator containers = Ejb3Registry.getContainers().iterator();
+      while (containers.hasNext())
+      {
+         Container container = (Container)containers.next();
+         EJBContainer ejbContainer = (EJBContainer) container;
+         if (ejbContainer == rtnContainer) continue;
+         if (ProxyFactoryHelper.publishesInterface(container, businessIntf))
+         {
+            if (rtnContainer != null)
+            {
+               throw new NameNotFoundException("duplicated in " + ejbContainer.getDeployment().getDeploymentUnit().getShortName()
+                       + " and " + jarName);
+            }
+            rtnContainer = ejbContainer;
+            jarName = ejbContainer.getDeployment().getDeploymentUnit().getShortName();
+         }
+      }
+      if (rtnContainer != null) return rtnContainer;
+      throw new NameNotFoundException("not used by any EJBs");
+   }
+
+   protected abstract EJBContainer searchForEjbContainerInternally(Class businessIntf) throws NameNotFoundException;
+
+   public String getEjbJndiName(Class businessIntf) throws NameNotFoundException
+   {
+      EJBContainer container = getEjbContainer(businessIntf);
+      String jndiName = ProxyFactoryHelper.getJndiName(container, businessIntf);
+      if (jndiName == null) throw new NameNotFoundException("not used by any EJBs");
+      return jndiName;
+   }
+}

Property changes on: src/main/org/jboss/ejb3/deployers/tmp/DeploymentEjbResolver.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/deployers/tmp/EjbModuleEjbResolver.java
===================================================================
--- src/main/org/jboss/ejb3/deployers/tmp/EjbModuleEjbResolver.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/deployers/tmp/EjbModuleEjbResolver.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,86 @@
+/*
+ * 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.deployers.tmp;
+
+import java.util.Map;
+
+import javax.naming.NameNotFoundException;
+
+import org.jboss.ejb3.DeploymentScope;
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.ejb3.Ejb3Deployment;
+
+/**
+ * Resolve EJBs.
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ * @version $Revision$
+ */
+public class EjbModuleEjbResolver extends DeploymentEjbResolver
+{
+   protected Map<?, EJBContainer> ejbContainers;
+   protected Ejb3Deployment deployment;
+
+   public EjbModuleEjbResolver(DeploymentScope deploymentScope, String errorName)
+   {
+      this(deploymentScope, errorName, null, null);
+   }
+   public EjbModuleEjbResolver(DeploymentScope deploymentScope, String errorName,
+         Map ejbContainers, Ejb3Deployment deployment)
+   {
+      super(deploymentScope, errorName);
+      this.ejbContainers = ejbContainers;
+      this.deployment = deployment;
+   }
+
+   public Ejb3Deployment getDeployment()
+   {
+      return deployment;
+   }
+   public void setDeployment(Ejb3Deployment deployment)
+   {
+      this.deployment = deployment;
+      this.ejbContainers = deployment.getEjbContainers();
+   }
+
+   @Override
+   protected EJBContainer searchDeploymentInternally(String ejbLink, Class businessIntf)
+   {
+      for (EJBContainer container : ejbContainers.values())
+      {
+         if (container.getEjbName().equals(ejbLink))
+         {
+            return container;
+         }
+      }
+      return null;
+   }
+
+   @Override
+   protected EJBContainer searchForEjbContainerInternally(Class businessIntf) throws NameNotFoundException
+   {
+      EJBContainer rtnContainer;
+      rtnContainer = getEjbContainer(deployment, businessIntf);
+      return rtnContainer;
+   }
+
+}

Property changes on: src/main/org/jboss/ejb3/deployers/tmp/EjbModuleEjbResolver.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/deployers/Ejb3ClientDeployer.java
===================================================================
--- src/main/org/jboss/ejb3/deployers/Ejb3ClientDeployer.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/deployers/Ejb3ClientDeployer.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,322 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.deployers;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+import javax.management.MBeanServer;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+
+import org.jboss.beans.metadata.api.annotations.Inject;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.structure.ClassPathEntry;
+import org.jboss.deployers.spi.structure.StructureMetaData;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.deployer.AbstractSimpleVFSRealDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.ejb3.InitialContextFactory;
+import org.jboss.ejb3.KernelAbstraction;
+import org.jboss.ejb3.clientmodule.ClientENCInjectionContainer;
+import org.jboss.jpa.resolvers.PersistenceUnitDependencyResolver;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.metadata.client.jboss.JBossClientMetaData;
+import org.jboss.metadata.ear.jboss.JBossAppMetaData;
+import org.jboss.naming.Util;
+import org.jboss.virtual.VFSUtils;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Deploys a client application jar.
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @author adrian@jboss.org
+ * @version $Revision$
+ */
+public class Ejb3ClientDeployer extends AbstractSimpleVFSRealDeployer<JBossClientMetaData>
+{
+   private Kernel kernel;
+   private MBeanServer server;
+   /** A flag indicating if a deployment based jndi should be linked to the JBossClientMetaData.jndiName */
+   private boolean linkDeploymentJndiName = true;
+   
+   private PersistenceUnitDependencyResolver persistenceUnitDependencyResolver;
+
+   /**
+    * Create a new Ejb3ClientDeployer.
+    */
+   public Ejb3ClientDeployer()
+   {
+      super(JBossClientMetaData.class);
+      setOutput(ClientENCInjectionContainer.class);
+      // JBossASKernel install output
+      setOutput(KernelDeployment.class);
+   }
+
+   public boolean isLinkDeploymentJndiName()
+   {
+      return linkDeploymentJndiName;
+   }
+
+   public void setLinkDeploymentJndiName(boolean linkDeploymentJndiName)
+   {
+      this.linkDeploymentJndiName = linkDeploymentJndiName;
+   }
+
+   /**
+    * Deploy a client application
+    * @param unit - the application jar unit
+    * @param metaData - the metadata for the application
+    */
+   @Override
+   public void deploy(VFSDeploymentUnit unit, JBossClientMetaData metaData) throws DeploymentException
+   {
+      log.debug("deploy " + unit.getName());
+      
+      String appClientName = getJndiName(metaData);
+      String deploymentClientName = null;
+      if(appClientName == null)
+         appClientName = getDeploymentJndiName(unit);
+      else if(linkDeploymentJndiName)
+         deploymentClientName = getDeploymentJndiName(unit);
+
+      try
+      {
+         // I create the namespace here, because I destroy it in undeploy
+         InitialContext iniCtx = InitialContextFactory.getInitialContext();
+         Context encCtx = Util.createSubcontext(iniCtx, appClientName);
+         log.debug("Creating client ENC binding under: " + appClientName);
+         if(deploymentClientName != null && deploymentClientName.equals(appClientName) == false)
+         {
+            Util.createLinkRef(iniCtx, deploymentClientName, appClientName);
+         }
+
+         // Notify the client launcher of extra class path entries in an EAR (See EE 8.2)
+         List<VirtualFile> classPath = unit.getClassPath();
+         ArrayList<String> cpURIs = new ArrayList<String>();
+         for(VirtualFile vf : classPath)
+         {
+            String uri = vf.toURI().toString();
+            cpURIs.add(uri);
+         }
+         // Also need to include the ear lib dir entries
+         VFSDeploymentUnit earUnit = unit.getParent();
+         if(earUnit != null)
+         {
+            List<VirtualFile> earClassPath = earUnit.getClassPath();
+            JBossAppMetaData earMD = earUnit.getAttachment(JBossAppMetaData.class);
+            if(earMD != null)
+            {
+               String libDir = earMD.getLibraryDirectory();
+               if(libDir == null)
+                  libDir = "lib";
+               String libDirPrefix = libDir + "/";
+               for(VirtualFile vf : earClassPath)
+               {
+                  if(vf.getPathName().startsWith(libDirPrefix))
+                  {
+                     String uri = vf.toURI().toString();
+                     cpURIs.add(uri);
+                  }
+               }
+            }
+         }
+
+         encCtx.bind("classPathEntries", cpURIs);
+         // java:comp/UserTransaction -> UserTransaction
+         Util.createLinkRef(encCtx, "UserTransaction", "UserTransaction");
+
+         // TODO: Notify the client launcher of other metadata stuff (injectors, lifecycle callbacks etc)
+         // FIXME: For now I expose the entire metadata
+         encCtx.bind("metaData", metaData);
+         
+         String mainClassName = getMainClassName(unit, true);
+
+         Class<?> mainClass = loadClass(unit, mainClassName);
+
+         ClientENCInjectionContainer container = new ClientENCInjectionContainer(unit, metaData, mainClass, appClientName, unit.getClassLoader(), encCtx, persistenceUnitDependencyResolver);
+
+         //di.deployedObject = container.getObjectName();
+         unit.addAttachment(ClientENCInjectionContainer.class, container);
+         JBoss5DeploymentUnit ejb3Unit = new JBoss5DeploymentUnit(unit);
+         getKernelAbstraction().install(container.getObjectName().getCanonicalName(),
+               container.getDependencyPolicy(), ejb3Unit, container);
+      }
+      catch(Exception e)
+      {
+         log.error("Could not deploy " + unit.getName(), e);
+         undeploy(unit, metaData);
+         throw new DeploymentException("Could not deploy " + unit.getName(), e);
+      }
+   }
+
+   /**
+    * Get the class path entries which have been determined by the EARStructure.
+    * Will return null if this unit is not part of an ear deployment.
+    */
+   private List<ClassPathEntry> getClassPathEntries(VFSDeploymentUnit unit)
+   {
+//      log.info("class path = " + unit.getTopLevel().getAttachment(StructureMetaData.class).getContext("").getClassPath());
+      StructureMetaData smd = unit.getTopLevel().getAttachment(StructureMetaData.class);
+      if(smd == null)
+         return null;
+      // A context without a path is the one we want (see AbstractStructureDeployer)
+      return smd.getContext("").getClassPath();
+   }
+   
+   /**
+    * If there is no deployment descriptor, or it doesn't specify a JNDI name, then we make up one.
+    * We use the basename from di.shortName.
+    *
+    * @param unit
+    * @param dd
+    * @return   a good JNDI name
+    */
+   private String getJndiName(JBossClientMetaData dd)
+   {
+      String jndiName = dd.getJndiName();
+      return jndiName;
+   }
+   private String getDeploymentJndiName(DeploymentUnit unit)
+   {
+      String jndiName;
+      String shortName = unit.getSimpleName();
+      if(shortName.endsWith(".jar/"))
+         jndiName = shortName.substring(0, shortName.length() - 5);
+      else if(shortName.endsWith(".jar"))
+         jndiName = shortName.substring(0, shortName.length() - 4);
+      else
+         throw new IllegalStateException("Expected either '.jar' or '.jar/' at the end of " + shortName);
+
+      return jndiName;
+   }
+
+//   public Kernel getKernel()
+//   {
+//      return kernel;
+//   }
+
+   private KernelAbstraction getKernelAbstraction()
+   {
+      return new JBossASKernel(kernel);
+   }
+
+   // TODO: move this method either to a utility class or to the scanning deployer
+   protected String getMainClassName(VFSDeploymentUnit unit, boolean fail) throws Exception
+   {
+      VirtualFile file = unit.getMetaDataFile("MANIFEST.MF");
+      log.trace("parsing " + file);
+      // Default to the jboss client main
+      String mainClassName = "org.jboss.client.AppClientMain";
+
+      if (file != null)
+      {
+         try
+         {
+            Manifest mf = VFSUtils.readManifest(file);
+            Attributes attrs = mf.getMainAttributes();
+            String className = attrs.getValue(Attributes.Name.MAIN_CLASS);
+            if (className != null)
+            {
+               mainClassName = className;
+            }
+         }
+         finally
+         {
+            file.close();
+         }
+      }
+      return mainClassName;
+   }
+
+   private Class<?> loadClass(DeploymentUnit unit, String className) throws ClassNotFoundException
+   {
+      ClassLoader old = Thread.currentThread().getContextClassLoader();
+      try
+      {
+         Thread.currentThread().setContextClassLoader(unit.getClassLoader());
+         return Thread.currentThread().getContextClassLoader().loadClass(className);
+      }
+      finally
+      {
+         Thread.currentThread().setContextClassLoader(old);
+      }
+   }
+
+   public void setKernel(Kernel kernel)
+   {
+      this.kernel = kernel;
+   }
+
+   public void setMbeanServer(MBeanServer server)
+   {
+      this.server = server;
+   }
+
+   @Inject
+   public void setPersistenceUnitDependencyResolver(PersistenceUnitDependencyResolver resolver)
+   {
+      this.persistenceUnitDependencyResolver = resolver;
+   }
+   
+   @Override
+   public void undeploy(VFSDeploymentUnit unit, JBossClientMetaData metaData)
+   {
+      log.debug("undeploy " + unit.getName());
+
+      ClientENCInjectionContainer container = unit.getAttachment(ClientENCInjectionContainer.class);
+      if(container != null)
+         getKernelAbstraction().uninstall(container.getObjectName().getCanonicalName());
+
+      String appClientName = getJndiName(metaData);
+      String deploymentClientName = null;
+      if(appClientName == null)
+         appClientName = getDeploymentJndiName(unit);
+      else if(linkDeploymentJndiName)
+         deploymentClientName = getDeploymentJndiName(unit);
+
+      log.debug("Removing client ENC from: " + appClientName);
+      try
+      {
+         InitialContext iniCtx = InitialContextFactory.getInitialContext();
+         Util.unbind(iniCtx, appClientName);
+         if(deploymentClientName != null && deploymentClientName.equals(appClientName) == false)
+            Util.removeLinkRef(deploymentClientName);
+      }
+      catch(NameNotFoundException e)
+      {
+         // make sure stop doesn't fail for no reason
+         log.debug("Could not find client ENC");
+      }
+      catch (NamingException e)
+      {
+         log.error("Failed to remove client ENC", e);
+      }
+   }
+
+}

Property changes on: src/main/org/jboss/ejb3/deployers/Ejb3ClientDeployer.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/deployers/Ejb3Deployer.java
===================================================================
--- src/main/org/jboss/ejb3/deployers/Ejb3Deployer.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/deployers/Ejb3Deployer.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,373 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.deployers;
+
+import java.util.Set;
+
+import javax.management.MBeanServer;
+
+import org.jboss.beans.metadata.api.annotations.Inject;
+import org.jboss.beans.metadata.api.annotations.Start;
+import org.jboss.beans.metadata.api.annotations.Stop;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.vfs.spi.deployer.AbstractSimpleVFSRealDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.deployment.security.JaccPolicyUtil;
+import org.jboss.deployment.spi.DeploymentEndpointResolver;
+import org.jboss.ejb.deployers.MergedJBossMetaDataDeployer;
+import org.jboss.ejb3.DeploymentScope;
+import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.ejb3.cache.CacheFactoryRegistry;
+import org.jboss.ejb3.cache.persistence.PersistenceManagerFactoryRegistry;
+import org.jboss.ejb3.common.deployers.spi.AttachmentNames;
+import org.jboss.ejb3.common.registrar.plugin.mc.Ejb3McRegistrar;
+import org.jboss.ejb3.common.registrar.spi.Ejb3Registrar;
+import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
+import org.jboss.ejb3.pool.PoolFactoryRegistry;
+import org.jboss.ejb3.resolvers.MessageDestinationReferenceResolver;
+import org.jboss.jpa.resolvers.PersistenceUnitDependencyResolver;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.metadata.ear.jboss.JBossAppMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Deployes EJB 3 components based on meta data coming from JBossEjbParsingDeployer.
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public class Ejb3Deployer extends AbstractSimpleVFSRealDeployer<JBossMetaData>
+{
+   private Set<String> allowedSuffixes;
+   
+   /** EJBTHREE-1040: mandate a deployment descriptor to actually deploy */
+   private boolean deploymentDescriptorRequired;
+   
+   private Set<String> ignoredJarsSet;
+   
+   private Kernel kernel;
+   
+   private MBeanServer mbeanServer;
+   
+   private CacheFactoryRegistry cacheFactoryRegistry;
+   
+   private PoolFactoryRegistry poolFactoryRegistry;
+   
+   private PersistenceManagerFactoryRegistry persistenceManagerFactoryRegistry;
+   /** A flag indicating if wars should be scanned for ejbs */
+   private boolean scanWars = false;
+   
+   private PersistenceUnitDependencyResolver persistenceUnitDependencyResolver;
+
+   private MessageDestinationReferenceResolver messageDestinationReferenceResolver;
+   
+   public Ejb3Deployer()
+   {
+	   // let the super deployer do the necessary stuff
+	   // to add JBossMetaData as a requirement
+	   super(JBossMetaData.class);
+	   // we also want post processed metadata for processing.
+	   // Using addInput ensures ordering http://www.jboss.org/index.html?module=bb&op=viewtopic&t=156725
+      addInput(AttachmentNames.PROCESSED_METADATA);
+      // TODO: should we really output this
+      setOutput(Ejb3Deployment.class);
+      // JBossASKernel install output
+      setOutput(KernelDeployment.class);
+   }
+
+   
+   @Override
+   public void deploy(VFSDeploymentUnit unit, JBossMetaData metaData) throws DeploymentException
+   {
+      try
+      {
+         // Pickup any deployment which doesn't have metaData or metaData with ejbVersion unknown or 3
+         if(metaData != null && (metaData.isEJB2x() || metaData.isEJB1x()))
+         {
+            log.debug("Ignoring legacy EJB deployment " + unit);
+            return;
+         }
+         // If this is a war, check scanWars
+         if(unit.getAttachment(JBossWebMetaData.class) != null && scanWars == false)
+         {
+            log.trace("Skipping web deployment: "+unit.getSimpleName());
+            return;            
+         }
+
+         VirtualFile jar = unit.getRoot();
+         if (jar.isLeaf() || ignoredJarsSet.contains(jar.getName()))
+         {
+            log.trace(this.getClass().getName() + " ignoring: " + jar.getName());
+            return;
+         }
+         if(!hasAllowedSuffix(jar.getName()))
+         {
+            log.trace(this.getClass().getName() + " suffix not allowed: " + jar.getName());
+            return;
+         }
+         
+         // If DDs are required and none are present, skip deployment
+         // EJBTHREE-1040
+         if (this.isDeploymentDescriptorRequired() && (metaData == null))
+         {
+            log.trace(this.getClass().getSimpleName() + " skipping deployment \"" + unit.getSimpleName()
+                  + "\", jar: \"" + jar.getName()
+                  + "\" - either EJB3 Deployment Descriptor or \"jboss.xml\" is required and neither were found.");
+            return;
+         }
+            
+         log.debug("********* " + this.getClass().getSimpleName() + " Begin Unit: " + unit.getSimpleName() + " jar: "
+               + jar.getName());
+         JBoss5DeploymentScope scope = null;
+         VFSDeploymentUnit parent = unit.getTopLevel();
+         boolean initScopeDeployment = false;
+         if (parent != null)
+         {
+            // Check for an existing scope
+            scope = (JBoss5DeploymentScope) parent.getAttachment(DeploymentScope.class);
+            if (scope == null)
+            {
+               // Check for a scoped deployment or an ear top-level unit
+               boolean isEar = unit != unit.getTopLevel() || parent.isAttachmentPresent(JBossAppMetaData.class);
+               if(parent.isAttachmentPresent(DeploymentEndpointResolver.class) == true)
+                  scope = new JBoss5DeploymentScope(parent, isEar);
+               else
+               {
+                  // EJBTHREE-1291
+                  scope = new JBoss5DeploymentScope(parent, isEar, unit.getSimpleName());
+                  initScopeDeployment = true;
+               }
+               parent.addAttachment(DeploymentScope.class, scope);
+            }
+         }
+
+         JBoss5DeploymentUnit du = new JBoss5DeploymentUnit(unit);
+         Ejb3JBoss5Deployment deployment = new Ejb3JBoss5Deployment(du, kernel, mbeanServer, unit, scope, metaData);
+         if(initScopeDeployment)
+         {
+            scope.setDeployment(deployment);
+         }
+         deployment.setCacheFactoryRegistry(this.getCacheFactoryRegistry());
+         // TODO: if the deployment becomes a proper MC bean, it'll get injected by MC.
+         deployment.setMessageDestinationReferenceResolver(messageDestinationReferenceResolver);
+         deployment.setPersistenceManagerFactoryRegistry(this.getPersistenceManagerFactoryRegistry());
+         // TODO: if the deployment becomes a proper MC bean, it'll get injected by MC.
+         deployment.setPersistenceUnitDependencyResolver(persistenceUnitDependencyResolver);
+         deployment.setPoolFactoryRegistry(this.getPoolFactoryRegistry());
+         if (scope != null)
+            scope.register(deployment);
+         // create() creates initial EJB containers and initializes metadata.
+         deployment.create();
+         if (deployment.getEjbContainers().size() == 0)
+         {
+            log.trace("Found no containers in scanned jar, consider adding it to the ignore list: " + jar.getName() + " url: " + jar.toURL() + " unit: " + unit.getSimpleName());
+            deployment.destroy();
+            return;
+         }
+         deployment.start();
+         unit.addAttachment(Ejb3Deployment.class, deployment);
+         // TODO: temporarily disable the security deployment
+         unit.addAttachment(JaccPolicyUtil.IGNORE_ME_NAME, true, Boolean.class);
+      }
+      catch (Throwable t)
+      {
+         throw new DeploymentException("Error deploying " + unit.getSimpleName() + ": " + t.getMessage(), t);
+      }
+   }
+
+   public Set<String> getAllowedSuffixes()
+   {
+      return allowedSuffixes;
+   }
+   
+   public CacheFactoryRegistry getCacheFactoryRegistry()
+   {
+      return cacheFactoryRegistry;
+   }
+   
+   public void setCacheFactoryRegistry(CacheFactoryRegistry cacheFactoryRegistry)
+   {
+      this.cacheFactoryRegistry = cacheFactoryRegistry;
+   }
+
+   public PoolFactoryRegistry getPoolFactoryRegistry()
+   {
+      return poolFactoryRegistry;
+   }
+
+   public void setPoolFactoryRegistry(PoolFactoryRegistry poolFactoryRegistry)
+   {
+      this.poolFactoryRegistry = poolFactoryRegistry;
+   }
+
+   public PersistenceManagerFactoryRegistry getPersistenceManagerFactoryRegistry()
+   {
+      return persistenceManagerFactoryRegistry;
+   }
+
+   @Inject
+   public void setMessageDestinationReferenceResolver(MessageDestinationReferenceResolver resolver)
+   {
+      this.messageDestinationReferenceResolver = resolver;   
+   }
+   
+   public void setPersistenceManagerFactoryRegistry(PersistenceManagerFactoryRegistry persistenceManagerFactoryRegistry)
+   {
+      this.persistenceManagerFactoryRegistry = persistenceManagerFactoryRegistry;
+   }
+
+   @Inject
+   public void setPersistenceUnitDeploymentResolver(PersistenceUnitDependencyResolver resolver)
+   {
+      this.persistenceUnitDependencyResolver = resolver;
+   }
+   
+   public boolean isScanWars()
+   {
+      return scanWars;
+   }
+   public void setScanWars(boolean scanWars)
+   {
+      this.scanWars = scanWars;
+   }
+
+   private boolean hasAllowedSuffix(String name)
+   {
+      if(allowedSuffixes == null)
+         return true;
+      
+      for (String suffix : allowedSuffixes)
+      {
+         if (name.endsWith(suffix))
+         {
+            return true;
+         }
+      }
+      return false;
+   }
+   
+   public boolean isDeploymentDescriptorRequired()
+   {
+      return deploymentDescriptorRequired;
+   }
+   
+   public void setAllowedSuffixes(Set<String> s)
+   {
+      this.allowedSuffixes = s;
+   }
+   
+   public void setDeploymentDescriptorRequired(boolean b)
+   {
+      this.deploymentDescriptorRequired = b;
+   }
+   
+   public void setIgnoredJarsSet(Set<String> s)
+   {
+      this.ignoredJarsSet = s;
+   }
+   
+   public void setKernel(Kernel kernel)
+   {
+      this.kernel = kernel;
+   }
+   
+   public void setMbeanServer(MBeanServer server)
+   {
+      this.mbeanServer = server;
+   }
+   
+   @Override
+   public void undeploy(VFSDeploymentUnit unit, JBossMetaData metadata)
+   {
+      Ejb3Deployment deployment = unit.getAttachment(Ejb3Deployment.class);
+      if(deployment == null)
+         return;
+
+      try
+      {
+         deployment.stop();
+      }
+      catch(Exception e)
+      {
+         log.warn("Failed to stop deployment " + deployment, e);
+      }
+      try
+      {
+         deployment.destroy();
+      }
+      catch(Exception e)
+      {
+         log.warn("Failed to destroy deployment " + deployment, e);
+      }
+   }
+
+   /**
+    * LifeCycle Start
+    * 
+    * Responsible for Binding an MC-based EJB3 Registrar Object Store
+    * 
+    * @author ALR
+    * @throws Throwable
+    */
+   @Start
+   public void start() throws Throwable
+   {
+      // Bind an EJB3 Registrar Implementation if not already bound
+      if (!Ejb3RegistrarLocator.isRegistrarBound())
+      {
+         // Obtain the Kernel
+         Kernel sanders = this.kernel;
+         assert sanders != null : Kernel.class.getSimpleName() + " must be provided in order to bind "
+               + Ejb3Registrar.class.getSimpleName();
+
+         // Create an EJB3 Registrar
+         Ejb3Registrar registrar = new Ejb3McRegistrar(sanders);
+
+         // Bind Registrar to the Locator
+         Ejb3RegistrarLocator.bindRegistrar(registrar);
+         
+         // Log
+         log.debug("Bound " + Ejb3Registrar.class.getSimpleName() + " to static "
+               + Ejb3RegistrarLocator.class.getSimpleName());
+      }
+   }
+   
+   /**
+    * LifeCycle Stop
+    * 
+    * Responsible for Unbinding the MC-based EJB3 Registrar Object Store
+    * 
+    * @throws Throwable
+    */
+   @Stop
+   public void stop() throws Throwable
+   {
+      // If bound
+      if (Ejb3RegistrarLocator.isRegistrarBound())
+      {
+         Ejb3RegistrarLocator.unbindRegistrar();
+      }
+   }
+}

Property changes on: src/main/org/jboss/ejb3/deployers/Ejb3Deployer.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/deployers/Ejb3DependenciesDeployer.java
===================================================================
--- src/main/org/jboss/ejb3/deployers/Ejb3DependenciesDeployer.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/deployers/Ejb3DependenciesDeployer.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.deployers;
+
+import javax.transaction.TransactionManager;
+
+import org.jboss.dependency.plugins.AbstractDependencyItem;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployerWithInput;
+import org.jboss.deployers.spi.deployer.helpers.DeploymentVisitor;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.plugins.dependency.DependenciesMetaData;
+import org.jboss.deployers.vfs.plugins.dependency.DependencyItemMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+
+/**
+ * @author <a href="mailto:cdewolf@redhat.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public class Ejb3DependenciesDeployer extends AbstractRealDeployerWithInput<JBossMetaData>
+{
+   public Ejb3DependenciesDeployer()
+   {
+      setStage(DeploymentStages.PRE_REAL);
+      setOutput(DependenciesMetaData.class);
+      DeploymentVisitor<JBossMetaData> visitor = new DeploymentVisitor<JBossMetaData>()
+      {
+         public void deploy(DeploymentUnit unit, JBossMetaData deployment) throws DeploymentException
+         {
+            log.info("Encountered deployment " + unit);
+            
+            if(!deployment.isEJB3x())
+               return;
+            
+            // TODO: get the dependencies from beans.xml
+            /*
+            DependenciesMetaData dependencies = new DependenciesMetaData();
+            List<DependencyItemMetaData> items = new ArrayList<DependencyItemMetaData>();
+            items.add(createDependencyItemMetaData(TransactionManager.class.getName()));
+            dependencies.setItems(items);
+            log.debug("Encountered EJB3 deployment " + unit + ", adding dependencies " + items);
+            // We add to toplevel, because DeploymentControllerContext will deploy all kids when it goes to install
+            unit.getTopLevel().addAttachment(DependenciesMetaData.class, dependencies);
+            */
+            //ControllerContext context = unit.getAttachment(ControllerContext.class);
+            unit.addIDependOn(new AbstractDependencyItem(unit.getName(), TransactionManager.class, new ControllerState("Real"), ControllerState.INSTALLED));
+         }
+
+         private DependencyItemMetaData createDependencyItemMetaData(String name)
+         {
+            DependencyItemMetaData item = new DependencyItemMetaData();
+            item.setValue(name);
+            // This is ugly, MC checks on String value
+            //item.setWhenRequired(new ControllerState(DeploymentStages.REAL.toString()));
+            item.setWhenRequired(new ControllerState("Real"));
+            item.setDependentState(ControllerState.INSTALLED);
+            return item;
+         }
+
+         public Class<JBossMetaData> getVisitorType()
+         {
+            return JBossMetaData.class;
+         }
+
+         public void undeploy(DeploymentUnit unit, JBossMetaData deployment)
+         {
+         }
+      };
+      setDeploymentVisitor(visitor);
+   }
+}

Property changes on: src/main/org/jboss/ejb3/deployers/Ejb3DependenciesDeployer.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision

Index: src/main/org/jboss/ejb3/client/ClientLauncher.java
===================================================================
--- src/main/org/jboss/ejb3/client/ClientLauncher.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/client/ClientLauncher.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,581 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.client;
+
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.rmi.server.RMIClassLoader;
+import java.rmi.server.RMIClassLoaderSpi;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Properties;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.beans.metadata.plugins.builder.BeanMetaDataBuilderFactory;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.classloader.plugins.system.DefaultClassLoaderSystem;
+import org.jboss.classloader.spi.ClassLoaderDomain;
+import org.jboss.classloader.spi.ClassLoaderSystem;
+import org.jboss.classloader.spi.ParentPolicy;
+import org.jboss.classloading.spi.dependency.ClassLoading;
+import org.jboss.classloading.spi.vfs.dependency.VFSClassLoaderPolicyModule;
+import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory;
+import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory10;
+import org.jboss.client.AppClientLauncher;
+import org.jboss.dependency.spi.ControllerMode;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.deployment.dependency.JndiDependencyMetaData;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.plugins.bootstrap.AbstractBootstrap;
+import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
+import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
+import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.client.jboss.JBossClientMetaData;
+import org.jboss.remoting.Remoting;
+import org.jboss.xb.binding.JBossXBException;
+
+/**
+ * This class launches a JavaEE 5 application client.
+ * 
+ * The first argument is either a jar file containing the client deployment files or the application client class name.
+ * The manifest file Main-Class attribute must point to the application client class.
+ * It must also contain an application client deployment descriptor file (META-INF/application-client.xml).
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @author Scott.Stark@jboss.org
+ * @version $Revision$
+ */
+public class ClientLauncher
+   implements AppClientLauncher
+{
+   private static final Logger log = Logger.getLogger(ClientLauncher.class);
+   private static final String VERSION = "$Revision$";
+   private static Throwable exception;
+   /** The kernel for the client container */
+   private static Kernel kernel;
+
+   /** The deployer */
+   private static BasicXMLDeployer deployer;
+   /** The mainClass used by the ClientContainer */
+   private static Class<?> theMainClass;
+   /** Should the remoting class loader delegate to the tcl */
+   private static boolean remotingDelgatesToTCL = true;
+   /** Additional classpath elements to client container classpath */
+   private static List<String> extraClassPath = new ArrayList<String>();
+
+   /**
+    * Access the client main class as loaded by the MC/client container. This
+    * class should be used to ensure that any static variable set in the class
+    * as a by-product of invoking the client main(String[]) method are seen.
+    * @return client main class object
+    */
+   public static Class<?> getTheMainClass()
+   {
+      return theMainClass;
+   }
+
+   /**
+    * Convenience method to load the XML descriptor for the given applicationClientName.
+    * This does a lookup against the server for the xml metadata the client
+    * deployer bound.
+    * 
+    * @return the JBossClientMetaData
+    * @throws IOException 
+    * @throws JBossXBException 
+    */
+   public static JBossClientMetaData loadXML(String applicationClientName) throws NamingException
+   {
+      log.warn("FIXME: using an unsupported hack to get metadata");
+      InitialContext ctx = new InitialContext();
+      JBossClientMetaData metaData = (JBossClientMetaData) ctx.lookup(applicationClientName + "/metaData");
+      return metaData;
+   }
+   public static List<String> loadClassPath(String applicationClientName)
+      throws NamingException
+   {
+      InitialContext ctx = new InitialContext();
+      List<String> cp = (List<String>) ctx.lookup(applicationClientName + "/classPathEntries");
+      return cp;
+   }
+
+   /**
+    * Calls {@link #launch(String, String, String[], Properties)}
+    */
+   public void launch(String clientClass, String clientName, String[] args)
+         throws Throwable
+   {
+      launch(clientClass, clientName, args, null);
+   }
+
+   /**
+    * Convenience method for launching a client container.
+    * 
+    * @param xml
+    * @param mainClassName
+    * @param applicationClientName
+    * @param args
+    * @throws Exception
+    */
+   public static void launch(JBossClientMetaData xml, String mainClassName, String applicationClientName, String args[])
+      throws Throwable
+   {
+      List<String> cp = Collections.emptyList();
+      launch(xml, cp, mainClassName, applicationClientName, args, null);
+   }
+   /**
+    * The AppClientLauncher method for launching a client container.
+    * 
+    * @param mainClassName - the class whose main(String[]) will be invoked
+    * @param clientName - the client name that maps to the server side JNDI ENC
+    * @param args - the args to pass to main method
+    * @param jndiEnv - jndi properties to pass to set as System properties
+    * @throws Throwable
+    */
+   public static void launch(String mainClassName, String clientName, String args[],
+         Properties jndiEnv)
+      throws Throwable
+   {
+      // Set the RMIClassLoaderSpi implementation to JBossRMIClassLoader
+      System.setProperty("java.rmi.server.RMIClassLoaderSpi", JBossRMIClassLoader.class.getName());
+      // This is loaded lazily via a jndi dependency
+      JBossClientMetaData xml = null;
+      List<String> cp = loadClassPath(clientName);
+      launch(xml, cp, mainClassName, clientName, args, jndiEnv);
+   }
+
+   /**
+    * The client launcher entry point that create an mc to launch the client container.
+    * @param clientClass
+    * @param clientName
+    * @param cp
+    * @param args
+    * @throws Throwable
+    */
+   public static void launch(JBossClientMetaData xml, List<String> classPath,
+         String mainClassName, String applicationClientName, String args[],
+         Properties jndiEnv)
+      throws Throwable
+   {
+      log.info("ClientLauncher, version: "+VERSION);
+      // Init the kernel and deployers
+      args = init(args);
+
+      // Pass in the jndi env properties so InitialContext() works
+      if(jndiEnv != null)
+      {
+         for(Object key : jndiEnv.keySet())
+         {
+            String name = (String) key;
+            System.setProperty(name, jndiEnv.getProperty(name));
+         }
+      }
+      // Have the remoting class loader delegate to the tcl
+      if(remotingDelgatesToTCL)
+         System.setProperty(Remoting.CLASSLOADING_PARENT_FIRST_DELEGATION_PROP, "false");
+
+      // Setup the 
+      ArrayList<BeanMetaDataFactory> beanFactories = new ArrayList<BeanMetaDataFactory>();
+      ArrayList<BeanMetaData> beans = new ArrayList<BeanMetaData>();
+
+      // Add the common launcher beans, ClassLoaderSystem
+      BeanMetaDataBuilder builder = BeanMetaDataBuilderFactory.createBuilder("ClassLoaderSystem", ClassLoaderSystem.class.getName());
+      builder.setFactoryClass(ClientLauncher.class.getName());
+      builder.setFactoryMethod("getClassLoaderSystem");
+      BeanMetaData classLoaderSystemBMD = builder.getBeanMetaData();
+      addBeanMetaData(beanFactories, beans, classLoaderSystemBMD);
+
+      // ClassLoading
+      builder = BeanMetaDataBuilderFactory.createBuilder("ClassLoading", ClassLoading.class.getName());
+      builder.addMethodInstallCallback("addModule", ControllerState.CONFIGURED);
+      builder.addMethodUninstallCallback("removeModule", ControllerState.CONFIGURED);
+      BeanMetaData classLoadingBMD = builder.getBeanMetaData();
+      addBeanMetaData(beanFactories, beans, classLoadingBMD);
+
+      try
+      {
+         builder = BeanMetaDataBuilderFactory.createBuilder("ClientContainer",
+               "org.jboss.ejb3.client.ClientContainer");
+         VFSClassLoaderFactory factory = new VFSClassLoaderFactory("ClientLauncherClassPath");
+         ArrayList<String> roots = new ArrayList<String>();
+         // Create the classpath
+         log.info("Setting up classpath from: ");
+         for(String path : classPath)
+         {
+            log.info(path);
+            roots.add(path);
+         }
+         for(String path : extraClassPath)
+         {
+            log.info(path);
+            roots.add(path);
+         }
+         log.info("End classpath");
+         factory.setRoots(roots);
+         beanFactories.add(factory);
+         // ClientContainer(xml, mainClass, applicationClientName, jndiEnv);
+         String classLoaderName = factory.getContextName();
+         if(classLoaderName == null)
+            classLoaderName = factory.getName() + ":" + factory.getVersion();
+         String metaDataJndiName = applicationClientName + "/metaData";
+         ValueMetaData xmlMD = new JndiDependencyValueMetaData(metaDataJndiName, jndiEnv, classLoaderName);
+         builder.addConstructorParameter(JBossClientMetaData.class.getName(), xmlMD);
+         //builder.addConstructorParameter(JBossClientMetaData.class.getName(), xml);
+         builder.addConstructorParameter(Class.class.getName(), mainClassName);
+         builder.addConstructorParameter(String.class.getName(), applicationClientName);
+         builder.addConstructorParameter(Properties.class.getName(), jndiEnv);
+         // Use vfs class loader as the ClientContainer class loader
+         ValueMetaData classLoader = builder.createInject(classLoaderName);
+         builder.setClassLoader(classLoader);
+         BeanMetaData clientContainerMD = builder.getBeanMetaData();
+
+         AbstractKernelDeployment deployment = new AbstractKernelDeployment();
+         deployment.setName(factory.getName() + ":" + factory.getVersion());
+         addBeanMetaData(beanFactories, beans, clientContainerMD);
+         deployment.setBeanFactories(beanFactories);
+         if(beans.size() > 0)
+            deployment.setBeans(beans);
+         deploy(deployment);
+         validate();
+
+         KernelController controller = kernel.getController();
+         // ClientContainer
+         KernelControllerContext context = (KernelControllerContext) controller.getContext("ClientContainer", ControllerState.INSTALLED);
+         if (context == null)
+            throw new Exception("ClientContainer bean was not created");
+         Object client = context.getTarget();
+         KernelControllerContext cclContext = (KernelControllerContext) controller.getContext(classLoaderName, ControllerState.INSTALLED);
+         if (cclContext == null)
+            throw new Exception(classLoaderName+" bean was not created");
+         ClassLoader ccLoader = (ClassLoader) cclContext.getTarget();
+         if (ccLoader == null )
+            throw new Exception(classLoaderName+" bean was not created");
+         if (client.getClass().getClassLoader() != ccLoader)
+            log.warn(client.getClass().getClassLoader()+" != "+ccLoader);
+         Class<?> clientContainerClass = ccLoader.loadClass("org.jboss.ejb3.client.ClientContainer");
+         if (clientContainerClass.getClassLoader() != ccLoader)
+            log.warn(clientContainerClass.getClassLoader()+" != "+ccLoader);
+
+         // Invoke main on the underlying client main class through the ClientContainer
+         ClassLoader prevLoader = Thread.currentThread().getContextClassLoader();
+         try
+         {
+            // Get the mainClass
+            Class<?> empty[] = {};
+            Method getMainClass = clientContainerClass.getDeclaredMethod("getMainClass", empty);
+            theMainClass = (Class<?>) getMainClass.invoke(client, null);
+            // Invoke main
+            Thread.currentThread().setContextClassLoader(ccLoader);
+            Class<?> parameterTypes[] = { args.getClass() };
+            Method invokeMain = clientContainerClass.getDeclaredMethod("invokeMain", parameterTypes);
+            invokeMain.invoke(client, (Object) args);
+         }
+         finally
+         {
+            Thread.currentThread().setContextClassLoader(prevLoader);
+         }
+
+         // 
+         undeploy(deployment);
+      }
+      catch(Throwable e)
+      {
+         exception = e;
+         throw e;
+      }
+   }
+
+   /**
+    * Create a ClassLoaderSystem with the default ClassLoaderDomain set to use
+    * a AFTER ParentPolicy.
+    *
+    * @return ClassLoaderSystem instance
+    */
+   public static ClassLoaderSystem getClassLoaderSystem()
+   {
+      DefaultClassLoaderSystem system = new DefaultClassLoaderSystem();
+      ClassLoaderDomain defaultDomain = system.getDefaultDomain();
+      defaultDomain.setParentPolicy(ParentPolicy.AFTER);
+      return system;
+   }
+
+   private static void addBeanMetaData(
+         ArrayList<BeanMetaDataFactory> beanFactories,
+         ArrayList<BeanMetaData> beans, BeanMetaData bmd)
+   {
+      // TODO Auto-generated method stub
+      if(bmd instanceof BeanMetaDataFactory)
+      {
+         BeanMetaDataFactory bmdf = (BeanMetaDataFactory) bmd;
+         beanFactories.add(bmdf);
+      }
+      else
+      {
+         // Have to use the deprecated beans
+         beans.add(bmd);
+      }
+   }
+
+   /**
+    * Initialize the mc kernel and deployer as well as extract any client
+    * launcher specific args from the input arguments.
+    * 
+    * @param args - the input args to both the launcher and the client main. The
+    * launcher specific arguments are:
+    *   -remotingDelgatesToTCL : true if remoting should first delegate to the the tcl based class loader
+    *   -extraClassPath : comma separated list of vfsurls for additional classpath
+    * @return the remaining arguments to pass to the client main.
+    * @throws Throwable
+    */
+   private static String[] init(String[] args) throws Throwable
+   {
+      // Extract any launcher args from the input
+      String[] newArgs = parseArgs(args);
+      // Bootstrap the kernel
+      AbstractBootstrap bootstrap = new BasicBootstrap();
+      bootstrap.run();
+      kernel = bootstrap.getKernel();
+      
+      // Create the deployer
+      deployer = createDeployer();
+
+      return newArgs;
+   }
+   /**
+    * Extract the launcher specific arguments from the arguments array.
+    * @see #init(String[])
+    * @param args - the input args to both the launcher and the client main.
+    * @return the remaining arguments to pass to the client main.
+    */
+   private static String[] parseArgs(String[] args)
+   {
+      ArrayList<String> tmp = new ArrayList<String>();
+      for(int n = 0; n < args.length; n ++)
+      {
+         String arg = args[n];
+         if(arg.equalsIgnoreCase("-remotingDelgatesToTCL"))
+         {
+            remotingDelgatesToTCL = Boolean.parseBoolean(args[++ n]);
+         }
+         else if(arg.equalsIgnoreCase("-extraClassPath"))
+         {
+            // Split classpath elements based on ','
+            String cparg = args[++ n];
+            String[] cp = cparg.split(",");
+            for(String path : cp)
+            {
+               extraClassPath.add(path);
+            }
+            log.debug("Set extraClassPath to: "+extraClassPath);
+         }
+         else
+         {
+            tmp.add(arg);
+         }
+      }
+      String[] newArgs = new String[tmp.size()];
+      tmp.toArray(newArgs);
+      return newArgs;
+   }
+
+   private static BasicXMLDeployer createDeployer()
+   {
+      return new BasicXMLDeployer(kernel, ControllerMode.AUTOMATIC);
+   }
+
+   /**
+    * Deploy a deployment
+    *
+    * @param deployment the deployment
+    * @throws Exception for any error  
+    */
+   private static void deploy(KernelDeployment deployment) throws Exception
+   {
+      log.debug("Deploying " + deployment);
+      try
+      {
+         deployer.deploy(deployment);
+         log.debug("Deployed " + deployment);
+      }
+      catch (Exception e)
+      {
+         throw e;
+      }
+      catch (Error e)
+      {
+         throw e;
+      }
+      catch (Throwable t)
+      {
+         throw new RuntimeException("Error deploying deployment: " + deployment, t);
+      }
+   }
+   /**
+    * Undeploy a deployment
+    * 
+    * @param deployment the deployment
+    */
+   private static void undeploy(KernelDeployment deployment)
+   {
+      log.debug("Undeploying " + deployment.getName());
+      try
+      {
+         deployer.undeploy(deployment);
+         log.trace("Undeployed " + deployment.getName());
+      }
+      catch (Throwable t)
+      {
+         log.warn("Error during undeployment: " + deployment.getName(), t);
+      }
+   }
+
+   /**
+    * Validate
+    * 
+    * @throws Exception for any error
+    */
+   private static void validate() throws Exception
+   {
+      try
+      {
+         deployer.validate();
+      }
+      catch (RuntimeException e)
+      {
+         throw e;
+      }
+      catch (Exception e)
+      {
+         throw e;
+      }
+      catch (Error e)
+      {
+         throw e;
+      }
+      catch (Throwable t)
+      {
+         throw new RuntimeException(t);
+      }
+   }
+
+   public static void main(String[] args)
+   {
+      String[] roots = {
+            "vfszip:/home/svn/JBossHead/jboss-head/build/output/jboss-5.0.0.CR2/server/cts/tmp/jsr88/assembly_classpath_appclient.ear/assembly_classpath_appclient_client.jar",
+            "vfszip:/Users/svn/JBossHead/jboss-head/build/output/jboss-5.0.0.CR2/server/cts/tmp/jsr88/assembly_classpath_appclient.ear/libs/direct_classpath_util.jar",
+            "vfszip:/Users/svn/JBossHead/jboss-head/build/output/jboss-5.0.0.CR2/server/cts/tmp/jsr88/assembly_classpath_appclient.ear/libs/indirect_classpath_util.jar"
+      };
+      VFSClassLoaderFactory10 factory = new VFSClassLoaderFactory10();
+      factory.setRoots(Arrays.asList(roots));
+      VFSClassLoaderPolicyModule module = new VFSClassLoaderPolicyModule(factory, "AppClientLoaderModule");
+   
+   }
+
+   /**
+    * RMIClassLoaderSpi that uses the thread context class loader
+    * 
+    * @author <a href="mailto:adrian.brock@happeningtimes.com">Adrian Brock</a>
+    * @author Scott.Stark@jboss.org
+    * @version $Revision$
+    */
+   public static class JBossRMIClassLoader
+      extends RMIClassLoaderSpi
+   {
+      // Attributes ----------------------------------------------------
+   
+      /**
+       * The JVM implementation (we delegate most work to it)
+       */
+      RMIClassLoaderSpi delegate = RMIClassLoader.getDefaultProviderInstance();
+      
+      // Constructors --------------------------------------------------
+   
+      /**
+       * Required constructor
+       */
+      public JBossRMIClassLoader()
+      {
+      }
+      
+      // RMIClassLoaderSpi Implementation ------------------------------
+   
+      /*
+       * Ignore the JVM, use the thread context classloader for proxy caching
+       */
+      public Class<?> loadProxyClass(String codebase, String[] interfaces, ClassLoader ignored)
+         throws MalformedURLException, ClassNotFoundException
+      {
+         ClassLoader loader = Thread.currentThread().getContextClassLoader();
+         return delegate.loadProxyClass(codebase, interfaces, loader);
+      }
+
+      /*
+       * Just delegate
+       */
+      public Class<?> loadClass(String codebase, String name, ClassLoader ignored)
+         throws MalformedURLException, ClassNotFoundException
+      {
+         ClassLoader loader = Thread.currentThread().getContextClassLoader();
+         return delegate.loadClass(codebase, name, loader);
+      }
+
+      /*
+       * Just delegate
+       */
+      public ClassLoader getClassLoader(String codebase)
+         throws MalformedURLException
+      {
+         return delegate.getClassLoader(codebase);
+      }
+   
+      /*
+       * Try to delegate an default to the java.rmi.server.codebase on any
+       * failure.
+       */
+      public String getClassAnnotation(Class<?> cl)
+      {
+         String annotation = null;
+         try
+         {
+            annotation = delegate.getClassAnnotation(cl);
+         }
+         catch(Throwable t)
+         {
+            // Try the java.rmi.server.codebase property
+            annotation = System.getProperty("java.rmi.server.codebase");
+         }
+         return annotation;
+      }
+   }
+
+}

Property changes on: src/main/org/jboss/ejb3/client/ClientLauncher.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/client/Utils.java
===================================================================
--- src/main/org/jboss/ejb3/client/Utils.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/client/Utils.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,159 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.client;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.List;
+
+import org.jboss.injection.InjectionContainer;
+import org.jboss.injection.Injector;
+import org.jboss.injection.InjectorFactory;
+import org.jboss.injection.lang.reflect.BeanProperty;
+import org.jboss.injection.lang.reflect.BeanPropertyFactory;
+import org.jboss.metadata.javaee.spec.ResourceInjectionMetaData;
+import org.jboss.metadata.javaee.spec.ResourceInjectionTargetMetaData;
+
+/**
+ * Injection utilities
+ * 
+ * @author Scott.Stark@jboss.org
+ * @version $Revision$
+ */
+public class Utils
+{
+   /**
+    * Create and add multiple injectors for injection targets.
+    * 
+    * @param injectors          the list on which to add injectors
+    * @param classLoader        the class loader to resolve an injection target
+    * @param factory            the injector factory
+    * @param injectionTargets   the injection targets
+    */
+   public static void createInjectors(List<Injector> injectors,
+         ClassLoader classLoader,
+         InjectorFactory<?> factory,
+         Collection<ResourceInjectionTargetMetaData> injectionTargets)
+   {
+      if(injectionTargets == null)
+         return;
+
+      for(ResourceInjectionTargetMetaData injectionTarget : injectionTargets)
+      {
+         AccessibleObject ao = findInjectionTarget(classLoader, injectionTarget);
+         BeanProperty property = BeanPropertyFactory.create(ao);
+         injectors.add(factory.create(property));
+      }
+   }
+
+   public static Class<?> injectionTarget(String encName,
+         ResourceInjectionMetaData ref,
+         InjectionContainer container)
+   {
+      Class<?> injectionType = null;
+      
+      if(ref.getInjectionTargets() == null)
+         return injectionType;
+
+      ClassLoader loader = container.getClassloader();
+      for(ResourceInjectionTargetMetaData injectionTarget : ref.getInjectionTargets())
+      {
+         AccessibleObject ao = findInjectionTarget(loader, injectionTarget);
+         BeanProperty prop = BeanPropertyFactory.create(ao);
+         JndiPropertyInjector propInjector = new JndiPropertyInjector(prop, encName, container.getEnc());
+         container.getInjectors().add(propInjector);
+         // Validate all the injection types are consistent
+         Class<?> type;
+         if (ao instanceof Field)
+         {
+            type = ((Field) ao).getType();
+         }
+         else
+         {
+            type = ((Method) ao).getParameterTypes()[0];
+         }
+         if(injectionType == null)
+            injectionType = type;
+         else
+         {
+            if(!injectionType.equals(type))
+               throw new IllegalStateException("Found multiple injection targets with different types");
+         }
+      }
+      
+      return injectionType;
+   }
+   public static AccessibleObject findInjectionTarget(ClassLoader loader, ResourceInjectionTargetMetaData target)
+   {
+      Class<?> clazz = null;
+      try
+      {
+         clazz = loader.loadClass(target.getInjectionTargetClass());
+      }
+      catch (ClassNotFoundException e)
+      {
+         throw new RuntimeException("<injection-target> class: " + target.getInjectionTargetClass() + " was not found in deployment");
+      }
+
+      for (Field field : clazz.getDeclaredFields())
+      {
+         if (target.getInjectionTargetName().equals(field.getName()))
+            return field;
+      }
+
+      for (Method method : clazz.getDeclaredMethods())
+      {
+         if (method.getName().equals(target.getInjectionTargetName()))
+            return method;
+      }
+
+      throw new RuntimeException("<injection-target> could not be found: " + target.getInjectionTargetClass() + "." + target.getInjectionTargetName());
+   }
+
+   public static String getEncName(Class type)
+   {
+      return "env/" + type.getName();
+   }
+
+   public static String getEncName(Method method)
+   {
+      String encName = method.getName().substring(3);
+      if (encName.length() > 1)
+      {
+         encName = encName.substring(0, 1).toLowerCase() + encName.substring(1);
+      }
+      else
+      {
+         encName = encName.toLowerCase();
+      }
+
+      encName = getEncName(method.getDeclaringClass()) + "/" + encName;
+      return encName;
+   }
+
+   public static String getEncName(Field field)
+   {
+      return getEncName(field.getDeclaringClass()) + "/" + field.getName();
+   }
+}

Property changes on: src/main/org/jboss/ejb3/client/Utils.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/client/ClientContainer.java
===================================================================
--- src/main/org/jboss/ejb3/client/ClientContainer.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/client/ClientContainer.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,558 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.client;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Proxy;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.LinkRef;
+import javax.naming.NameClassPair;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+
+import org.jboss.ejb3.Container;
+import org.jboss.ejb3.DependencyPolicy;
+import org.jboss.ejb3.InitialContextFactory;
+import org.jboss.ejb3.client.injection.ClientPersistenceUnitHandler;
+import org.jboss.injection.DependsHandler;
+import org.jboss.injection.EncInjector;
+import org.jboss.injection.InjectionContainer;
+import org.jboss.injection.InjectionHandler;
+import org.jboss.injection.Injector;
+import org.jboss.injection.WebServiceRefHandler;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.client.jboss.JBossClientMetaData;
+import org.jboss.metadata.javaee.spec.LifecycleCallbacksMetaData;
+import org.jboss.metadata.javaee.spec.RemoteEnvironment;
+import org.jboss.util.NotImplementedException;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Injection of the application client main class is handled from here.
+ *
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @author Scott.Stark@jboss.org
+ * @version $Revision$
+ */
+public class ClientContainer implements InjectionContainer
+{
+   private static final Logger log = Logger.getLogger(ClientContainer.class);
+   private static final String VERSION = "$Revision$";
+   private static ThreadLocal<Properties> clientJndiEnv = new ThreadLocal<Properties>();
+
+   private Class<?> mainClass;
+   private JBossClientMetaData xml;
+   private String applicationClientName;
+   
+   // for performance there is an array.
+   private List<Injector> injectors = new ArrayList<Injector>();
+   private Context enc;
+   private DependencyPolicy dependsPolicy;
+
+   private List<Method> postConstructs = new ArrayList<Method>();
+
+   public static Properties getJndiEnv()
+   {
+      return clientJndiEnv.get();
+   }
+
+   public ClientContainer(JBossClientMetaData xml, Class<?> mainClass, String applicationClientName)
+      throws Exception
+   {
+      this(xml, mainClass, applicationClientName, null);
+   }
+   public ClientContainer(JBossClientMetaData xml, Class<?> mainClass, String applicationClientName, Properties jndiEnv)
+      throws Exception
+   {
+      log.info("ClientContainer(version="+VERSION+")");
+      log.info("DependencyPolicy.CS: "+DependencyPolicy.class.getProtectionDomain().getCodeSource());
+      log.info("ClientContainer.CS: "+getClass().getProtectionDomain().getCodeSource());
+      ClassLoader mainClassLoader = mainClass.getClassLoader();
+      log.info("mainClass.ClassLoader: "+mainClassLoader);
+      clientJndiEnv.set(jndiEnv);
+      this.xml = xml;
+      this.mainClass = mainClass;
+      this.applicationClientName = applicationClientName;
+      ClientJavaEEComponent client = new ClientJavaEEComponent(applicationClientName);
+      this.dependsPolicy = new NoopDependencyPolicy(client);
+
+      URL jndiPropertiesURL = mainClassLoader.getResource("jndi.properties");
+      log.info("mainClassLoader jndi.properties: "+jndiPropertiesURL);
+      Context ctx = InitialContextFactory.getInitialContext(jndiEnv);
+      enc = (Context) ctx.lookup(applicationClientName);
+      StringBuffer encInfo = new StringBuffer("Client ENC("+applicationClientName+"):\n");
+      list(enc, "", encInfo, true);
+      log.info(encInfo.toString());
+
+      //encEnv = (Context) enc.lookup("env");
+//      enc = ThreadLocalENCFactory.create(ctx);
+//      encEnv = Util.createSubcontext(enc, "env");
+      
+      processMetadata(null);
+
+      for(Injector injector : injectors)
+      {
+         log.debug("injector: " + injector);
+         injector.inject((Object) null);
+      }
+      
+      postConstruct();
+   }
+   
+   /* (non-Javadoc)
+    * @see org.jboss.injection.InjectionContainer#getAnnotation(java.lang.Class, java.lang.Class)
+    */
+   public <T extends Annotation> T getAnnotation(Class<T> annotationClass, Class<?> clazz)
+   {
+      return clazz.getAnnotation(annotationClass);
+   }
+   
+   /* (non-Javadoc)
+    * @see org.jboss.injection.InjectionContainer#getAnnotation(java.lang.Class, java.lang.Class, java.lang.reflect.Method)
+    */
+   public <T extends Annotation> T getAnnotation(Class<T> annotationClass, Class<?> clazz, Method method)
+   {
+      return method.getAnnotation(annotationClass);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.injection.InjectionContainer#getAnnotation(java.lang.Class, java.lang.reflect.Method)
+    */
+   public <T extends Annotation> T getAnnotation(Class<T> annotationClass, Method method)
+   {
+      return method.getAnnotation(annotationClass);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.injection.InjectionContainer#getAnnotation(java.lang.Class, java.lang.Class, java.lang.reflect.Field)
+    */
+   public <T extends Annotation> T getAnnotation(Class<T> annotationClass, Class<?> clazz, Field field)
+   {
+      return field.getAnnotation(annotationClass);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.injection.InjectionContainer#getAnnotation(java.lang.Class, java.lang.reflect.Field)
+    */
+   public <T extends Annotation> T getAnnotation(Class<T> annotationClass, Field field)
+   {
+      return field.getAnnotation(annotationClass);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.injection.InjectionContainer#getClassloader()
+    */
+   public ClassLoader getClassloader()
+   {
+      //throw new RuntimeException("NYI");
+      return Thread.currentThread().getContextClassLoader();
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.injection.InjectionContainer#getDependencyPolicy()
+    */
+   public DependencyPolicy getDependencyPolicy()
+   {
+      return dependsPolicy;
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.injection.InjectionContainer#getDeploymentDescriptorType()
+    */
+   public String getDeploymentDescriptorType()
+   {
+      return "application-client.xml";
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.injection.InjectionContainer#getEjbJndiName(java.lang.Class)
+    */
+   public String getEjbJndiName(Class businessInterface) throws NameNotFoundException
+   {
+      throw new RuntimeException("NYI");
+      //return null;
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.injection.InjectionContainer#getEjbJndiName(java.lang.String, java.lang.Class)
+    */
+   public String getEjbJndiName(String link, Class<?> businessInterface)
+   {
+      throw new NotImplementedException();
+      //return "java:comp/env/" + link + "/remote";
+      //return applicationClientName + "/" + link + "/remote";
+      //return null;
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.injection.InjectionContainer#getEnc()
+    */
+   public Context getEnc()
+   {
+      return enc;
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.injection.InjectionContainer#getEncInjections()
+    */
+   public Map<String, Map<AccessibleObject, Injector>> getEncInjections()
+   {
+      throw new IllegalStateException("ENC setup happens on the server");
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.injection.InjectionContainer#getEncInjectors()
+    */
+   public Map<String, EncInjector> getEncInjectors()
+   {
+      throw new IllegalStateException("ENC setup happens on the server");
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.injection.InjectionContainer#getEnvironmentRefGroup()
+    */
+   public RemoteEnvironment getEnvironmentRefGroup()
+   {
+      return xml;
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.injection.InjectionContainer#getIdentifier()
+    */
+   public String getIdentifier()
+   {
+//      throw new NotImplementedException;
+      // FIXME: return the real identifier
+      //return "client-identifier";
+      return applicationClientName;
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.injection.InjectionContainer#getInjectors()
+    */
+   public List<Injector> getInjectors()
+   {
+      return injectors;
+   }
+
+   public Class<?> getMainClass()
+   {
+      return mainClass;
+   }
+   
+   public boolean hasJNDIBinding(String jndiName)
+   {
+      return false;
+   }
+   
+   public void invokeMain(String args[]) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException
+   {
+      Class<?> parameterTypes[] = { args.getClass() };
+      Method method = mainClass.getDeclaredMethod("main", parameterTypes);
+      try
+      {
+         log.info("Invoking main: "+method);
+         method.invoke(null, (Object) args);
+         log.info("Successfully invoked main");
+      }
+      catch(Throwable e)
+      {
+         e.printStackTrace();
+         log.error("Invocation of client main failed", e);
+      }
+   }
+ 
+   /**
+    * Call post construct methods.
+    * @throws IllegalAccessException  
+    * @throws InstantiationException 
+    * @throws InvocationTargetException 
+    * @throws IllegalArgumentException 
+    *
+    */
+   private void postConstruct() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException
+   {
+      log.info("postConstructs = " + postConstructs);
+      for(Method method : postConstructs)
+      {
+         method.setAccessible(true);
+         Object instance;
+         if(Modifier.isStatic(method.getModifiers()))
+            instance = null;
+         else
+            instance = method.getDeclaringClass().newInstance();
+         Object args[] = null;
+         method.invoke(instance, args);
+      }
+   }
+   
+   private void processMetadata(DependencyPolicy dependencyPolicy) throws Exception
+   {
+      log.debug("processMetadata");
+      processPostConstructs();
+      
+      // TODO: check which handlers a client container should support
+      Collection<InjectionHandler<RemoteEnvironment>> handlers = new ArrayList<InjectionHandler<RemoteEnvironment>>();
+      handlers.add(new ClientEJBHandler<RemoteEnvironment>());
+      // This currently has no use in the ClientContainer, maybe in the future when running an mc
+      handlers.add(new DependsHandler<RemoteEnvironment>());
+      //handlers.add(new JndiInjectHandler<RemoteEnvironment>());
+      handlers.add(new ClientPersistenceUnitHandler<RemoteEnvironment>());
+      handlers.add(new ClientResourceHandler<RemoteEnvironment>(this.mainClass));
+      handlers.add(new WebServiceRefHandler<RemoteEnvironment>());
+
+      // TODO: we're going to use a jar class loader
+//      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<RemoteEnvironment> handler : handlers)
+            handler.loadXml(xml, this);
+
+         /*
+         Map<AccessibleObject, Injector> tmp = InjectionUtil.processAnnotations(this, handlers, getMainClass());
+         injectors.addAll(tmp.values());
+         */
+      }
+      finally
+      {
+//         Thread.currentThread().setContextClassLoader(old);
+      }
+   }
+   
+   /**
+    * Populate the list of the post construct callbacks ordered according to the spec rules defined in
+    * 12.4.1 Multiple Callback Interceptor Methods for a Life Cycle Callback Event.
+    * 
+    * @throws ClassNotFoundException 
+    * @throws NoSuchMethodException 
+    * @throws SecurityException 
+    *
+    */
+   private void processPostConstructs()
+      throws ClassNotFoundException, SecurityException, NoSuchMethodException
+   {
+      LifecycleCallbacksMetaData callbacks = xml.getPostConstructs();
+      if(callbacks == null || callbacks.isEmpty())
+         return;
+
+      List<Method> methods = callbacks.getOrderedCallbacks(mainClass);
+      postConstructs.addAll(methods);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.injection.InjectionContainer#resolveEjbContainer(java.lang.String, java.lang.Class)
+    */
+   public Container resolveEjbContainer(String link, Class businessIntf)
+   {
+      log.warn("resolveEjbContainer(" + link + ", " + businessIntf + ") not implemented");
+      return null;
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.injection.InjectionContainer#resolveEjbContainer(java.lang.Class)
+    */
+   public Container resolveEjbContainer(Class businessIntf) throws NameNotFoundException
+   {
+      return null;
+   }
+
+   public String resolveMessageDestination(String link)
+   {
+      // Resolving something here is a nop
+      return null;
+   }
+   
+   public VirtualFile getRootFile()
+   {
+      throw new NotImplementedException();
+   }
+
+   /**
+    * Recursively display the naming context information into the buffer.
+    * 
+    * @param ctx
+    * @param indent
+    * @param buffer
+    * @param verbose
+    */
+   private static void list(Context ctx, String indent, StringBuffer buffer,
+         boolean verbose)
+   {
+      ClassLoader loader = Thread.currentThread().getContextClassLoader();
+      try
+      {
+         NamingEnumeration ne = ctx.list("");
+         while (ne.hasMore())
+         {
+            NameClassPair pair = (NameClassPair) ne.next();
+
+            String name = pair.getName();
+            String className = pair.getClassName();
+            boolean recursive = false;
+            boolean isLinkRef = false;
+            boolean isProxy = false;
+            Class c = null;
+            try
+            {
+               c = loader.loadClass(className);
+
+               if (Context.class.isAssignableFrom(c))
+                  recursive = true;
+               if (LinkRef.class.isAssignableFrom(c))
+                  isLinkRef = true;
+
+               isProxy = Proxy.isProxyClass(c);
+            }
+            catch (ClassNotFoundException cnfe)
+            {
+               // If this is a $Proxy* class its a proxy
+               if (className.startsWith("$Proxy"))
+               {
+                  isProxy = true;
+                  // We have to get the class from the binding
+                  try
+                  {
+                     Object p = ctx.lookup(name);
+                     c = p.getClass();
+                  }
+                  catch (NamingException e)
+                  {
+                     Throwable t = e.getRootCause();
+                     if (t instanceof ClassNotFoundException)
+                     {
+                        // Get the class name from the exception msg
+                        String msg = t.getMessage();
+                        if (msg != null)
+                        {
+                           // Reset the class name to the CNFE class
+                           className = msg;
+                        }
+                     }
+                  }
+               }
+            }
+
+            buffer.append(indent + " +- " + name);
+
+            // Display reference targets
+            if (isLinkRef)
+            {
+               // Get the 
+               try
+               {
+                  Object obj = ctx.lookupLink(name);
+
+                  LinkRef link = (LinkRef) obj;
+                  buffer.append("[link -> ");
+                  buffer.append(link.getLinkName());
+                  buffer.append(']');
+               }
+               catch (Throwable t)
+               {
+                  buffer.append("invalid]");
+               }
+            }
+
+            // Display proxy interfaces
+            if (isProxy)
+            {
+               buffer.append(" (proxy: " + pair.getClassName());
+               if (c != null)
+               {
+                  Class[] ifaces = c.getInterfaces();
+                  buffer.append(" implements ");
+                  for (int i = 0; i < ifaces.length; i++)
+                  {
+                     buffer.append(ifaces[i]);
+                     buffer.append(',');
+                  }
+                  buffer.setCharAt(buffer.length() - 1, ')');
+               }
+               else
+               {
+                  buffer.append(" implements " + className + ")");
+               }
+            }
+            else if (verbose)
+            {
+               buffer.append(" (class: " + pair.getClassName() + ")");
+            }
+
+            buffer.append('\n');
+            if (recursive)
+            {
+               try
+               {
+                  Object value = ctx.lookup(name);
+                  if (value instanceof Context)
+                  {
+                     Context subctx = (Context) value;
+                     list(subctx, indent + " |  ", buffer, verbose);
+                  }
+                  else
+                  {
+                     buffer.append(indent + " |   NonContext: " + value);
+                     buffer.append('\n');
+                  }
+               }
+               catch (Throwable t)
+               {
+                  buffer.append("Failed to lookup: " + name + ", errmsg=" + t.getMessage());
+                  buffer.append('\n');
+               }
+            }
+         }
+         ne.close();
+      }
+      catch (NamingException ne)
+      {
+         buffer.append("error while listing context " + ctx.toString() + ": " + ne.toString(true));
+         formatException(buffer, ne);
+      }
+   }
+   private static void formatException(StringBuffer buffer, Throwable t)
+   {
+      StringWriter sw = new StringWriter();
+      PrintWriter pw = new PrintWriter(sw);
+      buffer.append("<pre>\n");
+      t.printStackTrace(pw);
+      buffer.append(sw.toString());
+      buffer.append("</pre>\n");
+   }
+}

Property changes on: src/main/org/jboss/ejb3/client/ClientContainer.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/client/JndiDependencyValueMetaData.java
===================================================================
--- src/main/org/jboss/ejb3/client/JndiDependencyValueMetaData.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/client/JndiDependencyValueMetaData.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.client;
+
+import java.util.Properties;
+
+import org.jboss.beans.metadata.plugins.AbstractDependencyValueMetaData;
+import org.jboss.beans.metadata.spi.MetaDataVisitor;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.reflect.spi.TypeInfo;
+
+/**
+ * @author Scott.Stark@jboss.org
+ * @version $Revision$
+ */
+public class JndiDependencyValueMetaData extends AbstractDependencyValueMetaData
+{
+   private static final long serialVersionUID = 1;
+
+   /** The demand jndi name */
+   private String jndiName;
+   private Properties env;
+   private String classLoaderName;
+   private JndiDependencyItem depends;
+
+   public JndiDependencyValueMetaData(String jndiName, Properties env, String classLoaderName)
+   {
+      this.jndiName = jndiName;
+      this.env = env;
+      this.classLoaderName = classLoaderName;
+   }
+
+   @Override
+   public void initialVisit(MetaDataVisitor visitor)
+   {
+      depends = new JndiDependencyItem(jndiName, env, classLoaderName);
+      visitor.addDependency(depends);
+      visitor.initialVisit(this);
+   }
+
+   @Override
+   public Object getValue(TypeInfo info, ClassLoader cl) throws Throwable
+   {
+      return depends.getIDependOn();
+   }
+
+}

Property changes on: src/main/org/jboss/ejb3/client/JndiDependencyValueMetaData.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/client/JndiDependencyItem.java
===================================================================
--- src/main/org/jboss/ejb3/client/JndiDependencyItem.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/client/JndiDependencyItem.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,116 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.client;
+
+import java.util.Properties;
+
+import javax.naming.InitialContext;
+import javax.naming.NameNotFoundException;
+
+import org.jboss.dependency.plugins.AbstractDependencyItem;
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.DependencyItem;
+import org.jboss.logging.Logger;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * @author Scott.Stark@jboss.org
+ * @version $Revision$
+ */
+public class JndiDependencyItem extends AbstractDependencyItem
+   implements DependencyItem
+{
+private static final Logger log = Logger.getLogger(JndiDependencyItem.class);
+
+   /** The demand jndi name */
+   private String jndiName;
+   private Properties env;
+   private String classLoaderName;
+
+   JndiDependencyItem(String jndiName, Properties env, String classLoaderName)
+   {
+      this.jndiName = jndiName;
+      this.env = env;
+      this.classLoaderName = classLoaderName;
+   }
+
+   @Override
+   public boolean resolve(Controller controller)
+   {
+      ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+      try
+      {
+         ControllerContext cc = controller.getContext(classLoaderName, ControllerState.INSTALLED);
+         ClassLoader loader = (ClassLoader) cc.getTarget();
+         if(loader != null)
+            Thread.currentThread().setContextClassLoader(loader);
+         Properties jndiEnv = env;
+         if(jndiEnv == null)
+            jndiEnv = System.getProperties();
+         InitialContext ctx = new InitialContext(jndiEnv);
+         Object depends = ctx.lookup(jndiName);
+         super.setIDependOn(depends);
+         log.info("Resolved("+jndiName+")"+depends);
+         setResolved(true);
+         return isResolved();
+      }
+      catch(NameNotFoundException e)
+      {
+         log.debug("Jndi lookup failed", e);
+      }
+      catch(Throwable ignored)
+      {
+         log.debug("Unexpected error", ignored);
+      }
+      finally
+      {
+         Thread.currentThread().setContextClassLoader(tcl);            
+      }
+      setResolved(false);
+      return isResolved();
+   }
+
+   @Override
+   public void toString(JBossStringBuilder buffer)
+   {
+      super.toString(buffer);
+      buffer.append(" depend=").append(jndiName);
+   }
+   
+   @Override
+   public void toShortString(JBossStringBuilder buffer)
+   {
+      buffer.append(getName()).append(" depend ").append(jndiName);
+   }
+
+   @Override
+   public String toHumanReadableString()
+   {
+      StringBuilder builder = new StringBuilder();
+      builder.append("JndiDepends: '");
+      builder.append(jndiName);
+      builder.append("'");
+      return builder.toString();
+   }
+}

Property changes on: src/main/org/jboss/ejb3/client/JndiDependencyItem.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/client/injection/ClientPersistenceUnitHandler.java
===================================================================
--- src/main/org/jboss/ejb3/client/injection/ClientPersistenceUnitHandler.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/client/injection/ClientPersistenceUnitHandler.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.client.injection;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Map;
+
+import org.jboss.ejb3.client.Utils;
+import org.jboss.injection.InjectionContainer;
+import org.jboss.injection.InjectionHandler;
+import org.jboss.injection.Injector;
+import org.jboss.metadata.javaee.spec.PersistenceUnitReferenceMetaData;
+import org.jboss.metadata.javaee.spec.RemoteEnvironment;
+
+/**
+ * Injection of persistence units into application clients.
+ * 
+ * Only setup injection of persistence units, the enc setup is done on the server.
+ * It's expected that the meta data is complete and no annotation handling should be performed.
+ * 
+ * @author <a href="mailto:cdewolf@redhat.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public class ClientPersistenceUnitHandler<X extends RemoteEnvironment> implements InjectionHandler<X>
+{
+   public void handleClassAnnotations(Class<?> clazz, InjectionContainer container)
+   {
+      throw new IllegalStateException("Annotations are not handled");
+   }
+
+   public void handleFieldAnnotations(Field field, InjectionContainer container,
+         Map<AccessibleObject, Injector> injectors)
+   {
+      throw new IllegalStateException("Annotations are not handled");
+   }
+
+   public void handleMethodAnnotations(Method method, InjectionContainer container,
+         Map<AccessibleObject, Injector> injectors)
+   {
+      throw new IllegalStateException("Annotations are not handled");
+   }
+
+   public void loadXml(X xml, InjectionContainer container)
+   {
+      if (xml == null) return;
+      if (xml.getPersistenceUnitRefs() == null) return;
+
+      for (PersistenceUnitReferenceMetaData ref : xml.getPersistenceUnitRefs())
+      {
+         String encName = "env/" + ref.getPersistenceUnitRefName();
+         Utils.injectionTarget(encName, ref, container);
+      }
+   }
+}

Property changes on: src/main/org/jboss/ejb3/client/injection/ClientPersistenceUnitHandler.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/client/ClientResourceHandler.java
===================================================================
--- src/main/org/jboss/ejb3/client/ClientResourceHandler.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/client/ClientResourceHandler.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,231 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.client;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Map;
+
+import javax.ejb.EJBContext;
+import javax.ejb.EJBException;
+import javax.transaction.UserTransaction;
+
+import org.jboss.injection.EJBContextPropertyInjector;
+import org.jboss.injection.InjectionContainer;
+import org.jboss.injection.InjectionHandler;
+import org.jboss.injection.Injector;
+import org.jboss.injection.InjectorFactory;
+import org.jboss.injection.UserTransactionPropertyInjector;
+import org.jboss.injection.lang.reflect.BeanProperty;
+import org.jboss.injection.lang.reflect.BeanPropertyFactory;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.javaee.spec.EnvironmentEntryMetaData;
+import org.jboss.metadata.javaee.spec.MessageDestinationReferenceMetaData;
+import org.jboss.metadata.javaee.spec.RemoteEnvironment;
+import org.jboss.metadata.javaee.spec.ResourceEnvironmentReferenceMetaData;
+import org.jboss.metadata.javaee.spec.ResourceReferenceMetaData;
+import org.omg.CORBA.ORB;
+
+/**
+ * Handler for @Resources on the client
+ * 
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ * @author Scott.Stark@jboss.org
+ * @version $Revision$
+ */
+public class ClientResourceHandler<X extends RemoteEnvironment>
+   implements InjectionHandler<X>
+{
+   private static final Logger log = Logger.getLogger(ClientResourceHandler.class);
+   private Class<?> clientClass;
+
+   public ClientResourceHandler(Class<?> clientClass)
+   {
+      this.clientClass = clientClass;
+   }
+   
+   private void loadEnvEntry(InjectionContainer container, Collection<EnvironmentEntryMetaData> envEntries)
+   {
+      for (EnvironmentEntryMetaData envEntry : envEntries)
+      {
+         String encName = "env/" + envEntry.getEnvEntryName();
+         // 16.4.1.3: If the env-entry-value is not specified, no value will be injected and it
+         // will not be initialized into the naming context.
+         if(envEntry.getValue() == null)
+         {
+            log.debug("ignoring env-entry " + envEntry);
+            continue;
+         }
+         Utils.injectionTarget(encName, envEntry, container);
+      }
+   }
+
+   private void loadXmlResourceRefs(InjectionContainer container, Collection<ResourceReferenceMetaData> refs)
+   {
+      for (ResourceReferenceMetaData envRef : refs)
+      {
+         String encName = "env/" + envRef.getResourceRefName();
+
+         if (envRef.getMappedName() == null || envRef.getMappedName().equals(""))
+         {
+            // Handle known injection types
+            if (envRef.getResUrl() != null)
+            {
+               try
+               {
+                  URL resURL = new URL(envRef.getResUrl().trim());
+                  URLInjectorFactory factory = new URLInjectorFactory(resURL);
+                  Utils.createInjectors(container.getInjectors(), container.getClassloader(), factory, envRef.getInjectionTargets());
+                  continue;
+               }
+               catch (MalformedURLException e)
+               {
+                  throw new RuntimeException(e);
+               }
+            }
+            else if (UserTransaction.class.getName().equals(envRef.getType()))
+            {
+               final InjectionContainer ic = container;
+               InjectorFactory<?> factory = new InjectorFactory<UserTransactionPropertyInjector>()
+               {
+                  public UserTransactionPropertyInjector create(BeanProperty property)
+                  {
+                     return new UserTransactionPropertyInjector(property, ic);
+                  }
+               };
+               Utils.createInjectors(container.getInjectors(), container.getClassloader(), factory, envRef.getInjectionTargets());
+               continue;
+            }
+            else if (ORB.class.getName().equals(envRef.getType()))
+            {
+               encName = "java:comp/ORB";
+            }
+            else
+            {
+               throw new RuntimeException("mapped-name is required for " + envRef.getResourceRefName() + " of deployment " + container.getIdentifier());
+            }
+         }
+         Utils.injectionTarget(encName, envRef, container);
+      }
+   }
+
+   private static void loadXmlResourceEnvRefs(InjectionContainer container, Collection<ResourceEnvironmentReferenceMetaData> refs)
+   {
+      for (ResourceEnvironmentReferenceMetaData envRef : refs)
+      {
+         // EJBTHREE-712
+         String resTypeName = envRef.getType();
+         String mappedName = envRef.getMappedName();
+         try
+         {
+            if(resTypeName != null)
+            {
+               Class<?> resType = Class.forName(resTypeName);
+               if (resType.equals(UserTransaction.class))
+               {
+                  final InjectionContainer ic = container;
+                  InjectorFactory<?> factory = new InjectorFactory<UserTransactionPropertyInjector>()
+                  {
+                     public UserTransactionPropertyInjector create(BeanProperty property)
+                     {
+                        return new UserTransactionPropertyInjector(property, ic);
+                     }
+                  };
+                  if(envRef.getInjectionTargets() != null)
+                  {
+                     Utils.createInjectors(container.getInjectors(), container.getClassloader(), factory, envRef.getInjectionTargets());
+                     continue;
+                  }
+                  else
+                  {
+                     mappedName = "java:comp/UserTransaction";
+                  }
+               }
+               else if (resType.equals(ORB.class))
+               {
+                  mappedName = "java:comp/ORB";
+               }
+            }
+         }
+         catch(ClassNotFoundException e)
+         {
+            throw new EJBException(e);
+         }
+         
+         String encName = "env/" + envRef.getResourceEnvRefName();
+         if (mappedName == null || mappedName.equals(""))
+         {
+            throw new RuntimeException("mapped-name is required for " + envRef.getResourceEnvRefName() + " of deployment " + container.getIdentifier());
+         }
+         Utils.injectionTarget(encName, envRef, container);
+      }
+   }
+
+   private static void loadXmlMessageDestinationRefs(InjectionContainer container, Collection<MessageDestinationReferenceMetaData> refs)
+   {
+      for (MessageDestinationReferenceMetaData envRef : refs)
+      {
+         String encName = "env/" + envRef.getMessageDestinationRefName();
+         String jndiName = envRef.getMappedName();
+         if (jndiName == null || jndiName.equals(""))
+         {
+            // Look for a message-destination-link
+            jndiName = envRef.getResolvedJndiName();
+            if (jndiName == null)    
+               throw new RuntimeException("message-destination has no jndi-name/resolved-jndi-name " + envRef);
+         }
+            
+         Utils.injectionTarget(encName, envRef, container);
+      }
+   }
+
+   public void loadXml(X xml, InjectionContainer container)
+   {
+      if (xml == null)
+         return;
+      if (xml.getMessageDestinationReferences() != null)
+         loadXmlMessageDestinationRefs(container, xml.getMessageDestinationReferences());
+      if (xml.getResourceEnvironmentReferences() != null)
+         loadXmlResourceEnvRefs(container, xml.getResourceEnvironmentReferences());
+      if (xml.getResourceReferences() != null)
+         loadXmlResourceRefs(container, xml.getResourceReferences());
+      if (xml.getEnvironmentEntries() != null)
+         loadEnvEntry(container, xml.getEnvironmentEntries());
+   }
+
+   public void handleClassAnnotations(Class<?> clazz, InjectionContainer container)
+   {
+      throw new IllegalStateException("Annotations are not handled in the client");
+   }
+   public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+   {
+      throw new IllegalStateException("Annotations are not handled in the client");
+   }
+   public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+   {
+      throw new IllegalStateException("Annotations are not handled in the client");
+   }
+}

Property changes on: src/main/org/jboss/ejb3/client/ClientResourceHandler.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/client/URLPropertyInjector.java
===================================================================
--- src/main/org/jboss/ejb3/client/URLPropertyInjector.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/client/URLPropertyInjector.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.client;
+
+import java.net.URL;
+
+import org.jboss.injection.AbstractPropertyInjector;
+import org.jboss.injection.lang.reflect.BeanProperty;
+
+/**
+ * Injects a URL into a bean property
+ * 
+ * @author Scott.Stark@jboss.org
+ * @version $Revision$
+ */
+public class URLPropertyInjector extends AbstractPropertyInjector
+{
+   private URL url;
+
+   URLPropertyInjector(BeanProperty property, URL url)
+   {
+      super(property);
+      this.url = url;
+   }
+
+   public void inject(Object instance)
+   {
+      property.set(instance, url);
+   }
+}

Property changes on: src/main/org/jboss/ejb3/client/URLPropertyInjector.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/client/JndiPropertyInjector.java
===================================================================
--- src/main/org/jboss/ejb3/client/JndiPropertyInjector.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/client/JndiPropertyInjector.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,169 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.client;
+
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.security.CodeSource;
+import java.security.ProtectionDomain;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.ejb3.BeanContext;
+import org.jboss.injection.AbstractPropertyInjector;
+import org.jboss.injection.PojoInjector;
+import org.jboss.injection.lang.reflect.BeanProperty;
+import org.jboss.logging.Logger;
+
+/**
+ * Injects a jndi dependency into a bean property.
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
+ * @author Scott.Stark@jboss.org
+ * @version $Revision$
+ */
+public class JndiPropertyInjector extends AbstractPropertyInjector
+   implements PojoInjector
+{
+   private static final Logger log = Logger.getLogger(JndiPropertyInjector.class);
+   
+   private String jndiName;
+   private Context ctx;
+
+   public JndiPropertyInjector(BeanProperty property, String jndiName,
+         Context ctx)
+   {
+      super(property);
+      this.jndiName = jndiName;
+      this.ctx = ctx;
+   }
+
+   public void inject(BeanContext bctx)
+   {
+   }
+   
+   public Class<?> getInjectionClass()
+   {
+      return property.getType();
+   }
+   
+   public void inject(BeanContext bctx, Object instance)
+   {
+   }
+
+   public void inject(Object instance)
+   {
+      Object value = lookup(jndiName);
+      log.trace("injecting " + value + " from " + jndiName + " into " + property + " of " + instance);
+      try
+      {
+         property.set(instance, value);
+      }
+      catch(IllegalArgumentException e)
+      {
+         Class c1 = value.getClass();
+         StringBuffer buffer = new StringBuffer("Jndi value '"+jndiName+"' class info:");
+         displayClassInfo(c1, buffer);
+         log.debug("Failed to inject jndi property, "+buffer);
+         Class c2 = property.getType();
+         buffer.setLength(0);
+         buffer.append("Field "+property.getName()+" class info:");
+         displayClassInfo(c2, buffer);
+         log.debug(", "+buffer);
+         throw e;
+      }
+   }
+
+   protected Object lookup(String jndiName)
+   {
+      Object dependency = null;
+      boolean trace = log.isTraceEnabled();
+      try
+      {
+         if(trace)
+            log.trace("Looking for enc entry: "+jndiName);
+         dependency = ctx.lookup(jndiName);
+         if(trace)
+            log.trace("Success: "+dependency);
+      }
+      catch (NamingException e)
+      {
+         // Try as a global jndi name
+         if(trace)
+            log.trace("Failed enc lookup: "+e.getExplanation());
+         try
+         {
+            if(trace)
+               log.trace("Failed trying as global entry: "+jndiName);
+            InitialContext ictx = new InitialContext(ctx.getEnvironment());
+            dependency = ictx.lookup(jndiName);
+            if(trace)
+               log.trace("Success: "+dependency);
+         }
+         catch(NamingException e2)
+         {
+            if(trace)
+               log.trace("Failed global lookup: "+e2.getExplanation());
+         }
+
+         if(dependency == null)
+         {
+            Throwable cause = e;
+            while(cause.getCause() != null)
+               cause = cause.getCause();
+            throw new RuntimeException("Unable to inject jndi dependency: " + jndiName + " into property " + property + ": " + cause.getMessage(), e);
+         }
+      }
+      return dependency;
+   }
+
+   static void displayClassInfo(Class clazz, StringBuffer results)
+   {
+      // Print out some codebase info for the ProbeHome
+      ClassLoader cl = clazz.getClassLoader();
+      results.append("\n"+clazz.getName()+".ClassLoader="+cl);
+      CodeSource clazzCS = clazz.getProtectionDomain().getCodeSource();
+      if( clazzCS != null )
+         results.append("\n++++CodeSource: "+clazzCS);
+      else
+         results.append("\n++++Null CodeSource");
+
+      results.append("\nImplemented Interfaces:");
+      Class[] ifaces = clazz.getInterfaces();
+      for(int i = 0; i < ifaces.length; i ++)
+      {
+         results.append("\n++"+ifaces[i]);
+         ClassLoader loader = ifaces[i].getClassLoader();
+         results.append("\n++++ClassLoader: "+loader);
+         ProtectionDomain pd = ifaces[i].getProtectionDomain();
+         CodeSource cs = pd.getCodeSource();
+         if( cs != null )
+            results.append("\n++++CodeSource: "+cs);
+         else
+            results.append("\n++++Null CodeSource");
+      }
+   }
+
+}

Property changes on: src/main/org/jboss/ejb3/client/JndiPropertyInjector.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/client/URLInjectorFactory.java
===================================================================
--- src/main/org/jboss/ejb3/client/URLInjectorFactory.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/client/URLInjectorFactory.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.client;
+
+import java.net.URL;
+
+import org.jboss.injection.Injector;
+import org.jboss.injection.InjectorFactory;
+import org.jboss.injection.lang.reflect.BeanProperty;
+
+/**
+ * @author Scott.Stark@jboss.org
+ * @version $Revision$
+ */
+public class URLInjectorFactory
+   implements InjectorFactory<URLPropertyInjector>
+{
+   private URL url;
+
+   URLInjectorFactory(URL url)
+   {
+      this.url = url;
+   }
+
+   public URLPropertyInjector create(BeanProperty property)
+   {
+      return new URLPropertyInjector(property, url);
+   }
+
+}

Property changes on: src/main/org/jboss/ejb3/client/URLInjectorFactory.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/client/NoopDependencyPolicy.java
===================================================================
--- src/main/org/jboss/ejb3/client/NoopDependencyPolicy.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/client/NoopDependencyPolicy.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,99 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.client;
+
+import java.util.Collections;
+import java.util.Set;
+
+import org.jboss.beans.metadata.spi.DemandMetaData;
+import org.jboss.beans.metadata.spi.DependencyMetaData;
+import org.jboss.beans.metadata.spi.SupplyMetaData;
+import org.jboss.ejb3.deployers.JBoss5DependencyPolicy;
+import org.jboss.ejb3.javaee.JavaEEComponent;
+
+/**
+ * @author Scott.Stark@jboss.org
+ * @version $Revision$
+ */
+public class NoopDependencyPolicy
+   extends JBoss5DependencyPolicy
+{
+
+   public NoopDependencyPolicy(JavaEEComponent component)
+   {
+      super(component);
+   }
+
+   @Override
+   public void addDependency(Class<?> businessInterface)
+   {
+   }
+
+   @Override
+   public void addDependency(DemandMetaData dependency)
+   {
+   }
+
+   @Override
+   public void addDependency(DependencyMetaData dependency)
+   {
+   }
+
+   @Override
+   public void addDependency(String ejbLink, Class<?> businessInterface)
+   {
+   }
+
+   @Override
+   public void addDependency(String dependency)
+   {
+   }
+
+   @Override
+   public void addJNDIName(String name)
+   {
+   }
+
+   @Override
+   public void addSupply(Class<?> businessInterface)
+   {
+   }
+
+   @Override
+   public Set<DemandMetaData> getDemands()
+   {
+      return Collections.emptySet();
+   }
+
+   @Override
+   public Set<DependencyMetaData> getDependencies()
+   {
+      return Collections.emptySet();
+   }
+
+   @Override
+   public Set<SupplyMetaData> getSupplies()
+   {
+      return Collections.emptySet();
+   }
+
+}

Property changes on: src/main/org/jboss/ejb3/client/NoopDependencyPolicy.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/client/ClientEJBHandler.java
===================================================================
--- src/main/org/jboss/ejb3/client/ClientEJBHandler.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/client/ClientEJBHandler.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,175 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.client;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Map;
+
+import javax.ejb.EJB;
+
+import org.jboss.injection.AbstractHandler;
+import org.jboss.injection.InjectionContainer;
+import org.jboss.injection.Injector;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.javaee.spec.AbstractEJBReferenceMetaData;
+import org.jboss.metadata.javaee.spec.AnnotatedEJBReferenceMetaData;
+import org.jboss.metadata.javaee.spec.AnnotatedEJBReferencesMetaData;
+import org.jboss.metadata.javaee.spec.EJBReferenceMetaData;
+import org.jboss.metadata.javaee.spec.RemoteEnvironment;
+
+/**
+ * @author Scott.Stark@jboss.org
+ * @version $Revision$
+ */
+public class ClientEJBHandler<X extends RemoteEnvironment>
+   extends AbstractHandler<X>
+{
+   private static final Logger log = Logger.getLogger(ClientEJBHandler.class);
+
+   public void loadXml(X xml, InjectionContainer container)
+   {
+      if (xml != null)
+      {
+         log.trace("ejbRefs = " + xml.getEjbReferences());
+         try
+         {
+         if (xml.getAnnotatedEjbReferences() != null)
+            loadEjbRefXml(xml.getAnnotatedEjbReferences(), container);
+         if (xml.getEjbReferences() != null)
+            loadEjbRefXml(xml.getEjbReferences(), container);
+         }
+         catch(Exception e)
+         {
+            throw new IllegalStateException(e);
+         }
+      }
+   }
+
+   public void handleClassAnnotations(Class<?> clazz, InjectionContainer container)
+   {
+      throw new IllegalStateException("Annotations are not handled");
+   }
+   public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+   {
+      throw new IllegalStateException("Annotations are not handled");
+   }
+   public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+   {
+      throw new IllegalStateException("Annotations are not handled");
+   }
+
+   protected void loadEjbRefXml(AnnotatedEJBReferencesMetaData refs,
+         InjectionContainer container)
+      throws Exception
+   {
+      for (AnnotatedEJBReferenceMetaData ref : refs)
+      {
+         String interfaceName = ref.getBeanInterface().getName();
+         String errorType = "@EJB";
+
+         ejbRefXml(ref, interfaceName, container, errorType);
+      }      
+   }
+
+   protected void loadEjbRefXml(Collection<EJBReferenceMetaData> refs, InjectionContainer container)
+      throws Exception
+   {
+      for (EJBReferenceMetaData ref : refs)
+      {
+         String interfaceName = ref.getRemote();
+         String errorType = "<ejb-ref>";
+
+         ejbRefXml(ref, interfaceName, container, errorType);
+      }
+   }
+
+   protected void ejbRefXml(AbstractEJBReferenceMetaData ref, String interfaceName, InjectionContainer container, String errorType)
+      throws Exception
+   {
+      String encName = "env/" + ref.getEjbRefName();
+      Utils.injectionTarget(encName, ref, container);
+
+      /*
+      String mappedName = ref.getMappedName();
+      if (mappedName != null && mappedName.equals(""))
+         mappedName = null;
+      if(mappedName == null && ref.getResolvedJndiName() != null)
+         mappedName = ref.getResolvedJndiName();
+
+      if(mappedName == null)
+         throw new IllegalStateException(ref+" has no mapped name");
+      // Handle the injection targets
+      ClassLoader loader = container.getClassloader();
+      Set<ResourceInjectionTargetMetaData> targets = ref.getInjectionTargets();
+      if(targets != null)
+      {
+         for(ResourceInjectionTargetMetaData target : targets)
+         {
+            String className = target.getInjectionTargetClass();
+            String targetName = target.getInjectionTargetName();
+            Class<?> c = loader.loadClass(className);
+            AccessibleObject ao = Utils.getAccessibleObject(c, targetName);
+            BeanProperty prop = BeanPropertyFactory.create(ao);
+            JndiPropertyInjector propInjector = new JndiPropertyInjector(prop, encName, container.getEnc());
+            container.getInjectors().add(propInjector);
+         }
+      }
+      else
+      {
+         log.warn("No injection targets seen for: "+ref);
+      }
+      */
+   }
+
+   protected String getEncName(EJB ref, Field field)
+   {
+      String encName = ref.name();
+      if (encName == null || encName.equals(""))
+      {
+         encName = Utils.getEncName(field);
+      }
+      else
+      {
+         encName = "env/" + encName;
+      }
+      return encName;
+   }
+   
+   protected String getEncName(EJB ref, Method method)
+   {
+      String encName = ref.name();
+      if (encName == null || encName.equals(""))
+      {
+         encName = Utils.getEncName(method);
+      }
+      else
+      {
+         encName = "env/" + encName;
+      }
+      return encName;
+   }
+
+}

Property changes on: src/main/org/jboss/ejb3/client/ClientEJBHandler.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/client/ClientJavaEEComponent.java
===================================================================
--- src/main/org/jboss/ejb3/client/ClientJavaEEComponent.java	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/client/ClientJavaEEComponent.java	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.client;
+
+import org.jboss.ejb3.javaee.AbstractJavaEEComponent;
+import org.jboss.ejb3.javaee.JavaEEModule;
+import org.jboss.ejb3.javaee.SimpleJavaEEModule;
+
+/**
+ * @author Scott.Stark@jboss.org
+ * @version $Revision$
+ */
+public class ClientJavaEEComponent extends AbstractJavaEEComponent
+{
+   public ClientJavaEEComponent(String clientName)
+   {
+      super(new SimpleJavaEEModule(clientName));
+   }
+
+   @Override
+   public String createObjectName(String unitName, String ejbName)
+   {
+      return "org.jboss.client:jar="+unitName;
+   }
+
+   @Override
+   public String createObjectName(String ejbName)
+   {
+      return "org.jboss.client:jar="+ejbName;
+   }
+
+}

Property changes on: src/main/org/jboss/ejb3/client/ClientJavaEEComponent.java
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: src/main/org/jboss/ejb3/client/package.html
===================================================================
--- src/main/org/jboss/ejb3/client/package.html	(.../trunk/ejb3)	(revision 0)
+++ src/main/org/jboss/ejb3/client/package.html	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,9 @@
+<html>
+	<head>
+		<title>org.jboss.ejb3.client</title>
+	</head>
+	<body>
+		This package contains all classes needed for running a client container.
+		(Java EE 5 Chapter 9, EJB3 Chapter 15)
+	</body>
+</html>
\ No newline at end of file

Property changes on: src/main/org/jboss/ejb3/client/package.html
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native


Property changes on: src/resources/test/appclient/Manifest
___________________________________________________________________
Deleted: svn:keywords
   - Author Date Id Revision
Deleted: svn:eol-style
   - native

Index: src/resources/META-INF/jpa-deployers-jboss-beans.xml
===================================================================
--- src/resources/META-INF/jpa-deployers-jboss-beans.xml	(.../trunk/ejb3)	(revision 97484)
+++ src/resources/META-INF/jpa-deployers-jboss-beans.xml	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -3,9 +3,9 @@
   vi:ts=3:sw=3:expandtab
 -->
 <deployment xmlns="urn:jboss:bean-deployer:2.0">
-   <!-- Install the default CEMFBuilder, this will build a JPA 1 compliant
-        container entity manager factory. -->
-   <bean name="CEMFBuilder" class="org.jboss.jpa.builder.DefaultCEMFBuilder"/>
+   <!-- Install the JPA 2 CEMFBuilder, this will build a container entity manager factory with
+        bean validation enabled. -->
+   <bean name="CEMFBuilder" class="org.jboss.as.jpa.builder.JPA2CEMFBuilder"/>
 
    <bean name="DataSourceDependencyResolver" class="org.jboss.as.jpa.resolvers.JBossASDataSourceDependencyResolver"/>
    

Property changes on: src/resources/META-INF/jpa-deployers-jboss-beans.xml
___________________________________________________________________
Deleted: svn:eol-style
   - native

Index: src/resources/META-INF/ejb3-deployers-jboss-beans.xml
===================================================================
--- src/resources/META-INF/ejb3-deployers-jboss-beans.xml	(.../trunk/ejb3)	(revision 97484)
+++ src/resources/META-INF/ejb3-deployers-jboss-beans.xml	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -104,6 +104,7 @@
             <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>
@@ -120,7 +121,6 @@
             <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>
Index: build.sh
===================================================================
--- build.sh	(.../trunk/ejb3)	(revision 97484)
+++ build.sh	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -3,7 +3,7 @@
 ##                                                                          ##
 ##  This is the main entry point for the build system.                      ##
 ##                                                                          ##
-##  Users should execute this file rather than 'mvn' to ensure              ##
+##  Users should be sure to execute this file rather than 'ant' to ensure   ##
 ##  the correct version is being used with the correct configuration.       ##
 ##                                                                          ##
 ### ====================================================================== ###
@@ -15,18 +15,21 @@
 GREP="grep"
 ROOT="/"
 
-# Ignore user's MAVEN_HOME if it is set
-MAVEN_HOME=""
+# Ignore user's ANT_HOME if it is set
+ANT_HOME=""
 
-# the default search path for maven
-MAVEN_SEARCH_PATH="\
+# the default search path for ant
+ANT_SEARCH_PATH="\
     tools
-    tools/maven \
-    tools/apache/maven \
-    maven"
+    tools/ant \
+    tools/apache/ant \
+    ant"
 
+# the default build file name
+ANT_BUILD_FILE="build.xml"
+
 # the default arguments
-MVN_OPTIONS=""
+ANT_OPTIONS="--noconfig -find $ANT_BUILD_FILE"
 
 # Use the maximum available, or set MAX_FD != -1 to use that
 MAX_FD="maximum"
@@ -73,11 +76,11 @@
 search() {
     search="$*"
     for d in $search; do
-	MAVEN_HOME="`pwd`/$d"
-	MVN="$MAVEN_HOME/bin/mvn"
-	if [ -x "$MVN" ]; then
+	ANT_HOME="`pwd`/$d"
+	ANT="$ANT_HOME/bin/ant"
+	if [ -x "$ANT" ]; then
 	    # found one
-	    echo $MAVEN_HOME
+	    echo $ANT_HOME
 	    break
 	fi
     done
@@ -109,17 +112,17 @@
     fi
 
     # try the search path
-    MAVEN_HOME=`search $MAVEN_SEARCH_PATH`
+    ANT_HOME=`search $ANT_SEARCH_PATH`
 
     # try looking up to root
-    if [ "x$MAVEN_HOME" = "x" ]; then
+    if [ "x$ANT_HOME" = "x" ]; then
 	target="build"
 	_cwd=`pwd`
 
-	while [ "x$MAVEN_HOME" = "x" ] && [ "$cwd" != "$ROOT" ]; do
+	while [ "x$ANT_HOME" = "x" ] && [ "$cwd" != "$ROOT" ]; do
 	    cd ..
 	    cwd=`pwd`
-	    MAVEN_HOME=`search $MAVEN_SEARCH_PATH`
+	    ANT_HOME=`search $ANT_SEARCH_PATH`
 	done
 
 	# make sure we get back
@@ -131,40 +134,40 @@
 
 	# complain if we did not find anything
 	if [ "$found" != "true" ]; then
-	    die "Could not locate Maven; check \$MVN or \$MAVEN_HOME."
+	    die "Could not locate Ant; check \$ANT or \$ANT_HOME."
 	fi
     fi
 
     # make sure we have one
-    MVN=$MAVEN_HOME/bin/mvn
-    if [ ! -x "$MVN" ]; then
-	die "Maven file is not executable: $MVN"
+    ANT=$ANT_HOME/bin/ant
+    if [ ! -x "$ANT" ]; then
+	die "Ant file is not executable: $ANT"
     fi
 
     # need to specify planet57/buildmagic protocol handler package
-    MVN_OPTS="-Djava.protocol.handler.pkgs=org.jboss.net.protocol"
+    ANT_OPTS="-Djava.protocol.handler.pkgs=org.jboss.net.protocol"
 
     # setup some build properties
-    MVN_OPTS="$MVN_OPTS -Dbuild.script=$0"
+    ANT_OPTS="$ANT_OPTS -Dbuild.script=$0"
 
+    # add some more memory
+    ANT_OPTS="$ANT_OPTS -Xmx512m"
+
+    # prevent default config beeing used
+    ANT_OPTIONS="--noconfig $ANT_OPTIONS"
+
     # change to the directory where the script lives so users are not forced
     # to be in the same directory as build.xml
     cd $DIRNAME
 
-    MVN_GOAL=$@
-    if [ -z "$MVN_GOAL" ]; then
-      MVN_GOAL="install"
-    fi
-    
-    # export some stuff for maven
-    export MVN MAVEN_HOME MVN_OPTS MVN_GOAL
+    # export some stuff for ant
+    export ANT ANT_HOME ANT_OPTS
 
-    
     # execute in debug mode, or simply execute
-    if [ "x$MVN_DEBUG" != "x" ]; then
-	  /bin/sh -x $MVN $MVN_OPTIONS $MVN_GOAL
+    if [ "x$ANT_DEBUG" != "x" ]; then
+	/bin/sh -x $ANT $ANT_OPTIONS "$@"
     else
-	  exec $MVN $MVN_OPTIONS $MVN_GOAL
+	exec $ANT $ANT_OPTIONS "$@"
     fi
 }
 
@@ -173,3 +176,4 @@
 ##
 
 main "$@"
+
Index: component-info.xml
===================================================================
--- component-info.xml	(.../trunk/ejb3)	(revision 0)
+++ component-info.xml	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -0,0 +1,26 @@
+<project name="ejb3-component-info">
+   <!-- ============================================================ -->
+   <!-- ejb3                                                        -->
+   <!-- ============================================================ -->
+
+   <component id="ejb3"
+              module="jboss-ejb3"
+              version="5.0-SNAPSHOT"
+   >
+      <artifact id="jboss-ejb3.jar"/>   
+      <artifact id="jboss-annotations-ejb3.jar"/>
+      <artifact id="embeddable" artifacttype="dir"/> 
+      <artifact id="ejb3.deployer" artifacttype="dir"/>             
+      <artifact id="lib" artifacttype="dir"/>             
+      <artifact id="conf" artifacttype="dir"/> 
+      <artifact id="ejb3-clustered-sfsbcache-service.xml" outputpath="resources"/>
+      <artifact id="ejb3-entity-cache-service.xml" outputpath="resources"/>
+      <artifact id="ejb3-interceptors-aop.xml" outputpath="resources"/>
+      <artifact id="persistence.properties" outputpath="resources/META-INF"/>
+      <artifact id="default.persistence.properties" outputpath="resources/META-INF"/>
+      <export>
+         <include input="jboss-ejb3.jar"/> 
+         <include input="jboss-annotations-ejb3.jar"/>
+      </export>
+   </component>
+</project>

Property changes on: component-info.xml
___________________________________________________________________
Added: svn:eol-style
   + native
Added: svn:keywords
   + Author Date Id Revision

Index: pom.xml
===================================================================
--- pom.xml	(.../trunk/ejb3)	(revision 97484)
+++ pom.xml	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -1,12 +1,10 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-  
   <parent>
     <groupId>org.jboss.jbossas</groupId>
     <artifactId>jboss-as-parent</artifactId>
-    <version>6.0.0-SNAPSHOT</version>
+    <version>6.0.0.M1</version>
   </parent>
-  
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.jboss.jbossas</groupId>
   <artifactId>jboss-as-ejb3</artifactId>
@@ -16,7 +14,7 @@
   <description>JBoss Application Server (ejb3 module)</description>
   
   <build>
-    <finalName>${artifactId}</finalName>
+    <sourceDirectory>src/main</sourceDirectory>
     <resources>
       <resource>
         <directory>src/resources</directory>
@@ -25,16 +23,6 @@
     <plugins>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-compiler-plugin</artifactId>
-        <configuration>
-          <!-- Exclude all test sources until they are fixed. -->
-          <testExcludes>
-            <testExclude>**/*</testExclude>
-          </testExcludes>
-        </configuration>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-assembly-plugin</artifactId>
         <executions>
           <execution>
@@ -49,68 +37,6 @@
           <descriptorSourceDirectory>src/assembly</descriptorSourceDirectory>
         </configuration>
       </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-antrun-plugin</artifactId>
-        <executions>
-          <execution>
-            <id>create-output</id>
-            <goals>
-              <goal>run</goal>
-            </goals>
-            <phase>package</phase>
-            <configuration>
-              <tasks>
-                                
-                <mkdir dir="target/etc"/>
-                <copy todir="target/etc" filtering="yes">
-                  <fileset dir="src/etc">
-                    <include name="**"/>
-                  </fileset>
-                </copy>
-                
-                <mkdir dir="target/resources"/>
-                <copy todir="target/resources" filtering="yes">
-                  <fileset dir="src/resources">
-                    <include name="**"/>
-                  </fileset>
-                </copy>
-                                
-                <unjar src="${maven.dependency.org.jboss.ejb3.jboss-ejb3-core.jar.path}" dest="target/resources">
-                  <patternset>
-                    <include name="*.xml" />
-                    <exclude name="META-INF/*.xml" />
-                    <include name="META-INF/*.properties" />
-                  </patternset>
-                </unjar>
-                
-                <mkdir dir="target/ejb3.deployer"/>
-                <copy todir="target/ejb3.deployer">
-                   <fileset dir="target">
-                      <include name="jboss-as-ejb3-deployer.jar"/>
-                   </fileset>
-                   <fileset dir="target/resources">
-                      <include name="META-INF/ejb3-deployers-jboss-beans.xml"/>
-                      <include name="META-INF/jpa-deployers-jboss-beans.xml"/>
-                   </fileset>
-                   <fileset dir="target/resources">
-                      <include name="META-INF/persistence.properties"/>
-                   </fileset>
-                </copy>
-                
-                <copy todir="target">
-                   <fileset dir="target/resources">
-                      <include name="ejb3-container-jboss-beans.xml"/>
-                      <include name="ejb3-connectors-jboss-beans.xml"/>
-                      <include name="ejb3-interceptors-aop.xml"/>
-                   </fileset>
-                </copy>
-                
-             </tasks>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
     </plugins>
   </build>
   
@@ -141,11 +67,6 @@
     </dependency>
     
     <dependency>
-      <groupId>javax.transaction</groupId>
-      <artifactId>jta</artifactId>
-    </dependency>
-    
-    <dependency>
       <groupId>org.jboss.logging</groupId>
       <artifactId>jboss-logging-spi</artifactId>
     </dependency>
@@ -165,6 +86,11 @@
       <groupId>org.hibernate</groupId>
       <artifactId>hibernate-entitymanager</artifactId>
     </dependency>
+
+    <dependency>
+      <groupId>javax.validation</groupId>
+      <artifactId>validation-api</artifactId>
+    </dependency>
     
     <dependency>
       <groupId>org.jboss</groupId>
@@ -201,17 +127,6 @@
     <dependency>
       <groupId>org.jboss.ejb3</groupId>
       <artifactId>jboss-ejb3-as-int</artifactId>
-      <exclusions>
-        <!-- JBAS-679, may be removed when as-int is >= 1.1.5 -->
-        <exclusion>
-          <groupId>org.jboss.ejb3</groupId>
-          <artifactId>jboss-ejb3-proxy</artifactId>
-        </exclusion>
-        <exclusion>
-          <groupId>org.jboss.cache</groupId>
-          <artifactId>jbosscache-core</artifactId>
-        </exclusion>
-      </exclusions>
     </dependency>
     
     <dependency>
@@ -241,8 +156,8 @@
     </dependency>
     
     <dependency>
-      <groupId>org.jboss.mx</groupId>
-      <artifactId>jboss-j2se</artifactId>
+      <groupId>org.jboss.jbossas</groupId>
+      <artifactId>jboss-as-j2se</artifactId>
     </dependency>
     
     <dependency>
@@ -284,7 +199,7 @@
       <groupId>org.jboss.integration</groupId>
       <artifactId>jboss-corba-ots-spi</artifactId>
     </dependency>
-    
+
   </dependencies>
   
 </project>
Index: build-test.xml
===================================================================
--- build-test.xml	(.../trunk/ejb3)	(revision 97484)
+++ build-test.xml	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -190,7 +190,7 @@
    <!-- The combined dependent module classpath -->
    <path id="dependentmodule.classpath">
       <path refid="jboss.jboss.javaee.classpath"/>
-      <path refid="jboss.mx.classpath"/>
+      <path refid="jboss.j2se.classpath"/>
       <path refid="jboss.aop.classpath"/>
       <path refid="jboss.aspects.classpath"/>
       <path refid="jboss.common.core.classpath"/>
Index: build.xml
===================================================================
--- build.xml	(.../trunk/ejb3)	(revision 97484)
+++ build.xml	(.../tags/JBoss_6_0_0_M1/ejb3)	(revision 97484)
@@ -86,6 +86,8 @@
          <path refid="jgroups.jgroups.classpath"/>
          <path refid="hibernate3.classpath"/>
          <path refid="ejb3-persistence.classpath"/>
+         <path refid="jboss.jboss.jpa.spi.classpath"/>
+         <path refid="jboss.jboss.jpa.impl.classpath"/>
          <path refid="javassist.classpath"/>
          <path refid="trove.classpath"/>
          <path refid="xdoclet.xdoclet.classpath"/>
@@ -116,8 +118,6 @@
          <path refid="jboss.jboss.ejb3.cache.classpath"/>
          <path refid="jboss.jboss.ejb3.common.classpath"/>
          <path refid="jboss.jboss.ejb3.core.classpath"/>
-	 <path refid="jboss.jboss.ejb3.endpoint.classpath" />
-	 <path refid="jboss.jboss.ejb3.endpoint.deployer.classpath" />
          <path refid="jboss.jboss.ejb3.ext.api.classpath" />
          <path refid="jboss.jboss.ejb3.ext.api.impl.classpath" />
          <path refid="jboss.jboss.ejb3.interceptors.classpath" />
@@ -128,6 +128,9 @@
          <path refid="jboss.jboss.jpa.deployers.classpath"/>
          <path refid="jboss.jboss.mdr.classpath"/>
          <path refid="jboss.jboss.reflect.classpath" />
+	 <path refid="jboss.jboss.ejb3.endpoint.classpath" />
+	 <path refid="jboss.jboss.ejb3.endpoint.deployer.classpath" />
+         <path refid="validation.api.classpath"/>
       </path>
 
       <!-- ======= -->
@@ -139,7 +142,7 @@
       <!-- The combined dependent module classpath -->
       <path id="dependentmodule.classpath">
          <path refid="jboss.jboss.javaee.classpath"/>
-         <path refid="jboss.mx.classpath"/>
+         <path refid="jboss.j2se.classpath"/>
          <path refid="jboss.aop.classpath"/>
          <path refid="jboss.cache.jbosscache.core.classpath"/>
          <path refid="jboss.aspects.classpath"/>
@@ -151,6 +154,7 @@
          <path refid="jboss.main.classpath"/>
          <path refid="jboss.system.classpath"/>
          <path refid="jboss.systemjmx.classpath"/>
+         <path refid="jboss.mbeans.classpath"/>
          <path refid="jboss.jnpserver.classpath"/>
          <path refid="jboss.jbosssx.classpath"/>
          <path refid="jboss.jboss.security.spi.classpath"/>

Property changes on: .
___________________________________________________________________
Modified: svn:ignore
   - output
build.log
.settings
run.tstamp
junit*.properties
temp
target
*.iml

   + output
build.log
.settings
run.tstamp
junit191723717.properties
junit*.properties
temp
target


