package nl.tudelft.simulation.naming; import java.util.Hashtable; import javax.naming.Context; import javax.naming.spi.InitialContextFactory; import org.djutils.logger.CategoryLogger; /** * A factory for JVMContext instances, automatically invoked by JNDI when the correct jndi.properties file has been * used. *
* Copyright (c) 2002-2019 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights * reserved. See for project information * https://simulation.tudelft.nl. The DSOL project is distributed under a three-clause BSD-style license, which can * be found at * https://simulation.tudelft.nl/dsol/3.0/license.html. *
* @author Peter Jacobs * @author Alexander Verbraeck */ 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) { CategoryLogger.always().warn("unused environment variables in jndi.properties"); } JVMContextFactory.context = new JVMContext(); } return context; } }