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 * Classes that implement this interface need initialization before
26 * they can work.
27 *
28 * These classes rely also on an <code>InitableBroker</code> that
29 * ensures that there is only one instance of the class in the system,
30 * and handles dependencies between <code>Initables</code>.
31 *
32 * @author <a href="mailto:burton@apache.org">Kevin Burton</a>
33 * @author <a href="mailto:krzewski@e-point.pl">Rafal Krzewski</a>
34 * @version $Id: Initable.java 615328 2008-01-25 20:25:05Z tv $
35 */
36 public interface Initable
37 {
38 /**
39 * Provides an Initable with a reference to the InitableBroker
40 * that instantiated this object, so that it can access other
41 * Initables.
42 *
43 * @param broker The InitableBroker that instantiated this object.
44 */
45 void setInitableBroker(InitableBroker broker);
46
47 /**
48 * Performs early initailization of an Initable
49 *
50 * During the startup of the system, different objects may be
51 * passed to your class using this method. It should ignore any
52 * objects that it doesn't need or understand.
53 *
54 * After the class changes its internal state so that getInit()
55 * returns true, this method will be called no more, and late
56 * initialization will not be performed.
57 *
58 * If your class relies on early initialization, and the object it
59 * expects was not received, you can use late initialization to
60 * throw an exception and complain.
61 *
62 * @param data An Object to use for initialization activities.
63 * @exception InitializationException if initilaization of this
64 * class was not successful.
65 */
66 void init(Object data) throws InitializationException;
67
68 /**
69 * Performs late initialization of an Initable.
70 *
71 * When your class is being requested from an InitableBroker, it
72 * will call getInit(), and if it returns false, this method will
73 * be invoked.
74 *
75 * @exception InitializationException if initialization of this
76 * class was not successful.
77 */
78 void init() throws InitializationException;
79
80 /**
81 * Returns an <code>Initable</code> to an uninitialized state.
82 *
83 * <p>This method must release all resources allocated by the
84 * <code>Initable</code> implementation, and resetting its internal state.
85 * You may chose to implement this operation or not. If you support
86 * this operation, getInit() should return false after successful
87 * shutdown of the service.
88 */
89 void shutdown();
90
91 /**
92 * Returns initialization status of an Initable.
93 *
94 * @return Initialization status of an Initable.
95 */
96 boolean getInit();
97 }