Ejemplo n.º 1
0
  /**
   * Returns context root associated with webservice deployment.
   *
   * <p>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;
  }
  @Override
  public void start(final Deployment dep) {
    if (WSHelper.isJaxrpcDeployment(dep)) return;

    for (final Endpoint ep : dep.getService().getEndpoints()) {
      setInjectionAwareInstanceProvider(ep);
    }
  }
  /**
   * Creates new Http Web Service endpoint.
   *
   * @param endpointClass endpoint class name
   * @param endpointName endpoint name
   * @param dep deployment
   * @return WS endpoint
   */
  protected final Endpoint newHttpEndpoint(
      final String endpointClass, final String endpointName, final Deployment dep) {
    if (endpointName == null) throw MESSAGES.nullEndpointName();
    if (endpointClass == null) throw MESSAGES.nullEndpointClass();

    final Endpoint endpoint = this.deploymentModelFactory.newHttpEndpoint(endpointClass);
    endpoint.setShortName(endpointName);
    endpoint.setType(endpointType);
    dep.getService().addEndpoint(endpoint);

    return endpoint;
  }
Ejemplo n.º 4
0
 /** Publishes the endpoints declared to the provided WSEndpointDeploymentUnit */
 public List<Endpoint> publish(ServiceTarget target, WSEndpointDeploymentUnit unit)
     throws Exception {
   List<DeploymentAspect> aspects = DeploymentAspectsProvider.getSortedDeploymentAspects();
   ClassLoader origClassLoader = SecurityActions.getContextClassLoader();
   Deployment dep = null;
   try {
     SecurityActions.setContextClassLoader(
         ClassLoaderProvider.getDefaultProvider().getServerIntegrationClassLoader());
     WSDeploymentBuilder.getInstance().build(unit);
     dep = unit.getAttachment(WSAttachmentKeys.DEPLOYMENT_KEY);
     dep.addAttachment(ServiceTarget.class, target);
     DeploymentAspectManager dam = new DeploymentAspectManagerImpl();
     dam.setDeploymentAspects(aspects);
     dam.deploy(dep);
   } finally {
     if (dep != null) {
       dep.removeAttachment(ServiceTarget.class);
     }
     SecurityActions.setContextClassLoader(origClassLoader);
   }
   Deployment deployment = unit.getAttachment(WSAttachmentKeys.DEPLOYMENT_KEY);
   deployment.addAttachment(
       StandardContext.class,
       startWebApp(host, unit)); // TODO simplify and use findChild later in destroy()/stopWebApp()
   return deployment.getService().getEndpoints();
 }
Ejemplo n.º 5
0
 @Override
 public void destroy(Context context) throws Exception {
   List<Endpoint> eps = context.getEndpoints();
   if (eps == null || eps.isEmpty()) {
     return;
   }
   Deployment deployment = eps.get(0).getService().getDeployment();
   List<DeploymentAspect> aspects = DeploymentAspectsProvider.getSortedDeploymentAspects();
   try {
     stopWebApp(deployment.getAttachment(StandardContext.class));
   } finally {
     ClassLoader origClassLoader = SecurityActions.getContextClassLoader();
     try {
       SecurityActions.setContextClassLoader(
           ClassLoaderProvider.getDefaultProvider().getServerIntegrationClassLoader());
       DeploymentAspectManager dam = new DeploymentAspectManagerImpl();
       dam.setDeploymentAspects(aspects);
       dam.undeploy(deployment);
     } finally {
       SecurityActions.setContextClassLoader(origClassLoader);
     }
   }
 }
Ejemplo n.º 6
0
 private boolean hasWebservicesMD(final Endpoint endpoint) {
   final Deployment dep = endpoint.getService().getDeployment();
   return dep.getAttachment(WebservicesMetaData.class) != null;
 }