    001    /*****************************************************************************
    002     * Copyright (c) PicoContainer Organization. All rights reserved.            *
    003     * ------------------------------------------------------------------------- *
    004     * The software in this package is published under the terms of the BSD      *
    005     * style license a copy of which has been included with this distribution in *
    006     * the LICENSE.txt file.                                                     *
    007     *                                                                           *
    008     *****************************************************************************/
    009
    010    package org.picocontainer.gems.jndi;
    011
    012    import java.util.Properties;
    013
    014    import javax.naming.NamingException;
    015
    016    import org.picocontainer.ComponentAdapter;
    017    import org.picocontainer.ComponentMonitor;
    018    import org.picocontainer.LifecycleStrategy;
    019    import org.picocontainer.Parameter;
    020    import org.picocontainer.PicoCompositionException;
    021    import org.picocontainer.behaviors.AbstractBehaviorFactory;
    022
    023    /**
    024     * produce JNDI exposing behaviour
    025     *
    026     * @author k.pribluda
    027     *
    028     * @param <T>
    029     */
    030    @SuppressWarnings("serial")
    031    public class JNDIExposing extends AbstractBehaviorFactory {
    032
    033            @Override
    034            public <T> ComponentAdapter<T> addComponentAdapter(
    035                            final ComponentMonitor componentMonitor,
    036                            final LifecycleStrategy lifecycleStrategy,
    037                            final Properties componentProperties, final ComponentAdapter<T> adapter) {
    038                    try {
    039                            return new JNDIExposed<T>(super.addComponentAdapter(
    040                                            componentMonitor, lifecycleStrategy, componentProperties,
    041                                            adapter));
    042                    } catch (NamingException e) {
    043                            throw new PicoCompositionException(
    044                                            "unable to create JNDI behaviour", e);
    045                    }
    046            }
    047
    048            @Override
    049            public <T> ComponentAdapter<T> createComponentAdapter(
    050                            final ComponentMonitor componentMonitor,
    051                            final LifecycleStrategy lifecycleStrategy,
    052                            final Properties componentProperties, final Object componentKey,
    053                            final Class<T> componentImplementation, final Parameter... parameters)
    054                            throws PicoCompositionException {
    055                    // TODO Auto-generated method stub
    056                    ComponentAdapter<T> componentAdapter = super.createComponentAdapter(
    057                                    componentMonitor, lifecycleStrategy, componentProperties,
    058                                    componentKey, componentImplementation, parameters);
    059
    060                    try {
    061                            return new JNDIExposed<T>(componentAdapter);
    062                    } catch (NamingException e) {
    063                            throw new PicoCompositionException(
    064                                            "unable to create JNDI behaviour", e);
    065                    }
    066            }
    067
    068    }