KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > webservice > samples > OrganizationClientBean


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.test.webservice.samples;
23
24 import org.jboss.logging.Logger;
25
26 import javax.ejb.EJBException JavaDoc;
27 import javax.ejb.SessionBean JavaDoc;
28 import javax.ejb.SessionContext JavaDoc;
29 import javax.naming.InitialContext JavaDoc;
30 import javax.naming.NamingException JavaDoc;
31 import javax.xml.rpc.Service JavaDoc;
32 import java.rmi.RemoteException JavaDoc;
33
34 /**
35  * An example of a SLSB
36  *
37  * @author Thomas.Diesler@jboss.org
38  * @since 26-Apr-2004
39  */

40 public class OrganizationClientBean implements SessionBean JavaDoc
41 {
42    // provide logging
43
private static final Logger log = Logger.getLogger(OrganizationClientBean.class);
44
45    /** Get the contact info from the EJB service */
46    public String JavaDoc getContactInfoEJB(String JavaDoc organization) throws RemoteException JavaDoc
47    {
48       Service JavaDoc service = null;
49       try
50       {
51          InitialContext JavaDoc iniCtx = new InitialContext JavaDoc();
52          service = (Service JavaDoc)iniCtx.lookup("java:/comp/env/service/OrganizationServiceEJB");
53          Organization endpoint = (Organization)service.getPort(Organization.class);
54          String JavaDoc info = endpoint.getContactInfo(organization);
55          return info;
56       }
57       catch (NamingException JavaDoc e)
58       {
59          throw new EJBException JavaDoc(e);
60       }
61       catch (Exception JavaDoc e)
62       {
63          throw new EJBException JavaDoc("Cannot invoke webservice", e);
64       }
65    }
66
67    /** Get the contact info from the JSE service */
68    public String JavaDoc getContactInfoJSE(String JavaDoc organization) throws RemoteException JavaDoc
69    {
70       try
71       {
72          InitialContext JavaDoc iniCtx = new InitialContext JavaDoc();
73          OrganizationService service = (OrganizationService)iniCtx.lookup("java:comp/env/service/OrganizationServiceJSE");
74          Organization endpoint = (Organization)service.getOrganizationPort();
75          String JavaDoc info = endpoint.getContactInfo(organization);
76          return info;
77       }
78       catch (NamingException JavaDoc e)
79       {
80          throw new EJBException JavaDoc(e);
81       }
82       catch (Exception JavaDoc e)
83       {
84          throw new EJBException JavaDoc("Cannot invoke webservice", e);
85       }
86    }
87
88    // SLSB Lifecycle ***************************************************************************************************
89

90    public void ejbCreate()
91    {
92    }
93
94    public void setSessionContext(SessionContext JavaDoc ctx) throws EJBException JavaDoc, RemoteException JavaDoc
95    {
96    }
97
98    public void ejbRemove() throws EJBException JavaDoc, RemoteException JavaDoc
99    {
100    }
101
102    public void ejbActivate() throws EJBException JavaDoc, RemoteException JavaDoc
103    {
104    }
105
106    public void ejbPassivate() throws EJBException JavaDoc, RemoteException JavaDoc
107    {
108    }
109 }
110
Popular Tags