%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.turbine.services.TurbineBaseService |
|
|
1 | package org.apache.turbine.services; |
|
2 | ||
3 | /* |
|
4 | * Copyright 2001-2005 The Apache Software Foundation. |
|
5 | * |
|
6 | * Licensed under the Apache License, Version 2.0 (the "License") |
|
7 | * you may not use this file except in compliance with the License. |
|
8 | * You may obtain a copy of the License at |
|
9 | * |
|
10 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
11 | * |
|
12 | * Unless required by applicable law or agreed to in writing, software |
|
13 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 | * See the License for the specific language governing permissions and |
|
16 | * limitations under the License. |
|
17 | */ |
|
18 | ||
19 | import javax.servlet.ServletConfig; |
|
20 | ||
21 | import org.apache.turbine.util.RunData; |
|
22 | ||
23 | /** |
|
24 | * <p>This class provides a <code>Service</code> implementation that |
|
25 | * Services used in Turbine are required to extend. The |
|
26 | * functionality provided in addition to <code>BaseService</code> |
|
27 | * functionality is recognizing objects used in early initialization |
|
28 | * of <code>Services</code> in Turbine, and passing them to |
|
29 | * appropriate convenience methods. These methods should be overriden |
|
30 | * to provide desired initialization functionality.</p> |
|
31 | * |
|
32 | * <p><strong>Note!</strong><br>Remember to call |
|
33 | * <code>setInit(true)</code> after successful initialization.</p> |
|
34 | * |
|
35 | * <p><strong>Note!</strong><br>If you need to use another |
|
36 | * <code>Service</code> inside your early initialization, remember to |
|
37 | * request initialization of that <code>Service</code> before using |
|
38 | * it:</p> |
|
39 | * |
|
40 | * <pre><code> |
|
41 | * getServiceBroker().initClass("OtherService",data); |
|
42 | * OtherService service = |
|
43 | * (OtherService)getServiceBroker().getService("OtherService"); |
|
44 | * </code></pre> |
|
45 | * |
|
46 | * @author <a href="mailto:greg@shwoop.com">Greg Ritter</a> |
|
47 | * @author <a href="mailto:bmclaugh@algx.net">Brett McLaughlin</a> |
|
48 | * @author <a href="mailto:burton@apache.org">Kevin Burton</a> |
|
49 | * @author <a href="mailto:krzewski@e-point.pl">Rafal Krzewski</a> |
|
50 | * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a> |
|
51 | * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a> |
|
52 | * @version $Id: TurbineBaseService.java 264148 2005-08-29 14:21:04Z henning $ |
|
53 | */ |
|
54 | 386 | public abstract class TurbineBaseService |
55 | extends BaseService |
|
56 | { |
|
57 | /** |
|
58 | * Performs early initialization. Overrides init() method in |
|
59 | * BaseService to detect objects used in Turbine's Service |
|
60 | * initialization and pass them to apropriate init() methods. |
|
61 | * |
|
62 | * @param data An Object to use for initialization activities. |
|
63 | * @exception InitializationException if initialization of this |
|
64 | * class was not successful. |
|
65 | */ |
|
66 | public void init(Object data) |
|
67 | throws InitializationException |
|
68 | { |
|
69 | 0 | if (data instanceof ServletConfig) |
70 | { |
|
71 | 0 | init((ServletConfig) data); |
72 | } |
|
73 | 0 | else if (data instanceof RunData) |
74 | { |
|
75 | 0 | init((RunData) data); |
76 | } |
|
77 | 0 | } |
78 | ||
79 | /** |
|
80 | * Performs early initialization. |
|
81 | * |
|
82 | * @param config A ServletConfing to use for initialization |
|
83 | * activities. |
|
84 | * @exception InitializationException if initialization of this |
|
85 | * class was not successful. |
|
86 | * @deprecated Use init() instead |
|
87 | */ |
|
88 | public void init(ServletConfig config) throws InitializationException |
|
89 | { |
|
90 | 0 | } |
91 | ||
92 | /** |
|
93 | * Performs early initialization. |
|
94 | * |
|
95 | * @param data An RunData to use for initialization activities. |
|
96 | * @exception InitializationException if initialization of this |
|
97 | * class was not successful. |
|
98 | */ |
|
99 | public void init(RunData data) throws InitializationException |
|
100 | { |
|
101 | 0 | } |
102 | ||
103 | /** |
|
104 | * Performs late initialization. |
|
105 | * |
|
106 | * If your class relies on early initialization, and the object it |
|
107 | * expects was not received, you can use late initialization to |
|
108 | * throw an exception and complain. |
|
109 | * |
|
110 | * @exception InitializationException, if initialization of this |
|
111 | * class was not successful. |
|
112 | */ |
|
113 | public void init() throws InitializationException |
|
114 | { |
|
115 | 0 | setInit(true); |
116 | 0 | } |
117 | ||
118 | /** |
|
119 | * Returns to uninitialized state. |
|
120 | * |
|
121 | * You can use this method to release resources thet your Service |
|
122 | * allocated when Turbine shuts down. |
|
123 | */ |
|
124 | public void shutdown() |
|
125 | { |
|
126 | 50 | setInit(false); |
127 | 50 | } |
128 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |