[jboss-cvs] JBossAS SVN: r97163 - in branches/JBPAPP_5_0: build and 14 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Nov 30 07:49:31 EST 2009


Author: wolfc
Date: 2009-11-30 07:49:29 -0500 (Mon, 30 Nov 2009)
New Revision: 97163

Added:
   branches/JBPAPP_5_0/ejb3/src/main/org/jboss/as/ejb3/deployers/
   branches/JBPAPP_5_0/ejb3/src/main/org/jboss/as/ejb3/deployers/EJBsDeployer.java
   branches/JBPAPP_5_0/ejb3/src/main/org/jboss/as/ejb3/deployers/IORDeployer.java
   branches/JBPAPP_5_0/ejb3/src/main/org/jboss/ejb3/iiop/
   branches/JBPAPP_5_0/ejb3/src/main/org/jboss/ejb3/iiop/BeanCorbaServant.java
   branches/JBPAPP_5_0/ejb3/src/main/org/jboss/ejb3/iiop/EJB3IIOPWebClassLoader.java
   branches/JBPAPP_5_0/ejb3/src/main/org/jboss/ejb3/iiop/IORFactory.java
   branches/JBPAPP_5_0/ejb3/src/resources/META-INF/ejb3-iiop-deployers-jboss-beans.xml
   branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/
   branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/TxTesterHome.java
   branches/JBPAPP_5_0/testsuite/src/resources/ejb3/iiop/
   branches/JBPAPP_5_0/testsuite/src/resources/ejb3/iiop/roles.properties
   branches/JBPAPP_5_0/testsuite/src/resources/ejb3/iiop/users.properties
Removed:
   branches/JBPAPP_5_0/ejb3/src/main/org/jboss/ejb3/iiop/BeanCorbaServant.java
   branches/JBPAPP_5_0/ejb3/src/main/org/jboss/ejb3/iiop/EJB3IIOPWebClassLoader.java
   branches/JBPAPP_5_0/ejb3/src/main/org/jboss/ejb3/iiop/IORFactory.java
   branches/JBPAPP_5_0/ejb3/src/test/org/jboss/ejb3/test/iiop/
Modified:
   branches/JBPAPP_5_0/aspects/.classpath
   branches/JBPAPP_5_0/build/build.xml
   branches/JBPAPP_5_0/ejb3/.classpath
   branches/JBPAPP_5_0/ejb3/build-test.xml
   branches/JBPAPP_5_0/ejb3/build.xml
   branches/JBPAPP_5_0/testsuite/.classpath
   branches/JBPAPP_5_0/testsuite/build.xml
   branches/JBPAPP_5_0/testsuite/imports/sections/ejb3.xml
   branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/HomedStatelessBean.java
   branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/HomedStatelessHome.java
   branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/MyServiceBean.java
   branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/MySession.java
   branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/MySessionBean.java
   branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/MyStateful.java
   branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/MyStatefulBean.java
   branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/MyStatefulHome.java
   branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/TxTester.java
   branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/TxTesterBean.java
   branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/unit/IiopRemoteUnitTestCase.java
Log:
JBPAPP-3135: re-enable IIOP for EJB 3

Modified: branches/JBPAPP_5_0/aspects/.classpath
===================================================================
--- branches/JBPAPP_5_0/aspects/.classpath	2009-11-30 12:23:57 UTC (rev 97162)
+++ branches/JBPAPP_5_0/aspects/.classpath	2009-11-30 12:49:29 UTC (rev 97163)
@@ -28,7 +28,7 @@
 	<classpathentry exported="true" kind="lib" path="/thirdparty/beanshell/lib/bsh.jar"/>
 	<classpathentry exported="true" kind="lib" path="/thirdparty/oswego-concurrent/lib/concurrent.jar"/>
 	<classpathentry kind="lib" path="/thirdparty/junit/lib/junit.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/test/lib/jboss-test.jar" sourcepath="/extra/work-clebert/workspaces/jtest/jboss-test/src"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/test/lib/jboss-test.jar" sourcepath="/thirdparty/jboss/test/lib/jboss-test-sources.jar"/>
 	<classpathentry exported="true" kind="lib" path="/thirdparty/jboss/aop/lib/pluggable-instrumentor.jar"/>
 	<classpathentry exported="true" kind="lib" path="/thirdparty/org/jboss/aspects/lib/jboss-remoting-aspects.jar" sourcepath="/thirdparty/org/jboss/aspects/lib/jboss-remoting-aspects-sources.jar"/>
 	<classpathentry exported="true" kind="lib" path="/thirdparty/org/jboss/aspects/lib/jboss-security-aspects.jar" sourcepath="/thirdparty/org/jboss/aspects/lib/jboss-security-aspects-sources.jar"/>

Modified: branches/JBPAPP_5_0/build/build.xml
===================================================================
--- branches/JBPAPP_5_0/build/build.xml	2009-11-30 12:23:57 UTC (rev 97162)
+++ branches/JBPAPP_5_0/build/build.xml	2009-11-30 12:49:29 UTC (rev 97163)
@@ -821,6 +821,7 @@
         <exclude name="deploy/juddi-service.sar/**"/>
         <exclude name="deploy/messaging/**"/>
         <exclude name="deployers/clustering-deployer-jboss-beans.xml"/>        
+        <exclude name="deployers/ejb3.deployer/META-INF/ejb3-iiop-deployers-jboss-beans.xml"/>        
       </fileset>
     </copy>
     <!-- leave the empty default/lib directory there --> 

Modified: branches/JBPAPP_5_0/ejb3/.classpath
===================================================================
--- branches/JBPAPP_5_0/ejb3/.classpath	2009-11-30 12:23:57 UTC (rev 97162)
+++ branches/JBPAPP_5_0/ejb3/.classpath	2009-11-30 12:49:29 UTC (rev 97163)
@@ -21,11 +21,19 @@
 	<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-common/lib/jboss-ejb3-common.jar" sourcepath="/thirdparty/jboss/jboss-ejb3-common/lib/jboss-ejb3-common-sources.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/jboss/jboss-ejb3-endpoint/lib/jboss-ejb3-endpoint.jar" sourcepath="/thirdparty/jboss/jboss-ejb3-endpoint/lib/jboss-ejb3-endpoint-sources.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-ejb3-proxy-spi/lib/jboss-ejb3-proxy-spi.jar" sourcepath="/thirdparty/jboss/jboss-ejb3-proxy-spi/lib/jboss-ejb3-proxy-spi-sources.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-ejb3-proxy-impl/lib/jboss-ejb3-proxy-impl.jar" sourcepath="/thirdparty/jboss/jboss-ejb3-proxy-impl/lib/jboss-ejb3-proxy-impl-sources.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-ejb3-endpoint-deployer/lib/jboss-ejb3-endpoint-deployer.jar" sourcepath="/thirdparty/jboss/jboss-ejb3-endpoint-deployer/lib/jboss-ejb3-endpoint-deployer-sources.jar"/>
 	<classpathentry kind="output" path="output/eclipse-classes"/>
 </classpath>

Modified: branches/JBPAPP_5_0/ejb3/build-test.xml
===================================================================
--- branches/JBPAPP_5_0/ejb3/build-test.xml	2009-11-30 12:23:57 UTC (rev 97162)
+++ branches/JBPAPP_5_0/ejb3/build-test.xml	2009-11-30 12:49:29 UTC (rev 97163)
@@ -434,25 +434,8 @@
       </copy>
    </target>
 
-   <target name="iiop"
-      description="Builds iiop.jar."
-      depends="compile-classes">
+   <target name="jars" depends="appclient"/>
 
-      <mkdir dir="${build.lib}"/>
-
-      <jar jarfile="${build.lib}/iiop.jar">
-         <fileset dir="${build.classes}">
-            <include name="org/jboss/ejb3/test/iiop/*.class"/>
-         </fileset>
-         <fileset dir="${resources}/test">
-            <include name="users.properties"/>
-            <include name="roles.properties"/>
-         </fileset>
-      </jar>
-   </target>
-   
-   <target name="jars" depends="appclient, iiop"/>
-
    <target name="test" depends="init" if="test"
       description="Execute all tests in the given test directory.">
       <!-- For use when we do not need to pass in any special jvmargs; forks the test process -->

Modified: branches/JBPAPP_5_0/ejb3/build.xml
===================================================================
--- branches/JBPAPP_5_0/ejb3/build.xml	2009-11-30 12:23:57 UTC (rev 97162)
+++ branches/JBPAPP_5_0/ejb3/build.xml	2009-11-30 12:49:29 UTC (rev 97163)
@@ -326,6 +326,7 @@
             
             <include name="org/jboss/ejb3/deployers/**"/>
             <include name="org/jboss/ejb3/clientmodule/*"/>
+            <include name="org/jboss/ejb3/iiop/*"/>
          </fileset>
       </jar>
 			
@@ -345,6 +346,7 @@
          </fileset>
          <fileset dir="${resources}">
             <include name="META-INF/ejb3-deployers-jboss-beans.xml"/>
+            <include name="META-INF/ejb3-iiop-deployers-jboss-beans.xml"/>
             <include name="META-INF/jpa-deployers-jboss-beans.xml"/>
          </fileset>
          <fileset dir="output/resources">

Added: branches/JBPAPP_5_0/ejb3/src/main/org/jboss/as/ejb3/deployers/EJBsDeployer.java
===================================================================
--- branches/JBPAPP_5_0/ejb3/src/main/org/jboss/as/ejb3/deployers/EJBsDeployer.java	                        (rev 0)
+++ branches/JBPAPP_5_0/ejb3/src/main/org/jboss/as/ejb3/deployers/EJBsDeployer.java	2009-11-30 12:49:29 UTC (rev 97163)
@@ -0,0 +1,135 @@
+/*
+ * 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.deployers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractComponentDeployer;
+import org.jboss.deployers.spi.deployer.helpers.AbstractDeploymentVisitor;
+import org.jboss.deployers.spi.deployer.helpers.DeploymentVisitor;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.ejb3.common.deployers.spi.AttachmentNames;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+
+/**
+ * Create components out of EJB 3 JBossMetaData.
+ * 
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class EJBsDeployer extends AbstractComponentDeployer<JBossMetaData, JBossEnterpriseBeanMetaData>
+{
+   private static final Logger log = Logger.getLogger(EJBsDeployer.class);
+   
+   private static final JBossDeploymentVisitor deploymentVisitor = new JBossDeploymentVisitor();
+   
+   /**
+    * 
+    */
+   public EJBsDeployer()
+   {
+      // Since we don't set component visitor
+      addInput(deploymentVisitor.getVisitorType());
+      setOutput(deploymentVisitor.getComponentType());
+      
+      // for ordering
+      addInput(AttachmentNames.PROCESSED_METADATA);
+      
+      setDeploymentVisitor(deploymentVisitor);
+   }
+   
+   private static class JBossDeploymentVisitor extends AbstractDeploymentVisitor<JBossEnterpriseBeanMetaData, JBossMetaData>
+   {
+      @Override
+      public Class<JBossEnterpriseBeanMetaData> getComponentType()
+      {
+         return JBossEnterpriseBeanMetaData.class;
+      }
+
+      @Override
+      protected List<? extends JBossEnterpriseBeanMetaData> getComponents(JBossMetaData deployment)
+      {
+         return new ArrayList<JBossEnterpriseBeanMetaData>(deployment.getEnterpriseBeans());
+      }
+
+      @Override
+      protected String getComponentName(JBossEnterpriseBeanMetaData attachment)
+      {
+         return JBossEnterpriseBeanMetaData.class.getName() + "." + attachment.getEjbName();
+      }
+
+      public Class<JBossMetaData> getVisitorType()
+      {
+         return JBossMetaData.class;
+      }
+   }
+   
+   @Override
+   protected <U> void deploy(DeploymentUnit unit, DeploymentVisitor<U> visitor) throws DeploymentException
+   {
+      // I only want a single attachment deployed
+      
+      U deployment = unit.getAttachment(visitor.getVisitorType());
+      try
+      {
+         visitor.deploy(unit, deployment);
+      }
+      catch(Throwable t)
+      {
+         throw DeploymentException.rethrowAsDeploymentException("Error deploying: " + unit.getName(), t);
+      }
+   }
+   
+   @Override
+   public void internalDeploy(DeploymentUnit unit) throws DeploymentException
+   {
+      if(!isValid(unit))
+         return;
+      
+      log.debug("Processing " + unit);
+      
+      super.internalDeploy(unit);
+   }
+   
+   @Override
+   public void internalUndeploy(DeploymentUnit unit)
+   {
+      // if we don't check then undeploy will be done for stuff that was never deployed.
+      if(!isValid(unit))
+         return;
+      
+      super.internalUndeploy(unit);
+   }
+   
+   protected boolean isValid(DeploymentUnit unit)
+   {
+      // for good measure, we only do this for EJB 3 deployments
+      JBossMetaData md = unit.getAttachment(JBossMetaData.class);
+      if(md == null || !md.isEJB3x())
+         return false;
+      return true;
+   }
+}

