Author: dblevins
Date: Thu Jul 1 17:21:36 2010
New Revision: 959728
URL: http://svn.apache.org/viewvc?rev=959728&view=rev
Log:
Interceptor and LockType attributes not fully stored and retrieved from the
MethodContext.
TransactionType still in progress -- currently still using a hashmap defined in
CoreDeploymentInfo
Added:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/TransactionAttribute.java
(with props)
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/LegacyInterfaceTest.java
(with props)
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/DeploymentInfo.java
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodInfoUtil.java
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodTransactionBuilder.java
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DebuggableVmHackery.java
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreDeploymentInfo.java
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/MethodContext.java
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/transaction/TransactionType.java
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/iTest.java
openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/EntityBean.java
openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/MethodParams.java
openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/QueryMethod.java
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/DeploymentInfo.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/DeploymentInfo.java?rev=959728&r1=959727&r2=959728&view=diff
==============================================================================
---
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/DeploymentInfo.java
(original)
+++
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/DeploymentInfo.java
Thu Jul 1 17:21:36 2010
@@ -33,12 +33,6 @@ import javax.ejb.EJBLocalHome;
public interface DeploymentInfo {
- final public static byte READ_LOCK = (byte) 6;
-
- final public static byte WRITE_LOCK = (byte) 7;
-
- final public static String AC_CREATE_EJBHOME = "create.ejbhome";
-
public BeanType getComponentType();
public InterfaceType getInterfaceType(Class clazz);
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java?rev=959728&r1=959727&r2=959728&view=diff
==============================================================================
---
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
(original)
+++
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
Thu Jul 1 17:21:36 2010
@@ -561,7 +561,7 @@ public class Assembler extends Assembler
if (ejbTimeout != null) {
// If user set the tx attribute to RequiresNew
change it to Required so a new transaction is not started
if
(coreDeploymentInfo.getTransactionType(ejbTimeout) ==
TransactionType.RequiresNew) {
-
coreDeploymentInfo.setMethodTransactionAttribute(ejbTimeout, "Required");
+
coreDeploymentInfo.setMethodTransactionAttribute(ejbTimeout,
TransactionType.Required);
}
// Create the timer
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodInfoUtil.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodInfoUtil.java?rev=959728&r1=959727&r2=959728&view=diff
==============================================================================
---
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodInfoUtil.java
(original)
+++
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodInfoUtil.java
Thu Jul 1 17:21:36 2010
@@ -16,10 +16,13 @@
*/
package org.apache.openejb.assembler.classic;
-import org.apache.openejb.core.CoreDeploymentInfo;
import org.apache.openejb.DeploymentInfo;
import org.apache.openejb.util.Join;
+import javax.ejb.EJBLocalObject;
+import javax.ejb.EJBObject;
+import javax.ejb.EJBHome;
+import javax.ejb.EJBLocalHome;
import static java.util.Arrays.asList;
import java.util.Comparator;
import java.util.List;
@@ -27,6 +30,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Map;
import java.util.LinkedHashMap;
+import java.util.Iterator;
import java.lang.reflect.Method;
/**
@@ -240,9 +244,7 @@ public class MethodInfoUtil {
}
for (Method method : methods) {
- if ((method.getDeclaringClass() ==
javax.ejb.EJBObject.class ||
- method.getDeclaringClass() ==
javax.ejb.EJBHome.class) &&
- !method.getName().equals("remove")) {
+ if (containerMethod(method)) {
continue;
}
@@ -254,6 +256,14 @@ public class MethodInfoUtil {
return attributes;
}
+ private static boolean containerMethod(Method method) {
+ return (method.getDeclaringClass() == EJBObject.class ||
+ method.getDeclaringClass() == EJBHome.class ||
+ method.getDeclaringClass() == EJBLocalObject.class ||
+ method.getDeclaringClass() == EJBLocalHome.class) &&
+ !method.getName().equals("remove");
+ }
+
private static List<Method> getWildCardView(DeploymentInfo info) {
List<Method> methods = new ArrayList<Method>();
@@ -263,29 +273,41 @@ public class MethodInfoUtil {
if (info.getRemoteInterface() != null) {
methods.addAll(exclude(beanMethods,
info.getRemoteInterface().getMethods()));
}
+
if (info.getHomeInterface() != null) {
methods.addAll(exclude(beanMethods,
info.getHomeInterface().getMethods()));
}
+
if (info.getLocalInterface() != null) {
methods.addAll(exclude(beanMethods,
info.getLocalInterface().getMethods()));
}
+
if (info.getLocalHomeInterface() != null) {
methods.addAll(exclude(beanMethods,
info.getLocalHomeInterface().getMethods()));
}
if(info.getMdbInterface() != null) {
methods.addAll(exclude(beanMethods,
info.getMdbInterface().getMethods()));
}
+
if(info.getServiceEndpointInterface() != null) {
methods.addAll(exclude(beanMethods,
info.getServiceEndpointInterface().getMethods()));
}
+
for (Class intf : info.getBusinessRemoteInterfaces()) {
methods.addAll(exclude(beanMethods, intf.getMethods()));
}
+
for (Class intf : info.getBusinessLocalInterfaces()) {
methods.addAll(exclude(beanMethods, intf.getMethods()));
}
-
+ // Remove methods that cannot be controlled by the user
+ Iterator<Method> iterator = methods.iterator();
+ while (iterator.hasNext()) {
+ Method method = iterator.next();
+ if (containerMethod(method)) iterator.remove();
+ }
+
return methods;
}
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodTransactionBuilder.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodTransactionBuilder.java?rev=959728&r1=959727&r2=959728&view=diff
==============================================================================
---
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodTransactionBuilder.java
(original)
+++
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodTransactionBuilder.java
Thu Jul 1 17:21:36 2010
@@ -18,6 +18,7 @@ package org.apache.openejb.assembler.cla
import static
org.apache.openejb.assembler.classic.MethodInfoUtil.resolveAttributes;
import org.apache.openejb.core.CoreDeploymentInfo;
+import org.apache.openejb.core.transaction.TransactionType;
import org.apache.openejb.OpenEJBException;
import org.apache.openejb.DeploymentInfo;
import org.apache.openejb.util.Logger;
@@ -64,7 +65,7 @@ public class MethodTransactionBuilder {
MethodTransactionInfo value = (MethodTransactionInfo)
entry.getValue();
// logger.info(entry.getKey().toString() +" "+
value.transAttribute);
- deploymentInfo.setMethodTransactionAttribute(entry.getKey(),
value.transAttribute);
+ deploymentInfo.setMethodTransactionAttribute(entry.getKey(),
TransactionType.get(value.transAttribute));
}
}
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DebuggableVmHackery.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DebuggableVmHackery.java?rev=959728&r1=959727&r2=959728&view=diff
==============================================================================
---
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DebuggableVmHackery.java
(original)
+++
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DebuggableVmHackery.java
Thu Jul 1 17:21:36 2010
@@ -65,6 +65,9 @@ class DebuggableVmHackery implements Dyn
pruneRefs(bean, ejbDeployment);
+// if (bean.getEjbName().equals("BasicSingletonBean")) {
+// continue;
+// }
if (!(bean instanceof MessageDrivenBean) && !(bean instanceof
EntityBean)) {
continue;
}
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreDeploymentInfo.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreDeploymentInfo.java?rev=959728&r1=959727&r2=959728&view=diff
==============================================================================
---
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreDeploymentInfo.java
(original)
+++
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreDeploymentInfo.java
Thu Jul 1 17:21:36 2010
@@ -348,8 +348,11 @@ public class CoreDeploymentInfo extends
}
public LockType getConcurrencyAttribute(Method beanMethod) {
- LockType attribute =
getMethodContext(beanMethod).getMethodConcurrencyAttribute();
- return (attribute == null)?LockType.WRITE: attribute;
+ return getMethodContext(beanMethod).getLockType();
+ }
+
+ public LockType getLockType() {
+ return LockType.WRITE;
}
public TransactionType getTransactionType(Method method) {
@@ -378,13 +381,17 @@ public class CoreDeploymentInfo extends
log.debug("The following method doesn't have a transaction policy
assigned: " + method);
// default transaction policy is required
- type = TransactionType.Required;
+ type = getTransactionType();
// cache this default to avoid extra log messages
methodTransactionType.put(method, type);
return type;
}
+ public TransactionType getTransactionType() {
+ return (isBeanManagedTransaction) ? TransactionType.BeanManaged :
TransactionType.Required;
+ }
+
public TransactionPolicyFactory getTransactionPolicyFactory() {
return transactionPolicyFactory;
}
@@ -571,36 +578,14 @@ public class CoreDeploymentInfo extends
}
public void setMethodConcurrencyAttribute(Method method, LockType
concurrencyAttribute) {
-
getMethodContext(method).setMethodConcurrencyAttribute(concurrencyAttribute);
+ getMethodContext(method).setLockType(concurrencyAttribute);
}
/**
* TODO: Move to MethodContext
*/
- public void setMethodTransactionAttribute(Method method, String
transAttribute) throws OpenEJBException {
- TransactionType transactionType;
- if (transAttribute.equalsIgnoreCase("Supports")) {
- transactionType = TransactionType.Supports;
-
- } else if (transAttribute.equalsIgnoreCase("RequiresNew")) {
- transactionType = TransactionType.RequiresNew;
-
- } else if (transAttribute.equalsIgnoreCase("Mandatory")) {
- transactionType = TransactionType.Mandatory;
-
- } else if (transAttribute.equalsIgnoreCase("NotSupported")) {
- transactionType = TransactionType.NotSupported;
-
- } else if (transAttribute.equalsIgnoreCase("Required")) {
- transactionType = TransactionType.Required;
-
- } else if (transAttribute.equalsIgnoreCase("Never")) {
- transactionType = TransactionType.Never;
-
- } else {
- throw new IllegalArgumentException("Invalid transaction attribute
\"" + transAttribute + "\" declared for method " + method.getName() + ". Please
check your configuration.");
- }
+ public void setMethodTransactionAttribute(Method method, TransactionType
transactionType) throws OpenEJBException {
// Only the NOT_SUPPORTED and REQUIRED transaction attributes may be
used for message-driven
// bean message listener methods. The use of the other transaction
attributes is not meaningful
@@ -673,7 +658,9 @@ public class CoreDeploymentInfo extends
}
public List<InterceptorData> getCallbackInterceptors() {
- return addSystemInterceptorDatas(callbackInterceptors);
+ List<InterceptorData> datas = getInterceptorData();
+ datas.addAll(callbackInterceptors);
+ return datas;
}
public void setCallbackInterceptors(List<InterceptorData>
callbackInterceptors) {
@@ -683,29 +670,19 @@ public class CoreDeploymentInfo extends
}
public List<InterceptorData> getMethodInterceptors(Method method) {
- return
addSystemInterceptorDatas(getMethodContext(method).getInterceptors());
+ return getMethodContext(method).getInterceptors();
}
- public List<InterceptorData>
addSystemInterceptorDatas(List<InterceptorData> interceptors) {
- if (interceptors == null) interceptors = Collections.EMPTY_LIST;
-
- if (systemInterceptors.size() <= 0) return interceptors;
-
- // we have system interceptors to add to the beginning of the stack
-
- List<InterceptorData> datas = new
ArrayList<InterceptorData>(systemInterceptors.size() + interceptors.size());
-
+ public List<InterceptorData> getInterceptorData() {
+ List<InterceptorData> datas = new ArrayList<InterceptorData>();
for (InterceptorInstance instance : systemInterceptors) {
datas.add(instance.getData());
}
-
- datas.addAll(interceptors);
-
return datas;
}
public void setMethodInterceptors(Method method, List<InterceptorData>
interceptors) {
- getMethodContext(method).getInterceptors().addAll(interceptors);
+ getMethodContext(method).setInterceptors(interceptors);
this.instanceScopedInterceptors.addAll(interceptors);
}
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/MethodContext.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/MethodContext.java?rev=959728&r1=959727&r2=959728&view=diff
==============================================================================
---
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/MethodContext.java
(original)
+++
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/MethodContext.java
Thu Jul 1 17:21:36 2010
@@ -24,7 +24,6 @@ import org.apache.openejb.util.Duration;
import javax.ejb.LockType;
import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
/**
@@ -34,18 +33,11 @@ public class MethodContext {
private final CoreDeploymentInfo beanContext;
private final Method beanMethod;
private final List<ScheduleData> schedules = new ArrayList<ScheduleData>();
- private final List<InterceptorData> methodInterceptors = new
ArrayList<InterceptorData>();
- private LockType methodConcurrencyAttribute;
+ private final List<InterceptorData> interceptors = new
ArrayList<InterceptorData>();
+ private LockType lockType;
private TransactionType transactionType;
private Duration accessTimeout;
- /**
- * Only initialized if this method represents metadata
- * associated with a specific interface view and not the
- * bean method itself.
- */
- private MethodContext beanMethodContext;
-
public MethodContext(CoreDeploymentInfo beanContext, Method beanMethod) {
this.beanContext = beanContext;
this.beanMethod = beanMethod;
@@ -56,7 +48,7 @@ public class MethodContext {
}
public Duration getAccessTimeout() {
- return accessTimeout;
+ return accessTimeout != null? accessTimeout:
beanContext.getAccessTimeout();
}
public CoreDeploymentInfo getBeanContext() {
@@ -67,20 +59,27 @@ public class MethodContext {
return beanMethod;
}
+ public void setInterceptors(List<InterceptorData> interceptors) {
+ this.interceptors.clear();
+ this.interceptors.addAll(interceptors);
+ }
+
public List<InterceptorData> getInterceptors() {
- return methodInterceptors;
+ List<InterceptorData> datas = beanContext.getInterceptorData();
+ datas.addAll(interceptors);
+ return datas;
}
- public LockType getMethodConcurrencyAttribute() {
- return methodConcurrencyAttribute;
+ public LockType getLockType() {
+ return lockType != null? lockType: beanContext.getLockType();
}
- public void setMethodConcurrencyAttribute(LockType
methodConcurrencyAttribute) {
- this.methodConcurrencyAttribute = methodConcurrencyAttribute;
+ public void setLockType(LockType lockType) {
+ this.lockType = lockType;
}
public TransactionType getTransactionType() {
- return transactionType;
+ return transactionType != null? transactionType:
beanContext.getTransactionType();
}
public void setTransactionType(TransactionType transactionType) {
@@ -91,12 +90,23 @@ public class MethodContext {
return schedules;
}
+ /**
+ * Currently (and as a matter of legacy) only EJB 2.x style
+ * interfaces may have different transaction attributes for an
+ * individual interface method.
+ */
public static class InterfaceMethodContext {
private final MethodContext beanMethod;
+ private final Method method;
private TransactionType transactionType;
- public InterfaceMethodContext(MethodContext beanMethod) {
+ public InterfaceMethodContext(MethodContext beanMethod, Method method)
{
this.beanMethod = beanMethod;
+ this.method = method;
+ }
+
+ public Method getMethod() {
+ return method;
}
public void setTransactionType(TransactionType transactionType) {
@@ -106,5 +116,9 @@ public class MethodContext {
public TransactionType getTransactionType() {
return transactionType != null ? transactionType :
beanMethod.getTransactionType();
}
+
+ public MethodContext getBeanMethod() {
+ return beanMethod;
+ }
}
}
Added:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/TransactionAttribute.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/TransactionAttribute.java?rev=959728&view=auto
==============================================================================
---
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/TransactionAttribute.java
(added)
+++
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/TransactionAttribute.java
Thu Jul 1 17:21:36 2010
@@ -0,0 +1,28 @@
+/**
+ * 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;
+
+import org.apache.openejb.core.transaction.TransactionType;
+
+/**
+ * @version $Rev$ $Date$
+*/
+public interface TransactionAttribute {
+ public TransactionType getTransactionType();
+
+ public void setTransactionType(TransactionType transactionType);
+}
Propchange:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/TransactionAttribute.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/transaction/TransactionType.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/transaction/TransactionType.java?rev=959728&r1=959727&r2=959728&view=diff
==============================================================================
---
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/transaction/TransactionType.java
(original)
+++
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/transaction/TransactionType.java
Thu Jul 1 17:21:36 2010
@@ -36,7 +36,15 @@ public enum TransactionType {
case NEVER: return Never;
case NOT_SUPPORTED: return NotSupported;
case SUPPORTS: return Supports;
- default: throw new IllegalStateException("Uknown
TransactionAttributeType"+ type);
+ default: throw new IllegalArgumentException("Uknown
TransactionAttributeType."+ type);
}
}
+
+ public static TransactionType get(String name) {
+ for (TransactionType type : values()) {
+ if (type.name().equalsIgnoreCase(name)) return type;
+ }
+
+ throw new IllegalArgumentException("Uknown TransactionType " + name);
+ }
}
Added:
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/LegacyInterfaceTest.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/LegacyInterfaceTest.java?rev=959728&view=auto
==============================================================================
---
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/LegacyInterfaceTest.java
(added)
+++
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/LegacyInterfaceTest.java
Thu Jul 1 17:21:36 2010
@@ -0,0 +1,301 @@
+/**
+ * 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;
+
+import junit.framework.TestCase;
+import org.apache.openejb.assembler.classic.Assembler;
+import org.apache.openejb.assembler.classic.SecurityServiceInfo;
+import org.apache.openejb.assembler.classic.TransactionServiceInfo;
+import org.apache.openejb.config.AppModule;
+import org.apache.openejb.config.ConfigurationFactory;
+import org.apache.openejb.config.EjbModule;
+import org.apache.openejb.core.ivm.naming.InitContextFactory;
+import org.apache.openejb.jee.CmpField;
+import org.apache.openejb.jee.ContainerTransaction;
+import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.EntityBean;
+import org.apache.openejb.jee.PersistenceType;
+import org.apache.openejb.jee.Query;
+import org.apache.openejb.jee.QueryMethod;
+import org.apache.openejb.jee.SingletonBean;
+import org.apache.openejb.jee.TransAttribute;
+import org.apache.openejb.test.entity.cmr.cmrmapping.OneInverseSideBean;
+import org.apache.openejb.test.entity.cmr.cmrmapping.OneInverseSideLocal;
+import org.apache.openejb.test.entity.cmr.cmrmapping.OneInverseSideLocalHome;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBException;
+import javax.ejb.EntityContext;
+import javax.ejb.LocalHome;
+import javax.ejb.RemoteHome;
+import javax.ejb.RemoveException;
+import javax.ejb.SessionContext;
+import java.rmi.RemoteException;
+import java.util.List;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class LegacyInterfaceTest extends TestCase {
+
+ public void test() throws Exception {
+
+ System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
InitContextFactory.class.getName());
+
+ ConfigurationFactory config = new ConfigurationFactory();
+ Assembler assembler = new Assembler();
+
+
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
+
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
+
+ EjbJar ejbJar = new EjbJar();
+ ejbJar.addEnterpriseBean(new SingletonBean(MySingletonBean.class));
+ ejbJar.addEnterpriseBean(new EntityBean(MyBmpBean.class,
PersistenceType.BEAN));
+
+ //<entity>
+ // <ejb-name>License</ejb-name>
+ //
<local-home>org.apache.openejb.test.entity.cmr.onetoone.LicenseLocalHome</local-home>
+ //
<local>org.apache.openejb.test.entity.cmr.onetoone.LicenseLocal</local>
+ //
<ejb-class>org.apache.openejb.test.entity.cmr.onetoone.LicenseBean</ejb-class>
+ // <persistence-type>Container</persistence-type>
+ // <prim-key-class>java.lang.Integer</prim-key-class>
+ // <reentrant>false</reentrant>
+ // <cmp-version>2.x</cmp-version>
+ // <abstract-schema-name>License</abstract-schema-name>
+ // <cmp-field>
+ // <field-name>id</field-name>
+ // </cmp-field>
+ // <cmp-field>
+ // <field-name>number</field-name>
+ // </cmp-field>
+ // <cmp-field>
+ // <field-name>points</field-name>
+ // </cmp-field>
+ // <cmp-field>
+ // <field-name>notes</field-name>
+ // </cmp-field>
+ // <primkey-field>id</primkey-field>
+ // <query>
+ // <!-- CompondPK one-to-one shares the local home interface so we
need to declare this useless finder -->
+ // <query-method>
+ // <method-name>findByPrimaryKey</method-name>
+ // <method-params>
+ //
<method-param>org.apache.openejb.test.entity.cmr.onetoone.LicensePk</method-param>
+ // </method-params>
+ // </query-method>
+ // <ejb-ql>SELECT OBJECT(DL) FROM License DL</ejb-ql>
+ // </query>
+ //</entity>
+
+ EntityBean cmp = ejbJar.addEnterpriseBean(new
EntityBean(MyCmpBean.class, PersistenceType.CONTAINER));
+ cmp.setPrimKeyClass(Integer.class.getName());
+ cmp.setPrimkeyField("id");
+ cmp.getCmpField().add(new CmpField("id"));
+ cmp.getCmpField().add(new CmpField("name"));
+ Query query = new Query();
+ query.setQueryMethod(new QueryMethod("findByPrimaryKey",
Integer.class.getName()));
+ query.setEjbQl("SELECT OBJECT(DL) FROM License DL");
+ cmp.getQuery().add(query);
+ List<ContainerTransaction> transactions =
ejbJar.getAssemblyDescriptor().getContainerTransaction();
+
+ //<container-transaction>
+ // <method>
+ // <ejb-name>MyBean</ejb-name>
+ // <method-name>*</method-name>
+ // </method>
+ // <trans-attribute>Supports</trans-attribute>
+ //</container-transaction>
+
+ transactions.add(new ContainerTransaction(TransAttribute.SUPPORTS,
null, "MyBmpBean", "*"));
+ transactions.add(new ContainerTransaction(TransAttribute.SUPPORTS,
null, "MyCmpBean", "*"));
+ transactions.add(new ContainerTransaction(TransAttribute.SUPPORTS,
null, "MySingletonBean", "*"));
+
+ AppModule module = new AppModule(this.getClass().getClassLoader(),
"test");
+ module.getEjbModules().add(new EjbModule(ejbJar));
+ assembler.createApplication(config.configureApplication(module));
+
+ }
+
+ @LocalHome(MyLocalHome.class)
+ @RemoteHome(MyRemoteHome.class)
+ public static abstract class MyCmpBean implements javax.ejb.EntityBean {
+
+ // CMP
+ public abstract Integer getId();
+
+ public abstract void setId(Integer id);
+
+ public abstract String getName();
+
+ public abstract void setName(String number);
+
+ public void doit() {
+ }
+
+ public Integer ejbCreateObject(String id) throws CreateException {
+ return null;
+ }
+
+ public void ejbPostCreateObject(String id) {
+ }
+
+ public void setEntityContext(EntityContext ctx) {
+ }
+
+ public void unsetEntityContext() {
+ }
+
+ public void ejbActivate() {
+ }
+
+ public void ejbPassivate() {
+ }
+
+ public void ejbLoad() {
+ }
+
+ public void ejbStore() {
+ }
+
+ public void ejbRemove() throws RemoveException {
+ }
+ }
+
+ @LocalHome(MyLocalHome.class)
+ @RemoteHome(MyRemoteHome.class)
+ public class MyBmpBean implements javax.ejb.EntityBean {
+
+ public void doit() {
+ }
+
+ public java.util.Collection ejbFindEmptyCollection() throws
javax.ejb.FinderException, java.rmi.RemoteException {
+ return new java.util.Vector();
+ }
+
+ public Integer ejbFindByPrimaryKey(Integer primaryKey) throws
javax.ejb.FinderException {
+ return new Integer(-1);
+ }
+
+ public Integer ejbCreateObject(String name) throws
javax.ejb.CreateException {
+ return new Integer(-1);
+ }
+
+ public void ejbPostCreateObject(String name) throws
javax.ejb.CreateException {
+ }
+
+
+ public void ejbLoad() throws EJBException, RemoteException {
+ }
+
+ public void setEntityContext(EntityContext entityContext) throws
EJBException, RemoteException {
+ }
+
+ public void unsetEntityContext() throws EJBException, RemoteException {
+ }
+
+ public void ejbStore() throws EJBException, RemoteException {
+ }
+
+ public void ejbRemove() throws RemoveException, EJBException,
RemoteException {
+ }
+
+ public void ejbActivate() throws EJBException, RemoteException {
+ }
+
+ public void ejbPassivate() throws EJBException, RemoteException {
+ }
+ }
+
+ public interface MyRemoteHome extends javax.ejb.EJBHome {
+
+ public MyRemoteObject createObject(String name)
+ throws javax.ejb.CreateException, java.rmi.RemoteException;
+
+ public MyRemoteObject findByPrimaryKey(Integer primarykey)
+ throws javax.ejb.FinderException, java.rmi.RemoteException;
+
+ public java.util.Collection findEmptyCollection()
+ throws javax.ejb.FinderException, java.rmi.RemoteException;
+
+ }
+
+ public interface MyRemoteObject extends javax.ejb.EJBObject {
+
+ public void doit() throws RemoteException;
+
+ }
+
+ public interface MyLocalHome extends javax.ejb.EJBLocalHome {
+
+ public MyLocalObject createObject(String name)
+ throws javax.ejb.CreateException;
+
+ public MyLocalObject findByPrimaryKey(Integer primarykey)
+ throws javax.ejb.FinderException;
+
+ public java.util.Collection findEmptyCollection()
+ throws javax.ejb.FinderException;
+
+ }
+
+ public interface MyLocalObject extends javax.ejb.EJBLocalObject {
+
+ public void doit();
+
+ }
+
+ @LocalHome(MySessionLocalHome.class)
+ @RemoteHome(MySessionRemoteHome.class)
+ public static class MySingletonBean implements javax.ejb.SessionBean {
+
+ public void doit(){}
+
+ public void ejbCreateObject() throws javax.ejb.CreateException {
+ }
+
+ public void ejbActivate() throws EJBException, RemoteException {
+ }
+
+ public void ejbPassivate() throws EJBException, RemoteException {
+ }
+
+ public void ejbRemove() throws EJBException, RemoteException {
+ }
+
+ public void setSessionContext(SessionContext sessionContext) throws
EJBException, RemoteException {
+ }
+ }
+
+ public interface MySessionRemoteHome extends javax.ejb.EJBHome {
+ public MySessionRemoteObject createObject()
+ throws javax.ejb.CreateException, java.rmi.RemoteException;
+ }
+
+ public interface MySessionRemoteObject extends javax.ejb.EJBObject {
+ public void doit();
+ }
+
+ public interface MySessionLocalHome extends javax.ejb.EJBLocalHome {
+ public MySessionLocalObject createObject()
+ throws javax.ejb.CreateException;
+ }
+
+ public interface MySessionLocalObject extends javax.ejb.EJBLocalObject {
+ public void doit();
+ }
+
+}
Propchange:
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/LegacyInterfaceTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/iTest.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/iTest.java?rev=959728&r1=959727&r2=959728&view=diff
==============================================================================
---
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/iTest.java
(original)
+++
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/iTest.java
Thu Jul 1 17:21:36 2010
@@ -60,11 +60,11 @@ public class iTest extends org.apache.op
// Copied from
org.apache.openejb.SomeoneBrokeSurefireAndThisIsADirtyHackForItTest that's now
gone
System.setProperty("openejb.assembler",
org.apache.openejb.assembler.classic.Assembler.class.getName());
- System.setProperty("openejb.deployments.classpath.include",
".*openejb-itests-[^a].*-.*");
+ System.setProperty("openejb.deployments.classpath.include",
".*openejb-itests-[^a].*");
System.setProperty("openejb.deployments.classpath.filter.descriptors",
"true");
System.setProperty("openejb.deployments.classpath.filter.systemapps",
"false");
System.setProperty("openejb.deployments.classpath.ear", "false");
-
+
TestManager.init(null);
TestManager.start();
}
Modified:
openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/EntityBean.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/EntityBean.java?rev=959728&r1=959727&r2=959728&view=diff
==============================================================================
---
openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/EntityBean.java
(original)
+++
openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/EntityBean.java
Thu Jul 1 17:21:36 2010
@@ -189,6 +189,19 @@ public class EntityBean implements Remot
}
}
+
+ public EntityBean(String ejbName, String ejbClass, PersistenceType
persistenceType) {
+ this();
+ this.ejbName = ejbName;
+ this.ejbClass = ejbClass;
+ this.persistenceType = persistenceType;
+ }
+
+ public EntityBean(Class<?> ejbClass, PersistenceType persistenceType) {
+ this(ejbClass.getSimpleName(), ejbClass.getName(), persistenceType);
+ }
+
+
public String getJndiConsumerName() {
return ejbName;
}
Modified:
openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/MethodParams.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/MethodParams.java?rev=959728&r1=959727&r2=959728&view=diff
==============================================================================
---
openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/MethodParams.java
(original)
+++
openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/MethodParams.java
Thu Jul 1 17:21:36 2010
@@ -28,6 +28,7 @@ import javax.xml.bind.annotation.adapter
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.util.ArrayList;
import java.util.List;
+import java.util.Arrays;
/**
@@ -65,6 +66,17 @@ public class MethodParams {
@XmlID
protected String id;
+ public MethodParams() {
+ }
+
+ public MethodParams(List<String> methodParam) {
+ this.methodParam = methodParam;
+ }
+
+ public MethodParams(String... params) {
+ this(Arrays.asList(params));
+ }
+
public List<String> getMethodParam() {
if (methodParam == null) {
methodParam = new ArrayList<String>();
Modified:
openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/QueryMethod.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/QueryMethod.java?rev=959728&r1=959727&r2=959728&view=diff
==============================================================================
---
openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/QueryMethod.java
(original)
+++
openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/QueryMethod.java
Thu Jul 1 17:21:36 2010
@@ -67,6 +67,14 @@ public class QueryMethod {
@XmlID
protected String id;
+ public QueryMethod() {
+ }
+
+ public QueryMethod(String methodName, String... params) {
+ this.methodName = methodName;
+ this.methodParams = new MethodParams(params);
+ }
+
public String getMethodName() {
return methodName;
}