You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2006/10/06 18:34:30 UTC
svn commit: r453666 - in /incubator/openejb/trunk/openejb3:
container/openejb-core/src/main/java/org/apache/openejb/
container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/
container/openejb-core/src/main/java/org/apache/openejb/core...
Author: dblevins
Date: Fri Oct 6 09:34:28 2006
New Revision: 453666
URL: http://svn.apache.org/viewvc?view=rev&rev=453666
Log:
OPENEJB-93 Local business interfaces via IntraVM Server
OPENEJB-157 iTest: StatelessLocalBusinessIntfcTests
OPENEJB-183 iTest: StatefulLocalBusinessIntfcTests
Added:
incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/BusinessLocalReference.java
incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/BusinessRemoteReference.java
incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateless/BasicStatelessBusinessLocal.java
incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateless/StatelessLocalBusinessIntfcTests.java
Modified:
incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/DeploymentInfo.java
incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java
incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreDeploymentInfo.java
incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulContainer.java
incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/StatefulContainerTest.java
incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateful/BasicStatefulPojoBean.java
incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateful/StatefulLocalTestSuite.java
incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateless/BasicStatelessPojoBean.java
incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateless/StatelessLocalTestSuite.java
incubator/openejb/trunk/openejb3/openejb-itests/src/main/resources/META-INF/ejb-jar.xml
Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/DeploymentInfo.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/DeploymentInfo.java?view=diff&rev=453666&r1=453665&r2=453666
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/DeploymentInfo.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/DeploymentInfo.java Fri Oct 6 09:34:28 2006
@@ -81,6 +81,7 @@
public interface BusinessLocalHome extends javax.ejb.EJBLocalHome {
Object create();
}
+
public interface BusinessRemoteHome extends javax.ejb.EJBHome {
Object create();
}
Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java?view=diff&rev=453666&r1=453665&r2=453666
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java Fri Oct 6 09:34:28 2006
@@ -18,59 +18,156 @@
import org.apache.openejb.DeploymentInfo;
import org.apache.openejb.core.CoreDeploymentInfo;
-import org.apache.openejb.core.ivm.naming.Reference;
+import org.apache.openejb.core.ivm.naming.BusinessLocalReference;
import org.apache.openejb.core.ivm.naming.ObjectReference;
+import org.apache.openejb.core.ivm.naming.Reference;
+import org.apache.openejb.core.ivm.naming.BusinessRemoteReference;
import javax.naming.Context;
+import javax.naming.NamingException;
/**
* @version $Rev$ $Date$
*/
public class JndiBuilder {
+
+ private JndiNameStrategy strategy = new LegacyAddedSuffixStrategy();
private final Context context;
public JndiBuilder(Context context) {
this.context = context;
}
- public void bind(DeploymentInfo deploymentInfo) {
- CoreDeploymentInfo deployment = (CoreDeploymentInfo) deploymentInfo;
- if (deployment.getHomeInterface() != null) {
- bindProxy(deployment, deployment.getEJBHome(), false);
+ public static interface JndiNameStrategy {
+ public static enum Interface {
+ REMOTE_HOME, LOCAL_HOME, BUSINESS_LOCAL, BUSINESS_REMOTE, SERVICE_ENDPOINT
}
- if (deployment.getLocalHomeInterface() != null) {
- bindProxy(deployment, deployment.getEJBLocalHome(), true);
+
+ public String getName(DeploymentInfo deploymentInfo, Class interfce, Interface type);
+ }
+
+ // TODO: put these into the classpath and get them with xbean-finder
+ public static class LegacyAddedSuffixStrategy implements JndiNameStrategy {
+ public String getName(DeploymentInfo deploymentInfo, Class interfce, Interface type) {
+ String id = deploymentInfo.getDeploymentID() + "";
+ if (id.charAt(0) == '/') {
+ id = id.substring(1);
+ }
+
+ switch (type) {
+ case REMOTE_HOME:
+ return id;
+ case LOCAL_HOME:
+ return id + "Local";
+ case BUSINESS_LOCAL:
+ return id + "BusinessLocal";
+ case BUSINESS_REMOTE:
+ return id + "BusinessRemote";
+ }
+ return id;
}
}
- private void bindProxy(CoreDeploymentInfo deployment, Object proxy, boolean isLocal) {
- Reference ref = new ObjectReference(proxy);
+ public static class AddedSuffixStrategy implements JndiNameStrategy {
+ public String getName(DeploymentInfo deploymentInfo, Class interfce, Interface type) {
+ String id = deploymentInfo.getDeploymentID() + "";
+ if (id.charAt(0) == '/') {
+ id = id.substring(1);
+ }
- if (deployment.getComponentType() == DeploymentInfo.STATEFUL) {
- ref = new org.apache.openejb.core.stateful.EncReference(ref);
- } else if (deployment.getComponentType() == DeploymentInfo.STATELESS) {
- ref = new org.apache.openejb.core.stateless.EncReference(ref);
- } else {
- ref = new org.apache.openejb.core.entity.EncReference(ref);
+ switch (type) {
+ case REMOTE_HOME:
+ return id + "Remote";
+ case LOCAL_HOME:
+ return id + "Local";
+ case BUSINESS_LOCAL:
+ return id + "BusinessLocal";
+ case BUSINESS_REMOTE:
+ return id + "BusinessRemote";
+ }
+ return id;
}
+ }
+
+ public static class CommonPrefixStrategy implements JndiNameStrategy {
+ public String getName(DeploymentInfo deploymentInfo, Class interfce, Interface type) {
+ String id = deploymentInfo.getDeploymentID() + "";
+ if (id.charAt(0) == '/') {
+ id = id.substring(1);
+ }
+
+ switch (type) {
+ case REMOTE_HOME:
+ return "component/remote/" + id;
+ case LOCAL_HOME:
+ return "component/local/" + id;
+ case BUSINESS_REMOTE:
+ return "business/remote/" + id;
+ case BUSINESS_LOCAL:
+ return "business/local/" + id;
+ }
+ return id;
+ }
+ }
+
+ public void bind(DeploymentInfo deploymentInfo) {
+
+ CoreDeploymentInfo deployment = (CoreDeploymentInfo) deploymentInfo;
+ Object id = deployment.getDeploymentID();
try {
+ Class homeInterface = deployment.getHomeInterface();
+ if (homeInterface != null) {
+ String name = strategy.getName(deployment, homeInterface, JndiNameStrategy.Interface.REMOTE_HOME);
+ context.bind("openejb/ejb/" + name, getReference(deployment.getEJBHome(), deployment));
+ }
+ } catch (NamingException e) {
+ throw new RuntimeException("Unable to bind home interface for deployment "+id, e);
+ }
- String bindName = deployment.getDeploymentID().toString();
+ try {
+ Class localHomeInterface = deployment.getLocalHomeInterface();
+ if (localHomeInterface != null) {
+ String name = strategy.getName(deployment, localHomeInterface, JndiNameStrategy.Interface.LOCAL_HOME);
+ context.bind("openejb/ejb/" + name, getReference(deployment.getEJBLocalHome(), deployment));
+ }
+ } catch (NamingException e) {
+ throw new RuntimeException("Unable to bind local interface for deployment "+id, e);
+ }
- if (bindName.charAt(0) == '/') {
- bindName = bindName.substring(1);
+ try {
+ Class businessLocalInterface = deployment.getBusinessLocalInterface();
+ if (businessLocalInterface != null) {
+ String name = strategy.getName(deployment, businessLocalInterface, JndiNameStrategy.Interface.BUSINESS_LOCAL);
+ DeploymentInfo.BusinessLocalHome businessLocalHome = deployment.getBusinessLocalHome();
+ context.bind("openejb/ejb/" + name, new BusinessLocalReference(businessLocalHome));
}
+ } catch (NamingException e) {
+ throw new RuntimeException("Unable to bind business local interface for deployment "+id, e);
+ }
- bindName = "openejb/ejb/" + bindName;
- if (isLocal) {
- bindName += "Local";
+ try {
+ Class businessRemoteInterface = deployment.getBusinessRemoteInterface();
+ if (businessRemoteInterface != null) {
+ String name = strategy.getName(deployment, businessRemoteInterface, JndiNameStrategy.Interface.BUSINESS_LOCAL);
+ DeploymentInfo.BusinessRemoteHome businessRemoteHome = deployment.getBusinessRemoteHome();
+ context.bind("openejb/ejb/" + name, new BusinessRemoteReference(businessRemoteHome));
}
- context.bind(bindName, ref);
+ } catch (NamingException e) {
+ throw new RuntimeException("Unable to bind business remote deployment in jndi.", e);
+ }
+ }
+
+ private Reference getReference(Object proxy, CoreDeploymentInfo deployment) {
+ Reference ref = new ObjectReference(proxy);
- } catch (Exception e) {
- e.printStackTrace();
- throw new RuntimeException();
+ if (deployment.getComponentType() == DeploymentInfo.STATEFUL) {
+ ref = new org.apache.openejb.core.stateful.EncReference(ref);
+ } else if (deployment.getComponentType() == DeploymentInfo.STATELESS) {
+ ref = new org.apache.openejb.core.stateless.EncReference(ref);
+ } else {
+ ref = new org.apache.openejb.core.entity.EncReference(ref);
}
+ return ref;
}
}
Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreDeploymentInfo.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreDeploymentInfo.java?view=diff&rev=453666&r1=453665&r2=453666
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreDeploymentInfo.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreDeploymentInfo.java Fri Oct 6 09:34:28 2006
@@ -163,13 +163,13 @@
this.componentType = componentType;
this.archiveURL = archiveURL;
- if (businessLocal != null && localHomeInterface == null){
- this.localHomeInterface = BusinessLocalHome.class;
- }
-
- if (businessRemote != null && homeInterface == null){
- this.homeInterface = BusinessRemoteHome.class;
- }
+// if (businessLocal != null && localHomeInterface == null){
+// this.localHomeInterface = BusinessLocalHome.class;
+// }
+//
+// if (businessRemote != null && homeInterface == null){
+// this.homeInterface = BusinessRemoteHome.class;
+// }
if (SessionBean.class.isAssignableFrom(beanClass)){
try {
Added: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/BusinessLocalReference.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/BusinessLocalReference.java?view=auto&rev=453666
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/BusinessLocalReference.java (added)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/BusinessLocalReference.java Fri Oct 6 09:34:28 2006
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.core.ivm.naming;
+
+import org.apache.openejb.DeploymentInfo;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BusinessLocalReference implements Reference {
+
+ private final DeploymentInfo.BusinessLocalHome businessHome;
+
+ public BusinessLocalReference(DeploymentInfo.BusinessLocalHome businessHome) {
+ this.businessHome = businessHome;
+ }
+
+ public Object getObject() throws javax.naming.NamingException {
+ return businessHome.create();
+ }
+
+}
Added: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/BusinessRemoteReference.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/BusinessRemoteReference.java?view=auto&rev=453666
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/BusinessRemoteReference.java (added)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/BusinessRemoteReference.java Fri Oct 6 09:34:28 2006
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.core.ivm.naming;
+
+import org.apache.openejb.DeploymentInfo;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BusinessRemoteReference implements Reference {
+
+ private final DeploymentInfo.BusinessRemoteHome businessHome;
+
+ public BusinessRemoteReference(DeploymentInfo.BusinessRemoteHome businessHome) {
+ this.businessHome = businessHome;
+ }
+
+ public Object getObject() throws javax.naming.NamingException {
+ return businessHome.create();
+ }
+}
Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulContainer.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulContainer.java?view=diff&rev=453666&r1=453665&r2=453666
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulContainer.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulContainer.java Fri Oct 6 09:34:28 2006
@@ -120,6 +120,28 @@
} catch (NoSuchMethodException thatsFine) {}
}
+ Class businessLocalHomeInterface = deploymentInfo.getBusinessLocalInterface();
+ if (businessLocalHomeInterface != null){
+ for (Method method : DeploymentInfo.BusinessLocalHome.class.getMethods()) {
+ if (method.getName().startsWith("create")){
+ methods.put(method, MethodType.CREATE);
+ } else if (method.getName().equals("remove")){
+ methods.put(method, MethodType.REMOVE);
+ }
+ }
+ }
+
+ Class businessRemoteHomeInterface = deploymentInfo.getBusinessRemoteInterface();
+ if (businessRemoteHomeInterface != null){
+ for (Method method : DeploymentInfo.BusinessRemoteHome.class.getMethods()) {
+ if (method.getName().startsWith("create")){
+ methods.put(method, MethodType.CREATE);
+ } else if (method.getName().equals("remove")){
+ methods.put(method, MethodType.REMOVE);
+ }
+ }
+ }
+
Class homeInterface = deploymentInfo.getHomeInterface();
if (homeInterface != null){
for (Method method : homeInterface.getMethods()) {
Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/StatefulContainerTest.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/StatefulContainerTest.java?view=diff&rev=453666&r1=453665&r2=453666
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/StatefulContainerTest.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/StatefulContainerTest.java Fri Oct 6 09:34:28 2006
@@ -56,7 +56,7 @@
public void testPojoStyleBean() throws Exception {
// Do a create...
- Method createMethod = deploymentInfo.getLocalHomeInterface().getMethod("create");
+ Method createMethod = DeploymentInfo.BusinessLocalHome.class.getMethod("create");
Object result = container.invoke("widget", createMethod, new Object[]{}, null, "");
assertTrue("instance of ProxyInfo", result instanceof ProxyInfo);
Modified: incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateful/BasicStatefulPojoBean.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateful/BasicStatefulPojoBean.java?view=diff&rev=453666&r1=453665&r2=453666
==============================================================================
--- incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateful/BasicStatefulPojoBean.java (original)
+++ incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateful/BasicStatefulPojoBean.java Fri Oct 6 09:34:28 2006
@@ -32,138 +32,67 @@
* @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
* @author <a href="mailto:nour.mohammad@gmail.com">Mohammad Nour El-Din</a>
*/
-public class BasicStatefulPojoBean {
+public class BasicStatefulPojoBean implements BasicStatefulBusinessLocal {
-
- private String name;
- private SessionContext ejbContext;
- private Hashtable allowedOperationsTable = new Hashtable();
-
- //=============================
- // Remote interface methods
- //
-
/**
- * Maps to BasicStatefulObject.businessMethod
- *
- * @return
- * @see BasicStatefulObject#businessMethod
+ * Maps to BasicStatelessObject.businessMethod
+ *
+ * @return
+ * @see org.apache.openejb.test.stateless.BasicStatelessObject#businessMethod
*/
public String businessMethod(String text){
- testAllowedOperations("businessMethod");
StringBuffer b = new StringBuffer(text);
return b.reverse().toString();
}
+
/**
* Throws an ApplicationException when invoked
- *
+ *
*/
- public void throwApplicationException() throws ApplicationException{
+ public void throwApplicationException() throws ApplicationException {
throw new ApplicationException("Testing ability to throw Application Exceptions");
}
-
+
/**
* Throws a java.lang.NullPointerException when invoked
- * This is a system exception and should result in the
+ * This is a system exception and should result in the
* destruction of the instance and invalidation of the
* remote reference.
- *
+ *
*/
public void throwSystemException_NullPointer() {
throw new NullPointerException("Testing ability to throw System Exceptions");
}
-
+
/**
- * Maps to BasicStatefulObject#getPermissionsReport
- *
+ * Maps to BasicStatelessObject.getPermissionsReport
+ *
* Returns a report of the bean's
* runtime permissions
- *
- * @return
- * @see BasicStatefulObject#getPermissionsReport
+ *
+ * @return
+ * @see org.apache.openejb.test.stateless.BasicStatelessObject#getPermissionsReport
*/
public Properties getPermissionsReport(){
/* TO DO: */
return null;
}
-
+
/**
- * Maps to BasicStatefulObject#getAllowedOperationsReport
- *
+ * Maps to BasicStatelessObject.getAllowedOperationsReport
+ *
* Returns a report of the allowed opperations
* for one of the bean's methods.
- *
+ *
* @param methodName The method for which to get the allowed opperations report
- * @return
- * @see BasicStatefulObject#getAllowedOperationsReport
+ * @return
+ * @see org.apache.openejb.test.stateless.BasicStatelessObject#getAllowedOperationsReport
*/
public OperationsPolicy getAllowedOperationsReport(String methodName){
- return (OperationsPolicy) allowedOperationsTable.get(methodName);
- }
-
- //
- // Remote interface methods
- //=============================
-
- protected void testAllowedOperations(String methodName){
- OperationsPolicy policy = new OperationsPolicy();
-
- /*[1] Test getEJBHome /////////////////*/
- try{
- ejbContext.getEJBHome();
- policy.allow(policy.Context_getEJBHome);
- }catch(IllegalStateException ise){}
-
- /*[2] Test getCallerPrincipal /////////*/
- try{
- ejbContext.getCallerPrincipal();
- policy.allow( policy.Context_getCallerPrincipal );
- }catch(IllegalStateException ise){}
-
- /*[3] Test isCallerInRole /////////////*/
- try{
- ejbContext.isCallerInRole("ROLE");
- policy.allow( policy.Context_isCallerInRole );
- }catch(IllegalStateException ise){}
-
- /*[4] Test getRollbackOnly ////////////*/
- try{
- ejbContext.getRollbackOnly();
- policy.allow( policy.Context_getRollbackOnly );
- }catch(IllegalStateException ise){}
-
- /*[5] Test setRollbackOnly ////////////*/
- try{
- ejbContext.setRollbackOnly();
- policy.allow( policy.Context_setRollbackOnly );
- }catch(IllegalStateException ise){}
-
- /*[6] Test getUserTransaction /////////*/
- try{
- ejbContext.getUserTransaction();
- policy.allow( policy.Context_getUserTransaction );
- }catch(IllegalStateException ise){}
-
- /*[7] Test getEJBObject ///////////////*/
- try{
- ejbContext.getEJBObject();
- policy.allow( policy.Context_getEJBObject );
- }catch(IllegalStateException ise){}
-
- /* TO DO:
- * Check for policy.Enterprise_bean_access
- * Check for policy.JNDI_access_to_java_comp_env
- * Check for policy.Resource_manager_access
- */
- allowedOperationsTable.put(methodName, policy);
- }
-
- /**
- * Set the associated session context. The container calls this method
- * after the instance creation.
- */
- public void setSessionContext(SessionContext ctx) throws EJBException,RemoteException {
+ return null;
}
+ public void setSessionContext(SessionContext ctx) throws EJBException, RemoteException {
+ }
}
Modified: incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateful/StatefulLocalTestSuite.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateful/StatefulLocalTestSuite.java?view=diff&rev=453666&r1=453665&r2=453666
==============================================================================
--- incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateful/StatefulLocalTestSuite.java (original)
+++ incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateful/StatefulLocalTestSuite.java Fri Oct 6 09:34:28 2006
@@ -18,6 +18,7 @@
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.apache.openejb.test.stateless.StatelessLocalBusinessIntfcTests;
/**
* @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
@@ -36,6 +37,7 @@
suite.addTest(new StatefulJndiTests());
suite.addTest(new StatefulPojoLocalJndiTests());
suite.addTest(new StatefulHomeIntfcTests());
+ suite.addTest(new StatefulLocalBusinessIntfcTests());
suite.addTest(new StatefulEjbHomeTests());
suite.addTest(new StatefulEjbObjectTests());
suite.addTest(new StatefulRemoteIntfcTests());
Added: incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateless/BasicStatelessBusinessLocal.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateless/BasicStatelessBusinessLocal.java?view=auto&rev=453666
==============================================================================
--- incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateless/BasicStatelessBusinessLocal.java (added)
+++ incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateless/BasicStatelessBusinessLocal.java Fri Oct 6 09:34:28 2006
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.test.stateless;
+
+import org.apache.openejb.test.ApplicationException;
+import org.apache.openejb.test.object.OperationsPolicy;
+
+import java.util.Properties;
+
+/**
+ *
+ * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
+ * @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
+ */
+public interface BasicStatelessBusinessLocal {
+
+ /**
+ * Reverses the string passed in then returns it
+ *
+ * @return string
+ */
+ public String businessMethod(String text);
+
+ /**
+ * Throws an ApplicationException when invoked
+ *
+ */
+ public void throwApplicationException() throws ApplicationException;
+
+ /**
+ * Throws a java.lang.NullPointerException when invoked
+ * This is a system exception and should result in the
+ * destruction of the instance and invalidation of the
+ * remote reference.
+ *
+ */
+ public void throwSystemException_NullPointer();
+
+ /**
+ * Returns a report of the bean's
+ * runtime permissions
+ *
+ * @return properties
+ */
+ public Properties getPermissionsReport();
+
+ /**
+ * Returns a report of the allowed opperations
+ * for one of the bean's methods.
+ *
+ * @param methodName The method for which to get the allowed opperations report
+ * @return operations policy
+ */
+ public OperationsPolicy getAllowedOperationsReport(String methodName);
+}
Modified: incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateless/BasicStatelessPojoBean.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateless/BasicStatelessPojoBean.java?view=diff&rev=453666&r1=453665&r2=453666
==============================================================================
--- incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateless/BasicStatelessPojoBean.java (original)
+++ incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateless/BasicStatelessPojoBean.java Fri Oct 6 09:34:28 2006
@@ -24,7 +24,7 @@
import java.util.Properties;
import java.rmi.RemoteException;
-public class BasicStatelessPojoBean {
+public class BasicStatelessPojoBean implements BasicStatelessBusinessLocal{
/**
* Maps to BasicStatelessObject.businessMethod
Added: incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateless/StatelessLocalBusinessIntfcTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateless/StatelessLocalBusinessIntfcTests.java?view=auto&rev=453666
==============================================================================
--- incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateless/StatelessLocalBusinessIntfcTests.java (added)
+++ incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateless/StatelessLocalBusinessIntfcTests.java Fri Oct 6 09:34:28 2006
@@ -0,0 +1,125 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.test.stateless;
+
+/**
+ *
+ * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
+ * @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
+ */
+public class StatelessLocalBusinessIntfcTests extends StatelessTestClient {
+ private BasicStatelessBusinessLocal businessLocal;
+
+ public StatelessLocalBusinessIntfcTests(){
+ super("LocalBusinessIntfc.");
+ }
+
+ protected void setUp() throws Exception{
+ super.setUp();
+ }
+
+ //=================================
+ // Test remote interface methods
+ //
+ public void test00_lookupBusinessInterface() throws Exception {
+ Object obj = initialContext.lookup("client/tests/stateless/BasicStatelessPojoHomeBusinessLocal");
+ assertNotNull(obj);
+ assertTrue("instance of BasicStatelessBusinessLocal", obj instanceof BasicStatelessBusinessLocal);
+ businessLocal = (BasicStatelessBusinessLocal) obj;
+ }
+
+ public void test01_businessMethod(){
+ try{
+ String expected = "Success";
+ String actual = businessLocal.businessMethod("sseccuS");
+ assertEquals(expected, actual);
+ } catch (Exception e){
+ fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ }
+ }
+
+ /**
+ * Throw an application exception and make sure the exception
+ * reaches the bean nicely.
+ */
+ public void test02_throwApplicationException(){
+ try{
+ businessLocal.throwApplicationException();
+ } catch (org.apache.openejb.test.ApplicationException e){
+ //Good. This is the correct behaviour
+ return;
+ } catch (Throwable e){
+ fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ }
+ fail("An ApplicationException should have been thrown.");
+ }
+
+ /**
+ * After an application exception we should still be able to
+ * use our bean
+ */
+ public void test03_invokeAfterApplicationException(){
+ try{
+ String expected = "Success";
+ String actual = businessLocal.businessMethod("sseccuS");
+ assertEquals(expected, actual);
+ } catch (Throwable e){
+ fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ }
+ }
+
+ // TODO: check which exception should be thrown
+ public void _test04_throwSystemException(){
+ try{
+ businessLocal.throwSystemException_NullPointer();
+ } catch (Exception e){
+ //Good, so far.
+ Throwable n = e.getCause();
+ assertNotNull("Nested exception should not be is null", n );
+ assertTrue("Nested exception should be an instance of NullPointerException, but exception is "+n.getClass().getName(), (n instanceof NullPointerException));
+ return;
+ } catch (Throwable e){
+ fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ }
+ fail("A NullPointerException should have been thrown.");
+ }
+
+ /**
+ * After a system exception the intance should be garbage collected
+ * and the remote reference should be invalidated.
+ *
+ * This one seems to fail. we should double-check the spec on this.
+ */
+ //TODO: implement
+ public void TODO_test05_invokeAfterSystemException(){
+// try{
+// businessLocal.businessMethod("This refernce is invalid");
+// fail("A java.rmi.NoSuchObjectException should have been thrown.");
+// } catch (java.rmi.NoSuchObjectException e){
+// // Good.
+// } catch (Throwable e){
+// fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+// }
+ }
+ //
+ // Test remote interface methods
+ //=================================
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+}
Modified: incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateless/StatelessLocalTestSuite.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateless/StatelessLocalTestSuite.java?view=diff&rev=453666&r1=453665&r2=453666
==============================================================================
--- incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateless/StatelessLocalTestSuite.java (original)
+++ incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateless/StatelessLocalTestSuite.java Fri Oct 6 09:34:28 2006
@@ -38,6 +38,7 @@
suite.addTest(new StatelessPojoLocalJndiTests());
suite.addTest(new StatelessHomeIntfcTests());
suite.addTest(new StatelessPojoLocalHomeIntfcTests());
+ suite.addTest(new StatelessLocalBusinessIntfcTests());
suite.addTest(new StatelessEjbHomeTests() );
suite.addTest(new StatelessEjbObjectTests());
suite.addTest(new StatelessRemoteIntfcTests());
Modified: incubator/openejb/trunk/openejb3/openejb-itests/src/main/resources/META-INF/ejb-jar.xml
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/openejb-itests/src/main/resources/META-INF/ejb-jar.xml?view=diff&rev=453666&r1=453665&r2=453666
==============================================================================
--- incubator/openejb/trunk/openejb3/openejb-itests/src/main/resources/META-INF/ejb-jar.xml (original)
+++ incubator/openejb/trunk/openejb3/openejb-itests/src/main/resources/META-INF/ejb-jar.xml Fri Oct 6 09:34:28 2006
@@ -262,6 +262,7 @@
<local-home>org.apache.openejb.test.stateful.BasicStatefulLocalHome</local-home>
<local>org.apache.openejb.test.stateful.BasicStatefulLocalObject</local>
<ejb-class>org.apache.openejb.test.stateful.BasicStatefulPojoBean</ejb-class>
+ <business-local>org.apache.openejb.test.stateful.BasicStatefulBusinessLocal</business-local>
<session-type>Stateful</session-type>
<transaction-type>Container</transaction-type>
<security-role-ref>
@@ -505,6 +506,7 @@
<remote>org.apache.openejb.test.stateless.BasicStatelessObject</remote>
<local-home>org.apache.openejb.test.stateless.BasicStatelessLocalHome</local-home>
<local>org.apache.openejb.test.stateless.BasicStatelessLocalObject</local>
+ <business-local>org.apache.openejb.test.stateless.BasicStatelessBusinessLocal</business-local>
<ejb-class>org.apache.openejb.test.stateless.BasicStatelessPojoBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>