[jboss-cvs] JBossAS SVN: r64097 - in branches/Branch_4_2/ejb3/docs/tutorial/mdb: src/org/jboss/tutorial/mdb/bean and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jul 17 13:06:08 EDT 2007
Author: bdecoste
Date: 2007-07-17 13:06:08 -0400 (Tue, 17 Jul 2007)
New Revision: 64097
Added:
branches/Branch_4_2/ejb3/docs/tutorial/mdb/custom-ejb3-interceptors-aop.xml
branches/Branch_4_2/ejb3/docs/tutorial/mdb/src/org/jboss/tutorial/mdb/bean/DefaultedExampleMDB.java
Modified:
branches/Branch_4_2/ejb3/docs/tutorial/mdb/build.xml
branches/Branch_4_2/ejb3/docs/tutorial/mdb/mdb.html
branches/Branch_4_2/ejb3/docs/tutorial/mdb/mdb.wiki
branches/Branch_4_2/ejb3/docs/tutorial/mdb/queue-example-service.xml
branches/Branch_4_2/ejb3/docs/tutorial/mdb/src/org/jboss/tutorial/mdb/client/Client.java
Log:
[EJBTHREE-809] tutorial for @DefaultActivationSpecs
Modified: branches/Branch_4_2/ejb3/docs/tutorial/mdb/build.xml
===================================================================
--- branches/Branch_4_2/ejb3/docs/tutorial/mdb/build.xml 2007-07-17 14:36:23 UTC (rev 64096)
+++ branches/Branch_4_2/ejb3/docs/tutorial/mdb/build.xml 2007-07-17 17:06:08 UTC (rev 64097)
@@ -60,8 +60,12 @@
<fileset dir="${build.classes.dir}">
<include name="**/*.class"/>
</fileset>
+ <fileset dir=".">
+ <include name="custom-ejb3-interceptors-aop.xml"/>
+ </fileset>
</jar>
<copy file="queue-example-service.xml" todir="${jboss.home}/server/${jboss.server.config}/deploy"/>
+ <!--copy file="custom-ejb3-interceptors-aop.xml" todir="${jboss.home}/server/${jboss.server.config}/deploy"/-->
<sleep seconds="5"/>
<copy file="build/tutorial.jar" todir="${jboss.home}/server/${jboss.server.config}/deploy"/>
</target>
@@ -83,6 +87,7 @@
<delete dir="${build.dir}"/>
<delete file="${jboss.home}/server/${jboss.server.config}/deploy/tutorial.jar"/>
<delete file="${jboss.home}/server/${jboss.server.config}/deploy/queue-example-service.xml"/>
+ <!--delete file="${jboss.home}/server/${jboss.server.config}/deploy/custom-ejb3-interceptors-aop.xml"/-->
</target>
Added: branches/Branch_4_2/ejb3/docs/tutorial/mdb/custom-ejb3-interceptors-aop.xml
===================================================================
--- branches/Branch_4_2/ejb3/docs/tutorial/mdb/custom-ejb3-interceptors-aop.xml (rev 0)
+++ branches/Branch_4_2/ejb3/docs/tutorial/mdb/custom-ejb3-interceptors-aop.xml 2007-07-17 17:06:08 UTC (rev 64097)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE aop PUBLIC
+ "-//JBoss//DTD JBOSS AOP 1.0//EN"
+ "http://labs.jboss.com/portal/jbossaop/dtd/jboss-aop_1_0.dtd">
+
+<aop>
+ <interceptor class="org.jboss.ejb3.AllowedOperationsInterceptor" scope="PER_VM"/>
+ <interceptor class="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor" scope="PER_VM"/>
+ <interceptor factory="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory" scope="PER_CLASS_JOINPOINT"/>
+ <interceptor factory="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory" scope="PER_CLASS"/>
+ <interceptor class="org.jboss.ejb3.stateless.StatelessInstanceInterceptor" scope="PER_VM"/>
+ <interceptor factory="org.jboss.ejb3.tx.TxInterceptorFactory" scope="PER_CLASS_JOINPOINT"/>
+
+ <domain name="Custom Message Driven Bean">
+ <bind pointcut="execution(public * @javax.annotation.security.RunAs->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
+ </bind>
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.stateless.StatelessInstanceInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
+ <interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
+ </bind>
+ <annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">
+ @org.jboss.annotation.ejb.PoolClass (value=org.jboss.ejb3.StrictMaxPool.class, maxSize=15, timeout=10000)
+ </annotation>
+ <annotation expr="!class(@org.jboss.annotation.ejb.DefaultActivationSpecs)">
+ @org.jboss.annotation.ejb.DefaultActivationSpecs (value={@javax.ejb.ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"), @javax.ejb.ActivationConfigProperty(propertyName="destination", propertyValue="queue/tutorial/defaultedexample")})
+ </annotation>
+ </domain>
+</aop>
Modified: branches/Branch_4_2/ejb3/docs/tutorial/mdb/mdb.html
===================================================================
--- branches/Branch_4_2/ejb3/docs/tutorial/mdb/mdb.html 2007-07-17 14:36:23 UTC (rev 64096)
+++ branches/Branch_4_2/ejb3/docs/tutorial/mdb/mdb.html 2007-07-17 17:06:08 UTC (rev 64097)
@@ -52,9 +52,21 @@
</p><p>
<h3> The Destination</h3>
-The <a href="queue-example-service.xml">queue-example-service.xml</a> file defines the Queue. There are no changes for deploying
+The <a href="queue-example-service.xml">queue-example-service.xml</a> file defines the Queues. There are no changes for deploying
an EJB3 ready Destination as a standard Destination.
</p><p>
+<h3> Configuring Default MDB Properties</h3>
+
+You can configure MDBs to have default properties using the @DefaultActivationSpecs annotations. Take a
+look at <a href="custom-ejb3-interceptors-aop.xml">custom-ejb3-interceptors-aop.xml</a>. Here we define a custom
+container configuration domain, "Custom Message Driven Bean", that adds a @DefaultActivationSpecs
+annotation and <tt>destinationType</tt> and <tt>destination</tt> properties to each MDB using this domain.
+Now take a look at <a href="src/org/jboss/tutorial/mdb/bean/DefaultedExampleMDB.java">DefaultedExampleMDB.java</a>.
+The MDB is configured to use the "Custom Message Driven Bean" container configuration domain via the
+ at AspectDomain annotation. Note there are no properties defined in the @MessageDriven annotation (they
+are all from the defaults).
+</p><p>
+</p><p>
<h4>Building and Running</h4>
To build and run the example, make sure you have <tt>ejb3.deployer</tt> installed in JBoss 4.0.x and have JBoss running. See the reference manual on how to install EJB 3.0.
@@ -66,12 +78,16 @@
</pre>
</p><p>
-Look in the console window to determine that the message was sent.
+Look in the console window to determine that the messages was sent and received.
</p><p>
<pre>
-01:01:20,828 INFO [STDOUT] ----------------
-01:01:20,828 INFO [STDOUT] Received message
-01:01:20,828 INFO [STDOUT] ----------------
+09:43:35,893 INFO [STDOUT] ----------------
+09:43:35,894 INFO [STDOUT] ----------------
+09:43:35,894 INFO [STDOUT] Received message
+09:43:35,894 INFO [STDOUT] Received defaulted message
+09:43:35,894 INFO [STDOUT] ----------------
+09:43:35,894 INFO [STDOUT] ----------------
+
</pre>
</p><p>
</p><p>
Modified: branches/Branch_4_2/ejb3/docs/tutorial/mdb/mdb.wiki
===================================================================
--- branches/Branch_4_2/ejb3/docs/tutorial/mdb/mdb.wiki 2007-07-17 14:36:23 UTC (rev 64096)
+++ branches/Branch_4_2/ejb3/docs/tutorial/mdb/mdb.wiki 2007-07-17 17:06:08 UTC (rev 64097)
@@ -46,9 +46,20 @@
}}}
!! The Destination
-The [queue-example-service.xml|queue-example-service.xml] file defines the Queue. There are no changes for deploying
+The [queue-example-service.xml|queue-example-service.xml] file defines the Queues. There are no changes for deploying
an EJB3 ready Destination as a standard Destination.
+!! Configuring Default MDB Properties
+You can configure MDBs to have default properties using the @DefaultActivationSpecs annotations. Take a
+look at [custom-ejb3-interceptors-aop.xml|custom-ejb3-interceptors-aop.xml]. Here we define a custom
+container configuration domain, "Custom Message Driven Bean", that adds a @DefaultActivationSpecs
+annotation and {{destinationType}} and {{destination}} properties to each MDB using this domain.
+Now take a look at [DefaultedExampleMDB.java|src/org/jboss/tutorial/mdb/bean/DefaultedExampleMDB.java].
+The MDB is configured to use the "Custom Message Driven Bean" container configuration domain via the
+ at AspectDomain annotation. Note there are no properties defined in the @MessageDriven annotation (they
+are all from the defaults).
+
+
!Building and Running
To build and run the example, make sure you have {{ejb3.deployer}} installed in JBoss 4.0.x and have JBoss running. See the reference manual on how to install EJB 3.0.
{{{
@@ -59,12 +70,16 @@
}}}
-Look in the console window to determine that the message was sent.
+Look in the console window to determine that the messages was sent and received.
{{{
-01:01:20,828 INFO [STDOUT] ----------------
-01:01:20,828 INFO [STDOUT] Received message
-01:01:20,828 INFO [STDOUT] ----------------
+09:43:35,893 INFO [STDOUT] ----------------
+09:43:35,894 INFO [STDOUT] ----------------
+09:43:35,894 INFO [STDOUT] Received message
+09:43:35,894 INFO [STDOUT] Received defaulted message
+09:43:35,894 INFO [STDOUT] ----------------
+09:43:35,894 INFO [STDOUT] ----------------
+
}}}
Modified: branches/Branch_4_2/ejb3/docs/tutorial/mdb/queue-example-service.xml
===================================================================
--- branches/Branch_4_2/ejb3/docs/tutorial/mdb/queue-example-service.xml 2007-07-17 14:36:23 UTC (rev 64096)
+++ branches/Branch_4_2/ejb3/docs/tutorial/mdb/queue-example-service.xml 2007-07-17 17:06:08 UTC (rev 64097)
@@ -6,5 +6,9 @@
<depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
</mbean>
-
+ <mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.mq.destination:service=Queue,name=defaultedtutorial">
+ <attribute name="JNDIName">queue/tutorial/defaultedexample</attribute>
+ <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
+ </mbean>
</server>
Added: branches/Branch_4_2/ejb3/docs/tutorial/mdb/src/org/jboss/tutorial/mdb/bean/DefaultedExampleMDB.java
===================================================================
--- branches/Branch_4_2/ejb3/docs/tutorial/mdb/src/org/jboss/tutorial/mdb/bean/DefaultedExampleMDB.java (rev 0)
+++ branches/Branch_4_2/ejb3/docs/tutorial/mdb/src/org/jboss/tutorial/mdb/bean/DefaultedExampleMDB.java 2007-07-17 17:06:08 UTC (rev 64097)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.tutorial.mdb.bean;
+
+import javax.ejb.MessageDriven;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+
+import org.jboss.annotation.ejb.AspectDomain;
+
+ at MessageDriven
+ at AspectDomain("Custom Message Driven Bean")
+public class DefaultedExampleMDB implements MessageListener
+{
+ public void onMessage(Message recvMsg)
+ {
+ System.out.println("----------------");
+ System.out.println("Received defaulted message");
+ System.out.println("----------------");
+ }
+
+}
Modified: branches/Branch_4_2/ejb3/docs/tutorial/mdb/src/org/jboss/tutorial/mdb/client/Client.java
===================================================================
--- branches/Branch_4_2/ejb3/docs/tutorial/mdb/src/org/jboss/tutorial/mdb/client/Client.java 2007-07-17 14:36:23 UTC (rev 64096)
+++ branches/Branch_4_2/ejb3/docs/tutorial/mdb/src/org/jboss/tutorial/mdb/client/Client.java 2007-07-17 17:06:08 UTC (rev 64097)
@@ -33,11 +33,17 @@
{
public static void main(String[] args) throws Exception
{
+ processMessage("queue/tutorial/example");
+ processMessage("queue/tutorial/defaultedexample");
+ }
+
+ private static void processMessage(String queueBinding) throws Exception
+ {
QueueConnection cnn = null;
QueueSender sender = null;
QueueSession session = null;
InitialContext ctx = new InitialContext();
- Queue queue = (Queue) ctx.lookup("queue/tutorial/example");
+ Queue queue = (Queue) ctx.lookup(queueBinding);
QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
cnn = factory.createQueueConnection();
session = cnn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
@@ -46,7 +52,7 @@
sender = session.createSender(queue);
sender.send(msg);
- System.out.println("Message sent successfully to remote queue.");
+ System.out.println("Message sent successfully to remote queue " + queueBinding);
}
}
More information about the jboss-cvs-commits
mailing list