KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > cts > service > CtsCmpService


1 /*
2  * JBoss, the OpenSource J2EE WebOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.test.cts.service;
8
9 import javax.naming.InitialContext JavaDoc;
10
11 import org.jboss.system.ServiceMBeanSupport;
12 import org.jboss.test.cts.interfaces.CtsCmp2Local;
13 import org.jboss.test.cts.interfaces.CtsCmp2LocalHome;
14 import org.jboss.test.util.Debug;
15
16 /** Version 2 of the MBean service that uses the version 2 of the
17  * CtsCmp2Local EJB interface.
18  *
19  * @author Scott.Stark@jboss.org
20  * @version $Revision: 16662 $
21  */

22 public class CtsCmpService extends ServiceMBeanSupport
23    implements CtsCmpServiceMBean
24 {
25    private CtsCmp2LocalHome home;
26    private String JavaDoc homeJndiName = "v2/local/CtsCmp2Bean";
27
28    public CtsCmpService()
29    {
30       log.info("CtsCmpService V2 ctor");
31    }
32
33    public void setHomeJndiName(String JavaDoc jndiName)
34    {
35       this.homeJndiName = jndiName;
36    }
37
38    protected void startService() throws Exception JavaDoc
39    {
40       InitialContext JavaDoc ctx = new InitialContext JavaDoc();
41       Object JavaDoc obj = new InitialContext JavaDoc().lookup(homeJndiName);
42       Class JavaDoc homeClass = obj.getClass();
43       StringBuffer JavaDoc results = new StringBuffer JavaDoc();
44       results.append("CtsCmpService V2 class info:\n");
45       Debug.displayClassInfo(getClass(), results);
46       results.append("CtsCmp2LocalHome Proxy class info:\n");
47       Debug.displayClassInfo(homeClass, results);
48       results.append("\nLocal CtsCmp2LocalHome.class info:\n");
49       Debug.displayClassInfo(CtsCmp2LocalHome.class, results);
50       log.info(results.toString());
51       home = (CtsCmp2LocalHome) obj;
52
53       CtsCmp2Local bean = home.create("V2key", "V2data");
54       log.info("CtsCmp2Local.key = "+bean.getKey());
55       log.info("CtsCmp2Local.data = "+bean.getData());
56       log.info("CtsCmp2Local.moreData = "+bean.getMoreData());
57    }
58 }
59
Popular Tags