private String getContextName(final String warFileName) { final ContextName contextName = CompatUtils.createContextName(warFileName); return contextName.getName(); } }
private void checkWebapp(final String webappName) { try { final ContextName cn = new ContextName(webappName); 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 } }
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 } }
@Override protected void deployDescriptor(ContextName cn, File contextXml) { super.deployDescriptor(cn, contextXml); addServiced(cn.getName()); }
/** * Deploy XML context descriptors. */ protected void deployDescriptors(File configBase, String[] files) { if (files == null) return; for (int i = 0; i < files.length; i++) { File contextXml = new File(configBase, files[i]); if (files[i].toLowerCase(Locale.ENGLISH).endsWith(".xml")) { ContextName cn = new ContextName(files[i]); String name = cn.getName(); if (isServiced(name)) continue; String file = files[i]; deployDescriptor(cn, contextXml, file); } } }
/** * Deploy directories. */ protected void deployDirectories(File appBase, String[] files) { if (files == null) return; for (int i = 0; i < files.length; i++) { if (files[i].equalsIgnoreCase("META-INF")) continue; if (files[i].equalsIgnoreCase("WEB-INF")) continue; File dir = new File(appBase, files[i]); if (dir.isDirectory()) { ContextName cn = new ContextName(files[i]); if (isServiced(cn.getName())) continue; deployDirectory(cn, dir, files[i]); } } }
/** * Deploy directories. */ protected void deployDirectories(File appBase, String[] files) { if (files == null) return; for (int i = 0; i < files.length; i++) { if (files[i].equalsIgnoreCase("META-INF")) continue; if (files[i].equalsIgnoreCase("WEB-INF")) continue; File dir = new File(appBase, files[i]); if (dir.isDirectory()) { ContextName cn = new ContextName(files[i]); if (isServiced(cn.getName())) continue; deployDirectory(cn, dir, files[i]); } } }
/** * Deploy directories. */ protected void deployDirectories(File appBase, String[] files) { if (files == null) return; for (int i = 0; i < files.length; i++) { if (files[i].equalsIgnoreCase("META-INF")) continue; if (files[i].equalsIgnoreCase("WEB-INF")) continue; File dir = new File(appBase, files[i]); if (dir.isDirectory()) { ContextName cn = new ContextName(files[i]); if (isServiced(cn.getName())) continue; deployDirectory(cn, dir, files[i]); } } }
/** * Deploy XML context descriptors. */ protected void deployDescriptors(File configBase, String[] files) { if (files == null) return; for (int i = 0; i < files.length; i++) { File contextXml = new File(configBase, files[i]); if (files[i].toLowerCase(Locale.ENGLISH).endsWith(".xml")) { ContextName cn = new ContextName(files[i]); String name = cn.getName(); if (isServiced(name)) continue; String file = files[i]; deployDescriptor(cn, contextXml, file); } } }
/** * Deploy XML context descriptors. */ protected void deployDescriptors(File configBase, String[] files) { if (files == null) return; for (int i = 0; i < files.length; i++) { File contextXml = new File(configBase, files[i]); if (files[i].toLowerCase(Locale.ENGLISH).endsWith(".xml")) { ContextName cn = new ContextName(files[i]); String name = cn.getName(); if (isServiced(name)) continue; String file = files[i]; deployDescriptor(cn, contextXml, file); } } }
@Override public void fileRemoved(File removeWar) { try { ContextName cn = new ContextName(removeWar.getName()); 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); } }
@Override public void fileRemoved(File removeWar) { try { ContextName cn = new ContextName(removeWar.getName()); 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); } }
/** * Deploy XML context descriptors. */ protected void deployDescriptors(File configBase, String[] files) { if (files == null) return; ExecutorService es = host.getStartStopExecutor(); List<Future<?>> results = new ArrayList<Future<?>>(); for (int i = 0; i < files.length; i++) { File contextXml = new File(configBase, files[i]); if (files[i].toLowerCase(Locale.ENGLISH).endsWith(".xml")) { ContextName cn = new ContextName(files[i]); if (isServiced(cn.getName()) || deploymentExists(cn.getName())) continue; results.add( es.submit(new DeployDescriptor(this, cn, contextXml))); } } for (Future<?> result : results) { try { result.get(); } catch (Exception e) { log.error(sm.getString( "hostConfig.deployDescriptor.threaded.error"), e); } } }
@Override public void deployWAR(ContextName cn, File war) { setCopyXML(true); super.deployWAR(cn, war); addServiced(cn.getName()); }
@Override public void fileModified(File newWar) { try { File deployWar = new File(getDeployDir(), newWar.getName()); copy(newWar, deployWar); ContextName cn = new ContextName(deployWar.getName()); if (log.isInfoEnabled()) log.info(sm.getString("farmWarDeployer.modInstall", cn.getName(), deployWar.getAbsolutePath())); try { remove(cn.getName(), false); } catch (Exception x) { log.error(sm.getString("farmWarDeployer.modRemoveFail"), x); } install(cn.getName(), deployWar); } catch (Exception x) { log.error(sm.getString("farmWarDeployer.modInstallFail"), x); } }
/** * 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); } }
protected Session getSessionForNameAndId(ContextName cn, String id, StringManager smClient) throws IOException { if ((cn == null) || !(cn.getPath().startsWith("/") || cn.getPath().equals(""))) { String path = null; if (cn != null) { path = cn.getPath(); } throw new IllegalArgumentException(smClient.getString( "managerServlet.invalidPath", RequestUtil.filter(path))); } Context ctxt = (Context) host.findChild(cn.getName()); if (null == ctxt) { throw new IllegalArgumentException(smClient.getString( "managerServlet.noContext", RequestUtil.filter(cn.getDisplayName()))); } Session session = ctxt.getManager().findSession(id); return session; }
protected Session getSessionForNameAndId(ContextName cn, String id, StringManager smClient) throws IOException { if ((cn == null) || !(cn.getPath().startsWith("/") || cn.getPath().equals(""))) { String path = null; if (cn != null) { path = cn.getPath(); } throw new IllegalArgumentException(smClient.getString( "managerServlet.invalidPath", RequestUtil.filter(path))); } Context ctxt = (Context) host.findChild(cn.getName()); if (null == ctxt) { throw new IllegalArgumentException(smClient.getString( "managerServlet.noContext", RequestUtil.filter(cn.getDisplayName()))); } Session session = ctxt.getManager().findSession(id); return session; }
protected Session getSessionForNameAndId(ContextName cn, String id, StringManager smClient) throws IOException { if ((cn == null) || !(cn.getPath().startsWith("/") || cn.getPath().equals(""))) { String path = null; if (cn != null) { path = cn.getPath(); } throw new IllegalArgumentException(smClient.getString( "managerServlet.invalidPath", RequestUtil.filter(path))); } Context ctxt = (Context) host.findChild(cn.getName()); if (null == ctxt) { throw new IllegalArgumentException(smClient.getString( "managerServlet.noContext", RequestUtil.filter(cn.getDisplayName()))); } Session session = ctxt.getManager().findSession(id); return session; }
@Override public ProtocolMetaData deploy(final Archive<?> archive) throws DeploymentException { try { // Ensure we don't create a corrupted archive by exporting to a file that already exists. deleteWar(archive); final File archiveFile = new File(appBase, archive.getName()); archive.as(ZipExporter.class).exportTo(archiveFile, true); embeddedHostConfig.deployWAR(archive.getName()); final ContextName contextName = getContextName(archive); final StandardContext standardContext = (StandardContext) host.findChild(contextName.getName()); standardContextProducer.set(standardContext); final HTTPContext httpContext = new HTTPContext(configuration.getBindAddress(), configuration.getBindHttpPort()); for (final String mapping : standardContext.findServletMappings()) { httpContext.add(new Servlet(standardContext.findServletMapping(mapping), contextName.getPath())); } return new ProtocolMetaData().addContext(httpContext); } catch (final Exception e) { throw new DeploymentException("Failed to deploy " + archive.getName(), e); } }