Search in sources :

Example 6 with NamingResourcesImpl

use of org.apache.catalina.deploy.NamingResourcesImpl in project tomcat by apache.

the class StandardServer method setGlobalNamingResources.

/**
 * Set the global naming resources.
 *
 * @param globalNamingResources The new global naming resources
 */
@Override
public void setGlobalNamingResources(NamingResourcesImpl globalNamingResources) {
    NamingResourcesImpl oldGlobalNamingResources = this.globalNamingResources;
    this.globalNamingResources = globalNamingResources;
    this.globalNamingResources.setContainer(this);
    support.firePropertyChange("globalNamingResources", oldGlobalNamingResources, this.globalNamingResources);
}
Also used : NamingResourcesImpl(org.apache.catalina.deploy.NamingResourcesImpl)

Example 7 with NamingResourcesImpl

use of org.apache.catalina.deploy.NamingResourcesImpl in project tomcat by apache.

the class NamingResourcesMBean method removeResource.

/**
 * Remove any resource reference with the specified name.
 *
 * @param resourceName Name of the resource reference to remove
 */
public void removeResource(String resourceName) {
    resourceName = ObjectName.unquote(resourceName);
    NamingResourcesImpl nresources = (NamingResourcesImpl) this.resource;
    if (nresources == null) {
        return;
    }
    ContextResource resource = nresources.findResource(resourceName);
    if (resource == null) {
        throw new IllegalArgumentException(sm.getString("namingResourcesMBean.removeNotFound.resource", resourceName));
    }
    nresources.removeResource(resourceName);
}
Also used : NamingResourcesImpl(org.apache.catalina.deploy.NamingResourcesImpl) ContextResource(org.apache.tomcat.util.descriptor.web.ContextResource)

Example 8 with NamingResourcesImpl

use of org.apache.catalina.deploy.NamingResourcesImpl in project tomcat by apache.

the class NamingResourcesMBean method removeEnvironment.

/**
 * Remove any environment entry with the specified name.
 *
 * @param envName Name of the environment entry to remove
 */
public void removeEnvironment(String envName) {
    NamingResourcesImpl nresources = (NamingResourcesImpl) this.resource;
    if (nresources == null) {
        return;
    }
    ContextEnvironment env = nresources.findEnvironment(envName);
    if (env == null) {
        throw new IllegalArgumentException(sm.getString("namingResourcesMBean.removeNotFound.environment", envName));
    }
    nresources.removeEnvironment(envName);
}
Also used : ContextEnvironment(org.apache.tomcat.util.descriptor.web.ContextEnvironment) NamingResourcesImpl(org.apache.catalina.deploy.NamingResourcesImpl)

Example 9 with NamingResourcesImpl

use of org.apache.catalina.deploy.NamingResourcesImpl in project tomcat by apache.

the class NamingResourcesSF method storeChildren.

/**
 * Store the specified NamingResources properties.
 *
 * @param aWriter
 *            PrintWriter to which we are storing
 * @param indent
 *            Number of spaces to indent this element
 * @param aElement
 *            Object whose properties are being stored
 * @param elementDesc
 *            element descriptor
 *
 * @exception Exception
 *                if an exception occurs while storing
 *
 * @see org.apache.catalina.storeconfig.StoreFactoryBase#storeChildren(java.io.PrintWriter,
 *      int, java.lang.Object, StoreDescription)
 */
@Override
public void storeChildren(PrintWriter aWriter, int indent, Object aElement, StoreDescription elementDesc) throws Exception {
    if (aElement instanceof NamingResourcesImpl) {
        NamingResourcesImpl resources = (NamingResourcesImpl) aElement;
        // Store nested <Ejb> elements
        ContextEjb[] ejbs = resources.findEjbs();
        storeElementArray(aWriter, indent, ejbs);
        // Store nested <Environment> elements
        ContextEnvironment[] envs = resources.findEnvironments();
        storeElementArray(aWriter, indent, envs);
        // Store nested <LocalEjb> elements
        ContextLocalEjb[] lejbs = resources.findLocalEjbs();
        storeElementArray(aWriter, indent, lejbs);
        // Store nested <Resource> elements
        ContextResource[] dresources = resources.findResources();
        storeElementArray(aWriter, indent, dresources);
        // Store nested <ResourceEnvRef> elements
        ContextResourceEnvRef[] resEnv = resources.findResourceEnvRefs();
        storeElementArray(aWriter, indent, resEnv);
        // Store nested <ResourceLink> elements
        ContextResourceLink[] resourceLinks = resources.findResourceLinks();
        storeElementArray(aWriter, indent, resourceLinks);
    }
}
Also used : ContextEnvironment(org.apache.tomcat.util.descriptor.web.ContextEnvironment) ContextResourceLink(org.apache.tomcat.util.descriptor.web.ContextResourceLink) ContextEjb(org.apache.tomcat.util.descriptor.web.ContextEjb) ContextResource(org.apache.tomcat.util.descriptor.web.ContextResource) ContextLocalEjb(org.apache.tomcat.util.descriptor.web.ContextLocalEjb) NamingResourcesImpl(org.apache.catalina.deploy.NamingResourcesImpl) ContextResourceEnvRef(org.apache.tomcat.util.descriptor.web.ContextResourceEnvRef)

Example 10 with NamingResourcesImpl

use of org.apache.catalina.deploy.NamingResourcesImpl in project tomcat by apache.

