KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > test > service > ServiceSix


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.service;
23
24 import javax.ejb.Remote JavaDoc;
25 import javax.ejb.Local JavaDoc;
26 import javax.naming.Context JavaDoc;
27 import javax.naming.InitialContext JavaDoc;
28 import javax.naming.NamingException JavaDoc;
29 import javax.sql.DataSource JavaDoc;
30
31 import org.jboss.annotation.ejb.Service;
32 import org.jboss.ejb3.Container;
33
34 /**
35  * @version <tt>$Revision: 42882 $</tt>
36  * @author <a HREF="mailto:bdecoste@jboss.com">William DeCoste</a>
37  */

38 public class ServiceSix implements ServiceSixLocal, ServiceSixRemote, ServiceSixManagement
39 {
40    boolean called;
41    
42    int localMethodCalls;
43    int remoteMethodCalls;
44    int jmxAttribute;
45    int someJmxAttribute;
46    int otherJmxAttribute;
47    int readWriteOnlyAttribute;
48    
49    StatelessRemote stateless;
50    StatelessLocal statelessLocal;
51    DataSource JavaDoc testDatasource;
52    
53    public void setStatelessLocal(StatelessLocal statelessLocal)
54    {
55       this.statelessLocal = statelessLocal;
56    }
57    
58    public void testInjection() throws Exception JavaDoc
59    {
60       try
61       {
62          stateless.test();
63          statelessLocal.testLocal();
64          testDatasource.getConnection();
65          
66          Context JavaDoc initCtx = new InitialContext JavaDoc();
67          Context JavaDoc myEnv = (Context JavaDoc) initCtx.lookup(Container.ENC_CTX_NAME + "/env");
68          Object JavaDoc obj = myEnv.lookup("res/aQueue");
69          if ((obj instanceof javax.jms.Queue JavaDoc) == false)
70             throw new NamingException JavaDoc("res/aQueue is not a javax.jms.Queue");
71       }
72       catch (Exception JavaDoc e)
73       {
74          e.printStackTrace();
75          throw e;
76       }
77    }
78
79    public boolean getCalled()
80    {
81       return called;
82    }
83
84    public void setCalled(boolean called)
85    {
86       this.called = called;
87    }
88
89    public void localMethod()
90    {
91       called = true;
92    }
93
94    public void remoteMethod()
95    {
96       called = true;
97    }
98    
99    public String JavaDoc jmxOperation(String JavaDoc s)
100    {
101       return "x" + s + "x";
102    }
103
104    public String JavaDoc[] jmxOperation(String JavaDoc[] s)
105    {
106       for (int i = 0 ; i < s.length ; i++)
107       {
108          s[i] = jmxOperation(s[i]);
109       }
110       return s;
111    }
112
113    public int getAttribute()
114    {
115       return jmxAttribute;
116    }
117
118    public void setAttribute(int i)
119    {
120       jmxAttribute = i;
121    }
122
123    public int getSomeAttr()
124    {
125       return someJmxAttribute;
126    }
127
128    public void setSomeAttr(int i)
129    {
130       someJmxAttribute = i;
131    }
132
133    public int getOtherAttr()
134    {
135       return otherJmxAttribute;
136    }
137
138    public void setOtherAttr(int i)
139    {
140       otherJmxAttribute = i;
141    }
142
143    public void setWriteOnly(int i)
144    {
145       readWriteOnlyAttribute = i;
146    }
147
148    public int getReadOnly()
149    {
150       return readWriteOnlyAttribute;
151    }
152
153
154    public void create() throws Exception JavaDoc
155    {
156      
157    }
158
159    public void start() throws Exception JavaDoc
160    {
161     
162    }
163
164    public void stop()
165    {
166     
167    }
168
169    public void destroy()
170    {
171    
172    }
173
174 }
175
Popular Tags