01: /*****************************************************************************
02: * Copyright (c) PicoContainer Organization. All rights reserved. *
03: * ------------------------------------------------------------------------- *
04: * The software in this package is published under the terms of the BSD *
05: * style license a copy of which has been included with this distribution in *
06: * the LICENSE.txt file. *
07: * *
08: *****************************************************************************/package org.picocontainer.gems.jndi;
09:
10: import java.util.Properties;
11:
12: import javax.naming.NamingException;
13:
14: import org.picocontainer.ComponentAdapter;
15: import org.picocontainer.ComponentMonitor;
16: import org.picocontainer.LifecycleStrategy;
17: import org.picocontainer.Parameter;
18: import org.picocontainer.PicoCompositionException;
19: import org.picocontainer.behaviors.AbstractBehaviorFactory;
20:
21: /**
22: * produce JNDI exposing behaviour
23: *
24: * @author k.pribluda
25: *
26: * @param <T>
27: */
28: @SuppressWarnings("serial")
29: public class JNDIExposing extends AbstractBehaviorFactory {
30:
31: @Override
32: public <T> ComponentAdapter<T> addComponentAdapter(
33: ComponentMonitor componentMonitor,
34: LifecycleStrategy lifecycleStrategy,
35: Properties componentProperties, ComponentAdapter<T> adapter) {
36: try {
37: return new JNDIExposed<T>(super .addComponentAdapter(
38: componentMonitor, lifecycleStrategy,
39: componentProperties, adapter));
40: } catch (NamingException e) {
41: throw new PicoCompositionException(
42: "unable to create JNDI behaviour", e);
43: }
44: }
45:
46: @Override
47: public <T> ComponentAdapter<T> createComponentAdapter(
48: ComponentMonitor componentMonitor,
49: LifecycleStrategy lifecycleStrategy,
50: Properties componentProperties, Object componentKey,
51: Class<T> componentImplementation, Parameter... parameters)
52: throws PicoCompositionException {
53: // TODO Auto-generated method stub
54: ComponentAdapter<T> componentAdapter = super
55: .createComponentAdapter(componentMonitor,
56: lifecycleStrategy, componentProperties,
57: componentKey, componentImplementation,
58: parameters);
59:
60: try {
61: return new JNDIExposed<T>(componentAdapter);
62: } catch (NamingException e) {
63: throw new PicoCompositionException(
64: "unable to create JNDI behaviour", e);
65: }
66: }
67:
68: }
|