Added: branches/JBPAPP_5_0/ejb3/src/main/org/jboss/as/ejb3/deployers/IORDeployer.java
===================================================================
--- branches/JBPAPP_5_0/ejb3/src/main/org/jboss/as/ejb3/deployers/IORDeployer.java	                        (rev 0)
+++ branches/JBPAPP_5_0/ejb3/src/main/org/jboss/as/ejb3/deployers/IORDeployer.java	2009-11-30 12:49:29 UTC (rev 97163)
@@ -0,0 +1,84 @@
+/*
+ * 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.deployers;
+
+import org.jboss.beans.metadata.api.annotations.Inject;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.ejb3.endpoint.deployers.EJBIdentifier;
+import org.jboss.ejb3.iiop.IORFactory;
+import org.jboss.ejb3.session.SessionContainer;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+
+/**
+ * For each session bean that has a remote EJB 2.1 view deploy an IOR into CorbaNaming.
+ * 
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class IORDeployer extends AbstractSimpleRealDeployer<JBossEnterpriseBeanMetaData>
+{
+   private EJBIdentifier ejbIdentifier;
+
+   public IORDeployer()
+   {
+      super(JBossEnterpriseBeanMetaData.class);
+      
+      setComponentsOnly(true);
+      addOutput(BeanMetaData.class);
+   }
+
+   @Override
+   public void deploy(DeploymentUnit unit, JBossEnterpriseBeanMetaData bmd) throws DeploymentException
+   {
+      if(!(bmd instanceof JBossSessionBeanMetaData))
+         return;
+      
+      JBossSessionBeanMetaData sbmd = (JBossSessionBeanMetaData) bmd;
+      
+      String homeInterface = sbmd.getHome();
+      if(homeInterface == null)
+         return;
+      
+      String ejbName = sbmd.getEjbName();
+      // TODO: how do we know it's in the parent?
+      String ejbContainerBeanName = ejbIdentifier.identifyEJB(unit.getParent(), ejbName);
+      String name = ejbContainerBeanName + "_IORFactory";
+      BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(name, IORFactory.class.getName());
+      ValueMetaData value = builder.createInject(ejbContainerBeanName);
+      builder.addConstructorParameter(SessionContainer.class.getName(), value);
+      
+      // just use the the parent and don't ask though questions
+      unit.getParent().addAttachment(BeanMetaData.class.getName() + "." + name, builder.getBeanMetaData(), BeanMetaData.class);
+   }
+   
+   @Inject
+   public void setEJBIdentifier(EJBIdentifier ejbIdentifier)
+   {
+      this.ejbIdentifier = ejbIdentifier;
+   }
+}

Copied: branches/JBPAPP_5_0/ejb3/src/main/org/jboss/ejb3/iiop (from rev 84680, branches/Branch_5_x/ejb3/src/main/org/jboss/ejb3/iiop)

Deleted: branches/JBPAPP_5_0/ejb3/src/main/org/jboss/ejb3/iiop/BeanCorbaServant.java
===================================================================
--- branches/Branch_5_x/ejb3/src/main/org/jboss/ejb3/iiop/BeanCorbaServant.java	2009-02-24 21:51:50 UTC (rev 84680)
+++ branches/JBPAPP_5_0/ejb3/src/main/org/jboss/ejb3/iiop/BeanCorbaServant.java	2009-11-30 12:49:29 UTC (rev 97163)
@@ -1,264 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.iiop;
-
-import java.lang.reflect.Method;
-import java.security.Principal;
-import java.util.HashMap;
-
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-
-import org.jboss.ejb3.Container;
-import org.jboss.ejb3.session.SessionContainer;
-import org.jboss.iiop.CorbaORB;
-import org.jboss.iiop.csiv2.SASCurrent;
-import org.jboss.iiop.rmi.AttributeAnalysis;
-import org.jboss.iiop.rmi.InterfaceAnalysis;
-import org.jboss.iiop.rmi.OperationAnalysis;
-import org.jboss.iiop.rmi.RmiIdlUtil;
-import org.jboss.iiop.rmi.marshal.strategy.SkeletonStrategy;
-import org.jboss.iiop.tm.InboundTransactionCurrent;
-import org.jboss.invocation.iiop.ReferenceData;
-import org.jboss.logging.Logger;
-import org.jboss.security.SecurityAssociation;
-import org.jboss.security.SimplePrincipal;
-import org.jboss.tm.TransactionManagerLocator;
-import org.omg.CORBA.BAD_OPERATION;
-import org.omg.CORBA.InterfaceDef;
-import org.omg.CORBA.SystemException;
-import org.omg.CORBA.ORBPackage.InvalidName;
-import org.omg.CORBA.portable.InputStream;
-import org.omg.CORBA.portable.InvokeHandler;
-import org.omg.CORBA.portable.OutputStream;
-import org.omg.CORBA.portable.ResponseHandler;
-import org.omg.PortableServer.Current;
-import org.omg.PortableServer.POA;
-import org.omg.PortableServer.Servant;
-
-/**
- * Comment
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @author  <a href="mailto:reverbel at ime.usp.br">Francisco Reverbel</a>
- * @version $Revision$
- */
-public class BeanCorbaServant extends Servant
-   implements InvokeHandler
-{
-   private static final Logger log = Logger.getLogger(BeanCorbaServant.class);
-
-   private final IORFactory factory;
-   private final Current poaCurrent;
-   private final Container container;
-   private final InterfaceDef interfaceDef;
-   private final String repositoryIds[];
-   private SASCurrent sasCurrent;
-   private InboundTransactionCurrent inboundTxCurrent;
-
-   private HashMap<String, SkeletonStrategy> methodMap;
-   
-   protected BeanCorbaServant(IORFactory factory, Current poaCurrent, Container container, InterfaceDef interfaceDef, InterfaceAnalysis interfaceAnalysis)
-   {
-      assert factory != null : "factory is null";
-      assert poaCurrent != null : "poaCurrent is null";
-      assert container != null : "container is null";
-      assert container instanceof SessionContainer : "only SessionContainer supported"; // see invoke
-      //assert interfaceDef != null : "interfaceDef is null";  // assertion breaks iiop unit test
-      assert interfaceAnalysis != null : "interfaceAnalysis is null";
-      
-      this.factory = factory;
-      this.poaCurrent = poaCurrent;
-      this.container = container;
-      this.interfaceDef = interfaceDef;
-      this.repositoryIds = interfaceAnalysis.getAllTypeIds();
-      
-      try
-      {
-         this.sasCurrent = (SASCurrent) CorbaORB.getInstance().resolve_initial_references("SASCurrent");
-      }
-      catch (InvalidName e)
-      {
-         log.warn("Can't find SASCurrent");
-         this.sasCurrent = null;
-      }
-      try
-      {
-         this.inboundTxCurrent = (InboundTransactionCurrent)
-            CorbaORB.getInstance().resolve_initial_references(InboundTransactionCurrent.NAME);
-      }
-      catch (InvalidName e)
-      {
-         log.warn("Can't find InboundTransactionCurrent");
-         this.inboundTxCurrent = null;
-      }
-      
-      this.methodMap = new HashMap<String, SkeletonStrategy>();
-      AttributeAnalysis[] attrs = interfaceAnalysis.getAttributes();
-      for (int i = 0; i < attrs.length; i++) {
-         OperationAnalysis op = attrs[i].getAccessorAnalysis();
-
-         log.debug("    " + op.getJavaName() + ": " + op.getIDLName());
-         methodMap.put(op.getIDLName(),
-                           new SkeletonStrategy(op.getMethod()));
-         op = attrs[i].getMutatorAnalysis();
-         if (op != null) {
-            log.debug("    " + op.getJavaName() + ": " + op.getIDLName());
-            methodMap.put(op.getIDLName(),
-                              new SkeletonStrategy(op.getMethod()));
-         }
-      }
-
-      OperationAnalysis[] ops = interfaceAnalysis.getOperations();
-      for (int i = 0; i < ops.length; i++) {
-         log.debug("    " + ops[i].getJavaName() + ": " + ops[i].getIDLName());
-         methodMap.put(ops[i].getIDLName(),
-                           new SkeletonStrategy(ops[i].getMethod()));
-      }
-   }
-   
-   @Override
-   public String[] _all_interfaces(POA poa, byte[] objectId)
-   {
-      return (String[]) repositoryIds.clone();
-   }
-
-   /**
-    * Returns an IR object describing the bean's remote interface.
-    */
-   @Override
-   public org.omg.CORBA.Object _get_interface_def()
-   {
-      if (interfaceDef != null)
-         return interfaceDef;
-      else
-         return super._get_interface_def();
-   }
-   
-   public OutputStream _invoke(String opName, InputStream in, ResponseHandler handler) throws SystemException
-   {
-      log.trace("invoke: " + opName);
-      
-      SkeletonStrategy op = (SkeletonStrategy) methodMap.get(opName);
-      if (op == null)
-      {
-         log.debug("Unable to find opname '" + opName + "' valid operations:" + methodMap.keySet());
-         throw new BAD_OPERATION(opName);
-      }
-
-      org.omg.CORBA_2_3.portable.OutputStream out;
-      try
-      {
-         Object id = ReferenceData.extractObjectId(poaCurrent.get_object_id());
-         log.trace("id = " + id);
-         
-         Transaction tx = null;
-         if (inboundTxCurrent != null)
-            tx = inboundTxCurrent.getCurrentTransaction();
-         log.trace("tx = " + tx);
-         
-         if(sasCurrent != null)
-         {
-            byte username[] = sasCurrent.get_incoming_username();
-            byte credentials[] = sasCurrent.get_incoming_password();
-            byte principalName[] = sasCurrent.get_incoming_principal_name();
-            
-            if(username != null && username.length > 0)
-            {
-               String name = new String(username, "UTF-8");
-               int domainIndex = name.lastIndexOf("@");
-               if(domainIndex > 0)
-                  name = name.substring(0, domainIndex);
-               log.debug("username = " + name);
-               Principal principal = new SimplePrincipal(name);
-               SecurityAssociation.setPrincipal(principal);
-            }
-            
-            if(credentials != null && credentials.length > 0)
-            {
-               SecurityAssociation.setCredential(new String(credentials, "UTF-8").toCharArray());
-            }
-            
-            if(principalName != null && principalName.length > 0)
-               log.warn("principalName = " + new String(principalName, "UTF-8")); // FIXME: implement principalName support
-         }
-         
-         Object args[] = op.readParams((org.omg.CORBA_2_3.portable.InputStream) in);
-         
-         Object retVal = invoke(tx, id, op.getMethod(), args);
-         
-         out = (org.omg.CORBA_2_3.portable.OutputStream) handler.createReply();
-         if(op.isNonVoid())
-            op.writeRetval(out, retVal);
-      }
-      catch(Throwable t)
-      {
-         // TODO: check log level before stacktrace?
-         t.printStackTrace();
-         if(t instanceof Exception)
-         {
-            Exception e = (Exception) t;
-            RmiIdlUtil.rethrowIfCorbaSystemException(e);
-            out = (org.omg.CORBA_2_3.portable.OutputStream) handler.createExceptionReply();
-            op.writeException(out, e);
-         }
-         else
-            throw new RuntimeException("NYI");
-      }
-      return out;
-   }
-
-   private TransactionManager getTransactionManager()
-   {
-      //return TxUtil.getTransactionManager();
-      return TransactionManagerLocator.getInstance().locate();
-   }
-   
-   private Object invoke(Object id, Method method, Object args[]) throws Throwable
-   {
-      // TODO: Support other containers beside Stateless and Stateful?
-      return ((SessionContainer) container).invoke(factory, id, method, args, null);
-   }
-   
-   private Object invoke(Transaction tx, Object id, Method method, Object args[]) throws Throwable
-   {
-      if(tx == null)
-         return invoke(id, method, args);
-      
-      // FIXME: refactor TxServerInterceptor so that it pushed the tpc into the invocation like ClientTxPropegationInterceptor
-      // this would require the localInvoke to be also refactored, so that it uses invocation instead of localInvoke.
-      TransactionManager tm = getTransactionManager();
-      
-      // see TxPropagationInterceptor
-      if(tm.getTransaction() != null)
-         throw new RuntimeException("cannot import a transaction context when a transaction is already associated with the thread");
-      tm.resume(tx);
-      try
-      {
-         return invoke(id, method, args);
-      }
-      finally
-      {
-         tm.suspend();
-      }
-   }
-}

