View Javadoc

1   /***
2    * @(#)ServiceLocator.java
3    * 
4    * JFoxSOAF, Service-Oriented Application Framework
5    * 
6    * Copyright(c) JFoxSOAF Team
7    * 
8    * Licensed under the GNU LGPL, Version 2.1 (the "License"); 
9    * you may not use this file except in compliance with the License. 
10   * You may obtain a copy of the License at  
11   * 
12   * http://www.gnu.org/copyleft/lesser.html
13   * 
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS, 
16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
17   * See the License for the specific language governing permissions and 
18   * limitations under the License. 
19   * 
20   * For more information, please visit:
21   * http://www.jfox.cn/confluence/display/JFoxSOAF/Home
22   * http://www.huihoo.org/jfox/jfoxsoaf
23   */
24  
25  package org.huihoo.jfox.soaf.services.ejb;
26  
27  import java.net.URL;
28  import java.rmi.Remote;
29  
30  import javax.ejb.EJBHome;
31  import javax.ejb.EJBLocalHome;
32  import javax.jms.ConnectionFactory;
33  import javax.jms.Destination;
34  import javax.jms.Queue;
35  import javax.jms.QueueConnectionFactory;
36  import javax.jms.Topic;
37  import javax.jms.TopicConnectionFactory;
38  import javax.mail.Session;
39  import javax.sql.DataSource;
40  import javax.transaction.UserTransaction;
41  
42  import org.huihoo.jfox.soaf.exception.ServiceLocatorException;
43  
44  /***
45   * <p>
46   * This class is an implementation of the Service Locator pattern. It is used to
47   * looukup resources such as EJBHomes, JMS Destinations, etc. This
48   * implementation uses the "singleton instance" strategy and also the "caching"
49   * strategy.
50   * </p>
51   * 
52   * @author <a href="mailto:founder_chen@yahoo.com.cn">Peter Cheng </a>
53   * @version $Revision: 1.10 $ $Date: 2005/05/22 06:49:31 $
54   * @version Revision: 1.0
55   */
56  
57  public interface ServiceLocator {
58  
59      /***
60       * will get the ejb Local home factory. If this ejb home factory has already
61       * been clients need to cast to the type of EJBHome they desire
62       * 
63       * @return the EJB Home corresponding to the homeName
64       */
65      public EJBLocalHome getLocalHome(String jndiHomeName)
66              throws ServiceLocatorException;
67  
68      /***
69       * will get the ejb Remote home factory. If this ejb home factory has
70       * already been clients need to cast to the type of EJBHome they desire
71       * 
72       * @return the EJB Home corresponding to the homeName
73       */
74      public EJBHome getRemoteHome(String jndiHomeName, Class className)
75              throws ServiceLocatorException;
76  
77      /***
78       * @return the factory for the factory to get queue connections from
79       */
80      public QueueConnectionFactory getQueueConnectionFactory(
81              String qConnFactoryName) throws ServiceLocatorException;
82  
83      /***
84       * @return the Queue Destination to send messages to
85       */
86      public Queue getQueue(String queueName) throws ServiceLocatorException;
87  
88      /***
89       * This method helps in obtaining the topic factory
90       * 
91       * @return the factory for the factory to get topic connections from
92       */
93      public TopicConnectionFactory getTopicConnectionFactory(
94              String topicConnFactoryName) throws ServiceLocatorException;
95  
96      /***
97       * This method helps in obtaining the unified factory.
98       * 
99       * @return the unified factory to get connections from
100      */
101     public ConnectionFactory getJMSConnectionFactory(String ConnFactoryName)
102             throws ServiceLocatorException;
103 
104     /***
105      * This method helps in obtianing hte unified destination.
106      * 
107      * @return the Destination to send messages to
108      */
109     public Destination getJMSDestination(String destName)
110             throws ServiceLocatorException;
111 
112     /***
113      * This method obtains the topc itself for a caller
114      * 
115      * @return the Topic Destination to send messages to
116      */
117     public Topic getTopic(String topicName) throws ServiceLocatorException;
118 
119     /***
120      * This method obtains the datasource itself for a caller
121      * 
122      * @return the DataSource corresponding to the name parameter
123      */
124     public DataSource getDataSource(String dataSourceName)
125             throws ServiceLocatorException;
126 
127     /***
128      * This method obtains the mail seesion itself for a caller
129      * 
130      * @return the Session corresponding to the name parameter
131      */
132     public Session getMailSession(String mailSessionName)
133             throws ServiceLocatorException;
134 
135     /***
136      * This method obtains the UserTransaction itself for a caller
137      * 
138      * @return the UserTransaction corresponding to the name parameter
139      */
140     public UserTransaction getUserTransaction(String utName)
141             throws ServiceLocatorException;
142 
143     /***
144      * @return the URL value corresponding to the env entry name.
145      */
146     public URL getUrl(String envName) throws ServiceLocatorException;
147 
148     /***
149      * @return the boolean value corresponding to the env entry such as
150      *         SEND_CONFIRMATION_MAIL property.
151      */
152     public boolean getBoolean(String envName) throws ServiceLocatorException;
153 
154     /***
155      * @return the String value corresponding to the env entry name.
156      */
157     public String getString(String envName) throws ServiceLocatorException;
158 
159     /***
160      * Service class acts as a factory of the Dynamic proxy for the target
161      * service endpoint.
162      * 
163      * @see java.xml.rpc.Service.java
164      * @return the Service instance
165      */
166     public Remote getServicePort(String jndiHomeName, Class className)
167             throws ServiceLocatorException;
168 
169 }