org.apache.catalina.core.NamingContextListener Java Examples

The following examples show how to use org.apache.catalina.core.NamingContextListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OpenEJBContextConfig.java    From tomee with Apache License 2.0 6 votes vote down vote up
@Override
protected void contextConfig(final Digester digester) {
    final NamingResourcesImpl resources;
    if (context != null) {
        resources = context.getNamingResources();
    } else {
        resources = null;
    }

    if (resources instanceof OpenEJBNamingResource) {
        ((OpenEJBNamingResource) resources).setTomcatResource(true);
    }
    super.contextConfig(digester);
    if (resources instanceof OpenEJBNamingResource) {
        ((OpenEJBNamingResource) resources).setTomcatResource(false);
    }

    if (context instanceof StandardContext) {
        final StandardContext standardContext = (StandardContext) context;
        final NamingContextListener namingContextListener = standardContext.getNamingContextListener();
        if (null != namingContextListener) {
            namingContextListener.setExceptionOnFailedWrite(standardContext.getJndiExceptionOnFailedWrite());
        }
    }
}
 
Example #2
Source File: Tomcat.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Enables JNDI naming which is disabled by default. Server must implement
 * {@link Lifecycle} in order for the {@link NamingContextListener} to be
 * used.
 *
 */
public void enableNaming() {
    // Make sure getServer() has been called as that is where naming is
    // disabled
    getServer();
    server.addLifecycleListener(new NamingContextListener());

    System.setProperty("catalina.useNaming", "true");

    String value = "org.apache.naming";
    String oldValue =
        System.getProperty(javax.naming.Context.URL_PKG_PREFIXES);
    if (oldValue != null) {
        if (oldValue.contains(value)) {
            value = oldValue;
        } else {
            value = value + ":" + oldValue;
        }
    }
    System.setProperty(javax.naming.Context.URL_PKG_PREFIXES, value);

    value = System.getProperty
        (javax.naming.Context.INITIAL_CONTEXT_FACTORY);
    if (value == null) {
        System.setProperty
            (javax.naming.Context.INITIAL_CONTEXT_FACTORY,
             "org.apache.naming.java.javaURLContextFactory");
    }
}
 
Example #3
Source File: Tomcat.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Enables JNDI naming which is disabled by default. Server must implement
 * {@link Lifecycle} in order for the {@link NamingContextListener} to be
 * used.
 * 
 */
public void enableNaming() {
    // Make sure getServer() has been called as that is where naming is
    // disabled
    getServer();
    server.addLifecycleListener(new NamingContextListener());
    
    System.setProperty("catalina.useNaming", "true");

    String value = "org.apache.naming";
    String oldValue =
        System.getProperty(javax.naming.Context.URL_PKG_PREFIXES);
    if (oldValue != null) {
        if (oldValue.contains(value)) {
            value = oldValue;
        } else {
            value = value + ":" + oldValue;
        }
    }
    System.setProperty(javax.naming.Context.URL_PKG_PREFIXES, value);

    value = System.getProperty
        (javax.naming.Context.INITIAL_CONTEXT_FACTORY);
    if (value == null) {
        System.setProperty
            (javax.naming.Context.INITIAL_CONTEXT_FACTORY,
             "org.apache.naming.java.javaURLContextFactory");
    }
}
 
Example #4
Source File: Tomcat.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Enables JNDI naming which is disabled by default. Server must implement
 * {@link Lifecycle} in order for the {@link NamingContextListener} to be
 * used.
 * 
 */
public void enableNaming() {
    // Make sure getServer() has been called as that is where naming is
    // disabled
    getServer();
    server.addLifecycleListener(new NamingContextListener());
    
    System.setProperty("catalina.useNaming", "true");

    String value = "org.apache.naming";
    String oldValue =
        System.getProperty(javax.naming.Context.URL_PKG_PREFIXES);
    if (oldValue != null) {
        if (oldValue.contains(value)) {
            value = oldValue;
        } else {
            value = value + ":" + oldValue;
        }
    }
    System.setProperty(javax.naming.Context.URL_PKG_PREFIXES, value);

    value = System.getProperty
        (javax.naming.Context.INITIAL_CONTEXT_FACTORY);
    if (value == null) {
        System.setProperty
            (javax.naming.Context.INITIAL_CONTEXT_FACTORY,
             "org.apache.naming.java.javaURLContextFactory");
    }
}