Copied: branches/JBPAPP_5_0/ejb3/src/main/org/jboss/ejb3/iiop/BeanCorbaServant.java (from rev 84680, branches/Branch_5_x/ejb3/src/main/org/jboss/ejb3/iiop/BeanCorbaServant.java)
===================================================================
--- branches/JBPAPP_5_0/ejb3/src/main/org/jboss/ejb3/iiop/BeanCorbaServant.java	                        (rev 0)
+++ branches/JBPAPP_5_0/ejb3/src/main/org/jboss/ejb3/iiop/BeanCorbaServant.java	2009-11-30 12:49:29 UTC (rev 97163)
@@ -0,0 +1,287 @@
+/*
+ * 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.iiop;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.security.Principal;
+import java.util.HashMap;
+
+import javax.ejb.EJBAccessException;
+import javax.ejb.EJBTransactionRequiredException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import org.jboss.ejb3.core.proxy.spi.CurrentRemoteProxyFactory;
+import org.jboss.ejb3.endpoint.Endpoint;
+import org.jboss.ejb3.session.SessionContainer;
+import org.jboss.iiop.CorbaORB;
+import org.jboss.iiop.csiv2.SASCurrent;
+import org.jboss.iiop.rmi.AttributeAnalysis;
+import org.jboss.iiop.rmi.InterfaceAnalysis;
+import org.jboss.iiop.rmi.OperationAnalysis;
+import org.jboss.iiop.rmi.RmiIdlUtil;
+import org.jboss.iiop.rmi.marshal.strategy.SkeletonStrategy;
+import org.jboss.iiop.tm.InboundTransactionCurrent;
+import org.jboss.invocation.iiop.ReferenceData;
+import org.jboss.logging.Logger;
+import org.jboss.security.SecurityAssociation;
+import org.jboss.security.SimplePrincipal;
+import org.jboss.tm.TransactionManagerLocator;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.InterfaceDef;
+import org.omg.CORBA.NO_PERMISSION;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.TRANSACTION_REQUIRED;
+import org.omg.CORBA.ORBPackage.InvalidName;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.InvokeHandler;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.ResponseHandler;
+import org.omg.PortableServer.Current;
+import org.omg.PortableServer.POA;
+import org.omg.PortableServer.Servant;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @author  <a href="mailto:reverbel at ime.usp.br">Francisco Reverbel</a>
+ * @version $Revision$
+ */
+public class BeanCorbaServant extends Servant
+   implements InvokeHandler
+{
+   private static final Logger log = Logger.getLogger(BeanCorbaServant.class);
+
+   private final IORFactory factory;
+   private final Current poaCurrent;
+   private final Endpoint container;
+   private final InterfaceDef interfaceDef;
+   private final String repositoryIds[];
+   private SASCurrent sasCurrent;
+   private InboundTransactionCurrent inboundTxCurrent;
+
+   private HashMap<String, SkeletonStrategy> methodMap;
+   
+   protected BeanCorbaServant(IORFactory factory, Current poaCurrent, Endpoint container, InterfaceDef interfaceDef, InterfaceAnalysis interfaceAnalysis)
+   {
+      assert factory != null : "factory is null";
+      assert poaCurrent != null : "poaCurrent is null";
+      assert container != null : "container is null";
+      assert container instanceof SessionContainer : "only SessionContainer supported"; // see invoke
+      //assert interfaceDef != null : "interfaceDef is null";  // assertion breaks iiop unit test
+      assert interfaceAnalysis != null : "interfaceAnalysis is null";
+      
+      this.factory = factory;
+      this.poaCurrent = poaCurrent;
+      this.container = container;
+      this.interfaceDef = interfaceDef;
+      this.repositoryIds = interfaceAnalysis.getAllTypeIds();
+      
+      try
+      {
+         this.sasCurrent = (SASCurrent) CorbaORB.getInstance().resolve_initial_references("SASCurrent");
+      }
+      catch (InvalidName e)
+      {
+         log.warn("Can't find SASCurrent");
+         this.sasCurrent = null;
+      }
+      try
+      {
+         this.inboundTxCurrent = (InboundTransactionCurrent)
+            CorbaORB.getInstance().resolve_initial_references(InboundTransactionCurrent.NAME);
+      }
+      catch (InvalidName e)
+      {
+         log.warn("Can't find InboundTransactionCurrent");
+         this.inboundTxCurrent = null;
+      }
+      
+      this.methodMap = new HashMap<String, SkeletonStrategy>();
+      AttributeAnalysis[] attrs = interfaceAnalysis.getAttributes();
+      for (int i = 0; i < attrs.length; i++) {
+         OperationAnalysis op = attrs[i].getAccessorAnalysis();
+
+         log.debug("    " + op.getJavaName() + ": " + op.getIDLName());
+         methodMap.put(op.getIDLName(),
+                           new SkeletonStrategy(op.getMethod()));
+         op = attrs[i].getMutatorAnalysis();
+         if (op != null) {
+            log.debug("    " + op.getJavaName() + ": " + op.getIDLName());
+            methodMap.put(op.getIDLName(),
+                              new SkeletonStrategy(op.getMethod()));
+         }
+      }
+
+      OperationAnalysis[] ops = interfaceAnalysis.getOperations();
+      for (int i = 0; i < ops.length; i++) {
+         log.debug("    " + ops[i].getJavaName() + ": " + ops[i].getIDLName());
+         methodMap.put(ops[i].getIDLName(),
+                           new SkeletonStrategy(ops[i].getMethod()));
+      }
+   }
+   
+   @Override
+   public String[] _all_interfaces(POA poa, byte[] objectId)
+   {
+      return (String[]) repositoryIds.clone();
+   }
+
+   /**
+    * Returns an IR object describing the bean's remote interface.
+    */
+   @Override
+   public org.omg.CORBA.Object _get_interface_def()
+   {
+      if (interfaceDef != null)
+         return interfaceDef;
+      else
+         return super._get_interface_def();
+   }
+   
+   public OutputStream _invoke(String opName, InputStream in, ResponseHandler handler) throws SystemException
+   {
+      log.trace("invoke: " + opName);
+      
+      SkeletonStrategy op = (SkeletonStrategy) methodMap.get(opName);
+      if (op == null)
+      {
+         log.debug("Unable to find opname '" + opName + "' valid operations:" + methodMap.keySet());
+         throw new BAD_OPERATION(opName);
+      }
+
+      org.omg.CORBA_2_3.portable.OutputStream out;
+      try
+      {
+         Object id = ReferenceData.extractObjectId(poaCurrent.get_object_id());
+         log.trace("id = " + id);
+         
+         Transaction tx = null;
+         if (inboundTxCurrent != null)
+            tx = inboundTxCurrent.getCurrentTransaction();
+         log.trace("tx = " + tx);
+         
+         if(sasCurrent != null)
+         {
+            byte username[] = sasCurrent.get_incoming_username();
+            byte credentials[] = sasCurrent.get_incoming_password();
+            byte principalName[] = sasCurrent.get_incoming_principal_name();
+            
+            if(username != null && username.length > 0)
+            {
+               String name = new String(username, "UTF-8");
+               int domainIndex = name.lastIndexOf("@");
+               if(domainIndex > 0)
+                  name = name.substring(0, domainIndex);
+               log.debug("username = " + name);
+               Principal principal = new SimplePrincipal(name);
+               SecurityAssociation.setPrincipal(principal);
+            }
+            
+            if(credentials != null && credentials.length > 0)
+            {
+               SecurityAssociation.setCredential(new String(credentials, "UTF-8").toCharArray());
+            }
+            
+            if(principalName != null && principalName.length > 0)
+               log.warn("principalName = " + new String(principalName, "UTF-8")); // FIXME: implement principalName support
+         }
+         
+         Object args[] = op.readParams((org.omg.CORBA_2_3.portable.InputStream) in);
+         
+         CurrentRemoteProxyFactory.set(factory.getRemoteProxyFactory());
+         Object retVal;
+         try
+         {
+            retVal = invoke(tx, id, op.getMethod(), args);
+         }
+         finally
+         {
+            CurrentRemoteProxyFactory.remove();
+         }
+         
+         out = (org.omg.CORBA_2_3.portable.OutputStream) handler.createReply();
+         if(op.isNonVoid())
+            op.writeRetval(out, retVal);
+      }
+      catch(Throwable t)
+      {
+         // TODO: we should really get the correct EJB 2.1 view exceptions from the container
+         if(t instanceof EJBAccessException)
+            throw new NO_PERMISSION(t.getMessage());
+         if(t instanceof EJBTransactionRequiredException)
+            throw new TRANSACTION_REQUIRED(t.getMessage());
+         
+         // TODO: check log level before stacktrace?
+         t.printStackTrace();
+         if(t instanceof Exception)
+         {
+            Exception e = (Exception) t;
+            RmiIdlUtil.rethrowIfCorbaSystemException(e);
+            out = (org.omg.CORBA_2_3.portable.OutputStream) handler.createExceptionReply();
+            op.writeException(out, e);
+         }
+         else
+            throw new RuntimeException("NYI");
+      }
+      return out;
+   }
+
+   private TransactionManager getTransactionManager()
+   {
+      //return TxUtil.getTransactionManager();
+      return TransactionManagerLocator.getInstance().locate();
+   }
+   
+   private Object invoke(Object id, Method method, Object args[]) throws Throwable
+   {
+      Serializable session = (Serializable) id;
+      // TODO: get the proper invoked interface
+      Class<?> invokedBusinessInterface = null;
+      return container.invoke(session, invokedBusinessInterface, method, args);
+   }
+   
+   private Object invoke(Transaction tx, Object id, Method method, Object args[]) throws Throwable
+   {
+      if(tx == null)
+         return invoke(id, method, args);
+      
+      // FIXME: refactor TxServerInterceptor so that it pushed the tpc into the invocation like ClientTxPropegationInterceptor
+      // this would require the localInvoke to be also refactored, so that it uses invocation instead of localInvoke.
+      TransactionManager tm = getTransactionManager();
+      
+      // see TxPropagationInterceptor
+      if(tm.getTransaction() != null)
+         throw new RuntimeException("cannot import a transaction context when a transaction is already associated with the thread");
+      tm.resume(tx);
+      try
+      {
+         return invoke(id, method, args);
+      }
+      finally
+      {
+         tm.suspend();
+      }
+   }
+}

Deleted: branches/JBPAPP_5_0/ejb3/src/main/org/jboss/ejb3/iiop/EJB3IIOPWebClassLoader.java
===================================================================
--- branches/Branch_5_x/ejb3/src/main/org/jboss/ejb3/iiop/EJB3IIOPWebClassLoader.java	2009-02-24 21:51:50 UTC (rev 84680)
+++ branches/JBPAPP_5_0/ejb3/src/main/org/jboss/ejb3/iiop/EJB3IIOPWebClassLoader.java	2009-11-30 12:49:29 UTC (rev 97163)
@@ -1,56 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.iiop;
-
-import javax.management.ObjectName;
-
-import org.jboss.classloading.spi.RealClassLoader;
-import org.jboss.iiop.WebCL;
-
-/**
- * The getKey method of the WebCL class is not working in EJB3, this class fixes that.
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @author adrian at jboss.org
- * @version $Revision$
- */
-public class EJB3IIOPWebClassLoader extends WebCL
-{
-   private String jndiName;
-   
-   public EJB3IIOPWebClassLoader(ObjectName container, RealClassLoader parent, String jndiName)
-   {
-      super(container, parent);
-      this.jndiName = jndiName;
-   }
-
-   @Override
-   public String getKey()
-   {
-      String className = getClass().getName();
-      int dot = className.lastIndexOf('.');
-      if( dot >= 0 )
-          className = className.substring(dot+1);
-      String key =  className + '[' + jndiName + ']';
-      return key;
-   }
-}

Copied: branches/JBPAPP_5_0/ejb3/src/main/org/jboss/ejb3/iiop/EJB3IIOPWebClassLoader.java (from rev 84680, branches/Branch_5_x/ejb3/src/main/org/jboss/ejb3/iiop/EJB3IIOPWebClassLoader.java)
===================================================================
--- branches/JBPAPP_5_0/ejb3/src/main/org/jboss/ejb3/iiop/EJB3IIOPWebClassLoader.java	                        (rev 0)
+++ branches/JBPAPP_5_0/ejb3/src/main/org/jboss/ejb3/iiop/EJB3IIOPWebClassLoader.java	2009-11-30 12:49:29 UTC (rev 97163)
@@ -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.iiop;
+
+import javax.management.ObjectName;
+
+import org.jboss.classloading.spi.RealClassLoader;
+import org.jboss.iiop.WebCL;
+
+/**
+ * The getKey method of the WebCL class is not working in EJB3, this class fixes that.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @author adrian at jboss.org
+ * @version $Revision$
+ */
+public class EJB3IIOPWebClassLoader extends WebCL
+{
+   private String jndiName;
+   
+   public EJB3IIOPWebClassLoader(ObjectName container, RealClassLoader parent, String jndiName)
+   {
+      super(container, parent);
+      this.jndiName = jndiName;
+   }
+
+   @Override
+   public String getKey()
+   {
+      String className = getClass().getName();
+      int dot = className.lastIndexOf('.');
+      if( dot >= 0 )
+          className = className.substring(dot+1);
+      String key =  className + '[' + jndiName + ']';
+      return key;
+   }
+}

Deleted: branches/JBPAPP_5_0/ejb3/src/main/org/jboss/ejb3/iiop/IORFactory.java
===================================================================
--- branches/Branch_5_x/ejb3/src/main/org/jboss/ejb3/iiop/IORFactory.java	2009-02-24 21:51:50 UTC (rev 84680)
+++ branches/JBPAPP_5_0/ejb3/src/main/org/jboss/ejb3/iiop/IORFactory.java	2009-11-30 12:49:29 UTC (rev 97163)
@@ -1,485 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.iiop;
-
-import java.lang.annotation.Annotation;
-import java.net.URL;
-
-import javax.ejb.EJBHome;
-import javax.ejb.EJBObject;
-import javax.ejb.Handle;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.rmi.PortableRemoteObject;
-
-import org.jboss.classloading.spi.RealClassLoader;
-import org.jboss.ejb3.InitialContextFactory;
-import org.jboss.ejb3.NonSerializableFactory;
-import org.jboss.ejb3.annotation.IIOP;
-import org.jboss.ejb3.annotation.RemoteBinding;
-import org.jboss.ejb3.proxy.factory.BaseSessionProxyFactory;
-import org.jboss.ejb3.proxy.factory.ProxyFactoryHelper;
-import org.jboss.ejb3.proxy.factory.RemoteProxyFactory;
-import org.jboss.ejb3.proxy.factory.SessionProxyFactory;
-import org.jboss.ejb3.session.ProxyAccessType;
-import org.jboss.ejb3.session.SessionContainer;
-import org.jboss.iiop.CorbaORBService;
-import org.jboss.iiop.codebase.CodebasePolicy;
-import org.jboss.iiop.csiv2.CSIv2Policy;
-import org.jboss.iiop.rmi.InterfaceAnalysis;
-import org.jboss.iiop.rmi.ir.InterfaceRepository;
-import org.jboss.invocation.iiop.ReferenceFactory;
-import org.jboss.invocation.iiop.ServantRegistries;
-import org.jboss.invocation.iiop.ServantRegistry;
-import org.jboss.invocation.iiop.ServantRegistryKind;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.IorSecurityConfigMetaData;
-import org.jboss.mx.util.MBeanProxyExt;
-import org.jboss.proxy.ejb.handle.HandleDelegateImpl;
-import org.jboss.system.Registry;
-import org.jboss.util.NotImplementedException;
-import org.jboss.web.WebClassLoader;
-import org.jboss.web.WebServiceMBean;
-import org.omg.CORBA.Any;
-import org.omg.CORBA.InterfaceDef;
-import org.omg.CORBA.InterfaceDefHelper;
-import org.omg.CORBA.ORB;
-import org.omg.CORBA.Policy;
-import org.omg.CORBA.Repository;
-import org.omg.CosNaming.NameComponent;
-import org.omg.CosNaming.NamingContext;
-import org.omg.CosNaming.NamingContextExt;
-import org.omg.CosNaming.NamingContextExtHelper;
-import org.omg.CosNaming.NamingContextHelper;
-import org.omg.CosNaming.NamingContextPackage.NotFound;
-import org.omg.PortableServer.Current;
-import org.omg.PortableServer.CurrentHelper;
-import org.omg.PortableServer.POA;
-import org.omg.PortableServer.Servant;
-
-/**
- * Comment
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision$
- */
-public class IORFactory extends BaseSessionProxyFactory
-   implements RemoteProxyFactory, SessionProxyFactory
-{
-   private static final Logger log = Logger.getLogger(IORFactory.class);
-   
-   private SessionContainer container;
-   private RemoteBinding binding;
-   private String webServiceName = "jboss:service=WebService"; // TODO: make webServiceName configurable
-   
-   // after start available
-   private String beanRepositoryIds[];
-   private String homeRepositoryIds[];
-//   private InterfaceAnalysis interfaceAnalysis;
-   private ORB orb;
-//   private POA poa;
-   private POA irPoa;
-   private InterfaceRepository iri;
-   private ServantRegistry servantRegistry;
-   private ServantRegistry homeServantRegistry;
-   private WebClassLoader wcl;
-   private ReferenceFactory referenceFactory;
-   private ReferenceFactory homeReferenceFactory;
-
-   public IORFactory(SessionContainer container, RemoteBinding binding)
-   {
-      assert container != null : "container is null";
-      assert binding != null : "binding is null";
-      
-      this.container = container;
-      this.binding = binding;
-   }
-   
-   // TODO: create a default IIOP annotation
-   private static final IIOP defaultIIOP = new IIOP()
-   {
-      public boolean interfaceRepositorySupported()
-      {
-         return false;
-      }
-
-      public String poa()
-      {
-         return POA_PER_SERVANT;
-      }
-      
-      public Class<? extends Annotation> annotationType()
-      {
-         return IIOP.class;
-      }
-   };
-   
-   // TODO: do I really need this method
-   public Object createHomeProxy()
-   {
-      try
-      {
-         org.omg.CORBA.Object corbaRef = homeReferenceFactory.createReference(homeRepositoryIds[0]);
-         
-         EJBHome corbaObj = (EJBHome) PortableRemoteObject.narrow(corbaRef, EJBHome.class);
-         
-         return corbaObj;
-      }
-      catch(Exception e)
-      {
-         throw new RuntimeException(e);
-      }
-   }
-   
-   public Object createProxy()
-   {
-      try
-      {
-         org.omg.CORBA.Object corbaRef = referenceFactory.createReference(beanRepositoryIds[0]);
-         
-         EJBObject corbaObj = (EJBObject) PortableRemoteObject.narrow(corbaRef, EJBObject.class);
-         
-         return corbaObj;
-      }
-      catch(Exception e)
-      {
-         throw new RuntimeException(e);
-      }
-   }
-   
-   public Object createProxy(Object id)
-   {
-      try
-      {
-         org.omg.CORBA.Object corbaRef = referenceFactory.createReferenceWithId(id, beanRepositoryIds[0]);
-         
-         EJBObject corbaObj = (EJBObject) PortableRemoteObject.narrow(corbaRef, EJBObject.class);
-         
-         return corbaObj;
-      }
-      catch(Exception e)
-      {
-         throw new RuntimeException(e);
-      }
-   }
-   
-   private IIOP getIIOP()
-   {
-      IIOP iiop = container.getAnnotation(IIOP.class);
-      if(iiop != null)
-         return iiop;
-      
-      return defaultIIOP;
-   }
-   
-//   private String getJndiName()
-//   {
-//      return ProxyFactoryHelper.getDefaultRemoteBusinessJndiName(container);
-//   }
-   
-   private String getServantName()
-   {
-      // TODO: is "Servant/" a good prefix for servant name
-      return "Servant/" + getJndiName();
-   }
-   
-   private WebServiceMBean getWebServer() throws MalformedObjectNameException
-   {
-      if(webServiceName == null)
-         throw new IllegalStateException("iiop is not going to work without a web service");
-      
-      return (WebServiceMBean) MBeanProxyExt.create(WebServiceMBean.class, webServiceName);
-   }
-   
-   /**
-    * Literal copy from org.jboss.proxy.ejb.IORFactory
-    */
-   private void rebind(NamingContextExt ctx, String strName, org.omg.CORBA.Object obj) throws Exception
-   {
-      NameComponent[] name = ctx.to_name(strName);
-      NamingContext intermediateCtx = ctx;
-
-      for (int i = 0; i < name.length - 1; i++ ) {
-         NameComponent[] relativeName = new NameComponent[] { name[i] };
-         try {
-            intermediateCtx = NamingContextHelper.narrow(
-                  intermediateCtx.resolve(relativeName));
-         }
-         catch (NotFound e) {
-            intermediateCtx = intermediateCtx.bind_new_context(relativeName);
-         }
-      }
-      intermediateCtx.rebind(new NameComponent[] { name[name.length - 1] }, obj);
-   }
-   
-   private void removeWebClassLoader() throws MalformedObjectNameException
-   {
-      getWebServer().removeClassLoader(wcl);
-   }
-   
-   public void setWebServiceName(String name)
-   {
-      this.webServiceName = name;
-   }
-   
-   public void start() throws Exception
-   {
-      // TODO: IORFactory only supports 1 remote interface
-      Class remoteInterfaces[] = ProxyFactoryHelper.getRemoteAndBusinessRemoteInterfaces(container);
-      if(remoteInterfaces.length > 1)
-         log.warn("IIOP binding only works on 1 interface, using: " + remoteInterfaces[0].getName());
-      InterfaceAnalysis interfaceAnalysis = InterfaceAnalysis.getInterfaceAnalysis(remoteInterfaces[0]);
-      this.beanRepositoryIds = interfaceAnalysis.getAllTypeIds();
-      
-      InterfaceAnalysis homeInterfaceAnalysis = null;
-      Class homeInterface = ProxyFactoryHelper.getRemoteHomeInterface(container);
-      if(homeInterface != null)
-      {
-         if(!EJBHome.class.isAssignableFrom(homeInterface))
-            throw new IllegalArgumentException("home interface " + homeInterface.getName() + " must extend javax.ejb.EJBHome (EJB3 4.6.8)");
-         homeInterfaceAnalysis = InterfaceAnalysis.getInterfaceAnalysis(homeInterface);
-         this.homeRepositoryIds = homeInterfaceAnalysis.getAllTypeIds();
-      }
-      // To allow EJB3 Stateless beans to operate we can function without a home interface.
-      
-      // Get orb and irPoa references
-      try {
-         orb = (ORB)InitialContextFactory.getInitialContext().lookup("java:/" + CorbaORBService.ORB_NAME);
-      }
-      catch (NamingException e) {
-         throw new Exception("Cannot lookup java:/" + CorbaORBService.ORB_NAME + ": " + e);
-      }
-      try {
-         irPoa = (POA)InitialContextFactory.getInitialContext().lookup("java:/" + CorbaORBService.IR_POA_NAME);
-      }
-      catch (NamingException e) {
-         throw new Exception("Cannot lookup java:/" + CorbaORBService.IR_POA_NAME + ": " + e);
-      }
-      
-      IIOP iiop = getIIOP();
-      if(iiop.interfaceRepositorySupported())
-      {
-         this.iri = new InterfaceRepository(orb, irPoa, getJndiName());
-         iri.mapClass(remoteInterfaces[0]);
-         if(homeInterface != null)
-            iri.mapClass(homeInterface);
-         iri.finishBuild();
-      }
-      
-      // TODO: obtain the iiop invoker name properly
-      ObjectName invokerName = new ObjectName("jboss:service=invoker,type=iiop");
-      ServantRegistries servantRegistries = (ServantRegistries) Registry.lookup(invokerName);
-      if(servantRegistries == null)
-         throw new Exception("can't find iiop invoker");
-      ServantRegistryKind registryWithTransientPOA;
-      ServantRegistryKind registryWithPersistentPOA; 
-      if(iiop.poa().equals(IIOP.POA_PER_SERVANT))
-      {
-         registryWithTransientPOA = ServantRegistryKind.TRANSIENT_POA_PER_SERVANT;
-         registryWithPersistentPOA = ServantRegistryKind.PERSISTENT_POA_PER_SERVANT;
-      }
-      else if(iiop.poa().equals(IIOP.POA_SHARED))
-      {
-         registryWithTransientPOA = ServantRegistryKind.SHARED_TRANSIENT_POA;
-         registryWithPersistentPOA = ServantRegistryKind.SHARED_PERSISTENT_POA;
-      }
-      else
-         throw new IllegalArgumentException("@IIOP.poa can only be 'per-servant' or 'shared'");
-      // Only works for session container
-      this.servantRegistry = servantRegistries.getServantRegistry(registryWithTransientPOA);
-      this.homeServantRegistry = servantRegistries.getServantRegistry(registryWithPersistentPOA); // TODO: why is home interface in persistent poa?
-      
-      // Hack in a WebCL (from org.jboss.ejb.EjbModule.initializeContainer)
-      // TODO:  seting up a WebClassLoader needs to be done somewhere where
-      ObjectName on = container.getObjectName();
-      this.wcl = new EJB3IIOPWebClassLoader(on, (RealClassLoader) ((SessionContainer) container).getClassloader(), getJndiName());
-      WebServiceMBean webServer = getWebServer();
-      URL[] codebaseURLs = {webServer.addClassLoader(wcl)};
-      wcl.setWebURLs(codebaseURLs);
-      
-      // setup a codebase policy, the CodebaseInterceptor will translate this to a TAG_JAVA_CODEBASE
-      String codebaseString = wcl.getCodebaseString();
-      log.debug("codebase = " + codebaseString);
-      Any codebase = orb.create_any();
-      codebase.insert_string(codebaseString);
-      Policy codebasePolicy;
-      codebasePolicy = orb.create_policy(CodebasePolicy.TYPE, codebase);
-      
-      // Create csiv2Policy for both home and remote containing
-      // IorSecurityConfigMetadata
-      Any secPolicy = orb.create_any();
-//      IorSecurityConfigMetaData iorSecurityConfigMetaData =
-//         container.getBeanMetaData().getIorSecurityConfigMetaData();
-      IorSecurityConfigMetaData iorSecurityConfigMetaData = new IorSecurityConfigMetaData(); // TODO: make ior security configurable
-      secPolicy.insert_Value(iorSecurityConfigMetaData);
-      Policy csiv2Policy = orb.create_policy(CSIv2Policy.TYPE, secPolicy);
-      
-      Policy policies[] = { codebasePolicy, csiv2Policy };
-      
-      InterfaceDef interfaceDef = null;
-      if(iri != null)
-      {
-         Repository ir = iri.getReference();
-         interfaceDef = InterfaceDefHelper.narrow(ir.lookup_id(beanRepositoryIds[0]));
-      }
-      
-      Current poaCurrent = CurrentHelper.narrow(orb.resolve_initial_references("POACurrent"));
-
-      NamingContextExt ctx = getNamingContextExt();
-
-      log.debug("binding servant name " + getServantName());
-      
-      Servant servant = new BeanCorbaServant(this, poaCurrent, container, interfaceDef, interfaceAnalysis);
-      this.referenceFactory = servantRegistry.bind(getServantName(), servant, policies);
-      
-      EJBObject corbaObj = (EJBObject) createProxy();
-      
-      rebind(ctx, getJndiName(), (org.omg.CORBA.Object) corbaObj);
-      
-      // TODO: use iri
-      if(homeInterfaceAnalysis != null)
-      {
-         servant = new BeanCorbaServant(this, poaCurrent, container, null, homeInterfaceAnalysis);
-         this.homeReferenceFactory = homeServantRegistry.bind(getServantName() + "Home", servant, policies);
-         
-         Object homeObject = createHomeProxy();
-         
-         rebind(ctx, ProxyFactoryHelper.getHomeJndiName(container), (org.omg.CORBA.Object) homeObject);
-      }
-      
-      // bind HandleDelegate stuff
-      Context compCtx = (Context) InitialContextFactory.getInitialContext().lookup("java:comp");
-      NonSerializableFactory.rebind(compCtx, "ORB", orb);
-      NonSerializableFactory.rebind(compCtx, "HandleDelegate", new HandleDelegateImpl());
-   }
-   
-   public void stop() throws Exception
-   {
-      if(homeReferenceFactory != null)
-      {
-         unbind(ProxyFactoryHelper.getHomeJndiName(container));
-         unbindHomeServant();
-      }
-      unbind(getJndiName());
-      
-      unbindServant();
-      
-      removeWebClassLoader();
-   }
-   
-   /**
-    * Unbind the bean from CosNaming
-    */
-   private void unbind(String strName)
-   {
-      try
-      {
-         NamingContextExt corbaContext = getNamingContextExt();
-         NameComponent n[] = corbaContext.to_name(strName);
-         getNamingContextExt().unbind(n);
-      }
-      catch(Exception e)
-      {
-         log.warn("unable to unbind '" + strName + "'", e);
-      }
-   }
-   
-   private void unbindHomeServant()
-   {
-      try
-      {
-         homeServantRegistry.unbind(getServantName() + "Home");
-      }
-      catch(Exception e)
-      {
-         log.warn("unable to unbind home servant", e);
-      }
-   }
-   
-   private void unbindServant()
-   {
-      try
-      {
-         servantRegistry.unbind(getServantName());
-      }
-      catch(Exception e)
-      {
-         log.warn("unable to unbind servant", e);
-      }
-   }
-
-   private NamingContextExt getNamingContextExt() throws NamingException
-   {
-      Context initialContext = InitialContextFactory.getInitialContext();
-      
-      // NOTE: eclipse editor parser crashes silently on this line (because of org.jboss.iiop.CorbaNamingService) with unknown reason
-      // that's why this method is at the end
-      return NamingContextExtHelper.narrow((org.omg.CORBA.Object) initialContext.lookup("java:/" + org.jboss.iiop.CorbaNamingService.NAMING_NAME));
-   }
-
-   public Object createProxyBusiness()
-   {
-      throw new NotImplementedException();
-   }
-
-   public Object createProxyBusiness(Object arg0)
-   {
-      throw new NotImplementedException();
-   }
-
-   @Override
-   protected boolean bindHomeAndBusinessTogether()
-   {
-      throw new NotImplementedException();
-   }
-
-   @Override
-   protected Handle createHandle()
-   {
-      throw new NotImplementedException();
-   }
-
-   @Override
-   protected Class<?> getHomeType()
-   {
-      throw new NotImplementedException();
-   }
-
-   @Override
-   protected ProxyAccessType getProxyAccessType()
-   {
-      throw new NotImplementedException();
-   }
-
-   @Override
-   protected void validateEjb21Views()
-   {
-      throw new NotImplementedException();
-   }
-
-   public Object createProxyBusiness(String arg0)
-   {
-      throw new NotImplementedException();
-   }
-}
\ No newline at end of file

