All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.picocontainer.gems.jndi.JNDIExposed Maven / Gradle / Ivy

The newest version!
/*****************************************************************************
 * Copyright (c) PicoContainer Organization. All rights reserved.            *
 * ------------------------------------------------------------------------- *
 * The software in this package is published under the terms of the BSD      *
 * style license a copy of which has been included with this distribution in *
 * the LICENSE.txt file.                                                     *
 *                                                                           *
 *****************************************************************************/
package org.picocontainer.gems.jndi;

import javax.naming.InitialContext;
import javax.naming.NamingException;

import org.picocontainer.ComponentAdapter;
import org.picocontainer.behaviors.Stored;

/**
 * exposes component to JNDI basically does same thing as cached, but uses JNDI
 * reference instead. Maybe Cached shall be refactored? as there is little new
 * functionality.
 * 
 * @author Konstantin Pribluda
 * 
 */
@SuppressWarnings("serial")
public class JNDIExposed extends Stored {


	/**
	 * construct reference itself using vanilla initial context.
	 * JNDI name is stringified component key
	 * @param delegate
	 *            delegate adapter

	 * @throws NamingException
	 */
	public JNDIExposed(final ComponentAdapter delegate) throws NamingException {
		super(delegate, new JNDIObjectReference>(delegate.getComponentKey()
				.toString(), new InitialContext()));
	}

	/**
	 * create with provided reference
	 * 
	 * @param delegate
	 * @param instanceReference
	 */
	public JNDIExposed(final ComponentAdapter delegate,
			final JNDIObjectReference> instanceReference) {
		super(delegate, instanceReference);
	}

	/**
	 * create adapter with desired name
	 * @param delegate
	 * @param name
	 * @throws NamingException
	 */
	public JNDIExposed(final ComponentAdapter delegate, final String name) throws NamingException {
		super(delegate, new JNDIObjectReference>(name, new InitialContext()));
	}
	
	@Override
	public String toString() {
		return "JNDI" + getDelegate().toString();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy