/** * Register the context builder by registering it with the JNDI NamingManager. * Note that once this has been done, {@code new InitialContext()} will always * return a context from this factory. Use the {@code emptyActivatedContextBuilder()} * static method to get an empty context (for example, in test methods). * @throws IllegalStateException if there's already a naming context builder * registered with the JNDI NamingManager */ public void activate() throws IllegalStateException, NamingException { logger.info("Activating simple JNDI environment"); synchronized (initializationLock) { if (!initialized) { Assert.state(!NamingManager.hasInitialContextFactoryBuilder(), "Cannot activate SimpleNamingContextBuilder: there is already a JNDI provider registered. " + "Note that JNDI is a JVM-wide service, shared at the JVM system class loader level, " + "with no reset option. As a consequence, a JNDI provider must only be registered once per JVM."); NamingManager.setInitialContextFactoryBuilder(this); initialized = true; } } activated = this; }
/** * Register the context builder by registering it with the JNDI NamingManager. * Note that once this has been done, {@code new InitialContext()} will always * return a context from this factory. Use the {@code emptyActivatedContextBuilder()} * static method to get an empty context (for example, in test methods). * @throws IllegalStateException if there's already a naming context builder * registered with the JNDI NamingManager */ public void activate() throws IllegalStateException, NamingException { logger.info("Activating simple JNDI environment"); synchronized (initializationLock) { if (!initialized) { Assert.state(!NamingManager.hasInitialContextFactoryBuilder(), "Cannot activate SimpleNamingContextBuilder: there is already a JNDI provider registered. " + "Note that JNDI is a JVM-wide service, shared at the JVM system class loader level, " + "with no reset option. As a consequence, a JNDI provider must only be registered once per JVM."); NamingManager.setInitialContextFactoryBuilder(this); initialized = true; } } activated = this; }
/** * Initialize the naming components required by {@link javax.naming.spi.NamingManager}. */ public static void initializeNamingManager() { // Setup naming environment final String property = WildFlySecurityManager.getPropertyPrivileged(Context.URL_PKG_PREFIXES, null); if(property == null || property.isEmpty()) { WildFlySecurityManager.setPropertyPrivileged(Context.URL_PKG_PREFIXES, PACKAGE_PREFIXES); } else if(!Arrays.asList(property.split(":")).contains(PACKAGE_PREFIXES)) { WildFlySecurityManager.setPropertyPrivileged(Context.URL_PKG_PREFIXES, PACKAGE_PREFIXES + ":" + property); } try { //If we are reusing the JVM. e.g. in tests we should not set this again if (!NamingManager.hasInitialContextFactoryBuilder()) NamingManager.setInitialContextFactoryBuilder(new InitialContextFactoryBuilder()); } catch (NamingException e) { ROOT_LOGGER.failedToSet(e, "InitialContextFactoryBuilder"); } }
/** * Returns {@code true} if SIS will try to fetch the {@link DataSource} from JNDI. * * @return {@code true} if a JNDI environment seems to be present. */ public static boolean hasJNDI() { return NamingManager.hasInitialContextFactoryBuilder() || AccessController.doPrivileged(new PrivilegedAction<Boolean>() { @Override public Boolean run() { return System.getProperty(Context.INITIAL_CONTEXT_FACTORY) != null; } }); }
/** * Returns {@code true} if SIS will try to fetch the {@link DataSource} from JNDI. * * @return {@code true} if a JNDI environment seems to be present. */ public static boolean hasJNDI() { return NamingManager.hasInitialContextFactoryBuilder() || AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> System.getProperty(Context.INITIAL_CONTEXT_FACTORY) != null); }
/** * Register the context builder by registering it with the JNDI NamingManager. * Note that once this has been done, {@code new InitialContext()} will always * return a context from this factory. Use the {@code emptyActivatedContextBuilder()} * static method to get an empty context (for example, in test methods). * @throws IllegalStateException if there's already a naming context builder * registered with the JNDI NamingManager */ public void activate() throws IllegalStateException, NamingException { logger.info("Activating simple JNDI environment"); synchronized (initializationLock) { if (!initialized) { Assert.state(!NamingManager.hasInitialContextFactoryBuilder(), "Cannot activate SimpleNamingContextBuilder: there is already a JNDI provider registered. " + "Note that JNDI is a JVM-wide service, shared at the JVM system class loader level, " + "with no reset option. As a consequence, a JNDI provider must only be registered once per JVM."); NamingManager.setInitialContextFactoryBuilder(this); initialized = true; } } activated = this; }
/** * Initialize the naming components required by {@link javax.naming.spi.NamingManager}. */ public static void initializeNamingManager() { // Setup naming environment System.setProperty(Context.URL_PKG_PREFIXES, PACKAGE_PREFIXES); try { //If we are reusing the JVM. e.g. in tests we should not set this again if (!NamingManager.hasInitialContextFactoryBuilder()) NamingManager.setInitialContextFactoryBuilder(new InitialContextFactoryBuilder()); } catch (NamingException e) { log.warn("Failed to set InitialContextFactoryBuilder", e); } }
/** * Register the context builder by registering it with the JNDI NamingManager. * Note that once this has been done, {@code new InitialContext()} will always * return a context from this factory. Use the {@code emptyActivatedContextBuilder()} * static method to get an empty context (for example, in test methods). * @throws IllegalStateException if there's already a naming context builder * registered with the JNDI NamingManager */ public void activate() throws IllegalStateException, NamingException { logger.info("Activating simple JNDI environment"); synchronized (initializationLock) { if (!initialized) { Assert.state(!NamingManager.hasInitialContextFactoryBuilder(), "Cannot activate SimpleNamingContextBuilder: there is already a JNDI provider registered. " + "Note that JNDI is a JVM-wide service, shared at the JVM system class loader level, " + "with no reset option. As a consequence, a JNDI provider must only be registered once per JVM."); NamingManager.setInitialContextFactoryBuilder(this); initialized = true; } } activated = this; }
private Context createInitialContext(Hashtable env) throws NamingException { SerialContext serialContext = new SerialContext(env, habitat); if (NamingManager.hasInitialContextFactoryBuilder()) { // When builder is used, JNDI does not go through // URL Context discovery anymore. To address that // we install a wrapper that first goes through // URL context discovery and then falls back to // serialContext. return new WrappedSerialContext(env, serialContext); } else { return serialContext ; } } }
private Context createInitialContext(Hashtable env) throws NamingException { SerialContext serialContext = new SerialContext(env, services); if (NamingManager.hasInitialContextFactoryBuilder()) { // When builder is used, JNDI does not go through // URL Context discovery anymore. To address that // we install a wrapper that first goes through // URL context discovery and then falls back to // serialContext. return new WrappedSerialContext(env, serialContext); } else { return serialContext ; } } }
if (NamingManager.hasInitialContextFactoryBuilder()) {
/** * Initialize the naming components required by {@link javax.naming.spi.NamingManager}. */ public static void initializeNamingManager() { // Setup naming environment final String property = WildFlySecurityManager.getPropertyPrivileged(Context.URL_PKG_PREFIXES, null); if(property == null || property.isEmpty()) { WildFlySecurityManager.setPropertyPrivileged(Context.URL_PKG_PREFIXES, PACKAGE_PREFIXES); } else if(!Arrays.asList(property.split(":")).contains(PACKAGE_PREFIXES)) { WildFlySecurityManager.setPropertyPrivileged(Context.URL_PKG_PREFIXES, PACKAGE_PREFIXES + ":" + property); } try { //If we are reusing the JVM. e.g. in tests we should not set this again if (!NamingManager.hasInitialContextFactoryBuilder()) NamingManager.setInitialContextFactoryBuilder(new InitialContextFactoryBuilder()); } catch (NamingException e) { ROOT_LOGGER.failedToSet(e, "InitialContextFactoryBuilder"); } }
/** * Initialize the naming components required by {@link javax.naming.spi.NamingManager}. */ public static void initializeNamingManager() { // Setup naming environment final String property = WildFlySecurityManager.getPropertyPrivileged(Context.URL_PKG_PREFIXES, null); if(property == null || property.isEmpty()) { WildFlySecurityManager.setPropertyPrivileged(Context.URL_PKG_PREFIXES, PACKAGE_PREFIXES); } else if(!Arrays.asList(property.split(":")).contains(PACKAGE_PREFIXES)) { WildFlySecurityManager.setPropertyPrivileged(Context.URL_PKG_PREFIXES, PACKAGE_PREFIXES + ":" + property); } try { //If we are reusing the JVM. e.g. in tests we should not set this again if (!NamingManager.hasInitialContextFactoryBuilder()) NamingManager.setInitialContextFactoryBuilder(new InitialContextFactoryBuilder()); } catch (NamingException e) { ROOT_LOGGER.failedToSet(e, "InitialContextFactoryBuilder"); } }
/** * Initialize the naming components required by {@link javax.naming.spi.NamingManager}. */ public static void initializeNamingManager() { // Setup naming environment final String property = SecurityActions.getSystemProperty(Context.URL_PKG_PREFIXES); if(property == null || property.isEmpty()) { SecurityActions.setSystemProperty(Context.URL_PKG_PREFIXES, PACKAGE_PREFIXES); } else if(!Arrays.asList(property.split(":")).contains(PACKAGE_PREFIXES)) { SecurityActions.setSystemProperty(Context.URL_PKG_PREFIXES, PACKAGE_PREFIXES + ":" + property); } try { //If we are reusing the JVM. e.g. in tests we should not set this again if (!NamingManager.hasInitialContextFactoryBuilder()) NamingManager.setInitialContextFactoryBuilder(new InitialContextFactoryBuilder()); } catch (NamingException e) { ROOT_LOGGER.failedToSet(e, "InitialContextFactoryBuilder"); } }
/** * Will create a JNDI Context and register it as the initial context factory builder * * @return the context * @throws NamingException * on any issue during initial context factory builder registration */ static JndiContext createJndiContext() throws NamingException { try { if (!NamingManager.hasInitialContextFactoryBuilder()) { JndiContext ctx = new JndiContext(); NamingManager.setInitialContextFactoryBuilder(ctx); return ctx; } else { return (JndiContext) NamingManager.getInitialContext(null); } } catch (Exception e) { jqmlogger.error("Could not create JNDI context: " + e.getMessage()); NamingException ex = new NamingException("Could not initialize JNDI Context"); ex.setRootCause(e); throw ex; } }
/** * Will create a JNDI Context and register it as the initial context factory builder * * @return the context * @throws NamingException * on any issue during initial context factory builder registration */ static JndiContext createJndiContext() throws NamingException { try { if (!NamingManager.hasInitialContextFactoryBuilder()) { JndiContext ctx = new JndiContext(); NamingManager.setInitialContextFactoryBuilder(ctx); return ctx; } else { return (JndiContext) NamingManager.getInitialContext(null); } } catch (Exception e) { jqmlogger.error("Could not create JNDI context: " + e.getMessage()); NamingException ex = new NamingException("Could not initialize JNDI Context"); ex.setRootCause(e); throw ex; } }
if (NamingManager.hasInitialContextFactoryBuilder()) { return getDefaultInitCtx();
@Before public void setUp() throws Exception { Locale.setDefault( Locale.US ); TimeZone.setDefault( TimeZone.getTimeZone( "UTC" ) ); // enforce binary compatibility for the xml-files so that comparing them can be faster. ClassicEngineBoot.getInstance().start(); if ( NamingManager.hasInitialContextFactoryBuilder() == false ) { NamingManager.setInitialContextFactoryBuilder( new DebugJndiContextFactoryBuilder() ); } localFontRegistry = new LocalFontRegistry(); localFontRegistry.initialize(); }
public void setUp() throws Exception { ClassicEngineBoot.getInstance().start(); if ( NamingManager.hasInitialContextFactoryBuilder() == false ) { NamingManager.setInitialContextFactoryBuilder( new DebugJndiContextFactoryBuilder() ); } }
if (NamingManager.hasInitialContextFactoryBuilder()) { return getDefaultInitCtx();