01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19:
20: package org.apache.geronimo.tomcat;
21:
22: import java.lang.reflect.InvocationTargetException;
23:
24: import javax.naming.Context;
25: import javax.naming.NamingException;
26:
27: import org.apache.InstanceManager;
28: import org.apache.geronimo.j2ee.annotation.Holder;
29:
30: /**
31: * @version $Rev: 543827 $ $Date: 2007-06-02 19:05:28 -0700 (Sat, 02 Jun 2007) $
32: */
33: public class TomcatInstanceManager implements InstanceManager {
34:
35: private final Holder holder;
36: private final ClassLoader classLoader;
37: private final Context context;
38:
39: public TomcatInstanceManager(Holder holder,
40: ClassLoader classLoader, Context context) {
41: this .holder = holder;
42: this .classLoader = classLoader;
43: this .context = context;
44: }
45:
46: public Object newInstance(String fqcn, ClassLoader classLoader)
47: throws IllegalAccessException, InvocationTargetException,
48: NamingException, InstantiationException,
49: ClassNotFoundException {
50: return holder.newInstance(fqcn, classLoader, context);
51: }
52:
53: public Object newInstance(String className)
54: throws IllegalAccessException, InvocationTargetException,
55: NamingException, InstantiationException,
56: ClassNotFoundException {
57: return holder.newInstance(className, classLoader, context);
58: }
59:
60: public void destroyInstance(Object o)
61: throws IllegalAccessException, InvocationTargetException {
62: try {
63: holder.destroyInstance(o);
64: } catch (Exception e) {
65: throw new InvocationTargetException(e,
66: "Attempted to destroy instance");
67: }
68: }
69:
70: public void newInstance(Object o) throws IllegalAccessException,
71: InvocationTargetException, NamingException {
72: throw new UnsupportedOperationException(
73: "separate instantiation and injection is not supported");
74: }
75: }
|