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/12/20 04:40:19 UTC
svn commit: r488905 - in /incubator/openejb/trunk/openejb3:
container/openejb-core/src/main/java/org/apache/openejb/alt/config/
container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/
container/openejb-core/src/main/java/org/apache/o...
Author: dblevins
Date: Tue Dec 19 19:40:19 2006
New Revision: 488905
URL: http://svn.apache.org/viewvc?view=rev&rev=488905
Log:
Patch from Manu George OPENEJB-409: NullPointer Exception on trying to deploy MessageDrivenBean
Thanks Manu!
Added:
incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/EncReference.java
incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/EncUserTransaction.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/
incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/BasicMdbBean.java
Modified:
incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/EjbJarUtils.java
incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/MessageBean.java
incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java
incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/EndpointHandler.java
incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/ejb-jar.xml
Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/EjbJarUtils.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/EjbJarUtils.java?view=diff&rev=488905&r1=488904&r2=488905
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/EjbJarUtils.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/EjbJarUtils.java Tue Dec 19 19:40:19 2006
@@ -274,7 +274,7 @@
} else if (enterpriseBean instanceof org.apache.openejb.jee.SessionBean) {
beans.add(new SessionBean((org.apache.openejb.jee.SessionBean) enterpriseBean));
} else if (enterpriseBean instanceof org.apache.openejb.jee.MessageDrivenBean) {
- beans.add(new SessionBean((org.apache.openejb.jee.SessionBean) enterpriseBean));
+ beans.add(new MessageBean((org.apache.openejb.jee.MessageDrivenBean) enterpriseBean));
}
}
return beans.toArray(new Bean[]{});
Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/MessageBean.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/MessageBean.java?view=diff&rev=488905&r1=488904&r2=488905
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/MessageBean.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/MessageBean.java Tue Dec 19 19:40:19 2006
@@ -16,21 +16,17 @@
*/
package org.apache.openejb.alt.config;
+import org.apache.openejb.jee.MessageDrivenBean;
import org.apache.openejb.jee.SessionType;
import org.apache.openejb.jee.ResourceRef;
public class MessageBean implements Bean {
- org.apache.openejb.jee.SessionBean bean;
+ org.apache.openejb.jee.MessageDrivenBean bean;
String type;
- MessageBean(org.apache.openejb.jee.SessionBean bean) {
- this.bean = bean;
- if (bean.getSessionType() == SessionType.STATEFUL) {
- type = STATEFUL;
- } else {
- type = STATELESS;
- }
+ MessageBean(MessageDrivenBean bean2) {
+ this.bean = bean2;
}
public String getType() {
@@ -50,19 +46,19 @@
}
public String getHome() {
- return bean.getHome();
+ return null;
}
public String getRemote() {
- return bean.getRemote();
+ return null;
}
public String getLocal() {
- return bean.getLocal();
+ return null;
}
public String getLocalHome() {
- return bean.getLocalHome();
+ return null;
}
public ResourceRef[] getResourceRef() {
Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java?view=diff&rev=488905&r1=488904&r2=488905
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java Tue Dec 19 19:40:19 2006
@@ -74,6 +74,8 @@
referenceWrapper = new StatefulRefereceWrapper();
} else if (ejbType == BeanType.STATELESS) {
referenceWrapper = new StatelessRefereceWrapper();
+ } else if (ejbType == BeanType.MESSAGE_DRIVEN) {
+ referenceWrapper = new MessageDrivenRefereceWrapper();
} else {
throw new org.apache.openejb.OpenEJBException("Unknown component type");
}
@@ -324,6 +326,17 @@
return new org.apache.openejb.core.stateful.EncUserTransaction((CoreUserTransaction) userTransaction);
}
}
+
+ static class MessageDrivenRefereceWrapper extends ReferenceWrapper {
+ public Object wrap(Reference reference) {
+ return new org.apache.openejb.core.mdb.EncReference(reference);
+ }
+
+ public Object wrap(UserTransaction userTransaction) {
+ return new org.apache.openejb.core.mdb.EncUserTransaction((CoreUserTransaction) userTransaction);
+ }
+ }
+
private static class DefaultReferenceWrapper extends ReferenceWrapper {
Object wrap(Reference reference) {
Added: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/EncReference.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/EncReference.java?view=auto&rev=488905
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/EncReference.java (added)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/EncReference.java Tue Dec 19 19:40:19 2006
@@ -0,0 +1,76 @@
+/**
+ * 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.mdb;
+
+import org.apache.openejb.core.ivm.naming.Reference;
+
+import javax.naming.NameNotFoundException;
+
+public class EncReference extends org.apache.openejb.core.ivm.naming.ENCReference {
+
+ public EncReference(Reference ref) {
+ super(ref);
+ }
+
+ public void checkOperation(byte operation) throws NameNotFoundException {
+
+/*
+ if( operation != Operations.OP_BUSINESS ){
+ throw new NameNotFoundException("Operation Not Allowed");
+ }
+*/
+ }
+
+}
+/**
+ * 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.mdb;
+
+import org.apache.openejb.core.ivm.naming.Reference;
+
+import javax.naming.NameNotFoundException;
+
+public class EncReference extends org.apache.openejb.core.ivm.naming.ENCReference {
+
+ public EncReference(Reference ref) {
+ super(ref);
+ }
+
+ public void checkOperation(byte operation) throws NameNotFoundException {
+
+/*
+ if( operation != Operations.OP_BUSINESS ){
+ throw new NameNotFoundException("Operation Not Allowed");
+ }
+*/
+ }
+
+}
Added: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/EncUserTransaction.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/EncUserTransaction.java?view=auto&rev=488905
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/EncUserTransaction.java (added)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/EncUserTransaction.java Tue Dec 19 19:40:19 2006
@@ -0,0 +1,102 @@
+/**
+ * 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.mdb;
+
+import org.apache.openejb.core.Operations;
+import org.apache.openejb.core.ivm.naming.ObjectReference;
+
+import javax.naming.NameNotFoundException;
+
+/*
+ This class is a wrapper for CoreUserTransaction reference in the
+ JNDI ENC of a message driven bean. When the getObject( ) method is invoked the
+ Operation is checked to ensure that its is allowed for the bean's current state.
+*/
+
+public class EncUserTransaction extends org.apache.openejb.core.ivm.naming.ENCReference {
+
+ /*
+ * This constructor take a new CoreUserTransaction object as the object reference
+ */
+ public EncUserTransaction(org.apache.openejb.core.CoreUserTransaction reference) {
+ super(new ObjectReference(reference));
+ }
+
+ /*
+ * This method is invoked by the ENCReference super class each time its
+ * getObject() method is called within the container system. This checkOperation
+ * method ensures that the message driven bean is in the correct state before the super
+ * class can return the requested reference object.
+ */
+ public void checkOperation(byte operation) throws NameNotFoundException {
+ if (operation == Operations.OP_SET_CONTEXT) {
+ throw new NameNotFoundException("Operation Not Allowed");
+ }
+ }
+
+}
+/**
+ * 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.mdb;
+
+import org.apache.openejb.core.Operations;
+import org.apache.openejb.core.ivm.naming.ObjectReference;
+
+import javax.naming.NameNotFoundException;
+
+/*
+ This class is a wrapper for CoreUserTransaction reference in the
+ JNDI ENC of a message driven bean. When the getObject( ) method is invoked the
+ Operation is checked to ensure that its is allowed for the bean's current state.
+*/
+
+public class EncUserTransaction extends org.apache.openejb.core.ivm.naming.ENCReference {
+
+ /*
+ * This constructor take a new CoreUserTransaction object as the object reference
+ */
+ public EncUserTransaction(org.apache.openejb.core.CoreUserTransaction reference) {
+ super(new ObjectReference(reference));
+ }
+
+ /*
+ * This method is invoked by the ENCReference super class each time its
+ * getObject() method is called within the container system. This checkOperation
+ * method ensures that the message driven bean is in the correct state before the super
+ * class can return the requested reference object.
+ */
+ public void checkOperation(byte operation) throws NameNotFoundException {
+ if (operation == Operations.OP_SET_CONTEXT) {
+ throw new NameNotFoundException("Operation Not Allowed");
+ }
+ }
+
+}
Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/EndpointHandler.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/EndpointHandler.java?view=diff&rev=488905&r1=488904&r2=488905
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/EndpointHandler.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/EndpointHandler.java Tue Dec 19 19:40:19 2006
@@ -141,6 +141,7 @@
throw new IllegalStateException("Message endpoint factory has been released");
case BEFORE_CALLED:
state = State.METHOD_CALLED;
+ break;
case METHOD_CALLED:
case SYSTEM_EXCEPTION:
throw new IllegalStateException("The last message delivery must be completed with an afterDeliver before another message can be delivered");
Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/BasicMdbBean.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/BasicMdbBean.java?view=auto&rev=488905
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/BasicMdbBean.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/BasicMdbBean.java Tue Dec 19 19:40:19 2006
@@ -0,0 +1,47 @@
+/**
+ * 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.mdb;
+
+import javax.ejb.EJBException;
+import javax.ejb.MessageDrivenBean;
+import javax.ejb.MessageDrivenContext;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+
+import junit.framework.Assert;
+
+public class BasicMdbBean implements MessageDrivenBean, MessageListener {
+
+ MessageDrivenContext ctx = null;
+
+
+ public void ejbRemove() throws EJBException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setMessageDrivenContext(MessageDrivenContext ctx)
+ throws EJBException {
+ this.ctx = ctx;
+ }
+
+ public void onMessage(Message msg) {
+ Assert.assertNotNull("The MessageDrivenContext is null", ctx );
+
+ }
+
+}
Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/ejb-jar.xml
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/ejb-jar.xml?view=diff&rev=488905&r1=488904&r2=488905
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/ejb-jar.xml (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/ejb-jar.xml Tue Dec 19 19:40:19 2006
@@ -1794,6 +1794,38 @@
<role-link>Executive</role-link>
</security-role-ref>
</entity>
+
+ <!--
+ ########################################################
+ ########################################################
+ ######### MESSAGE D R I V E N B E A N S #########
+ ########################################################
+ ########################################################
+ -->
+
+ <!--
+ ########################################################
+ ID: client/tests/messagedriven/mdb/BasicMdbHome
+ ########################################################
+ -->
+
+ <message-driven>
+ <description>
+ Blah blah blah . . .
+ </description>
+ <ejb-name>BasicMdbBean</ejb-name>
+ <ejb-class>org.apache.openejb.test.mdb.BasicMdbBean</ejb-class>
+ <messaging-type>javax.jms.MessageListener</messaging-type>
+ <transaction-type>Container</transaction-type>
+ <message-destination-type>javax.jms.Queue</message-destination-type>
+ <message-destination-link>SendReceiveQueue</message-destination-link>
+ <activation-config>
+ <activation-property>
+ <activation-config-property-name>destination</activation-config-property-name>
+ <activation-config-property-value>SendReceiveQueue</activation-config-property-value>
+ </activation-property>
+ </activation-config>
+ </message-driven>
</enterprise-beans>
<relationships>