1 package nl.tudelft.simulation.naming.context;
2
3 import java.util.Hashtable;
4
5 /**
6 * A factory for JVMContext instances, automatically invoked by JNDI when the correct jndi.properties file has been used.
7 * <p>
8 * Copyright (c) 2002-2023 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See
9 * for project information <a href="https://simulation.tudelft.nl/" target="_blank"> https://simulation.tudelft.nl</a>. The DSOL
10 * project is distributed under a three-clause BSD-style license, which can be found at
11 * <a href="https://https://simulation.tudelft.nl/dsol/docs/latest/license.html" target="_blank">
12 * https://https://simulation.tudelft.nl/dsol/docs/latest/license.html</a>.
13 * </p>
14 * @author <a href="https://www.linkedin.com/in/peterhmjacobs">Peter Jacobs </a>
15 * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
16 */
17 public class JVMContextFactory implements ContextFactory
18 {
19 /** context refers to the static JVMContext. */
20 private static JVMContext context = null;
21
22 /** {@inheritDoc} */
23 @Override
24 public synchronized ContextInterface getInitialContext(final Hashtable<?, ?> environment, final String atomicName)
25 {
26 if (context == null)
27 {
28 JVMContextFactory.context = new JVMContext(atomicName);
29 }
30 return context;
31 }
32 }