Search in sources :

Example 21 with ContextName

use of org.apache.catalina.util.ContextName in project tomcat by apache.

the class FarmWarDeployer method fileModified.

/**
     * Modification from watchDir war detected!
     *
     * @see org.apache.catalina.ha.deploy.FileChangeListener#fileModified(File)
     */
@Override
public void fileModified(File newWar) {
    try {
        File deployWar = new File(getDeployDirFile(), newWar.getName());
        ContextName cn = new ContextName(deployWar.getName(), true);
        if (deployWar.exists() && deployWar.lastModified() > newWar.lastModified()) {
            if (log.isInfoEnabled())
                log.info(sm.getString("farmWarDeployer.alreadyDeployed", cn.getName()));
            return;
        }
        if (log.isInfoEnabled())
            log.info(sm.getString("farmWarDeployer.modInstall", cn.getName(), deployWar.getAbsolutePath()));
        // install local
        if (!isServiced(cn.getName())) {
            addServiced(cn.getName());
            try {
                copy(newWar, deployWar);
                check(cn.getName());
            } finally {
                removeServiced(cn.getName());
            }
        } else {
            log.error(sm.getString("farmWarDeployer.servicingDeploy", cn.getName(), deployWar.getName()));
        }
        install(cn.getName(), deployWar);
    } catch (Exception x) {
        log.error(sm.getString("farmWarDeployer.modInstallFail"), x);
    }
}
Also used : File(java.io.File) LifecycleException(org.apache.catalina.LifecycleException) IOException(java.io.IOException) ContextName(org.apache.catalina.util.ContextName)

Example 22 with ContextName

use of org.apache.catalina.util.ContextName in project tomcat by apache.

the class FarmWarDeployer method fileRemoved.

/**
     * War remove from watchDir
     *
     * @see org.apache.catalina.ha.deploy.FileChangeListener#fileRemoved(File)
     */
@Override
public void fileRemoved(File removeWar) {
    try {
        ContextName cn = new ContextName(removeWar.getName(), true);
        if (log.isInfoEnabled())
            log.info(sm.getString("farmWarDeployer.removeLocal", cn.getName()));
        remove(cn.getName(), true);
    } catch (Exception x) {
        log.error(sm.getString("farmWarDeployer.removeLocalFail"), x);
    }
}
Also used : LifecycleException(org.apache.catalina.LifecycleException) IOException(java.io.IOException) ContextName(org.apache.catalina.util.ContextName)

Example 23 with ContextName

use of org.apache.catalina.util.ContextName in project tomee by apache.

the class WebappDeployer method checkWebapp.

private void checkWebapp(final String webappName) {
    try {
        final ContextName cn = new ContextName(webappName, true);
        final String name = "Catalina:type=Deployer,host=localhost";
        final ObjectName oname = new ObjectName(name);
        final String[] params = { cn.getName() };
        final String[] signature = { "java.lang.String" };
        mBeanServer.invoke(oname, "check", params, signature);
    } catch (Exception e) {
    //Ignore
    }
}
Also used : UndeployException(org.apache.openejb.UndeployException) OpenEJBException(org.apache.openejb.OpenEJBException) TomEERuntimeException(org.apache.tomee.catalina.TomEERuntimeException) NoSuchApplicationException(org.apache.openejb.NoSuchApplicationException) ContextName(org.apache.catalina.util.ContextName) ObjectName(javax.management.ObjectName)

Aggregations

ContextName (org.apache.catalina.util.ContextName)23 File (java.io.File)10 Context (org.apache.catalina.Context)8 IOException (java.io.IOException)7 Container (org.apache.catalina.Container)7 Host (org.apache.catalina.Host)6 ObjectName (javax.management.ObjectName)5 StandardContext (org.apache.catalina.core.StandardContext)5 StringManager (org.apache.tomcat.util.res.StringManager)5 JarFile (java.util.jar.JarFile)4 ArrayList (java.util.ArrayList)3 ExecutorService (java.util.concurrent.ExecutorService)3 Future (java.util.concurrent.Future)3 MBeanServer (javax.management.MBeanServer)3 Server (org.apache.catalina.Server)3 StandardHost (org.apache.catalina.core.StandardHost)3 PrintWriter (java.io.PrintWriter)2 URL (java.net.URL)2 UnknownHostException (java.net.UnknownHostException)2 ServletException (javax.servlet.ServletException)2