package nl.tudelft.simulation.naming; import java.util.Hashtable; import javax.naming.Context; import javax.naming.spi.InitialContextFactory; import nl.tudelft.simulation.logger.Logger; /** * A factory for JVMContext instances, automatically invoked by JNDI when the correct jndi.properties file has been * used. *
* (c) copyright 2002-2005 Delft University of Technology , the
* Netherlands.
* See for project information www.simulation.tudelft.nl
* License of use: Lesser General Public License (LGPL) , no
* warranty.
* @author Peter Jacobs
* @version 1.2 2004-03-24
* @since 1.5
*/
public class JVMContextFactory implements InitialContextFactory
{
/** context refers to the static JVMContext. */
private static JVMContext context = null;
/** {@inheritDoc} */
@Override
public synchronized Context getInitialContext(final Hashtable, ?> environment)
{
if (JVMContextFactory.context == null)
{
environment.remove("java.naming.factory.initial");
if (environment.size() != 0)
{
Logger.warning(this, "getInitialContext", "unused environment variables in jndi.properties");
}
JVMContextFactory.context = new JVMContext();
}
return context;
}
}