Copied: branches/JBPAPP_5_0/ejb3/src/main/org/jboss/ejb3/iiop/IORFactory.java (from rev 84680, branches/Branch_5_x/ejb3/src/main/org/jboss/ejb3/iiop/IORFactory.java)
===================================================================
--- branches/JBPAPP_5_0/ejb3/src/main/org/jboss/ejb3/iiop/IORFactory.java	                        (rev 0)
+++ branches/JBPAPP_5_0/ejb3/src/main/org/jboss/ejb3/iiop/IORFactory.java	2009-11-30 12:49:29 UTC (rev 97163)
@@ -0,0 +1,456 @@
+/*
+ * 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.iiop;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.net.URL;
+
+import javax.ejb.EJBHome;
+import javax.ejb.EJBObject;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.rmi.PortableRemoteObject;
+
+import org.jboss.classloading.spi.RealClassLoader;
+import org.jboss.ejb3.InitialContextFactory;
+import org.jboss.ejb3.annotation.IIOP;
+import org.jboss.ejb3.core.proxy.spi.EJB2RemoteProxyFactory;
+import org.jboss.ejb3.core.proxy.spi.RemoteProxyFactory;
+import org.jboss.ejb3.proxy.factory.ProxyFactoryHelper;
+import org.jboss.ejb3.session.SessionContainer;
+import org.jboss.iiop.CorbaORBService;
+import org.jboss.iiop.codebase.CodebasePolicy;
+import org.jboss.iiop.csiv2.CSIv2Policy;
+import org.jboss.iiop.rmi.InterfaceAnalysis;
+import org.jboss.iiop.rmi.ir.InterfaceRepository;
+import org.jboss.invocation.iiop.ReferenceFactory;
+import org.jboss.invocation.iiop.ServantRegistries;
+import org.jboss.invocation.iiop.ServantRegistry;
+import org.jboss.invocation.iiop.ServantRegistryKind;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.IorSecurityConfigMetaData;
+import org.jboss.mx.util.MBeanProxyExt;
+import org.jboss.proxy.ejb.handle.HandleDelegateImpl;
+import org.jboss.system.Registry;
+import org.jboss.util.naming.NonSerializableFactory;
+import org.jboss.web.WebClassLoader;
+import org.jboss.web.WebServiceMBean;
+import org.omg.CORBA.Any;
+import org.omg.CORBA.InterfaceDef;
+import org.omg.CORBA.InterfaceDefHelper;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Policy;
+import org.omg.CORBA.Repository;
+import org.omg.CosNaming.NameComponent;
+import org.omg.CosNaming.NamingContext;
+import org.omg.CosNaming.NamingContextExt;
+import org.omg.CosNaming.NamingContextExtHelper;
+import org.omg.CosNaming.NamingContextHelper;
+import org.omg.CosNaming.NamingContextPackage.NotFound;
+import org.omg.PortableServer.Current;
+import org.omg.PortableServer.CurrentHelper;
+import org.omg.PortableServer.POA;
+import org.omg.PortableServer.Servant;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public class IORFactory
+//   implements SessionProxyFactory
+{
+   private static final Logger log = Logger.getLogger(IORFactory.class);
+   
+   private SessionContainer container;
+   //private RemoteBinding binding;
+   private String webServiceName = "jboss:service=WebService"; // TODO: make webServiceName configurable
+   
+   // after start available
+   private String beanRepositoryIds[];
+   private String homeRepositoryIds[];
+//   private InterfaceAnalysis interfaceAnalysis;
+   private ORB orb;
+//   private POA poa;
+   private POA irPoa;
+   private InterfaceRepository iri;
+   private ServantRegistry servantRegistry;
+   private ServantRegistry homeServantRegistry;
+   private WebClassLoader wcl;
+   private ReferenceFactory referenceFactory;
+   private ReferenceFactory homeReferenceFactory;
+
+   private EJB2RemoteProxyFactory remoteProxyFactory = new EJB2RemoteProxyFactory()
+   {   
+      public EJBObject create(Serializable id)
+      {
+         if(id == null)
+            return createProxy();
+         else
+            return createProxy(id);
+      }
+
+      public EJBHome createHome()
+      {
+         return createHomeProxy();
+      }
+   };
+   
+   public IORFactory(SessionContainer container)
+   {
+      assert container != null : "container is null";
+      //assert binding != null : "binding is null";
+      
+      this.container = container;
+      //this.binding = binding;
+   }
+   
+   // TODO: create a default IIOP annotation
+   private static final IIOP defaultIIOP = new IIOP()
+   {
+      public boolean interfaceRepositorySupported()
+      {
+         return false;
+      }
+
+      public String poa()
+      {
+         return POA_PER_SERVANT;
+      }
+      
+      public Class<? extends Annotation> annotationType()
+      {
+         return IIOP.class;
+      }
+   };
+   
+   public EJBHome createHomeProxy()
+   {
+      try
+      {
+         org.omg.CORBA.Object corbaRef = homeReferenceFactory.createReference(homeRepositoryIds[0]);
+         
+         EJBHome corbaObj = (EJBHome) PortableRemoteObject.narrow(corbaRef, EJBHome.class);
+         
+         return corbaObj;
+      }
+      catch(Exception e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+   
+   public EJBObject createProxy()
+   {
+      try
+      {
+         org.omg.CORBA.Object corbaRef = referenceFactory.createReference(beanRepositoryIds[0]);
+         
+         EJBObject corbaObj = (EJBObject) PortableRemoteObject.narrow(corbaRef, EJBObject.class);
+         
+         return corbaObj;
+      }
+      catch(Exception e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+   
+   public EJBObject createProxy(Object id)
+   {
+      try
+      {
+         org.omg.CORBA.Object corbaRef = referenceFactory.createReferenceWithId(id, beanRepositoryIds[0]);
+         
+         EJBObject corbaObj = (EJBObject) PortableRemoteObject.narrow(corbaRef, EJBObject.class);
+         
+         return corbaObj;
+      }
+      catch(Exception e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+   
+   private IIOP getIIOP()
+   {
+      IIOP iiop = container.getAnnotation(IIOP.class);
+      if(iiop != null)
+         return iiop;
+      
+      return defaultIIOP;
+   }
+   
+   private String getJndiName()
+   {
+      return ProxyFactoryHelper.getDefaultRemoteBusinessJndiName(container);
+   }
+   
+   protected RemoteProxyFactory getRemoteProxyFactory()
+   {
+      return remoteProxyFactory;
+   }
+   
+   private String getServantName()
+   {
+      // TODO: is "Servant/" a good prefix for servant name
+      return "Servant/" + getJndiName();
+   }
+   
+   private WebServiceMBean getWebServer() throws MalformedObjectNameException
+   {
+      if(webServiceName == null)
+         throw new IllegalStateException("iiop is not going to work without a web service");
+      
+      return (WebServiceMBean) MBeanProxyExt.create(WebServiceMBean.class, webServiceName);
+   }
+   
+   /**
+    * Literal copy from org.jboss.proxy.ejb.IORFactory
+    */
+   private void rebind(NamingContextExt ctx, String strName, org.omg.CORBA.Object obj) throws Exception
+   {
+      NameComponent[] name = ctx.to_name(strName);
+      NamingContext intermediateCtx = ctx;
+
+      for (int i = 0; i < name.length - 1; i++ ) {
+         NameComponent[] relativeName = new NameComponent[] { name[i] };
+         try {
+            intermediateCtx = NamingContextHelper.narrow(
+                  intermediateCtx.resolve(relativeName));
+         }
+         catch (NotFound e) {
+            intermediateCtx = intermediateCtx.bind_new_context(relativeName);
+         }
+      }
+      intermediateCtx.rebind(new NameComponent[] { name[name.length - 1] }, obj);
+   }
+   
+   private void removeWebClassLoader() throws MalformedObjectNameException
+   {
+      getWebServer().removeClassLoader(wcl);
+   }
+   
+   public void setWebServiceName(String name)
+   {
+      this.webServiceName = name;
+   }
+   
+   public void start() throws Exception
+   {
+      // TODO: IORFactory only supports 1 remote interface
+      Class remoteInterfaces[] = ProxyFactoryHelper.getRemoteAndBusinessRemoteInterfaces(container);
+      if(remoteInterfaces.length > 1)
+         log.warn("IIOP binding only works on 1 interface, using: " + remoteInterfaces[0].getName());
+      InterfaceAnalysis interfaceAnalysis = InterfaceAnalysis.getInterfaceAnalysis(remoteInterfaces[0]);
+      this.beanRepositoryIds = interfaceAnalysis.getAllTypeIds();
+      
+      InterfaceAnalysis homeInterfaceAnalysis = null;
+      Class homeInterface = ProxyFactoryHelper.getRemoteHomeInterface(container);
+      if(homeInterface != null)
+      {
+         if(!EJBHome.class.isAssignableFrom(homeInterface))
+            throw new IllegalArgumentException("home interface " + homeInterface.getName() + " must extend javax.ejb.EJBHome (EJB3 4.6.8)");
+         homeInterfaceAnalysis = InterfaceAnalysis.getInterfaceAnalysis(homeInterface);
+         this.homeRepositoryIds = homeInterfaceAnalysis.getAllTypeIds();
+      }
+      // To allow EJB3 Stateless beans to operate we can function without a home interface.
+      
+      // Get orb and irPoa references
+      try {
+         orb = (ORB)InitialContextFactory.getInitialContext().lookup("java:/" + CorbaORBService.ORB_NAME);
+      }
+      catch (NamingException e) {
+         throw new Exception("Cannot lookup java:/" + CorbaORBService.ORB_NAME + ": " + e);
+      }
+      try {
+         irPoa = (POA)InitialContextFactory.getInitialContext().lookup("java:/" + CorbaORBService.IR_POA_NAME);
+      }
+      catch (NamingException e) {
+         throw new Exception("Cannot lookup java:/" + CorbaORBService.IR_POA_NAME + ": " + e);
+      }
+      
+      IIOP iiop = getIIOP();
+      if(iiop.interfaceRepositorySupported())
+      {
+         this.iri = new InterfaceRepository(orb, irPoa, getJndiName());
+         iri.mapClass(remoteInterfaces[0]);
+         if(homeInterface != null)
+            iri.mapClass(homeInterface);
+         iri.finishBuild();
+      }
+      
+      // TODO: obtain the iiop invoker name properly
+      ObjectName invokerName = new ObjectName("jboss:service=invoker,type=iiop");
+      ServantRegistries servantRegistries = (ServantRegistries) Registry.lookup(invokerName);
+      if(servantRegistries == null)
+         throw new Exception("can't find iiop invoker");
+      ServantRegistryKind registryWithTransientPOA;
+      ServantRegistryKind registryWithPersistentPOA; 
+      if(iiop.poa().equals(IIOP.POA_PER_SERVANT))
+      {
+         registryWithTransientPOA = ServantRegistryKind.TRANSIENT_POA_PER_SERVANT;
+         registryWithPersistentPOA = ServantRegistryKind.PERSISTENT_POA_PER_SERVANT;
+      }
+      else if(iiop.poa().equals(IIOP.POA_SHARED))
+      {
+         registryWithTransientPOA = ServantRegistryKind.SHARED_TRANSIENT_POA;
+         registryWithPersistentPOA = ServantRegistryKind.SHARED_PERSISTENT_POA;
+      }
+      else
+         throw new IllegalArgumentException("@IIOP.poa can only be 'per-servant' or 'shared'");
+      // Only works for session container
+      this.servantRegistry = servantRegistries.getServantRegistry(registryWithTransientPOA);
+      this.homeServantRegistry = servantRegistries.getServantRegistry(registryWithPersistentPOA); // TODO: why is home interface in persistent poa?
+      
+      // Hack in a WebCL (from org.jboss.ejb.EjbModule.initializeContainer)
+      // TODO:  seting up a WebClassLoader needs to be done somewhere where
+      ObjectName on = container.getObjectName();
+      this.wcl = new EJB3IIOPWebClassLoader(on, (RealClassLoader) container.getClassloader(), getJndiName());
+      WebServiceMBean webServer = getWebServer();
+      URL[] codebaseURLs = {webServer.addClassLoader(wcl)};
+      wcl.setWebURLs(codebaseURLs);
+      
+      // setup a codebase policy, the CodebaseInterceptor will translate this to a TAG_JAVA_CODEBASE
+      String codebaseString = wcl.getCodebaseString();
+      log.debug("codebase = " + codebaseString);
+      Any codebase = orb.create_any();
+      codebase.insert_string(codebaseString);
+      Policy codebasePolicy;
+      codebasePolicy = orb.create_policy(CodebasePolicy.TYPE, codebase);
+      
+      // Create csiv2Policy for both home and remote containing
+      // IorSecurityConfigMetadata
+      Any secPolicy = orb.create_any();
+//      IorSecurityConfigMetaData iorSecurityConfigMetaData =
+//         container.getBeanMetaData().getIorSecurityConfigMetaData();
+      IorSecurityConfigMetaData iorSecurityConfigMetaData = new IorSecurityConfigMetaData(); // TODO: make ior security configurable
+      secPolicy.insert_Value(iorSecurityConfigMetaData);
+      Policy csiv2Policy = orb.create_policy(CSIv2Policy.TYPE, secPolicy);
+      
+      Policy policies[] = { codebasePolicy, csiv2Policy };
+      
+      InterfaceDef interfaceDef = null;
+      if(iri != null)
+      {
+         Repository ir = iri.getReference();
+         interfaceDef = InterfaceDefHelper.narrow(ir.lookup_id(beanRepositoryIds[0]));
+      }
+      
+      Current poaCurrent = CurrentHelper.narrow(orb.resolve_initial_references("POACurrent"));
+
+      NamingContextExt ctx = getNamingContextExt();
+
+      log.debug("binding servant name " + getServantName());
+      
+      Servant servant = new BeanCorbaServant(this, poaCurrent, container, interfaceDef, interfaceAnalysis);
+      this.referenceFactory = servantRegistry.bind(getServantName(), servant, policies);
+      
+      EJBObject corbaObj = (EJBObject) createProxy();
+      
+      rebind(ctx, getJndiName(), (org.omg.CORBA.Object) corbaObj);
+      
+      // TODO: use iri
+      if(homeInterfaceAnalysis != null)
+      {
+         servant = new BeanCorbaServant(this, poaCurrent, container, null, homeInterfaceAnalysis);
+         this.homeReferenceFactory = homeServantRegistry.bind(getServantName() + "Home", servant, policies);
+         
+         Object homeObject = createHomeProxy();
+         
+         rebind(ctx, ProxyFactoryHelper.getHomeJndiName(container), (org.omg.CORBA.Object) homeObject);
+      }
+      
+      // bind HandleDelegate stuff for client usage
+      Context compCtx = (Context) InitialContextFactory.getInitialContext().lookup("java:comp");
+      NonSerializableFactory.rebind(compCtx, "ORB", orb);
+      NonSerializableFactory.rebind(compCtx, "HandleDelegate", new HandleDelegateImpl());
+   }
+   
+   public void stop() throws Exception
+   {
+      if(homeReferenceFactory != null)
+      {
+         unbind(ProxyFactoryHelper.getHomeJndiName(container));
+         unbindHomeServant();
+      }
+      unbind(getJndiName());
+      
+      unbindServant();
+      
+      removeWebClassLoader();
+   }
+   
+   /**
+    * Unbind the bean from CosNaming
+    */
+   private void unbind(String strName)
+   {
+      try
+      {
+         NamingContextExt corbaContext = getNamingContextExt();
+         NameComponent n[] = corbaContext.to_name(strName);
+         getNamingContextExt().unbind(n);
+      }
+      catch(Exception e)
+      {
+         log.warn("unable to unbind '" + strName + "'", e);
+      }
+   }
+   
+   private void unbindHomeServant()
+   {
+      try
+      {
+         homeServantRegistry.unbind(getServantName() + "Home");
+      }
+      catch(Exception e)
+      {
+         log.warn("unable to unbind home servant", e);
+      }
+   }
+   
+   private void unbindServant()
+   {
+      try
+      {
+         servantRegistry.unbind(getServantName());
+      }
+      catch(Exception e)
+      {
+         log.warn("unable to unbind servant", e);
+      }
+   }
+
+   private NamingContextExt getNamingContextExt() throws NamingException
+   {
+      Context initialContext = InitialContextFactory.getInitialContext();
+      
+      // NOTE: eclipse editor parser crashes silently on this line (because of org.jboss.iiop.CorbaNamingService) with unknown reason
+      // that's why this method is at the end
+      return NamingContextExtHelper.narrow((org.omg.CORBA.Object) initialContext.lookup("java:/" + org.jboss.iiop.CorbaNamingService.NAMING_NAME));
+   }
+}
\ No newline at end of file

