static String pathNameOfDeployment(final DeploymentUnit deploymentUnit, final JBossWebMetaData metaData) { String pathName; if (metaData.getContextRoot() == null) { final EEModuleDescription description = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION); if (description != null) { // if there is an EEModuleDescription we need to take into account that the module name may have been overridden pathName = "/" + description.getModuleName(); } else { pathName = "/" + deploymentUnit.getName().substring(0, deploymentUnit.getName().length() - 4); } } else { pathName = metaData.getContextRoot(); if (pathName.length() > 0 && pathName.charAt(0) != '/') { pathName = "/" + pathName; } } return pathName; }
String contextRoot = WebModuleMetaData.class.cast(moduleMetaData.getValue()).getContextRoot(); if(contextRoot == null && (warMetaData.getJBossWebMetaData() == null || warMetaData.getJBossWebMetaData().getContextRoot() == null)) { contextRoot = "/" + parent.getName().substring(0, parent.getName().length() - 4) + "/" + deploymentUnit.getName().substring(0, deploymentUnit.getName().length() - 4);
/** * Get the object name of the ServiceMetaData instance associated with * the WebMetaData. This uses the pattern: * "jboss.web.deployment:war="+metaData.getContextRoot() * if there are no virtual hosts, otherwise * "jboss.web.deployment:war="+metaData.getVirtualHosts()[0]+metaData.getContextRoot() * @param metaData - the web app metaData * @return the war object name */ protected String getObjectName(JBossWebMetaData metaData) { // Obtain the war virtual host and context root to define a unique war name String virtualHost = ""; List<String> hosts = metaData.getVirtualHosts(); if (hosts != null && hosts.size() > 0) { virtualHost = hosts.get(0); } String ctxPath = metaData.getContextRoot(); // The ctx path value cannot be empty in the object name if (ctxPath == null || ctxPath.length() == 0) ctxPath = "/"; return "jboss.web.deployment:war=" + virtualHost + ctxPath; }
static String pathNameOfDeployment(final DeploymentUnit deploymentUnit, final JBossWebMetaData metaData) { String pathName; if (metaData.getContextRoot() == null) { final EEModuleDescription description = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION); if (description != null) { // if there is an EEModuleDescription we need to take into account that the module name may have been overridden pathName = "/" + description.getModuleName(); } else { pathName = "/" + deploymentUnit.getName().substring(0, deploymentUnit.getName().length() - 4); } } else { pathName = metaData.getContextRoot(); if (pathName.length() > 0 && pathName.charAt(0) != '/') { pathName = "/" + pathName; } } return pathName; }
static String pathNameOfDeployment(final DeploymentUnit deploymentUnit, final JBossWebMetaData metaData) { String pathName; if (metaData.getContextRoot() == null) { final EEModuleDescription description = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION); if (description != null) { // if there is an EEModuleDescription we need to take into account that the module name may have been overridden pathName = "/" + description.getModuleName(); } else { pathName = "/" + deploymentUnit.getName().substring(0, deploymentUnit.getName().length() - 4); } } else { pathName = metaData.getContextRoot(); if (pathName.length() > 0 && pathName.charAt(0) != '/') { pathName = "/" + pathName; } } return pathName; }
/** * Called as part of the undeploy() method template to ask the subclass for perform the web container specific * undeployment steps. */ @Override protected void performUndeploy(WebApplication warInfo, String warUrl) throws Exception { if (warInfo == null) { log.debug("performUndeploy, no WebApplication found for URL " + warUrl); return; } log.info("undeploy, ctxPath=" + warInfo.getMetaData().getContextRoot()); JBossWebMetaData metaData = warInfo.getMetaData(); // Get any jboss-web/virtual-hosts List<String> vhostNames = metaData.getVirtualHosts(); // Map the virtual hosts onto the configured hosts String hostName = mapVirtualHosts(vhostNames); if (hostName == null) { Iterator hostNames = getDefaultHosts(); if (hostNames.hasNext()) { hostName = hostNames.next().toString(); } } performUndeployInternal(warInfo, hostName, warUrl); }
protected void performUndeployInternal(WebApplication warInfo, String hostName, String warUrlStr) throws Exception { JBossWebMetaData metaData = warInfo.getMetaData(); String ctxPath = metaData.getContextRoot(); // TODO: Need to remove the dependency on MBeanServer MBeanServer server = MBeanServerLocator.locateJBoss(); // If the server is gone, all apps were stopped already if (server == null) return; ObjectName objectName = new ObjectName(config.getCatalinaDomain() + ":j2eeType=WebModule,name=//" + ((hostName == null) ? "localhost" : hostName) + ctxPath + ",J2EEApplication=none,J2EEServer=none"); if (server.isRegistered(objectName)) { try { // JBAS-8406: Temp hack, will move to NamingListener CurrentComponent.push(component); // Contexts should be stopped by the host already server.invoke(objectName, "destroy", new Object[] {}, new String[] {}); } finally { CurrentComponent.pop(); } } }
public void build(DeploymentUnit unit, Set<String> outputs, Map<String, ManagedObject> managedObjects) throws DeploymentException { JBossWebMetaData meta = unit.getAttachment(JBossWebMetaData.class); if (meta == null) return; ManagedObject mo = ManagedObjectFactory.getInstance().createManagedObject(ContextMO.class); if (mo == null) throw new DeploymentException("could not create managed object"); mo.getProperty("contextRoot").setValue(SimpleValueSupport.wrap(meta.getContextRoot())); managedObjects.put("ContextMO", mo); }
private static WebDeploymentController startWebApp(WebHost host, DeploymentUnit unit) throws Exception { WebDeploymentBuilder deployment = new WebDeploymentBuilder(); WebDeploymentController handle; try { JBossWebMetaData jbwebMD = unit.getAttachment(WSAttachmentKeys.JBOSSWEB_METADATA_KEY); deployment.setContextRoot(jbwebMD.getContextRoot()); File docBase = new File(ServerConfigFactoryImpl.getConfig().getServerTempDir(), jbwebMD.getContextRoot()); if (!docBase.exists()) { docBase.mkdirs(); } deployment.setDocumentRoot(docBase); deployment.setClassLoader(unit.getAttachment(WSAttachmentKeys.CLASSLOADER_KEY)); deployment.addAllowedRequestPredicate(new AllowWSRequestPredicate()); addServlets(jbwebMD, deployment); handle = host.addWebDeployment(deployment); handle.create(); } catch (Exception e) { throw WSLogger.ROOT_LOGGER.createContextPhaseFailed(e); } try { handle.start(); } catch (Exception e) { throw WSLogger.ROOT_LOGGER.startContextPhaseFailed(e); } return handle; }
private static WebDeploymentController startWebApp(WebHost host, DeploymentUnit unit) throws Exception { WebDeploymentBuilder deployment = new WebDeploymentBuilder(); WebDeploymentController handle; try { JBossWebMetaData jbwebMD = unit.getAttachment(WSAttachmentKeys.JBOSSWEB_METADATA_KEY); deployment.setContextRoot(jbwebMD.getContextRoot()); ServerConfigService config = (ServerConfigService)unit.getServiceRegistry().getService(WSServices.CONFIG_SERVICE).getService(); File docBase = new File(config.getValue().getServerTempDir(), jbwebMD.getContextRoot()); if (!docBase.exists()) { docBase.mkdirs(); } deployment.setDocumentRoot(docBase); deployment.setClassLoader(unit.getAttachment(WSAttachmentKeys.CLASSLOADER_KEY)); deployment.addAllowedRequestPredicate(new AllowWSRequestPredicate()); addServlets(jbwebMD, deployment); handle = host.addWebDeployment(deployment); handle.create(); } catch (Exception e) { throw WSLogger.ROOT_LOGGER.createContextPhaseFailed(e); } try { handle.start(); } catch (Exception e) { throw WSLogger.ROOT_LOGGER.startContextPhaseFailed(e); } return handle; }
private static StandardContext startWebApp(Host host, WSEndpointDeploymentUnit unit) throws Exception { StandardContext context = new StandardContext(); try { JBossWebMetaData jbwebMD = unit.getAttachment(WSAttachmentKeys.JBOSSWEB_METADATA_KEY); context.setPath(jbwebMD.getContextRoot()); context.addLifecycleListener(new ContextConfig()); ServerConfigService config = (ServerConfigService)unit.getServiceRegistry().getService(WSServices.CONFIG_SERVICE).getService(); File docBase = new File(config.getValue().getServerTempDir(), jbwebMD.getContextRoot()); if (!docBase.exists()) { docBase.mkdirs(); } context.setDocBase(docBase.getPath()); final Loader loader = new WebCtxLoader(unit.getAttachment(WSAttachmentKeys.CLASSLOADER_KEY)); loader.setContainer(host); context.setLoader(loader); context.setInstanceManager(new LocalInstanceManager()); addServlets(jbwebMD, context); host.addChild(context); context.create(); } catch (Exception e) { throw MESSAGES.createContextPhaseFailed(e); } try { context.start(); } catch (LifecycleException e) { throw MESSAGES.startContextPhaseFailed(e); } return context; }
/** * Returns context root associated with webservice deployment. * * If there's application.xml descriptor provided defining nested web module, * then context root defined there will be returned. * Otherwise context root defined in jboss-web.xml will be returned. * * @param dep webservice deployment * @param jbossWebMD jboss web meta data * @return context root */ private String getContextRoot(final Deployment dep, final JBossWebMetaData jbossWebMD) { final DeploymentUnit unit = WSHelper.getRequiredAttachment(dep, DeploymentUnit.class); final JBossAppMetaData jbossAppMD = unit.getParent() == null ? null : ASHelper.getOptionalAttachment(unit .getParent(), JBossAppMetaData.class); String contextRoot = null; if (jbossAppMD != null) { final ModuleMetaData moduleMD = jbossAppMD.getModule(dep.getSimpleName()); if (moduleMD != null) { final WebModuleMetaData webModuleMD = (WebModuleMetaData) moduleMD.getValue(); contextRoot = webModuleMD.getContextRoot(); } } // prefer context root defined in application.xml over one defined in jboss-web.xml return contextRoot != null ? contextRoot : jbossWebMD.getContextRoot(); }
/** * Returns context root associated with webservice deployment. * * If there's application.xml descriptor provided defining nested web module, * then context root defined there will be returned. * Otherwise context root defined in jboss-web.xml will be returned. * * @param dep webservice deployment * @param jbossWebMD jboss web meta data * @return context root */ private String getContextRoot(final Deployment dep, final JBossWebMetaData jbossWebMD) { final DeploymentUnit unit = WSHelper.getRequiredAttachment(dep, DeploymentUnit.class); final JBossAppMetaData jbossAppMD = unit.getParent() == null ? null : ASHelper.getOptionalAttachment(unit .getParent(), JBossAppMetaData.class); String contextRoot = null; if (jbossAppMD != null) { final ModuleMetaData moduleMD = jbossAppMD.getModule(dep.getSimpleName()); if (moduleMD != null) { final WebModuleMetaData webModuleMD = (WebModuleMetaData) moduleMD.getValue(); contextRoot = webModuleMD.getContextRoot(); } } // prefer context root defined in application.xml over one defined in jboss-web.xml return contextRoot != null ? contextRoot : jbossWebMD.getContextRoot(); }
/** * Returns context root associated with webservice deployment. * * If there's application.xml descriptor provided defining nested web module, * then context root defined there will be returned. * Otherwise context root defined in jboss-web.xml will be returned. * * @param dep webservice deployment * @param jbossWebMD jboss web meta data * @return context root */ private String getContextRoot(final Deployment dep, final JBossWebMetaData jbossWebMD) { final DeploymentUnit unit = WSHelper.getRequiredAttachment(dep, DeploymentUnit.class); final JBossAppMetaData jbossAppMD = unit.getParent() == null ? null : ASHelper.getOptionalAttachment(unit .getParent(), JBossAppMetaData.class); String contextRoot = null; if (jbossAppMD != null) { final ModuleMetaData moduleMD = jbossAppMD.getModule(dep.getSimpleName()); if (moduleMD != null) { final WebModuleMetaData webModuleMD = (WebModuleMetaData) moduleMD.getValue(); contextRoot = webModuleMD.getContextRoot(); } } // prefer context root defined in application.xml over one defined in jboss-web.xml return contextRoot != null ? contextRoot : jbossWebMD.getContextRoot(); }
/** * Returns context root associated with webservice deployment. * * If there's application.xml descriptor provided defining nested web module, then context root defined there will be * returned. Otherwise context root defined in jboss-web.xml will be returned. * * @param dep webservice deployment * @param jbossWebMD jboss web meta data * @return context root */ public static String getContextRoot(final Deployment dep, final JBossWebMetaData jbossWebMD) { final DeploymentUnit unit = WSHelper.getRequiredAttachment(dep, DeploymentUnit.class); final JBossAppMetaData jbossAppMD = unit.getParent() == null ? null : ASHelper.getOptionalAttachment(unit.getParent(), WSAttachmentKeys.JBOSS_APP_METADATA_KEY); String contextRoot = null; // prefer context root defined in application.xml over one defined in jboss-web.xml if (jbossAppMD != null) { final ModuleMetaData moduleMD = jbossAppMD.getModules().get(dep.getSimpleName()); if (moduleMD != null) { final WebModuleMetaData webModuleMD = (WebModuleMetaData) moduleMD.getValue(); contextRoot = webModuleMD.getContextRoot(); } } if (contextRoot == null) { contextRoot = jbossWebMD != null ? jbossWebMD.getContextRoot() : null; } return contextRoot; }
/** * Returns context root associated with webservice deployment. * * If there's application.xml descriptor provided defining nested web module, then context root defined there will be * returned. Otherwise context root defined in jboss-web.xml will be returned. * * @param dep webservice deployment * @param jbossWebMD jboss web meta data * @return context root */ public static String getContextRoot(final Deployment dep, final JBossWebMetaData jbossWebMD) { final DeploymentUnit unit = WSHelper.getRequiredAttachment(dep, DeploymentUnit.class); final JBossAppMetaData jbossAppMD = unit.getParent() == null ? null : ASHelper.getOptionalAttachment(unit.getParent(), WSAttachmentKeys.JBOSS_APP_METADATA_KEY); String contextRoot = null; // prefer context root defined in application.xml over one defined in jboss-web.xml if (jbossAppMD != null) { final ModuleMetaData moduleMD = jbossAppMD.getModules().get(dep.getSimpleName()); if (moduleMD != null) { final WebModuleMetaData webModuleMD = (WebModuleMetaData) moduleMD.getValue(); contextRoot = webModuleMD.getContextRoot(); } } if (contextRoot == null) { contextRoot = jbossWebMD != null ? jbossWebMD.getContextRoot() : null; } return contextRoot; }
/** * Returns context root associated with webservice deployment. * * If there's application.xml descriptor provided defining nested web module, then context root defined there will be * returned. Otherwise context root defined in jboss-web.xml will be returned. * * @param dep webservice deployment * @param jbossWebMD jboss web meta data * @return context root */ public static String getContextRoot(final Deployment dep, final JBossWebMetaData jbossWebMD) { final DeploymentUnit unit = WSHelper.getRequiredAttachment(dep, DeploymentUnit.class); final JBossAppMetaData jbossAppMD = unit.getParent() == null ? null : ASHelper.getOptionalAttachment(unit.getParent(), WSAttachmentKeys.JBOSS_APP_METADATA_KEY); String contextRoot = null; // prefer context root defined in application.xml over one defined in jboss-web.xml if (jbossAppMD != null) { final ModuleMetaData moduleMD = jbossAppMD.getModules().get(dep.getSimpleName()); if (moduleMD != null) { final WebModuleMetaData webModuleMD = (WebModuleMetaData) moduleMD.getValue(); contextRoot = webModuleMD.getContextRoot(); } } if (contextRoot == null) { contextRoot = jbossWebMD != null ? jbossWebMD.getContextRoot() : null; } return contextRoot; }
/** * Publish the webapp for the WS deployment unit * * @param target * @param unit * @return * @throws Exception */ protected Context doPublish(ServiceTarget target, DeploymentUnit unit) throws Exception { Deployment deployment = unit.getAttachment(WSAttachmentKeys.DEPLOYMENT_KEY); List<Endpoint> endpoints = deployment.getService().getEndpoints(); //If we're running in a Service, that will already have proper dependencies set on the installed endpoint services, //otherwise we need to explicitly wait for the endpoint services to be started before creating the webapp. if (!runningInService) { final ServiceRegistry registry = unit.getServiceRegistry(); for (Endpoint ep : endpoints) { final ServiceName serviceName = EndpointService.getServiceName(unit, ep.getShortName()); registry.getRequiredService(serviceName).awaitValue(); } } deployment.addAttachment(WebDeploymentController.class, startWebApp(host, unit)); //TODO simplify and use findChild later in destroy()/stopWebApp() return new Context(unit.getAttachment(WSAttachmentKeys.JBOSSWEB_METADATA_KEY).getContextRoot(), endpoints); }
/** * Publish the webapp for the WS deployment unit * * @param target * @param unit * @return * @throws Exception */ protected Context doPublish(ServiceTarget target, DeploymentUnit unit) throws Exception { Deployment deployment = unit.getAttachment(WSAttachmentKeys.DEPLOYMENT_KEY); List<Endpoint> endpoints = deployment.getService().getEndpoints(); //If we're running in a Service, that will already have proper dependencies set on the installed endpoint services, //otherwise we need to explicitly wait for the endpoint services to be started before creating the webapp. if (!runningInService) { final ServiceRegistry registry = unit.getServiceRegistry(); final StabilityMonitor monitor = new StabilityMonitor(); for (Endpoint ep : endpoints) { final ServiceName serviceName = EndpointService.getServiceName(unit, ep.getShortName()); monitor.addController(registry.getRequiredService(serviceName)); } try { monitor.awaitStability(); } finally { monitor.clear(); } } deployment.addAttachment(WebDeploymentController.class, startWebApp(host, unit)); //TODO simplify and use findChild later in destroy()/stopWebApp() return new Context(unit.getAttachment(WSAttachmentKeys.JBOSSWEB_METADATA_KEY).getContextRoot(), endpoints); }
contextRoot = jbossWebMetaData.getContextRoot();