View Javadoc

1   /*
2    * Copyright [2007] [University Corporation for Advanced Internet Development, Inc.]
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package edu.internet2.middleware.shibboleth.common.service;
18  
19  /**
20   * A simple interface that represents coarse grained services, or components, within the software.
21   */
22  public interface Service {
23  
24      /**
25       * Gets the ID of this service.
26       * 
27       * @return ID of this service
28       */
29      public String getId();
30  
31      /**
32       * Gets whether the service is initialized and ready for use.
33       * 
34       * @return true if the service is ready for use, false it not
35       */
36      public boolean isInitialized();
37  
38      /**
39       * Initializes this service. Calling this on an initialized service should return immediately without affecting any
40       * service state.
41       * 
42       * @throws ServiceException thrown if there is a problem initializing the service
43       */
44      public void initialize() throws ServiceException;
45  
46      /**
47       * Gets whether the service has been destroyed.
48       * 
49       * @return true if the service has been destroyed
50       */
51      public boolean isDestroyed();
52  
53      /**
54       * Destroys a service, freeing any resources it may currently be using. Whether a service can be re-initialized
55       * after being destroyed is implementation dependent.
56       * 
57       * @throws ServiceException thrown if there is a problem destroying the service
58       */
59      public void destroy() throws ServiceException;
60  }