KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > slide > common > Service


1 /*
2  * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/Service.java,v 1.14 2004/07/28 09:38:15 ib Exp $
3  * $Revision: 1.14 $
4  * $Date: 2004/07/28 09:38:15 $
5  *
6  * ====================================================================
7  *
8  * Copyright 1999-2002 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

23
24 package org.apache.slide.common;
25
26 import java.util.Hashtable JavaDoc;
27
28 import javax.transaction.xa.XAResource JavaDoc;
29
30 import org.apache.slide.authenticate.CredentialsToken;
31 import org.apache.slide.util.logger.Logger;
32
33 /**
34  * Slide Service interface.
35  *
36  * @version $Revision: 1.14 $
37  */

38 public interface Service
39     extends XAResource JavaDoc {
40     
41     
42     // -------------------------------------------------------------- Constants
43

44     
45     // ------------------------------------------------------ Interface Methods
46

47         
48         
49     /**
50      * Set the scope of the store as specified in domain.xml.
51      */

52     void setScope(Scope scope);
53     
54     
55     
56     
57     /**
58      * Namespace setter.
59      */

60     void setNamespace(Namespace namespace);
61     
62     
63     /**
64      * Initializes the service with a set of parameters. Those could be :
65      * <li>User name, login info
66      * <li>Host name on which to connect
67      * <li>Remote port
68      * <li>JDBC driver whoich is to be used :-)
69      * <li>Anything else ...
70      *
71      * @param parameters Hashtable containing the parameters' names and
72      * associated values
73      * @exception ServiceParameterErrorException Incorrect service parameter
74      * @exception ServiceParameterMissingException Service parameter missing
75      */

76     void setParameters(Hashtable JavaDoc parameters)
77         throws ServiceParameterErrorException,
78         ServiceParameterMissingException;
79     
80     
81     /**
82      * Connects to the underlying data source (if any is needed).
83      *
84      * @exception ServiceConnectionFailedException Connection failed
85      * @param crdtoken the Credentials token containing e.g. the credential
86      */

87     void connect(CredentialsToken crdtoken)
88         throws ServiceConnectionFailedException;
89     
90     
91     
92     /**
93      * Connects to the underlying data source (if any is needed).
94      *
95      * @exception ServiceConnectionFailedException Connection failed
96      */

97     void connect()
98         throws ServiceConnectionFailedException;
99     
100     
101     /**
102      * Disconnects from the underlying data source.
103      *
104      * @exception ServiceDisconnectionFailedException Disconnection failed
105      */

106     void disconnect()
107         throws ServiceDisconnectionFailedException;
108     
109     
110     /**
111      * Initializes service.
112      *
113      * @param token Namespace access token, needed if the service needs to
114      * access objects or data within the namespace during its initialization
115      * @exception ServiceInitializationFailedException May throw an exception
116      * if the service has already been initialized before
117      */

118     void initialize(NamespaceAccessToken token)
119         throws ServiceInitializationFailedException;
120     
121     
122     /**
123      * Deletes service underlying data source, if possible (and meaningful).
124      *
125      * @exception ServiceResetFailedException Reset failed
126      */

127     void reset()
128         throws ServiceResetFailedException;
129     
130     
131     /**
132      * This function tells whether or not the service is connected.
133      *
134      * @return boolean true if we are connected
135      * @exception ServiceAccessException Service access error
136      */

137     boolean isConnected()
138         throws ServiceAccessException;
139     
140     
141     /**
142      * Connects to the service, if we were not previously connected.
143      *
144      * @param crdtoken the Credentials token containing e.g. the credential
145      * @return boolean true if we were not already connected
146      * @exception ServiceAccessException Unspecified service access error
147      * @exception ServiceConnectionFailedException Connection failed
148      */

149     boolean connectIfNeeded(CredentialsToken crdtoken)
150         throws ServiceConnectionFailedException, ServiceAccessException;
151     
152     
153     /**
154      * Connects to the service, if we were not previously connected.
155      *
156      * @deprecated
157      * @return boolean true if we were not already connected
158      * @exception ServiceAccessException Unspecified service access error
159      * @exception ServiceConnectionFailedException Connection failed
160      */

161     boolean connectIfNeeded()
162         throws ServiceConnectionFailedException, ServiceAccessException;
163     
164     
165     /**
166      * Idicates whether or not the objects managed by this service should be
167      * cached. Useful if the service is fast enough, and / or if it already
168      * includes its own custom caching mechanism, which might be more efficient
169      * than the default one provided by the helpers.
170      *
171      * @return boolean True if results should be cached
172      */

173     boolean cacheResults();
174     
175     
176     /**
177      * Get logger associated with the service.
178      *
179      * @return The logger if one has been set for the associated namespace,
180      * or the Domain logger otherwise
181      */

182     Logger getLogger();
183     
184     
185 }
186
Popular Tags