01: // ***************************************************************
02: // * *
03: // * File:ServiceAdapter.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: * The ServiceAdapter is a convenience class for creating
18: * services.
19: * <P>
20: *
21: * @author <A HREF="mailto:tucu@sun.com">Alejandro Abdelnur</A>
22: *
23: */
24: public class ServiceAdapter implements Service {
25:
26: private ServiceConfig _config;
27:
28: /**
29: * Called by the ServiceContext to initialized the service.
30: * <P>
31: * This implementation stores the ServletConfig object it
32: * receives from the servlet container for later use and
33: * calls the init() method. When overriding this form of the
34: * method, call super.init(config) at the very beginning of
35: * the method.
36: * <P>
37: *
38: * @param config a ServiceConfig object containing the
39: * service's configuration and initialization parameters
40: *
41: * @throws ServiceException if an exception has occurred that
42: * interferes with the service's normal operation
43: *
44: */
45: public void init(ServiceConfig config) throws ServiceException {
46: _config = config;
47: init();
48: }
49:
50: /**
51: * A convenience method which can be overridden so that there's
52: * no need to call super.init(config).
53: * <P>
54: * Instead of overriding init(PortletConfig), simply override this
55: * method and it will be called by ServiceAdapter.init(ServiceConfig
56: * config). The ServiceConfig object can still be retrieved via
57: * getServletConfig().
58: * <P>
59: *
60: * @throws ServiceException if an exception has occurred that
61: * interferes with the service's normal operation
62: *
63: *
64: */
65: public void init() throws ServiceException {
66: }
67:
68: /**
69: * Returns this service's ServiceConfig object.
70: * <P>
71: *
72: * @returns the ServiceConfig object of the initialized service
73: *
74: */
75: public ServiceConfig getConfig() {
76: return _config;
77: }
78:
79: /**
80: * Called by the service container to indicate to a service that
81: * the service is being taken out of service.
82: * <P>
83: *
84: *
85: */
86: public void destroy() {
87: _config = null;
88: }
89: }
|