Added: branches/JBPAPP_5_0/ejb3/src/resources/META-INF/ejb3-iiop-deployers-jboss-beans.xml
===================================================================
--- branches/JBPAPP_5_0/ejb3/src/resources/META-INF/ejb3-iiop-deployers-jboss-beans.xml	                        (rev 0)
+++ branches/JBPAPP_5_0/ejb3/src/resources/META-INF/ejb3-iiop-deployers-jboss-beans.xml	2009-11-30 12:49:29 UTC (rev 97163)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+   <!-- This will be taken over by a deployer from ejb3 project -->
+   <bean name="EJBsDeployer" class="org.jboss.as.ejb3.deployers.EJBsDeployer"/>
+   
+   <bean name="EJB3IORDeployer" class="org.jboss.as.ejb3.deployers.IORDeployer"/>
+</deployment>
\ No newline at end of file

Modified: branches/JBPAPP_5_0/testsuite/.classpath
===================================================================
--- branches/JBPAPP_5_0/testsuite/.classpath	2009-11-30 12:23:57 UTC (rev 97162)
+++ branches/JBPAPP_5_0/testsuite/.classpath	2009-11-30 12:49:29 UTC (rev 97163)
@@ -28,7 +28,7 @@
 	<classpathentry kind="lib" path="/thirdparty/apache-codec/lib/commons-codec.jar"/>
 	<classpathentry kind="lib" path="/thirdparty/xmlunit-xmlunit/lib/xmlunit1.0.jar"/>
 	<classpathentry kind="lib" path="/tools/lib/ant.jar"/>
