01: // ***************************************************************
02: // * *
03: // * File:Service.java *
04: // * *
05: // * Copyright (c) 2002 Sun Microsystems, Inc. *
06: // * All rights reserved. *
07: // * *
08: // * *
09: // * Date - Jul/16/2002 *
10: // * Author - alejandro.abdelnur@sun.com *
11: // * *
12: // ***************************************************************
13:
14: package com.sun.portal.common.service;
15:
16: /**
17: * A service is an entity that has a well established lifecycle.
18: * <P>
19: * The Service interface provides for creation and destruction
20: * lifecycle methods.
21: * <P>
22: * A Service is managed by a ServiceContext
23: *
24: * @author <A HREF="mailto:tucu@sun.com">Alejandro Abdelnur</A>
25: *
26: */
27: public interface Service {
28:
29: /**
30: * Called by the ServiceContext to initialized the service.
31: * <P>
32: * The service container calls the init method exactly
33: * once after instantiating the service. The init method
34: * must complete successfully before the service is active for
35: * regular use.
36: * <P>
37: * The service container cannot place the service in use if the
38: * init method:
39: * <UL>
40: * <LI>Throws a ServiceException</LI>
41: * <LI>Does not return within a time period defined by the
42: * service or the service container, whatever is less</LI>
43: * </UL>
44: *
45: * @param config a ServiceConfig object containing the
46: * service's configuration and initialization parameters
47:
48: * @throws ServiceException if an exception has occurred that
49: * interferes with the service's normal operation
50: *
51: */
52: public void init(ServiceConfig config) throws ServiceException;
53:
54: /**
55: * Returns the ServiceConfig object for the service.
56: *
57: * @return the ServiceConfig object
58: */
59: public ServiceConfig getConfig();
60:
61: /**
62: * Called by the service container to indicate to a service that the
63: * service is being taken out of service. After the service container
64: * calls this method, the service is not active anymore.
65: * <P>
66: * This method gives the service an opportunity to clean up any
67: * resources that are being held (for example, memory, file handles,
68: * threads).
69: *
70: */
71: public void destroy();
72:
73: }
|