[jboss-cvs] JBossAS SVN: r84048 - in branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686: server/src/main/org/jboss/proxy/ejb/handle and 11 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Feb 10 06:30:48 EST 2009
Author: galder.zamarreno at jboss.com
Date: 2009-02-10 06:30:48 -0500 (Tue, 10 Feb 2009)
New Revision: 84048
Added:
branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/imports/sections/ejb.xml
branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/main/org/jboss/test/ejb/
branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/main/org/jboss/test/ejb/proxy/
branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/main/org/jboss/test/ejb/proxy/beans/
branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/main/org/jboss/test/ejb/proxy/beans/HandleRetrievalStatefulSessionInterceptor.java
branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/main/org/jboss/test/ejb/proxy/beans/StatefulCounter.java
branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/main/org/jboss/test/ejb/proxy/beans/StatefulCounterBean.java
branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/main/org/jboss/test/ejb/proxy/beans/StatefulCounterHome.java
branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/main/org/jboss/test/ejb/proxy/test/
branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/main/org/jboss/test/ejb/proxy/test/ProxyLogicTestCase.java
branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/resources/ejb/
branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/resources/ejb/proxy/
branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/resources/ejb/proxy/META-INF/
branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/resources/ejb/proxy/META-INF/ejb-jar.xml
branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/resources/ejb/proxy/META-INF/jboss.xml
Modified:
branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/server/src/main/org/jboss/proxy/ejb/StatefulSessionInterceptor.java
branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/server/src/main/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/imports/test-jars.xml
Log:
[JBPAPP-1686] Legacy invoker based EJBObject retrieval method has been properly implemented. A test was also added that verifies which retrieval method is used in each case.
Modified: branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/server/src/main/org/jboss/proxy/ejb/StatefulSessionInterceptor.java
===================================================================
--- branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/server/src/main/org/jboss/proxy/ejb/StatefulSessionInterceptor.java 2009-02-10 09:59:33 UTC (rev 84047)
+++ branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/server/src/main/org/jboss/proxy/ejb/StatefulSessionInterceptor.java 2009-02-10 11:30:48 UTC (rev 84048)
@@ -24,6 +24,8 @@
import java.lang.reflect.Method;
import java.rmi.RemoteException;
+import javax.ejb.Handle;
+
import org.jboss.invocation.Invocation;
import org.jboss.invocation.InvocationContext;
import org.jboss.invocation.InvocationKey;
@@ -34,6 +36,7 @@
/**
*
* @author <a href="mailto:marc.fleury at jboss.org">Marc Fleury</a>
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
* @version $Revision$
*/
public class StatefulSessionInterceptor
@@ -86,13 +89,7 @@
String jndiName = (String) ctx.getValue(InvocationKey.JNDI_NAME);
Invoker invoker = ctx.getInvoker();
Object id = ctx.getCacheId();
- return new StatefulHandleImpl(
- objectName,
- jndiName,
- invoker,
- ctx.getInvokerProxyBinding(),
- id,
- ctx.getValue("InvokerID"));
+ return createHandle(objectName, jndiName, invoker, id, ctx);
}
else if (m.equals(GET_EJB_HOME))
{
@@ -121,6 +118,18 @@
return getNext().invoke(invocation);
}
}
+
+ protected Handle createHandle(int objectName, String jndiName, Invoker invoker,
+ Object id, InvocationContext ctx)
+ {
+ return new StatefulHandleImpl(
+ objectName,
+ jndiName,
+ invoker,
+ ctx.getInvokerProxyBinding(),
+ id,
+ ctx.getValue("InvokerID"));
+ }
private String toString(InvocationContext ctx)
{
Modified: branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/server/src/main/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
===================================================================
--- branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/server/src/main/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java 2009-02-10 09:59:33 UTC (rev 84047)
+++ branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/server/src/main/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java 2009-02-10 11:30:48 UTC (rev 84048)
@@ -27,14 +27,24 @@
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.security.AccessControlException;
+import java.security.AccessController;
+import java.security.Principal;
+import java.security.PrivilegedAction;
import java.util.Hashtable;
import javax.ejb.Handle;
import javax.ejb.EJBObject;
import javax.naming.InitialContext;
+import org.jboss.invocation.Invocation;
+import org.jboss.invocation.InvocationContext;
+import org.jboss.invocation.InvocationKey;
+import org.jboss.invocation.InvocationType;
import org.jboss.invocation.Invoker;
+import org.jboss.invocation.InvokerInterceptor;
+import org.jboss.invocation.PayloadKey;
import org.jboss.logging.Logger;
import org.jboss.naming.NamingContextFactory;
+import org.jboss.security.SecurityAssociation;
/**
* An EJB stateful session bean handle.
@@ -42,6 +52,7 @@
* @author <a href="mailto:marc.fleury at jboss.org">Marc Fleury</a>
* @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
* @author <a href="bill at burkecentral.com">Bill Burke</a>
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
* @version $Revision$
*/
public class StatefulHandleImpl
@@ -160,8 +171,75 @@
*/
public EJBObject getEJBObject() throws RemoteException
{
+ if (invokerProxyBinding != null)
+ {
+ try
+ {
+ return getEjbObjectViaInvoker();
+ }
+ catch(Exception e)
+ {
+ log.debug("Exception reported, try JNDI method to recover EJB object instead", e);
+ return getEjbObjectViaJndi();
+ }
+ }
+
+ return getEjbObjectViaJndi();
+ }
+
+ /**
+ * Returns wether we are local to the originating container or not.
+ */
+ protected boolean isLocal()
+ {
+ return invokerID != null && invokerID.equals(Invoker.ID);
+ }
+
+ protected EJBObject getEjbObjectViaInvoker() throws Exception
+ {
+ if (log.isTraceEnabled())
+ {
+ log.trace("Using legacy invoker method for getEJBObject() invocation.");
+ }
+ SecurityActions sa = SecurityActions.UTIL.getSecurityActions();
+ Invocation invocation = new Invocation(
+ null,
+ GET_EJB_OBJECT,
+ new Object[]{id},
+ //No transaction set up in here? it will get picked up in the proxy
+ null,
+ // fix for bug 474134 from Luke Taylor
+ sa.getPrincipal(),
+ sa.getCredential());
+
+ invocation.setObjectName(new Integer(objectName));
+ invocation.setValue(InvocationKey.INVOKER_PROXY_BINDING,
+ invokerProxyBinding, PayloadKey.AS_IS);
+
+ // It is a home invocation
+ invocation.setType(InvocationType.HOME);
+
+ // Create an invocation context for the invocation
+ InvocationContext ctx = new InvocationContext();
+ invocation.setInvocationContext(ctx);
+
+ // Get the invoker to the target server (cluster or node)
+
+ // Ship it
+ if (isLocal())
+ return (EJBObject) InvokerInterceptor.getLocal().invoke(invocation);
+ else
+ return (EJBObject) invoker.invoke(invocation);
+ }
+
+ protected EJBObject getEjbObjectViaJndi() throws RemoteException
+ {
try
{
+ if (log.isTraceEnabled())
+ {
+ log.trace("Using JNDI method for getEJBObject() invocation.");
+ }
InitialContext ic = null;
if( jndiEnv != null )
ic = new InitialContext(jndiEnv);
@@ -184,5 +262,62 @@
throw new RemoteException("Error during getEJBObject", t);
}
}
+
+ interface SecurityActions
+ {
+ class UTIL
+ {
+ static SecurityActions getSecurityActions()
+ {
+ return System.getSecurityManager() == null ? NON_PRIVILEGED : PRIVILEGED;
+ }
+ }
+
+ SecurityActions NON_PRIVILEGED = new SecurityActions()
+ {
+ public Principal getPrincipal()
+ {
+ return SecurityAssociation.getPrincipal();
+ }
+
+ public Object getCredential()
+ {
+ return SecurityAssociation.getCredential();
+ }
+ };
+
+ SecurityActions PRIVILEGED = new SecurityActions()
+ {
+ private final PrivilegedAction getPrincipalAction = new PrivilegedAction()
+ {
+ public Object run()
+ {
+ return SecurityAssociation.getPrincipal();
+ }
+ };
+
+ private final PrivilegedAction getCredentialAction = new PrivilegedAction()
+ {
+ public Object run()
+ {
+ return SecurityAssociation.getCredential();
+ }
+ };
+
+ public Principal getPrincipal()
+ {
+ return (Principal)AccessController.doPrivileged(getPrincipalAction);
+ }
+
+ public Object getCredential()
+ {
+ return AccessController.doPrivileged(getCredentialAction);
+ }
+ };
+
+ Principal getPrincipal();
+
+ Object getCredential();
+ }
}
Added: branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/imports/sections/ejb.xml
===================================================================
--- branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/imports/sections/ejb.xml (rev 0)
+++ branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/imports/sections/ejb.xml 2009-02-10 11:30:48 UTC (rev 84048)
@@ -0,0 +1,14 @@
+<project name="tests-ejb-jars">
+ <target name="_jars-ejbproxy">
+ <mkdir dir="${build.lib}"/>
+
+ <jar destfile="${build.lib}/ejbproxy-test.jar">
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/test/ejb/proxy/beans/**"/>
+ </fileset>
+ <fileset dir="${build.resources}/ejb/proxy/">
+ <include name="META-INF/*.*"/>
+ </fileset>
+ </jar>
+ </target>
+</project>
\ No newline at end of file
Modified: branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/imports/test-jars.xml
===================================================================
--- branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/imports/test-jars.xml 2009-02-10 09:59:33 UTC (rev 84047)
+++ branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/imports/test-jars.xml 2009-02-10 11:30:48 UTC (rev 84048)
@@ -22,6 +22,7 @@
<import file="sections/deadlock.xml"/>
<import file="sections/deployers.xml"/>
<import file="sections/ejbconf.xml"/>
+ <import file="sections/ejb.xml"/>
<import file="sections/entity.xml"/>
<import file="sections/exception.xml"/>
<import file="sections/foedeployer.xml"/>
@@ -95,6 +96,7 @@
_jars-deployers,
_jars-deployment,
_jars-ejbconf,
+ _jars-ejbproxy,
_jars-entity,
_jars-entitydepends,
_jars-entityexc,
Added: branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/main/org/jboss/test/ejb/proxy/beans/HandleRetrievalStatefulSessionInterceptor.java
===================================================================
--- branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/main/org/jboss/test/ejb/proxy/beans/HandleRetrievalStatefulSessionInterceptor.java (rev 0)
+++ branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/main/org/jboss/test/ejb/proxy/beans/HandleRetrievalStatefulSessionInterceptor.java 2009-02-10 11:30:48 UTC (rev 84048)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.ejb.proxy.beans;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.EJBObject;
+import javax.ejb.Handle;
+
+import org.jboss.invocation.InvocationContext;
+import org.jboss.invocation.Invoker;
+import org.jboss.proxy.ejb.StatefulSessionInterceptor;
+import org.jboss.proxy.ejb.handle.StatefulHandleImpl;
+
+/**
+ * StatefulSessionInterceptor.
+ *
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ */
+public class HandleRetrievalStatefulSessionInterceptor extends StatefulSessionInterceptor
+{
+ private RetrievalMethodHandle handle;
+
+ @Override
+ protected Handle createHandle(int objectName, String jndiName, Invoker invoker, Object id, InvocationContext ctx)
+ {
+ handle = new RetrievalMethodHandle(objectName, jndiName, invoker, ctx.getInvokerProxyBinding(), id, ctx.getValue("InvokerID"));
+ return handle;
+ }
+
+ public class RetrievalMethodHandle extends StatefulHandleImpl
+ {
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -5424836611145344994L;
+
+ private boolean gotEjbObjectViaInvoker;
+
+ private boolean gotEjbObjectViaJndi;
+
+ public RetrievalMethodHandle()
+ {
+ }
+
+ public RetrievalMethodHandle(int objectName, String jndiName, Invoker invoker, String invokerProxyBinding,
+ Object id, Object invokerID)
+ {
+ super(objectName, jndiName, invoker, invokerProxyBinding, id, invokerID);
+ }
+
+ public boolean isGotEjbObjectViaInvoker()
+ {
+ return gotEjbObjectViaInvoker;
+ }
+
+ public boolean isGotEjbObjectViaJndi()
+ {
+ return gotEjbObjectViaJndi;
+ }
+
+ @Override
+ public EJBObject getEJBObject() throws RemoteException
+ {
+ gotEjbObjectViaInvoker = false;
+ gotEjbObjectViaJndi = false;
+ return super.getEJBObject();
+ }
+
+ @Override
+ protected EJBObject getEjbObjectViaInvoker() throws Exception
+ {
+ EJBObject ejbObject = super.getEjbObjectViaInvoker();
+ gotEjbObjectViaInvoker = true;
+ return ejbObject;
+ }
+
+ @Override
+ protected EJBObject getEjbObjectViaJndi() throws RemoteException
+ {
+ EJBObject ejbObject = super.getEjbObjectViaJndi();
+ gotEjbObjectViaJndi = true;
+ return ejbObject;
+ }
+ }
+}
Added: branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/main/org/jboss/test/ejb/proxy/beans/StatefulCounter.java
===================================================================
--- branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/main/org/jboss/test/ejb/proxy/beans/StatefulCounter.java (rev 0)
+++ branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/main/org/jboss/test/ejb/proxy/beans/StatefulCounter.java 2009-02-10 11:30:48 UTC (rev 84048)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.ejb.proxy.beans;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.EJBObject;
+
+/**
+ * StatefulCounter.
+ *
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ */
+public interface StatefulCounter extends EJBObject
+{
+ int count() throws RemoteException;
+}
Added: branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/main/org/jboss/test/ejb/proxy/beans/StatefulCounterBean.java
===================================================================
--- branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/main/org/jboss/test/ejb/proxy/beans/StatefulCounterBean.java (rev 0)
+++ branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/main/org/jboss/test/ejb/proxy/beans/StatefulCounterBean.java 2009-02-10 11:30:48 UTC (rev 84048)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.ejb.proxy.beans;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+
+/**
+ * StatefulCounterBean.
+ *
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ */
+public class StatefulCounterBean implements SessionBean
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -7371337258053062049L;
+
+ private int counter;
+
+ public void ejbCreate() throws CreateException
+ {
+ }
+
+ public void ejbActivate() throws EJBException, RemoteException
+ {
+ }
+
+ public void ejbPassivate() throws EJBException, RemoteException
+ {
+ }
+
+ public void ejbRemove() throws EJBException, RemoteException
+ {
+ }
+
+ public void setSessionContext(SessionContext ctx) throws EJBException, RemoteException
+ {
+ }
+
+ public int count()
+ {
+ return ++counter;
+ }
+}
\ No newline at end of file
Added: branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/main/org/jboss/test/ejb/proxy/beans/StatefulCounterHome.java
===================================================================
--- branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/main/org/jboss/test/ejb/proxy/beans/StatefulCounterHome.java (rev 0)
+++ branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/main/org/jboss/test/ejb/proxy/beans/StatefulCounterHome.java 2009-02-10 11:30:48 UTC (rev 84048)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.ejb.proxy.beans;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBHome;
+
+/**
+ * StatefulCounterHome.
+ *
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ */
+public interface StatefulCounterHome extends EJBHome
+{
+ StatefulCounter create() throws RemoteException, CreateException;
+}
Added: branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/main/org/jboss/test/ejb/proxy/test/ProxyLogicTestCase.java
===================================================================
--- branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/main/org/jboss/test/ejb/proxy/test/ProxyLogicTestCase.java (rev 0)
+++ branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/main/org/jboss/test/ejb/proxy/test/ProxyLogicTestCase.java 2009-02-10 11:30:48 UTC (rev 84048)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.ejb.proxy.test;
+
+import javax.rmi.PortableRemoteObject;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossTestCase;
+import org.jboss.test.ejb.proxy.beans.StatefulCounter;
+import org.jboss.test.ejb.proxy.beans.StatefulCounterHome;
+import org.jboss.test.ejb.proxy.beans.HandleRetrievalStatefulSessionInterceptor.RetrievalMethodHandle;
+
+/**
+ * ProxyLogicTestCase.
+ *
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ */
+public class ProxyLogicTestCase extends JBossTestCase
+{
+ public ProxyLogicTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(ProxyLogicTestCase.class, "ejbproxy-test.jar");
+ }
+
+ public void testEjbGetObjectRetrievalMethod() throws Exception
+ {
+ getLog().debug(getName());
+
+ Object ref = getInitialContext().lookup("ejb/StatefulCounterEjb");
+ StatefulCounterHome home = (StatefulCounterHome) PortableRemoteObject.narrow(ref, StatefulCounterHome.class);
+ StatefulCounter counter = home.create();
+
+ assertEquals(1, counter.count());
+ assertEquals(2, counter.count());
+
+ RetrievalMethodHandle handle = (RetrievalMethodHandle)counter.getHandle();
+ counter = (StatefulCounter) handle.getEJBObject();
+
+ assertEquals(3, counter.count());
+ assertEquals(4, counter.count());
+
+ assertTrue(handle.isGotEjbObjectViaJndi());
+ assertFalse(handle.isGotEjbObjectViaInvoker());
+
+ System.setProperty("org.jboss.ejb.sfsb.handle.V327", "whateveryouwant");
+
+ handle = (RetrievalMethodHandle)counter.getHandle();
+ counter = (StatefulCounter) handle.getEJBObject();
+
+ assertEquals(5, counter.count());
+ assertEquals(6, counter.count());
+
+ assertFalse(handle.isGotEjbObjectViaJndi());
+ assertTrue(handle.isGotEjbObjectViaInvoker());
+ }
+}
\ No newline at end of file
Added: branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/resources/ejb/proxy/META-INF/ejb-jar.xml
===================================================================
--- branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/resources/ejb/proxy/META-INF/ejb-jar.xml (rev 0)
+++ branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/resources/ejb/proxy/META-INF/ejb-jar.xml 2009-02-10 11:30:48 UTC (rev 84048)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"
+ version="2.1">
+ <enterprise-beans>
+ <session>
+ <ejb-name>StatefulCounterEjb</ejb-name>
+ <home>org.jboss.test.ejb.proxy.beans.StatefulCounterHome</home>
+ <remote>org.jboss.test.ejb.proxy.beans.StatefulCounter</remote>
+ <ejb-class>org.jboss.test.ejb.proxy.beans.StatefulCounterBean</ejb-class>
+ <session-type>Stateful</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+ </enterprise-beans>
+</ejb-jar>
\ No newline at end of file
Added: branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/resources/ejb/proxy/META-INF/jboss.xml
===================================================================
--- branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/resources/ejb/proxy/META-INF/jboss.xml (rev 0)
+++ branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/resources/ejb/proxy/META-INF/jboss.xml 2009-02-10 11:30:48 UTC (rev 84048)
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 4.0//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">
+<jboss>
+ <enterprise-beans>
+ <session>
+ <ejb-name>StatefulCounterEjb</ejb-name>
+ <jndi-name>ejb/StatefulCounterEjb</jndi-name>
+ <configuration-name>Mock Standard Stateful SessionBean</configuration-name>
+ </session>
+ </enterprise-beans>
+
+ <invoker-proxy-bindings>
+ <invoker-proxy-binding>
+ <name>mock-stateful-unified-invoker</name>
+ <invoker-mbean>jboss:service=invoker,type=unified</invoker-mbean>
+ <proxy-factory>org.jboss.proxy.ejb.ProxyFactory</proxy-factory>
+ <proxy-factory-config>
+ <client-interceptors>
+ <home>
+ <interceptor>org.jboss.proxy.ejb.HomeInterceptor</interceptor>
+ <interceptor>org.jboss.proxy.SecurityInterceptor</interceptor>
+ <interceptor>org.jboss.proxy.TransactionInterceptor</interceptor>
+ <interceptor call-by-value="false">org.jboss.invocation.InvokerInterceptor</interceptor>
+ <interceptor call-by-value="true">org.jboss.invocation.MarshallingInvokerInterceptor</interceptor>
+ </home>
+ <bean>
+ <interceptor>org.jboss.test.ejb.proxy.beans.HandleRetrievalStatefulSessionInterceptor</interceptor>
+ <interceptor>org.jboss.proxy.SecurityInterceptor</interceptor>
+ <interceptor>org.jboss.proxy.TransactionInterceptor</interceptor>
+ <interceptor call-by-value="false">org.jboss.invocation.InvokerInterceptor</interceptor>
+ <interceptor call-by-value="true">org.jboss.invocation.MarshallingInvokerInterceptor</interceptor>
+ </bean>
+ </client-interceptors>
+ </proxy-factory-config>
+ </invoker-proxy-binding>
+ </invoker-proxy-bindings>
+
+ <container-configurations>
+ <container-configuration extends="Standard Stateful SessionBean">
+ <container-name>Mock Standard Stateful SessionBean</container-name>
+ <invoker-proxy-binding-name>mock-stateful-unified-invoker</invoker-proxy-binding-name>
+ </container-configuration>
+ </container-configurations>
+</jboss>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list