-  	<classpathentry kind="lib" path="/tools/lib/ant-junit.jar"/>
+	<classpathentry kind="lib" path="/tools/lib/ant-junit.jar"/>
 	<classpathentry kind="lib" path="/thirdparty/httpunit/lib/httpunit.jar"/>
 	<classpathentry kind="lib" path="/thirdparty/junit/lib/junit.jar" sourcepath="/thirdparty/junit/lib/junit-sources.jar"/>
 	<classpathentry kind="lib" path="/thirdparty/org/easymock/lib/easymock.jar" sourcepath="/thirdparty/org/easymock/lib/easymock-sources.jar"/>
@@ -57,7 +57,7 @@
 	<classpathentry kind="lib" path="/thirdparty/org/jboss/slf4j/lib/slf4j-jboss-logging.jar" sourcepath="/thirdparty/org/jboss/slf4j/lib/slf4j-jboss-logging-sources.jar"/>
 	<classpathentry kind="lib" path="/thirdparty/jboss/jbossts/lib/jbossjts.jar"/>
 	<classpathentry kind="lib" path="/thirdparty/jboss/server/manager/lib/jboss-server-manager.jar" sourcepath="/thirdparty/jboss/server/manager/lib/jboss-server-manager-sources.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-ejb3-proxy-impl/lib/jboss-ejb3-proxy-impl.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-ejb3-proxy-impl/lib/jboss-ejb3-proxy-impl.jar" sourcepath="/thirdparty/jboss/jboss-ejb3-proxy-impl/lib/jboss-ejb3-proxy-impl-sources.jar"/>
 	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-ejb3-proxy-spi/lib/jboss-ejb3-proxy-spi.jar"/>
 	<classpathentry kind="lib" path="/thirdparty/jboss/jbossts/lib/jbossjts-integration.jar"/>
 	<classpathentry kind="output" path="output/eclipse-classes"/>

Modified: branches/JBPAPP_5_0/testsuite/build.xml
===================================================================
--- branches/JBPAPP_5_0/testsuite/build.xml	2009-11-30 12:23:57 UTC (rev 97162)
+++ branches/JBPAPP_5_0/testsuite/build.xml	2009-11-30 12:49:29 UTC (rev 97163)
@@ -1091,10 +1091,12 @@
    <!-- Tests needing IIOP setup -->
    <patternset id="iiop.includes">
       <include name="org/jboss/test/*iiop/test/*TestCase.class"/>
+      <include name="org/jboss/test/ejb3/*iiop/unit/*TestCase.class"/>
       <exclude name="org/jboss/test/txiiop/test/*TestCase.class"/>
    </patternset>
    <patternset id="iiop.excludes">
       <exclude name="org/jboss/test/*iiop/test/*"/>
+      <exclude name="org/jboss/test/ejb3/*iiop/unit/*"/>
    </patternset>
    <!-- A patternset that requires jboss to run with a JACC security manager -->
    <patternset id="jacc.includes">
@@ -2798,6 +2800,7 @@
          timeout="${junit.timeout}"
          jvm="${junit.jvm}">
 
+         <jvmarg value="-Dj2ee.clientName=test"/>
          <jvmarg value="-Dorg.omg.CORBA.ORBClass=org.jacorb.orb.ORB"/>
          <jvmarg value="-Dorg.omg.CORBA.ORBSingletonClass=org.jacorb.orb.ORBSingleton"/>
          <jvmarg value="-Djacorb.orb.print_version=off"/>
@@ -2806,8 +2809,10 @@
          <jvmarg value="-Djacorb.log.loggerFactory=org.jboss.util.Log4jLoggerFactory"/>
          <jvmarg value="-Djacorb.security.ssl.client.supported_options=0"/>
          <jvmarg value="-Djacorb.security.ssl.client.required_options=0"/>
+         <jvmarg value="-Djava.naming.factory.url.pkgs=org.jboss.naming.client"/>
          <jvmarg value="-DORBInitRef.NameService=corbaloc::${node0}:3528/JBoss/Naming/root"/>
          <jvmarg value="-Dorg.omg.PortableInterceptor.ORBInitializerClass.org.jboss.tm.iiop.TxClientInterceptorInitializer"/>
+         <jvmarg value="-Dorg.omg.PortableInterceptor.ORBInitializerClass.org.jboss.iiop.csiv2.SASClientInitializer"/>
          <jvmarg value="-Djava.security.manager"/>
          <sysproperty key="java.naming.provider.url" value="${node0.jndi.url}"/>
          <sysproperty key="jbosstest.server.host" value="${node0}"/>
@@ -3554,7 +3559,7 @@
       | Run iiop testcases in a single directory by specifing the test
       | directory name in -Dtest=dirname in tests/dirname/test/**TestCase.class
     -->
-   <target name="iiop-test" depends="maybejars" if="test"
+   <target name="iiop-test" if="test"
       description="Execute a single test.">
       <mkdir dir="${build.reports}"/>
       <mkdir dir="${build.testlog}"/>
@@ -3574,6 +3579,7 @@
          <sysproperty key="build.testlog" value="${build.testlog}"/>
          <sysproperty key="log4j.configuration" value="file:${build.resources}/log4j.xml"/>
 
+         <jvmarg value="-Dj2ee.clientName=test"/>
          <jvmarg value="-Dorg.omg.CORBA.ORBClass=org.jacorb.orb.ORB"/>
          <jvmarg value="-Dorg.omg.CORBA.ORBSingletonClass=org.jacorb.orb.ORBSingleton"/>
          <jvmarg value="-Djacorb.orb.print_version=off"/>
@@ -3582,8 +3588,10 @@
          <jvmarg value="-Djacorb.log.loggerFactory=org.jboss.util.Log4jLoggerFactory"/>
          <jvmarg value="-Djacorb.security.ssl.client.supported_options=0"/>
          <jvmarg value="-Djacorb.security.ssl.client.required_options=0"/>
+         <jvmarg value="-Djava.naming.factory.url.pkgs=org.jboss.naming.client"/>
          <jvmarg value="-DORBInitRef.NameService=corbaloc::${node0}:3528/JBoss/Naming/root"/>
          <jvmarg value="-Dorg.omg.PortableInterceptor.ORBInitializerClass.org.jboss.tm.iiop.TxClientInterceptorInitializer"/>
+         <jvmarg value="-Dorg.omg.PortableInterceptor.ORBInitializerClass.org.jboss.iiop.csiv2.SASClientInitializer"/>
          <jvmarg value="-Djava.security.manager"/>
          <sysproperty key="java.security.policy" value="${build.resources}/iiop/client.policy"/>
          <sysproperty key="log4j.properties" file="${build.resources}/log4j.properties"/>

Modified: branches/JBPAPP_5_0/testsuite/imports/sections/ejb3.xml
===================================================================
--- branches/JBPAPP_5_0/testsuite/imports/sections/ejb3.xml	2009-11-30 12:23:57 UTC (rev 97162)
+++ branches/JBPAPP_5_0/testsuite/imports/sections/ejb3.xml	2009-11-30 12:49:29 UTC (rev 97163)
@@ -1,4 +1,21 @@
 <project name="tests-ejb3-jars">
+   <target name="ejb3iiop"
+      description="Builds iiop.jar."
+      depends="compile">
+
+      <mkdir dir="${build.lib}"/>
+
+      <jar jarfile="${build.lib}/ejb3iiop.jar">
+         <fileset dir="${build.classes}">
+            <include name="org/jboss/test/ejb3/iiop/*.class"/>
+         </fileset>
+         <fileset dir="${source.resources}/ejb3/iiop">
+            <include name="users.properties"/>
+            <include name="roles.properties"/>
+         </fileset>
+      </jar>
+   </target>
+   
    <target name="jbas5713" depends="compile">
       <mkdir dir="${build.lib}" />
       

Copied: branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop (from rev 96440, branches/JBPAPP_5_0/ejb3/src/test/org/jboss/ejb3/test/iiop)

Modified: branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/HomedStatelessBean.java
===================================================================
--- branches/JBPAPP_5_0/ejb3/src/test/org/jboss/ejb3/test/iiop/HomedStatelessBean.java	2009-11-16 14:07:55 UTC (rev 96440)
+++ branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/HomedStatelessBean.java	2009-11-30 12:49:29 UTC (rev 97163)
@@ -19,18 +19,14 @@
  * 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;
+package org.jboss.test.ejb3.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
  *
@@ -38,9 +34,9 @@
  * @version $Revision$
  */
 @Stateless
- at Remote(MySession.class)
+//@Remote(MySession.class) // EJB 3.0 4.6.6, no longer allowed
 @RemoteHome(HomedStatelessHome.class)
