KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > test > consumer > TestStatusBean


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.ejb3.test.consumer;
23
24 import javax.ejb.Remote JavaDoc;
25 import javax.ejb.Stateless JavaDoc;
26 import org.jboss.annotation.JndiInject;
27 import org.jboss.ejb3.mdb.ProducerManager;
28 import org.jboss.ejb3.mdb.ProducerObject;
29
30 /**
31  * Comment
32  *
33  * @author <a HREF="mailto:bill@jboss.org">Bill Burke</a>
34  * @version $Revision: 37459 $
35  */

36 @Stateless JavaDoc
37 @Remote JavaDoc(TestStatus.class)
38 public class TestStatusBean implements TestStatus
39 {
40    public static String JavaDoc queueRan = null;
41    public static String JavaDoc topicRan = null;
42    public static String JavaDoc interceptedTopic = null;
43    public static String JavaDoc interceptedQueue = null;
44    public static boolean postConstruct = false;
45    public static boolean preDestroy = false;
46    public static boolean fieldMessage = false;
47    public static boolean setterMessage = false;
48
49
50    public void clear()
51    {
52       queueRan = null;
53       topicRan = null;
54       interceptedTopic = null;
55       interceptedQueue = null;
56       postConstruct = false;
57       preDestroy = false;
58       fieldMessage = setterMessage = false;
59    }
60
61    private QueueTestXA xa;
62    private ProducerManager xaManager;
63
64    @JndiInject(jndiName="org.jboss.ejb3.test.consumer.QueueTestXA")
65    public void setXa(QueueTestXA xa)
66    {
67       this.xa = xa;
68       this.xaManager = ((ProducerObject)xa).getProducerManager();
69    }
70
71    private QueueTest local;
72    private ProducerManager localManager;
73
74    @JndiInject(jndiName="org.jboss.ejb3.test.consumer.QueueTestLocal")
75    public void setLocal(QueueTest local)
76    {
77       this.local = local;
78       this.localManager = ((ProducerObject)local).getProducerManager();
79    }
80    
81    private DeploymentDescriptorQueueTestXA xaDeploymentDescriptor;
82    private ProducerManager xaManagerDeploymentDescriptor;
83
84    @JndiInject(jndiName="org.jboss.ejb3.test.consumer.DeploymentDescriptorQueueTestXA")
85    public void setXaDeploymentDescriptor(DeploymentDescriptorQueueTestXA xa)
86    {
87       this.xaDeploymentDescriptor = xa;
88       this.xaManagerDeploymentDescriptor = ((ProducerObject)xa).getProducerManager();
89    }
90
91    private DeploymentDescriptorQueueTestLocal localDeploymentDescriptor;
92    private ProducerManager localManagerDeploymentDescriptor;
93
94    @JndiInject(jndiName="org.jboss.ejb3.test.consumer.DeploymentDescriptorQueueTestLocal")
95    public void setLocalDeploymentDescriptor(DeploymentDescriptorQueueTestLocal local)
96    {
97       this.localDeploymentDescriptor = local;
98       this.localManagerDeploymentDescriptor = ((ProducerObject)local).getProducerManager();
99    }
100
101    public void testXA() throws Exception JavaDoc
102    {
103
104       xaManager.connect();
105       xa.method1("testXA", 1);
106       Thread.sleep(1000);
107       xa.method2("testXA2", 4.4F);
108       System.out.println("end TESTXA **");
109       xaManager.close();
110    }
111
112    public void testLocal() throws Exception JavaDoc
113    {
114
115       localManager.connect();
116       local.method1("testLocal", 1);
117       Thread.sleep(1000);
118       local.method2("testLocal2", 4.4F);
119       localManager.close();
120    }
121    
122    public void testDeploymentDescriptorXA() throws Exception JavaDoc
123    {
124
125       xaManagerDeploymentDescriptor.connect();
126       xaDeploymentDescriptor.method1("testXA", 1);
127       Thread.sleep(1000);
128       xaDeploymentDescriptor.method2("testXA2", 4.4F);
129       System.out.println("end TESTXA **");
130       xaManagerDeploymentDescriptor.close();
131    }
132
133    public void testDeploymentDescriptorLocal() throws Exception JavaDoc
134    {
135
136       localManagerDeploymentDescriptor.connect();
137       localDeploymentDescriptor.method1("testLocal", 1);
138       Thread.sleep(1000);
139       localDeploymentDescriptor.method2("testLocal2", 4.4F);
140       localManagerDeploymentDescriptor.close();
141    }
142
143    public String JavaDoc queueFired()
144    {
145       return queueRan;
146    }
147
148    public String JavaDoc topicFired()
149    {
150       return topicRan;
151    }
152
153    public String JavaDoc interceptedTopic()
154    {
155       return interceptedTopic;
156    }
157
158    public String JavaDoc interceptedQueue()
159    {
160       return interceptedQueue;
161    }
162
163    public boolean postConstruct()
164    {
165       return postConstruct;
166    }
167
168    public boolean preDestroy()
169    {
170       return preDestroy;
171    }
172
173    public boolean fieldMessage()
174    {
175       return fieldMessage;
176    }
177
178    public boolean setterMessage()
179    {
180       return setterMessage;
181    }
182 }
183
Popular Tags