##### Coverage Report - org.apache.turbine.services.BaseInitable

Classes in this File | Line Coverage | Branch Coverage | Complexity
BaseInitable |
46% | 6/13
N/A | N/A
| 1.0;1

1 |  |
     package org.apache.turbine.services;
2 |  |
3 |  |
4 |  |
     /*
5 |  |
      * Licensed to the Apache Software Foundation (ASF) under one
6 |  |
      * or more contributor license agreements.  See the NOTICE file
7 |  |
      * distributed with this work for additional information
8 |  |
      * regarding copyright ownership.  The ASF licenses this file
9 |  |
      * to you under the Apache License, Version 2.0 (the
10 |  |
      * "License"); you may not use this file except in compliance
11 |  |
      * with the License.  You may obtain a copy of the License at
12 |  |
      *
13 |  |
      *   http://www.apache.org/licenses/LICENSE-2.0
14 |  |
      *
15 |  |
      * Unless required by applicable law or agreed to in writing,
16 |  |
      * software distributed under the License is distributed on an
17 |  |
      * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 |  |
      * KIND, either express or implied.  See the License for the
19 |  |
      * specific language governing permissions and limitations
20 |  |
      * under the License.
21 |  |
      */
22 |  |
23 |  |
24 |  |
     /**
25 |  |
      * This class provides a generic implementation of
26 |  |
      * <code>Initable</code>.  This implementation, that other
27 |  |
      * <code>Initables</code> are welcome to extend, contains facilities
28 |  |
      * to maintain internal state.
29 |  |
      *
30 |  |
      * @author <a href="mailto:burton@apache.org">Kevin Burton</a>
31 |  |
      * @author <a href="mailto:krzewski@e-point.pl">Rafal Krzewski</a>
32 |  |
      * @version $Id: BaseInitable.java 1706239 2015-10-01 13:18:35Z tv $
33 |  |
      */
34 |  |
     public class BaseInitable
35 |  |
             implements Initable
36 |  |
     {
37 |  |
         /** InitableBroker that instantiatd this class. */
38 |  |
         protected InitableBroker initableBroker;
39 |  |
40 |  |
         /** Initialization status of this class. */
41 | 261 |
         protected boolean isInitialized = false;
42 |  |
43 |  |
         /**
44 |  |
          * Default constructor of BaseInitable.
45 |  |
          *
46 |  |
          * This constructor does nothing.  Your own constructurs should be
47 |  |
          * modest in allocating memory and other resources, leaving this
48 |  |
          * to the <code>init()</code> method.
49 |  |
          */
50 |  |
         public BaseInitable()
51 | 261 |
         {
52 |  |
             // empty
53 | 261 |
         }
54 |  |
55 |  |
         /**
56 |  |
          * Saves InitableBroker reference for later use.
57 |  |
          *
58 |  |
          * @param broker The InitableBroker that instantiated this object.
59 |  |
          */
60 |  |
         @Override
61 |  |
         public void setInitableBroker(InitableBroker broker)
62 |  |
         {
63 | 0 |
             this.initableBroker = broker;
64 | 0 |
         }
65 |  |
66 |  |
         /**
67 |  |
          * Returns an InitableBroker reference.
68 |  |
          *
69 |  |
          * @return The InitableBroker that instantiated this object.
70 |  |
          */
71 |  |
         public InitableBroker getInitableBroker()
72 |  |
         {
73 | 0 |
             return initableBroker;
74 |  |
         }
75 |  |
76 |  |
         /**
77 |  |
          * Performs early initialization.  Used in a manner similar to a ctor.
78 |  |
          *
79 |  |
          * BaseInitable doesn't need early initialization, therefore it
80 |  |
          * ignores all objects passed to it and performs no initialization
81 |  |
          * activities.
82 |  |
          *
83 |  |
          * @param data An Object to use for initialization activities.
84 |  |
          * @exception InitializationException Initialization of this
85 |  |
          * class was not successful.
86 |  |
          */
87 |  |
         @Override
88 |  |
         public void init(Object data) throws InitializationException
89 |  |
         {
90 |  |
             // empty
91 | 0 |
         }
92 |  |
93 |  |
         /**
94 |  |
          * Performs late initialization.  Called when the Service is requested
95 |  |
          * for the first time (if not already completely initialized by the
96 |  |
          * early initializer).
97 |  |
          *
98 |  |
          * Late initialization of a BaseInitable is always successful.
99 |  |
          *
100 |  |
          * @exception InitializationException Initialization of this
101 |  |
          * class was not successful.
102 |  |
          */
103 |  |
         @Override
104 |  |
         public void init() throws InitializationException
105 |  |
         {
106 |  |
             // empty
107 | 0 |
         }
108 |  |
109 |  |
         /**
110 |  |
          * Returns an Initable to uninitialized state.
111 |  |
          *
112 |  |
          * Calls setInit(false) to mark that we are no longer in initialized
113 |  |
          * state.
114 |  |
          */
115 |  |
         @Override
116 |  |
         public void shutdown()
117 |  |
         {
118 | 0 |
             setInit(false);
119 | 0 |
         }
120 |  |
121 |  |
         /**
122 |  |
          * Returns initialization status.
123 |  |
          *
124 |  |
          * @return True if the initable is initialized.
125 |  |
          */
126 |  |
         @Override
127 |  |
         public boolean getInit()
128 |  |
         {
129 | 4879 |
             return isInitialized;
130 |  |
         }
131 |  |
132 |  |
         /**
133 |  |
          * Sets initialization status.
134 |  |
          *
135 |  |
          * @param value The new initialization status.
136 |  |
          */
137 |  |
         protected void setInit(boolean value)
138 |  |
         {
139 | 533 |
             this.isInitialized = value;
140 | 533 |
         }
141 |  |
     }