- at RemoteBinding(factory=RemoteBindingDefaults.PROXY_FACTORY_IMPLEMENTATION_IOR)
+//@RemoteBinding(factory=RemoteBindingDefaults.PROXY_FACTORY_IMPLEMENTATION_IOR) // JBMETA-117
 public class HomedStatelessBean
 {
    @Resource SessionContext ctx;

Modified: branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/HomedStatelessHome.java
===================================================================
--- branches/JBPAPP_5_0/ejb3/src/test/org/jboss/ejb3/test/iiop/HomedStatelessHome.java	2009-11-16 14:07:55 UTC (rev 96440)
+++ branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/HomedStatelessHome.java	2009-11-30 12:49:29 UTC (rev 97163)
@@ -19,7 +19,7 @@
  * 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;
+package org.jboss.test.ejb3.iiop;
 
 import java.rmi.RemoteException;
 

Modified: branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/MyServiceBean.java
===================================================================
--- branches/JBPAPP_5_0/ejb3/src/test/org/jboss/ejb3/test/iiop/MyServiceBean.java	2009-11-16 14:07:55 UTC (rev 96440)
+++ branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/MyServiceBean.java	2009-11-30 12:49:29 UTC (rev 97163)
@@ -19,12 +19,9 @@
  * 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;
+package org.jboss.test.ejb3.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;
 
@@ -34,8 +31,9 @@
  * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
  * @version $Revision$
  */
- at Service
- at Remote(MyStateful.class)
+// TODO
+//@Service
+//@Remote(MyStateful.class)
 @RemoteBinding(factory=RemoteBindingDefaults.PROXY_FACTORY_IMPLEMENTATION_IOR)
 public class MyServiceBean
 {

Modified: branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/MySession.java
===================================================================
--- branches/JBPAPP_5_0/ejb3/src/test/org/jboss/ejb3/test/iiop/MySession.java	2009-11-16 14:07:55 UTC (rev 96440)
+++ branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/MySession.java	2009-11-30 12:49:29 UTC (rev 97163)
@@ -19,7 +19,7 @@
  * 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;
+package org.jboss.test.ejb3.iiop;
 
 import java.rmi.RemoteException;
 

Modified: branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/MySessionBean.java
===================================================================
--- branches/JBPAPP_5_0/ejb3/src/test/org/jboss/ejb3/test/iiop/MySessionBean.java	2009-11-16 14:07:55 UTC (rev 96440)
+++ branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/MySessionBean.java	2009-11-30 12:49:29 UTC (rev 97163)
@@ -19,18 +19,16 @@
  * 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;
+package org.jboss.test.ejb3.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.IIOP;
-import org.jboss.ejb3.annotation.RemoteBinding;
 import org.jboss.ejb3.annotation.SecurityDomain;
-import org.jboss.ejb3.annotation.defaults.RemoteBindingDefaults;
 
 /**
  * Comment
@@ -39,8 +37,9 @@
  * @version $Revision$
  */
 @Stateless
- at Remote(MySession.class)
- at RemoteBinding(factory=RemoteBindingDefaults.PROXY_FACTORY_IMPLEMENTATION_IOR)
+//@Remote(MySession.class) // EJB 3.0 4.6.6, no longer allowed
+ at RemoteHome(HomedStatelessHome.class)
+//@RemoteBinding(factory=RemoteBindingDefaults.PROXY_FACTORY_IMPLEMENTATION_IOR) // JBMETA-117
 @IIOP(interfaceRepositorySupported=false)
 @SecurityDomain("other")
 public class MySessionBean

Modified: branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/MyStateful.java
===================================================================
--- branches/JBPAPP_5_0/ejb3/src/test/org/jboss/ejb3/test/iiop/MyStateful.java	2009-11-16 14:07:55 UTC (rev 96440)
+++ branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/MyStateful.java	2009-11-30 12:49:29 UTC (rev 97163)
@@ -19,7 +19,7 @@
  * 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;
+package org.jboss.test.ejb3.iiop;
 
 import java.rmi.RemoteException;
 

Modified: branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/MyStatefulBean.java
===================================================================
--- branches/JBPAPP_5_0/ejb3/src/test/org/jboss/ejb3/test/iiop/MyStatefulBean.java	2009-11-16 14:07:55 UTC (rev 96440)
+++ branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/MyStatefulBean.java	2009-11-30 12:49:29 UTC (rev 97163)
@@ -19,21 +19,18 @@
  * 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;
+package org.jboss.test.ejb3.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;
 
 /**
@@ -43,9 +40,9 @@
  * @version $Revision$
  */
 @Stateful
- at Remote(MyStateful.class)
+//@Remote(MyStateful.class) // EJB 3.0 4.6.6, no longer allowed
 @RemoteHome(MyStatefulHome.class)
- at RemoteBinding(factory=RemoteBindingDefaults.PROXY_FACTORY_IMPLEMENTATION_IOR)
+//@RemoteBinding(factory=RemoteBindingDefaults.PROXY_FACTORY_IMPLEMENTATION_IOR) // JBMETA-117
 public class MyStatefulBean
 {
    private static final Logger log = Logger.getLogger(MyStatefulBean.class);

Modified: branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/MyStatefulHome.java
===================================================================
--- branches/JBPAPP_5_0/ejb3/src/test/org/jboss/ejb3/test/iiop/MyStatefulHome.java	2009-11-16 14:07:55 UTC (rev 96440)
+++ branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/MyStatefulHome.java	2009-11-30 12:49:29 UTC (rev 97163)
@@ -19,7 +19,7 @@
  * 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;
+package org.jboss.test.ejb3.iiop;
 
 import java.rmi.RemoteException;
 

Modified: branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/TxTester.java
===================================================================
--- branches/JBPAPP_5_0/ejb3/src/test/org/jboss/ejb3/test/iiop/TxTester.java	2009-11-16 14:07:55 UTC (rev 96440)
+++ branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/TxTester.java	2009-11-30 12:49:29 UTC (rev 97163)
@@ -19,7 +19,7 @@
  * 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;
+package org.jboss.test.ejb3.iiop;
 
 import java.rmi.RemoteException;
 

Modified: branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/TxTesterBean.java
===================================================================
--- branches/JBPAPP_5_0/ejb3/src/test/org/jboss/ejb3/test/iiop/TxTesterBean.java	2009-11-16 14:07:55 UTC (rev 96440)
+++ branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/TxTesterBean.java	2009-11-30 12:49:29 UTC (rev 97163)
@@ -19,10 +19,10 @@
  * 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;
+package org.jboss.test.ejb3.iiop;
 
 import javax.ejb.EJBException;
-import javax.ejb.Remote;
+import javax.ejb.RemoteHome;
 import javax.ejb.Stateless;
 import javax.ejb.TransactionAttribute;
 import javax.ejb.TransactionAttributeType;
@@ -34,8 +34,6 @@
 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;
 
 /**
@@ -45,8 +43,9 @@
  * @version $Revision$
  */
 @Stateless
- at Remote(TxTester.class)
- at RemoteBinding(factory=RemoteBindingDefaults.PROXY_FACTORY_IMPLEMENTATION_IOR)
+//@Remote(TxTester.class) // EJB 3.0 4.6.6, no longer allowed
+ at RemoteHome(TxTesterHome.class)
+//@RemoteBinding(factory=RemoteBindingDefaults.PROXY_FACTORY_IMPLEMENTATION_IOR) // JBMETA-117
 @TransactionManagement(TransactionManagementType.CONTAINER)
 public class TxTesterBean
 {

Added: branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/TxTesterHome.java
===================================================================
--- branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/TxTesterHome.java	                        (rev 0)
+++ branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/TxTesterHome.java	2009-11-30 12:49:29 UTC (rev 97163)
@@ -0,0 +1,36 @@
+/*
+ * 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.test.ejb3.iiop;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBHome;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface TxTesterHome extends EJBHome
+{
+   TxTester create() throws CreateException, RemoteException;
+}

Modified: branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/unit/IiopRemoteUnitTestCase.java
===================================================================
--- branches/JBPAPP_5_0/ejb3/src/test/org/jboss/ejb3/test/iiop/unit/IiopRemoteUnitTestCase.java	2009-11-16 14:07:55 UTC (rev 96440)
+++ branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/iiop/unit/IiopRemoteUnitTestCase.java	2009-11-30 12:49:29 UTC (rev 97163)
@@ -19,31 +19,28 @@
  * 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;
+package org.jboss.test.ejb3.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;
+import org.jboss.test.JBossIIOPTestCase;
+import org.jboss.test.ejb3.iiop.HomedStatelessHome;
+import org.jboss.test.ejb3.iiop.MySession;
+import org.jboss.test.ejb3.iiop.MyStateful;
+import org.jboss.test.ejb3.iiop.MyStatefulHome;
+import org.jboss.test.ejb3.iiop.TxTester;
 
 /**
  * TODO: use JBossIIOPTestCase
@@ -51,7 +48,7 @@
  * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
  * @version $Revision$
  */
-public class IiopRemoteUnitTestCase extends CustomJNDIJBossTestCase
+public class IiopRemoteUnitTestCase extends JBossIIOPTestCase
 {
 
    public IiopRemoteUnitTestCase(String name)
@@ -59,6 +56,7 @@
       super(name);
    }
 
+   /*
    @Override
    public InitialContext getInitialContext() throws NamingException
    {
@@ -79,7 +77,9 @@
       
       return props;
 //      return null;
+   
    }
+   */
    
    @Override
    protected void tearDown() throws Exception
@@ -89,10 +89,10 @@
       SecurityAssociation.clear();
    }
    
-   public void test0() throws Exception
-   {
-      System.out.println("java: " + getInitialContext().lookup("java:comp/HandleDelegate"));
-   }
+//   public void test0() throws Exception
+//   {
+//      System.out.println("java: " + getInitialContext().lookup("java:comp/HandleDelegate"));
+//   }
    
    public void test1() throws Exception
    {
@@ -163,7 +163,8 @@
       // TODO: check home2
    }
    
-   public void testGetPrimaryKeyAndRemove() throws Exception
+   // IGNORE: EJB 3.0 Specification Violation 3.6.2.2: Session beans do not have a primary key
+   public void _testGetPrimaryKeyAndRemove() throws Exception
    {
       InitialContext ctx = getInitialContext();
       Object obj = ctx.lookup("MyStatefulBean/home");
@@ -244,7 +245,8 @@
       assertEquals(actual, "somebody");
    }
    
-   public void testService() throws Exception
+   // IGNORE: Service beans are no longer invokable through IIOP
+   public void _testService() throws Exception
    {
       InitialContext ctx = getInitialContext();
       Object obj = ctx.lookup("MyServiceBean/remote");
@@ -310,7 +312,7 @@
       {
          t.printStackTrace();
       }
-      return getDeploySetup(IiopRemoteUnitTestCase.class, "iiop.jar");
+      return getDeploySetup(IiopRemoteUnitTestCase.class, "ejb3iiop.jar");
    }
 
 }

Copied: branches/JBPAPP_5_0/testsuite/src/resources/ejb3/iiop/roles.properties (from rev 96440, branches/JBPAPP_5_0/ejb3/src/resources/test/roles.properties)
===================================================================
--- branches/JBPAPP_5_0/testsuite/src/resources/ejb3/iiop/roles.properties	                        (rev 0)
+++ branches/JBPAPP_5_0/testsuite/src/resources/ejb3/iiop/roles.properties	2009-11-30 12:49:29 UTC (rev 97163)
@@ -0,0 +1,2 @@
+rolefail=willfail
+somebody=allowed

Copied: branches/JBPAPP_5_0/testsuite/src/resources/ejb3/iiop/users.properties (from rev 96440, branches/JBPAPP_5_0/ejb3/src/resources/test/users.properties)
===================================================================
--- branches/JBPAPP_5_0/testsuite/src/resources/ejb3/iiop/users.properties	                        (rev 0)
+++ branches/JBPAPP_5_0/testsuite/src/resources/ejb3/iiop/users.properties	2009-11-30 12:49:29 UTC (rev 97163)
@@ -0,0 +1,2 @@
+somebody=password
+rolefail=password




More information about the jboss-cvs-commits mailing list