KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > InjectionManager


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise;
24
25 import com.sun.enterprise.deployment.JndiNameEnvironment;
26
27 /**
28  * InjectionManager provides runtime resource injection(@Resource, @EJB, etc.)
29  * and generic callback(PostConstruct/PreDestroy) services It performs
30  * the actual injection into the fields and methods of designated
31  * J2EE 5 component instances and managed class instances. The decision
32  * as to when injection takes place is determined by the caller.
33  *
34  * @author Kenneth Saks
35  */

36 public interface InjectionManager {
37
38     /**
39      * Inject the given object instance with the resources from its
40      * component environment. The applicable component naming environment
41      * information will be retrieved from the current invocation context.
42      *
43      * Any @PostConstruct methods on the instance's class(and super-classes)
44      * will be invoked after injection.
45      *
46      * @exception InjectionException Thrown if an error occurs during injection
47      *
48      */

49     public void injectInstance(Object JavaDoc instance)
50         throws InjectionException;
51
52     /**
53      * Inject the injectable resources from the given component environment
54      * into an object instance. The specified componentEnv must match the
55      * environment that is associated with the component on top of the
56      * invocation stack at the time this method is invoked.
57      *
58      * Any @PostConstruct methods on the instance's class(and super-classes)
59      * will be invoked after injection.
60      *
61      *
62      * @exception InjectionException Thrown if an error occurs during injection
63      *
64      */

65     public void injectInstance(Object JavaDoc instance,
66                                JndiNameEnvironment componentEnv)
67         throws InjectionException;
68
69     /**
70      * Inject the injectable resources from the given component environment
71      * into an object instance. The specified componentEnv must match the
72      * environment that is associated with the component on top of the
73      * invocation stack at the time this method is invoked.
74      *
75      * @param invokePostConstruct if true, invoke any @PostConstruct methods
76      * on the instance's class(and super-classes) after injection.
77      *
78      * @exception InjectionException Thrown if an error occurs during injection
79      *
80      */

81     public void injectInstance(Object JavaDoc instance,
82                                JndiNameEnvironment componentEnv,
83                                boolean invokePostConstruct)
84         throws InjectionException;
85
86     /**
87      * Inject the injectable resources from the given component environment
88      * into a Class instance. Only class-level(static) fields/methods are
89      * supported. E.g., this injection operation would be used for the
90      * Application Client Container main class.
91      *
92      * Any @PostConstruct methods on the class(and super-classes)
93      * will be invoked after injection.
94      *
95      * @exception InjectionException Thrown if an error occurs during injection
96      */

97     public void injectClass(Class JavaDoc clazz,
98                             JndiNameEnvironment componentEnv)
99         throws InjectionException;
100
101     /**
102      * Inject the injectable resources from the given component environment
103      * into a Class instance. Only class-level(static) fields/methods are
104      * supported. E.g., this injection operation would be used for the
105      * Application Client Container main class.
106      *
107      * @param invokePostConstruct if true, invoke any @PostConstruct methods
108      * on the class(and super-classes) after injection.
109      *
110      * @exception InjectionException Thrown if an error occurs during injection
111      */

112     public void injectClass(Class JavaDoc clazz,
113                             JndiNameEnvironment componentEnv,
114                             boolean invokePostConstruct)
115         throws InjectionException;
116
117     /**
118      *
119      * Invoke any @PreDestroy methods defined on the instance's class
120      * (and super-classes). Invocation information will be retrieved from
121      * the current component invocation context.
122      *
123      * @exception InjectionException Thrown if an error occurs
124      *
125      */

126     public void invokeInstancePreDestroy(Object JavaDoc instance)
127         throws InjectionException;
128
129
130     /**
131      *
132      * Invoke any @PreDestroy methods defined on the instance's class
133      * (and super-classes). The specified componentEnv must match the
134      * environment that is associated with the component on top of the
135      * invocation stack at the time this method is invoked.
136      *
137      * @exception InjectionException Thrown if an error occurs
138      *
139      */

140     public void invokeInstancePreDestroy(Object JavaDoc instance,
141                                          JndiNameEnvironment componentEnv)
142         throws InjectionException;
143
144     /**
145      *
146      * Invoke any static @PreDestroy methods defined on the class
147      * (and super-classes). The specified componentEnv must match the
148      * environment that is associated with the component on top of the
149      * invocation stack at the time this method is invoked.
150      *
151      * @exception InjectionException Thrown if an error occurs
152      *
153      */

154     public void invokeClassPreDestroy(Class JavaDoc clazz,
155                                       JndiNameEnvironment componentEnv)
156         throws InjectionException;
157
158
159 }
160
Popular Tags