/** * 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"); } }
public Void run() throws NamingException { if (isUsingBuilder()) { NamingManager.setInitialContextFactoryBuilder(GlassFishNamingBuilder.this); } return null; //Nothing to return } });
public Void run() throws NamingException { if (isUsingBuilder()) { NamingManager.setInitialContextFactoryBuilder(GlassFishNamingBuilder.this); } return null; //Nothing to return } });
public static void setInitialContextFactoryBuilder() { try { javax.naming.spi.NamingManager.setInitialContextFactoryBuilder( new javax.naming.spi.InitialContextFactoryBuilder() { public InitialContextFactory createInitialContextFactory(Hashtable env) { return new DesignTimeInitialContextFactory(); } } ); // Set a flag so that only one instance of DesignTimeInitialContextFactory is created ProjectDataSourceTracker.isInitialContextInitialized = true; } catch (NamingException e) { } }
private void mockJndiEnvironment(DataSource dataSource) throws NamingException { NamingManager.setInitialContextFactoryBuilder((env) -> (environment) -> new InitialContext() { @Override public Object lookup(Name name) throws NamingException { return lookup(name.toString()); } @Override public Object lookup(String name) throws NamingException { if ("spring/datasource".equals(name)) { return dataSource; } return null; } @Override public NameParser getNameParser(String name) throws NamingException { return CompositeName::new; } @Override public void close() throws NamingException { //NOOP } }); } }
/** * * Notification that the web application initialization * * process is starting. * * All ServletContextListeners are notified of context * * initialization before any filter or servlet in the web * * application is initialized. */ @Override public void contextInitialized(ServletContextEvent sce) { log.info("JNDI: registering Apache Marmotta JNDI implementation ..."); try { NamingManager.setInitialContextFactoryBuilder(new MarmottaInitialContextFactoryBuilder()); } catch (NamingException e) { } catch (IllegalStateException e) { log.info("JNDI: a context factory of type is already installed"); } }
/** * * Notification that the web application initialization * * process is starting. * * All ServletContextListeners are notified of context * * initialization before any filter or servlet in the web * * application is initialized. */ @Override public void contextInitialized(ServletContextEvent sce) { log.info("JNDI: registering Apache Marmotta JNDI implementation ..."); try { NamingManager.setInitialContextFactoryBuilder(new MarmottaInitialContextFactoryBuilder()); } catch (NamingException e) { } catch (IllegalStateException e) { log.info("JNDI: a context factory of type is already installed"); } }
/** * 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; }
/** * 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; } }
public static void start(Context ctx) throws NamingException { if (icf == null) { NamingManager.setInitialContextFactoryBuilder(new MockInitialContextFactoryBuilder()); } icf = Skeleton.newMock(InitialContextFactory.class); getSkeleton().setReturnValue(new MethodCall(InitialContextFactory.class, "getInitialContext", Hashtable.class), ctx); }
public static void start(Context ctx) throws NamingException { if (icf == null) { NamingManager.setInitialContextFactoryBuilder(new MockInitialContextFactoryBuilder()); } icf = Skeleton.newMock(InitialContextFactory.class); getSkeleton().setReturnValue(new MethodCall(InitialContextFactory.class, "getInitialContext", Hashtable.class), ctx); }
@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() ); } }