the class StandardContextSF method storeChildren.

/**
 * Store the specified context element children.
 *
 * @param aWriter Current output writer
 * @param indent Indentation level
 * @param aContext Context to store
 * @param parentDesc The element description
 * @throws Exception Configuration storing error
 */
@Override
public void storeChildren(PrintWriter aWriter, int indent, Object aContext, StoreDescription parentDesc) throws Exception {
    if (aContext instanceof StandardContext) {
        StandardContext context = (StandardContext) aContext;
        // Store nested <Listener> elements
        LifecycleListener[] listeners = context.findLifecycleListeners();
        List<LifecycleListener> listenersArray = new ArrayList<>();
        for (LifecycleListener listener : listeners) {
            if (!(listener instanceof ThreadLocalLeakPreventionListener)) {
                listenersArray.add(listener);
            }
        }
        storeElementArray(aWriter, indent, listenersArray.toArray());
        // Store nested <Valve> elements
        Valve[] valves = context.getPipeline().getValves();
        storeElementArray(aWriter, indent, valves);
        // Store nested <Loader> elements
        Loader loader = context.getLoader();
        storeElement(aWriter, indent, loader);
        // Store nested <Manager> elements
        if (context.getCluster() == null || !context.getDistributable()) {
            Manager manager = context.getManager();
            storeElement(aWriter, indent, manager);
        }
        // Store nested <Realm> element
        Realm realm = context.getRealm();
        if (realm != null) {
            Realm parentRealm = null;
            // @TODO is this case possible?
            if (context.getParent() != null) {
                parentRealm = context.getParent().getRealm();
            }
            if (realm != parentRealm) {
                storeElement(aWriter, indent, realm);
            }
        }
        // Store nested resources
        WebResourceRoot resources = context.getResources();
        storeElement(aWriter, indent, resources);
        // Store nested <WrapperListener> elements
        String[] wLifecycles = context.findWrapperLifecycles();
        getStoreAppender().printTagArray(aWriter, "WrapperListener", indent + 2, wLifecycles);
        // Store nested <WrapperLifecycle> elements
        String[] wListeners = context.findWrapperListeners();
        getStoreAppender().printTagArray(aWriter, "WrapperLifecycle", indent + 2, wListeners);
        // Store nested <Parameter> elements
        ApplicationParameter[] appParams = context.findApplicationParameters();
        storeElementArray(aWriter, indent, appParams);
        // Store nested naming resources elements (EJB,Resource,...)
        NamingResourcesImpl nresources = context.getNamingResources();
        storeElement(aWriter, indent, nresources);
        // Store nested watched resources <WatchedResource>
        String[] wresources = context.findWatchedResources();
        wresources = filterWatchedResources(context, wresources);
        getStoreAppender().printTagArray(aWriter, "WatchedResource", indent + 2, wresources);
        // Store nested <JarScanner> elements
        JarScanner jarScanner = context.getJarScanner();
        storeElement(aWriter, indent, jarScanner);
        // Store nested <CookieProcessor> elements
        CookieProcessor cookieProcessor = context.getCookieProcessor();
        storeElement(aWriter, indent, cookieProcessor);
    }
}
Also used : ApplicationParameter(org.apache.tomcat.util.descriptor.web.ApplicationParameter) ArrayList(java.util.ArrayList) Loader(org.apache.catalina.Loader) LifecycleListener(org.apache.catalina.LifecycleListener) Manager(org.apache.catalina.Manager) JarScanner(org.apache.tomcat.JarScanner) ThreadLocalLeakPreventionListener(org.apache.catalina.core.ThreadLocalLeakPreventionListener) CookieProcessor(org.apache.tomcat.util.http.CookieProcessor) StandardContext(org.apache.catalina.core.StandardContext) Valve(org.apache.catalina.Valve) NamingResourcesImpl(org.apache.catalina.deploy.NamingResourcesImpl) Realm(org.apache.catalina.Realm) WebResourceRoot(org.apache.catalina.WebResourceRoot)

Aggregations

NamingResourcesImpl (org.apache.catalina.deploy.NamingResourcesImpl)24 ContextResource (org.apache.tomcat.util.descriptor.web.ContextResource)10 ObjectName (javax.management.ObjectName)6 ContextEnvironment (org.apache.tomcat.util.descriptor.web.ContextEnvironment)6 ContextResourceLink (org.apache.tomcat.util.descriptor.web.ContextResourceLink)6 ArrayList (java.util.ArrayList)5 MalformedObjectNameException (javax.management.MalformedObjectNameException)3 ManagedBean (org.apache.tomcat.util.modeler.ManagedBean)3 Context (org.apache.catalina.Context)2 LifecycleListener (org.apache.catalina.LifecycleListener)2 StandardContext (org.apache.catalina.core.StandardContext)2 StandardServer (org.apache.catalina.core.StandardServer)2 ResourceInfo (org.apache.openejb.assembler.classic.ResourceInfo)2 ContextEjb (org.apache.tomcat.util.descriptor.web.ContextEjb)2 ContextResourceEnvRef (org.apache.tomcat.util.descriptor.web.ContextResourceEnvRef)2 ContextTransaction (org.apache.tomcat.util.descriptor.web.ContextTransaction)2 File (java.io.File)1 URI (java.net.URI)1 Properties (java.util.Properties)1 JarFile (java.util.jar.JarFile)1