KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > bsf > remoteIterator > server > RemoteIteratorServiceBean


1 /* ******************************************************************************** *
2  * Copyright (c) 2002 - 2004 Bright Side Factory. All rights reserved. *
3  * *
4  * Redistribution and use in source and binary forms, with or without modification, *
5  * are permitted provided that the following conditions are met: *
6  * *
7  * 1. Redistributions of source code must retain the above copyright notice, this *
8  * list of conditions and the following disclaimer. *
9  * *
10  * 2. Redistributions in binary form must reproduce the above copyright notice, *
11  * this list of conditions and the following disclaimer in the documentation and/or *
12  * other materials provided with the distribution. *
13  * *
14  * 3. The end-user documentation included with the redistribution, if any, must *
15  * include the following acknowledgment: "This product includes software developed *
16  * by the Bright Side Factory (http://www.bs-factory.org/)." Alternately, this *
17  * acknowledgment may appear in the software itself, if and wherever such *
18  * third-party acknowledgments normally appear. *
19  * *
20  * 4. The names "Bright Side", "BS Framework" and "Bright Side Factory" must not be *
21  * used to endorse or promote products derived from this software without prior *
22  * written permission. For written permission, please contact info@bs-factory.org. *
23  * *
24  * 5. Products derived from this software may not be called "Bright Side", nor may *
25  * "Bright Side" appear in their name, without prior written permission of the *
26  * Bright Side Factory. *
27  * *
28  * THIS SOFTWARE IS PROVIDED ''AS IS'' BY THE COPYRIGHT OWNER AND ANY EXPRESSED OR *
29  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
30  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT *
31  * SHALL THE COPYRIGHT OWNER OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, *
32  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, *
33  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
34  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
35  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE *
36  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS OFTWARE, EVEN IF ADVISED *
37  * OF THE POSSIBILITY OF SUCH DAMAGE. *
38  * *
39  * ================================================================================ *
40  * *
41  * This software consists of voluntary contributions made by many individuals on *
42  * behalf of the Bright Side Factory. For more information on the Bright Side *
43  * Factory, please see http://www.bs-factory.org. *
44  * *
45  * ******************************************************************************** */

46 package org.bsf.remoteIterator.server;
47
48 import org.bsf.commons.ejb.SessionAdapterBean;
49
50 import javax.ejb.CreateException JavaDoc;
51 import javax.naming.InitialContext JavaDoc;
52 import javax.naming.NamingException JavaDoc;
53
54 /**
55  * This stateless ejb provides access to the remote iterator features.
56  *
57  * @see org.bsf.remoteIterator.server.RemoteIteratorBean
58  *
59  * @ejb:bean type="Stateless"
60  * name="RemoteIteratorService"
61  * jndi-name="ejb/RemoteIteratorService"
62  * local-jndi-name="ejb/RemoteIteratorServiceLocal"
63  * view-type="both"
64  *
65  * @ejb:home extends="javax.ejb.EJBHome"
66  * local-extends="javax.ejb.EJBLocalHome"
67  *
68  * @ejb:interface extends="javax.ejb.EJBObject"
69  * local-extends="javax.ejb.EJBLocalObject"
70  *
71  * @ejb:ejb-ref ejb-name="RemoteIterator"
72  * view-type="remote"
73  *
74  * @ejb:transaction type="Supports"
75  *
76  * @jonas.bean ejb-name="RemoteIteratorService"
77  * jndi-name="ejb/RemoteIteratorService"
78  */

79 public class RemoteIteratorServiceBean extends SessionAdapterBean {
80     private RemoteIteratorHome _remoteIteratorHome = null;
81
82     /**
83      * @ejb:interface-method
84      */

85     public RemoteIterator getRemoteIterator( String JavaDoc p_query ) {
86         RemoteIterator remoteIterator = null;
87
88         try {
89             remoteIterator = _remoteIteratorHome.create( p_query );
90         } catch( Exception JavaDoc e ) {
91             // A RemoteException or a CreateException...
92
logError( "Unable to create ri with sql: " + p_query );
93
94             handleExceptionAsSystemException( e );
95         }
96
97         return remoteIterator;
98     }
99
100     // *************************************************************************
101
// ******************** SesssionAdapterBean Methods ************************
102
// *************************************************************************
103

104     public void ejbCreate() throws CreateException JavaDoc {
105         logDebug( "ejbCreate() -> Retrieving the home(s)..." );
106
107         // Retrieves the local home of the RemoteIteratorBean and keeps it for further use
108
try {
109             InitialContext JavaDoc ic = new InitialContext JavaDoc();
110             _remoteIteratorHome = (RemoteIteratorHome) ic.lookup( "java:comp/env/ejb/RemoteIterator" );
111         } catch( NamingException JavaDoc e ) {
112             handleExceptionAsSystemException( e );
113         }
114     }
115 }
116
117
Popular Tags