Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: ejb/service/AddressBookSessionBean.java


1   /*
2    * The Apache Software License, Version 1.1
3    *
4    *
5    * Copyright (c) 2002 The Apache Software Foundation.  All rights 
6    * reserved.
7    *
8    * Redistribution and use in source and binary forms, with or without
9    * modification, are permitted provided that the following conditions
10   * are met:
11   *
12   * 1. Redistributions of source code must retain the above copyright
13   *    notice, this list of conditions and the following disclaimer. 
14   *
15   * 2. Redistributions in binary form must reproduce the above copyright
16   *    notice, this list of conditions and the following disclaimer in
17   *    the documentation and/or other materials provided with the
18   *    distribution.
19   *
20   * 3. The end-user documentation included with the redistribution,
21   *    if any, must include the following acknowledgment:  
22   *       "This product includes software developed by the
23   *        Apache Software Foundation (http://www.apache.org/)."
24   *    Alternately, this acknowledgment may appear in the software itself,
25   *    if and wherever such third-party acknowledgments normally appear.
26   *
27   * 4. The names "WSIF" and "Apache Software Foundation" must
28   *    not be used to endorse or promote products derived from this
29   *    software without prior written permission. For written 
30   *    permission, please contact apache@apache.org.
31   *
32   * 5. Products derived from this software may not be called "Apache",
33   *    nor may "Apache" appear in their name, without prior written
34   *    permission of the Apache Software Foundation.
35   *
36   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47   * SUCH DAMAGE.
48   * ====================================================================
49   *
50   * This software consists of voluntary contributions made by many
51   * individuals on behalf of the Apache Software Foundation and was
52   * originally based on software copyright (c) 2001, 2002, International
53   * Business Machines, Inc., http://www.apache.org.  For more
54   * information on the Apache Software Foundation, please see
55   * <http://www.apache.org/>.
56   */
57  
58  package ejb.service;
59  
60  import java.util.*;
61  import org.w3c.dom.*;
62  import javax.xml.parsers.*;
63  
64  import java.rmi.RemoteException;
65  import javax.ejb.CreateException;
66  import javax.ejb.EJBException;
67  import javax.ejb.FinderException;
68  import javax.ejb.RemoveException;
69  import javax.ejb.SessionBean;
70  import javax.ejb.SessionContext;
71  import javax.naming.Context;
72  import javax.naming.InitialContext;
73  import javax.naming.NamingException;
74  import javax.rmi.PortableRemoteObject;
75  
76  import ejb.service.addressbook.wsiftypes.Address;
77  
78  /**
79   * AddressBook Session Bean
80   *
81   * ATTENTION: Some of the XDoclet tags are hidden from XDoclet by
82   *            adding a "--" between @ and the namespace. Please remove
83   *            this "--" to make it active or add a space to make an
84   *            active tag inactive.
85   *
86   * @ejb:bean name="service/AddressBookSession"
87   *           display-name="AddressBook Bean"
88   *           type="Stateful"
89   *           transaction-type="Container"
90   *           jndi-name="ejb/service/AddressBook"
91   *
92   * @ejb:ejb-ref ejb-name="service/AddressBookSession"
93   *              ref-name="myservice/AddressBook"
94   *
95   * @ejb:resource-ref res-name="test/Mail"
96   *                   res-type="javax.mail.Session"
97   *                   res-auth="Container"
98   *
99   * @jboss:resource-manager res-man-class="javax.mail.Session"
100  *                         res-man-name="test/Mail"
101  *                         res-man-jndi-name="java:Mail"
102  **/
103 public class AddressBookSessionBean implements SessionBean {
104     private HashMap name2AddressTable = new HashMap();
105     private SessionContext mContext;
106 
107     /**
108      * @ejb:interface-method view-type="remote"
109      **/
110     public void addEntry(String name, Address address)
111     {
112   name2AddressTable.put(name, address);
113     }
114 
115     /**
116      * @ejb:interface-method view-type="remote"
117      **/
118     public void addEntry(String firstName, String lastName, Address address)
119     {
120   name2AddressTable.put(firstName+" "+lastName, address);
121     }
122 
123     /**
124      * @ejb:interface-method view-type="remote"
125      **/
126     public Address getAddressFromName(String name)
127   throws IllegalArgumentException
128     {
129   return (Address)name2AddressTable.get(name);
130     }
131 
132     /**
133      * Create the Session Bean
134      *
135      * @throws CreateException 
136      *
137      * @ejb:create-method view-type="remote"
138      **/
139     public void ejbCreate()
140   throws
141       CreateException
142     {
143   System.out.println( "AddressBookSessionBean.ejbCreate()" );
144     }
145    
146     /**
147      * Describes the instance and its content for debugging purpose
148      *
149      * @return Debugging information about the instance and its content
150      **/
151     public String toString()
152     {
153   return "AddressBookSessionBean [ " + " ]";
154     }
155    
156    
157     // -------------------------------------------------------------------------
158     // Framework Callbacks
159     // -------------------------------------------------------------------------  
160    
161     public void setSessionContext( SessionContext aContext )
162   throws
163       EJBException
164     {
165   mContext = aContext;
166     }
167    
168     public void ejbActivate()
169   throws
170       EJBException
171     {
172     }
173    
174     public void ejbPassivate()
175   throws
176       EJBException
177     {
178     }
179    
180     public void ejbRemove()
181   throws
182       EJBException
183     {
184     }
185 }
186