src/main/java/ru/indvdum/jpa/jndi/SimpleContextFactory.java
changeset 2 f692598b3742
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/main/java/ru/indvdum/jpa/jndi/SimpleContextFactory.java	Fri Nov 09 03:00:49 2012 +0400
     1.3 @@ -0,0 +1,28 @@
     1.4 +package ru.indvdum.jpa.jndi;
     1.5 +
     1.6 +import java.util.Hashtable;
     1.7 +
     1.8 +import javax.naming.Context;
     1.9 +import javax.naming.NamingException;
    1.10 +import javax.naming.spi.InitialContextFactory;
    1.11 +
    1.12 +/**
    1.13 + * @author indvdum (gotoindvdum[at]gmail[dot]com)
    1.14 + * @since 03.11.2011 16:37:21
    1.15 + * 
    1.16 + */
    1.17 +public class SimpleContextFactory implements InitialContextFactory {
    1.18 +
    1.19 +	private static Context simpleContext = null;
    1.20 +
    1.21 +	@Override
    1.22 +	public Context getInitialContext(Hashtable<?, ?> environment) throws NamingException {
    1.23 +		if (simpleContext == null) {
    1.24 +			synchronized (this) {
    1.25 +				simpleContext = new SimpleContext(environment);
    1.26 +			}
    1.27 +		}
    1.28 +
    1.29 +		return simpleContext;
    1.30 +	}
    1.31 +}
    1.32 \ No newline at end of file