@Override
 public ServiceBuilder<?> build(ServiceTarget target, String connector, int statusInterval) {
   InjectedValue<ContainerEventHandler> eventHandler = new InjectedValue<>();
   InjectedValue<UndertowService> undertowService = new InjectedValue<>();
   InjectedValue<SuspendController> suspendController = new InjectedValue<>();
   @SuppressWarnings("rawtypes")
   InjectedValue<ListenerService> listener = new InjectedValue<>();
   return new AsynchronousServiceBuilder<>(
           SERVICE_NAME,
           new UndertowEventHandlerAdapter(
               eventHandler, undertowService, listener, suspendController, statusInterval))
       .build(target)
       .addDependency(
           ContainerEventHandlerService.SERVICE_NAME, ContainerEventHandler.class, eventHandler)
       .addDependency(UndertowService.UNDERTOW, UndertowService.class, undertowService)
       .addDependency(UndertowService.listenerName(connector), ListenerService.class, listener)
       .addDependency(SuspendController.SERVICE_NAME, SuspendController.class, suspendController);
 }
  @Override
  public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    SipMetaData sipMetaData = deploymentUnit.getAttachment(SipMetaData.ATTACHMENT_KEY);
    if (sipMetaData == null) {
      SipAnnotationMetaData sipAnnotationMetaData =
          deploymentUnit.getAttachment(SipAnnotationMetaData.ATTACHMENT_KEY);
      if (sipAnnotationMetaData == null
          || !sipAnnotationMetaData.isSipApplicationAnnotationPresent()) {
        // http://code.google.com/p/sipservlets/issues/detail?id=168
        // When no sip.xml but annotations only, Application is not recognized as SIP App by AS7

        // In case there is no metadata attached, it means this is not a sip deployment, so we can
        // safely
        // ignore
        // it!
        return;
      }
    }

    final WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
    final JBossWebMetaData metaData = warMetaData.getMergedJBossWebMetaData();

    // lets find default server service:
    final ServiceName defaultServerServiceName = UndertowService.DEFAULT_SERVER;
    ServiceController<?> defaultServerServiceController =
        phaseContext.getServiceRegistry().getService(defaultServerServiceName);
    Server defaultServerService = (Server) defaultServerServiceController.getValue();

    final String defaultServer = defaultServerService.getName();
    final String defaultHost = defaultServerService.getDefaultHost();

    String hostName = UndertowSipDeploymentProcessor.hostNameOfDeployment(warMetaData, defaultHost);
    final String pathName =
        UndertowSipDeploymentProcessor.pathNameOfDeployment(deploymentUnit, metaData);

    String serverInstanceName =
        metaData.getServerInstanceName() == null ? defaultServer : metaData.getServerInstanceName();

    // lets find udertowdeployment service
    final ServiceName deploymentServiceName =
        UndertowService.deploymentServiceName(serverInstanceName, hostName, pathName);
    ServiceController<?> deploymentServiceController =
        phaseContext.getServiceRegistry().getService(deploymentServiceName);
    UndertowDeploymentService deploymentService =
        (UndertowDeploymentService) deploymentServiceController.getValue();

    // lets find udertowdeploymentinfo service
    final ServiceName deploymentInfoServiceName =
        deploymentServiceName.append(UndertowDeploymentInfoService.SERVICE_NAME);
    ServiceController<?> deploymentInfoServiceController =
        phaseContext.getServiceRegistry().getService(deploymentInfoServiceName);
    UndertowDeploymentInfoService deploymentInfoService =
        (UndertowDeploymentInfoService) deploymentInfoServiceController.getService();

    // lets inject undertowdeployment service to sip deploymentinfo service:
    final ServiceName sipDeploymentInfoServiceName =
        deploymentServiceName.append(UndertowSipDeploymentInfoService.SERVICE_NAME);
    ServiceController<?> sipDeplyomentInfoServiceController =
        phaseContext.getServiceRegistry().getService(sipDeploymentInfoServiceName);
    UndertowSipDeploymentInfoService sipDeplyomentInfoService =
        (UndertowSipDeploymentInfoService) sipDeplyomentInfoServiceController.getService();
    sipDeplyomentInfoService
        .getDeploymentInfoServiceInjectedValue()
        .setValue(new ImmediateValue<UndertowDeploymentInfoService>(deploymentInfoService));

    // initiate undertowsipdeployment service:
    final ServiceName sipDeploymentServiceName =
        deploymentServiceName.append(UndertowSipDeploymentService.SERVICE_NAME);
    UndertowSipDeploymentService sipDeploymentService =
        new UndertowSipDeploymentService(deploymentService, deploymentUnit);
    ServiceBuilder<UndertowSipDeploymentService> sipDeploymentServiceBuilder =
        phaseContext.getServiceTarget().addService(sipDeploymentServiceName, sipDeploymentService);

    // this service depends on the base undertowdeployment service:
    sipDeploymentServiceBuilder.addDependency(deploymentServiceName);
    sipDeploymentServiceBuilder.install();
  }
  private void processDeployment(
      final WarMetaData warMetaData,
      final DeploymentUnit deploymentUnit,
      final ServiceTarget serviceTarget,
      String hostName)
      throws DeploymentUnitProcessingException {
    ResourceRoot deploymentResourceRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
    final VirtualFile deploymentRoot = deploymentResourceRoot.getRoot();
    final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
    if (module == null) {
      throw new DeploymentUnitProcessingException(
          UndertowLogger.ROOT_LOGGER.failedToResolveModule(deploymentUnit));
    }
    final JBossWebMetaData metaData = warMetaData.getMergedJBossWebMetaData();
    final List<SetupAction> setupActions =
        deploymentUnit.getAttachmentList(org.jboss.as.ee.component.Attachments.WEB_SETUP_ACTIONS);
    metaData.resolveRunAs();

    ScisMetaData scisMetaData = deploymentUnit.getAttachment(ScisMetaData.ATTACHMENT_KEY);

    final Set<ServiceName> dependentComponents = new HashSet<>();
    // see AS7-2077
    // basically we want to ignore components that have failed for whatever reason
    // if they are important they will be picked up when the web deployment actually starts
    final List<ServiceName> components =
        deploymentUnit.getAttachmentList(WebComponentDescription.WEB_COMPONENTS);
    final Set<ServiceName> failed =
        deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.FAILED_COMPONENTS);
    for (final ServiceName component : components) {
      if (!failed.contains(component)) {
        dependentComponents.add(component);
      }
    }

    boolean componentRegistryExists = true;
    ComponentRegistry componentRegistry =
        deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.COMPONENT_REGISTRY);
    if (componentRegistry == null) {
      componentRegistryExists = false;
      // we do this to avoid lots of other null checks
      // this will only happen if the EE subsystem is not installed
      componentRegistry = new ComponentRegistry(null);
    }

    final WebInjectionContainer injectionContainer =
        new WebInjectionContainer(module.getClassLoader(), componentRegistry);

    String jaccContextId = metaData.getJaccContextID();

    if (jaccContextId == null) {
      jaccContextId = deploymentUnit.getName();
    }
    if (deploymentUnit.getParent() != null) {
      jaccContextId = deploymentUnit.getParent().getName() + "!" + jaccContextId;
    }

    String deploymentName;
    if (deploymentUnit.getParent() == null) {
      deploymentName = deploymentUnit.getName();
    } else {
      deploymentName = deploymentUnit.getParent().getName() + "." + deploymentUnit.getName();
    }

    final String pathName = pathNameOfDeployment(deploymentUnit, metaData);

    boolean securityEnabled = deploymentUnit.hasAttachment(SecurityAttachments.SECURITY_ENABLED);

    String metaDataSecurityDomain = metaData.getSecurityDomain();
    if (metaDataSecurityDomain == null) {
      metaDataSecurityDomain = getJBossAppSecurityDomain(deploymentUnit);
    }
    if (metaDataSecurityDomain != null) {
      metaDataSecurityDomain = metaDataSecurityDomain.trim();
    }

    final String securityDomain;
    if (securityEnabled) {
      securityDomain =
          metaDataSecurityDomain == null
              ? SecurityConstants.DEFAULT_APPLICATION_POLICY
              : SecurityUtil.unprefixSecurityDomain(metaDataSecurityDomain);
    } else {
      securityDomain = null;
    }

    String serverInstanceName =
        metaData.getServerInstanceName() == null ? defaultServer : metaData.getServerInstanceName();
    final ServiceName deploymentServiceName =
        UndertowService.deploymentServiceName(serverInstanceName, hostName, pathName);

    final Set<ServiceName> additionalDependencies = new HashSet<>();
    for (final SetupAction setupAction : setupActions) {
      Set<ServiceName> dependencies = setupAction.dependencies();
      if (dependencies != null) {
        additionalDependencies.addAll(dependencies);
      }
    }
    SharedSessionManagerConfig sharedSessionManagerConfig =
        deploymentUnit.getParent() != null
            ? deploymentUnit
                .getParent()
                .getAttachment(UndertowAttachments.SHARED_SESSION_MANAGER_CONFIG)
            : null;

    if (!deploymentResourceRoot.isUsePhysicalCodeSource()) {
      try {
        deploymentUnit.addToAttachmentList(
            ServletContextAttribute.ATTACHMENT_KEY,
            new ServletContextAttribute(
                Constants.CODE_SOURCE_ATTRIBUTE_NAME, deploymentRoot.toURL()));
      } catch (MalformedURLException e) {
        throw new DeploymentUnitProcessingException(e);
      }
    }

    deploymentUnit.addToAttachmentList(
        ServletContextAttribute.ATTACHMENT_KEY,
        new ServletContextAttribute(
            Constants.PERMISSION_COLLECTION_ATTRIBUTE_NAME,
            deploymentUnit.getAttachment(Attachments.MODULE_PERMISSIONS)));

    additionalDependencies.addAll(warMetaData.getAdditionalDependencies());

    final ServiceName hostServiceName =
        UndertowService.virtualHostName(serverInstanceName, hostName);
    TldsMetaData tldsMetaData = deploymentUnit.getAttachment(TldsMetaData.ATTACHMENT_KEY);
    UndertowDeploymentInfoService undertowDeploymentInfoService =
        UndertowDeploymentInfoService.builder()
            .setAttributes(deploymentUnit.getAttachmentList(ServletContextAttribute.ATTACHMENT_KEY))
            .setTopLevelDeploymentName(
                deploymentUnit.getParent() == null
                    ? deploymentUnit.getName()
                    : deploymentUnit.getParent().getName())
            .setContextPath(pathName)
            .setDeploymentName(
                deploymentName) // todo: is this deployment name concept really applicable?
            .setDeploymentRoot(deploymentRoot)
            .setMergedMetaData(warMetaData.getMergedJBossWebMetaData())
            .setModule(module)
            .setScisMetaData(scisMetaData)
            .setJaccContextId(jaccContextId)
            .setSecurityDomain(securityDomain)
            .setSharedTlds(
                tldsMetaData == null
                    ? Collections.<TldMetaData>emptyList()
                    : tldsMetaData.getSharedTlds(deploymentUnit))
            .setTldsMetaData(tldsMetaData)
            .setSetupActions(setupActions)
            .setSharedSessionManagerConfig(sharedSessionManagerConfig)
            .setOverlays(warMetaData.getOverlays())
            .setExpressionFactoryWrappers(
                deploymentUnit.getAttachmentList(ExpressionFactoryWrapper.ATTACHMENT_KEY))
            .setPredicatedHandlers(
                deploymentUnit.getAttachment(
                    UndertowHandlersDeploymentProcessor.PREDICATED_HANDLERS))
            .setInitialHandlerChainWrappers(
                deploymentUnit.getAttachmentList(
                    UndertowAttachments.UNDERTOW_INITIAL_HANDLER_CHAIN_WRAPPERS))
            .setInnerHandlerChainWrappers(
                deploymentUnit.getAttachmentList(
                    UndertowAttachments.UNDERTOW_INNER_HANDLER_CHAIN_WRAPPERS))
            .setOuterHandlerChainWrappers(
                deploymentUnit.getAttachmentList(
                    UndertowAttachments.UNDERTOW_OUTER_HANDLER_CHAIN_WRAPPERS))
            .setThreadSetupActions(
                deploymentUnit.getAttachmentList(UndertowAttachments.UNDERTOW_THREAD_SETUP_ACTIONS))
            .setServletExtensions(
                deploymentUnit.getAttachmentList(UndertowAttachments.UNDERTOW_SERVLET_EXTENSIONS))
            .setExplodedDeployment(ExplodedDeploymentMarker.isExplodedDeployment(deploymentUnit))
            .setWebSocketDeploymentInfo(
                deploymentUnit.getAttachment(UndertowAttachments.WEB_SOCKET_DEPLOYMENT_INFO))
            .setTempDir(warMetaData.getTempDir())
            .setExternalResources(
                deploymentUnit.getAttachmentList(UndertowAttachments.EXTERNAL_RESOURCES))
            .createUndertowDeploymentInfoService();

    final ServiceName deploymentInfoServiceName =
        deploymentServiceName.append(UndertowDeploymentInfoService.SERVICE_NAME);
    ServiceBuilder<DeploymentInfo> infoBuilder =
        serviceTarget
            .addService(deploymentInfoServiceName, undertowDeploymentInfoService)
            .addDependency(
                UndertowService.SERVLET_CONTAINER.append(defaultContainer),
                ServletContainerService.class,
                undertowDeploymentInfoService.getContainer())
            .addDependency(
                UndertowService.UNDERTOW,
                UndertowService.class,
                undertowDeploymentInfoService.getUndertowService())
            .addDependencies(deploymentUnit.getAttachmentList(Attachments.WEB_DEPENDENCIES))
            .addDependency(hostServiceName, Host.class, undertowDeploymentInfoService.getHost())
            .addDependency(
                SuspendController.SERVICE_NAME,
                SuspendController.class,
                undertowDeploymentInfoService.getSuspendControllerInjectedValue())
            .addDependencies(additionalDependencies);
    if (securityDomain != null) {
      infoBuilder.addDependency(
          SecurityDomainService.SERVICE_NAME.append(securityDomain),
          SecurityDomainContext.class,
          undertowDeploymentInfoService.getSecurityDomainContextValue());
    }

    if (RequestControllerActivationMarker.isRequestControllerEnabled(deploymentUnit)) {
      String topLevelName;
      if (deploymentUnit.getParent() == null) {
        topLevelName = deploymentUnit.getName();
      } else {
        topLevelName = deploymentUnit.getParent().getName();
      }
      infoBuilder.addDependency(
          ControlPointService.serviceName(topLevelName, UndertowExtension.SUBSYSTEM_NAME),
          ControlPoint.class,
          undertowDeploymentInfoService.getControlPointInjectedValue());
    }
    final Set<String> seenExecutors = new HashSet<String>();
    if (metaData.getExecutorName() != null) {
      final InjectedValue<Executor> executor = new InjectedValue<Executor>();
      infoBuilder.addDependency(
          IOServices.WORKER.append(metaData.getExecutorName()), Executor.class, executor);
      undertowDeploymentInfoService.addInjectedExecutor(metaData.getExecutorName(), executor);
      seenExecutors.add(metaData.getExecutorName());
    }
    if (metaData.getServlets() != null) {
      for (JBossServletMetaData servlet : metaData.getServlets()) {
        if (servlet.getExecutorName() != null
            && !seenExecutors.contains(servlet.getExecutorName())) {
          final InjectedValue<Executor> executor = new InjectedValue<Executor>();
          infoBuilder.addDependency(
              IOServices.WORKER.append(servlet.getExecutorName()), Executor.class, executor);
          undertowDeploymentInfoService.addInjectedExecutor(servlet.getExecutorName(), executor);
          seenExecutors.add(servlet.getExecutorName());
        }
      }
    }

    if (componentRegistryExists) {
      infoBuilder.addDependency(
          ComponentRegistry.serviceName(deploymentUnit),
          ComponentRegistry.class,
          undertowDeploymentInfoService.getComponentRegistryInjectedValue());
    } else {
      undertowDeploymentInfoService
          .getComponentRegistryInjectedValue()
          .setValue(new ImmediateValue<>(componentRegistry));
    }

    if (sharedSessionManagerConfig != null) {
      infoBuilder.addDependency(
          deploymentUnit
              .getParent()
              .getServiceName()
              .append(SharedSessionManagerConfig.SHARED_SESSION_MANAGER_SERVICE_NAME),
          SessionManagerFactory.class,
          undertowDeploymentInfoService.getSessionManagerFactoryInjector());
      infoBuilder.addDependency(
          deploymentUnit
              .getParent()
              .getServiceName()
              .append(SharedSessionManagerConfig.SHARED_SESSION_IDENTIFIER_CODEC_SERVICE_NAME),
          SessionIdentifierCodec.class,
          undertowDeploymentInfoService.getSessionIdentifierCodecInjector());
    } else {
      ServiceName sessionManagerFactoryServiceName =
          installSessionManagerFactory(
              serviceTarget, deploymentServiceName, deploymentName, module, metaData);
      infoBuilder.addDependency(
          sessionManagerFactoryServiceName,
          SessionManagerFactory.class,
          undertowDeploymentInfoService.getSessionManagerFactoryInjector());

      ServiceName sessionIdentifierCodecServiceName =
          installSessionIdentifierCodec(
              serviceTarget, deploymentServiceName, deploymentName, metaData);
      infoBuilder.addDependency(
          sessionIdentifierCodecServiceName,
          SessionIdentifierCodec.class,
          undertowDeploymentInfoService.getSessionIdentifierCodecInjector());
    }

    infoBuilder.install();

    final boolean isWebappBundle = deploymentUnit.hasAttachment(Attachments.OSGI_MANIFEST);

    final UndertowDeploymentService service =
        new UndertowDeploymentService(injectionContainer, !isWebappBundle);
    final ServiceBuilder<UndertowDeploymentService> builder =
        serviceTarget
            .addService(deploymentServiceName, service)
            .addDependencies(dependentComponents)
            .addDependency(
                UndertowService.SERVLET_CONTAINER.append(defaultContainer),
                ServletContainerService.class,
                service.getContainer())
            .addDependency(hostServiceName, Host.class, service.getHost())
            .addDependencies(deploymentUnit.getAttachmentList(Attachments.WEB_DEPENDENCIES))
            .addDependency(
                deploymentInfoServiceName,
                DeploymentInfo.class,
                service.getDeploymentInfoInjectedValue());
    // inject the server executor which can be used by the WebDeploymentService for blocking tasks
    // in start/stop
    // of that service
    Services.addServerExecutorDependency(builder, service.getServerExecutorInjector(), false);

    deploymentUnit.addToAttachmentList(
        Attachments.DEPLOYMENT_COMPLETE_SERVICES, deploymentServiceName);

    // adding JACC service
    if (securityEnabled) {
      AbstractSecurityDeployer<WarMetaData> deployer = new WarJACCDeployer();
      JaccService<WarMetaData> jaccService = deployer.deploy(deploymentUnit, jaccContextId);
      if (jaccService != null) {
        final ServiceName jaccServiceName =
            deploymentUnit.getServiceName().append(JaccService.SERVICE_NAME);
        ServiceBuilder<?> jaccBuilder = serviceTarget.addService(jaccServiceName, jaccService);
        if (deploymentUnit.getParent() != null) {
          // add dependency to parent policy
          final DeploymentUnit parentDU = deploymentUnit.getParent();
          jaccBuilder.addDependency(
              parentDU.getServiceName().append(JaccService.SERVICE_NAME),
              PolicyConfiguration.class,
              jaccService.getParentPolicyInjector());
        }
        // add dependency to web deployment service
        jaccBuilder.addDependency(deploymentServiceName);
        jaccBuilder.setInitialMode(Mode.PASSIVE).install();
      }
    }

    // OSGi web applications are activated in {@link WebContextActivationProcessor} according to
    // bundle lifecycle changes
    if (isWebappBundle) {
      UndertowDeploymentService.ContextActivatorImpl activator =
          new UndertowDeploymentService.ContextActivatorImpl(builder.install());
      deploymentUnit.putAttachment(ContextActivator.ATTACHMENT_KEY, activator);
      deploymentUnit.addToAttachmentList(
          Attachments.BUNDLE_ACTIVE_DEPENDENCIES, deploymentServiceName);
    } else {
      builder.install();
    }

    // Process the web related mgmt information
    final DeploymentResourceSupport deploymentResourceSupport =
        deploymentUnit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT);
    final ModelNode node =
        deploymentResourceSupport.getDeploymentSubsystemModel(UndertowExtension.SUBSYSTEM_NAME);
    node.get(DeploymentDefinition.CONTEXT_ROOT.getName()).set("".equals(pathName) ? "/" : pathName);
    node.get(DeploymentDefinition.VIRTUAL_HOST.getName()).set(hostName);
    node.get(DeploymentDefinition.SERVER.getName()).set(serverInstanceName);
    processManagement(deploymentUnit, metaData);
  }
    @Override
    public void execute(OperationContext context, ModelNode operation)
        throws OperationFailedException {
      PathAddress address = context.getCurrentAddress();
      String clsName = address.getLastElement().getValue();
      PathAddress parentAddress = address.getParent();
      final ModelNode subModel =
          context
              .readResourceFromRoot(
                  parentAddress
                      .subAddress(0, parentAddress.size() - 1)
                      .append(SUBSYSTEM, UndertowExtension.SUBSYSTEM_NAME),
                  false)
              .getModel();
      final String host = VIRTUAL_HOST.resolveModelAttribute(context, subModel).asString();
      final String contextPath = CONTEXT_ROOT.resolveModelAttribute(context, subModel).asString();
      final String server = SERVER.resolveModelAttribute(context, subModel).asString();

      final ServiceController<?> controller =
          context
              .getServiceRegistry(false)
              .getService(UndertowService.deploymentServiceName(server, host, contextPath));
      final UndertowDeploymentService deploymentService =
          (UndertowDeploymentService) controller.getService();
      Servlet resteasyServlet = null;
      Handle handle = deploymentService.getDeployment().getThreadSetupAction().setup(null);
      try {
        for (Map.Entry<String, ServletHandler> servletHandler :
            deploymentService.getDeployment().getServlets().getServletHandlers().entrySet()) {
          if (HttpServletDispatcher.class.isAssignableFrom(
              servletHandler.getValue().getManagedServlet().getServletInfo().getServletClass())) {
            resteasyServlet =
                (Servlet) servletHandler.getValue().getManagedServlet().getServlet().getInstance();
            break;
          }
        }
        if (resteasyServlet != null) {
          final Collection<String> servletMappings =
              resteasyServlet
                  .getServletConfig()
                  .getServletContext()
                  .getServletRegistration(resteasyServlet.getServletConfig().getServletName())
                  .getMappings();
          final ResourceMethodRegistry registry =
              (ResourceMethodRegistry)
                  ((HttpServletDispatcher) resteasyServlet).getDispatcher().getRegistry();
          context.addStep(
              new OperationStepHandler() {
                @Override
                public void execute(OperationContext context, ModelNode operation)
                    throws OperationFailedException {
                  final ModelNode response = new ModelNode();
                  List<JaxrsResourceMethodDescription> resMethodInvokers = new ArrayList<>();
                  List<JaxrsResourceLocatorDescription> resLocatorInvokers = new ArrayList<>();
                  for (Map.Entry<String, List<ResourceInvoker>> resource :
                      registry.getBounded().entrySet()) {
                    String mapping = resource.getKey();
                    List<ResourceInvoker> resouceInvokers = resource.getValue();
                    for (ResourceInvoker resourceInvoker : resouceInvokers) {
                      if (ResourceMethodInvoker.class.isAssignableFrom(
                          resourceInvoker.getClass())) {
                        ResourceMethodInvoker methodInvoker =
                            (ResourceMethodInvoker) resourceInvoker;
                        if (methodInvoker.getResourceClass().getCanonicalName().equals(clsName)) {
                          JaxrsResourceMethodDescription resMethodDesc =
                              resMethodDescription(
                                  methodInvoker, contextPath, mapping, servletMappings);
                          resMethodInvokers.add(resMethodDesc);
                        }
                      } else if (ResourceLocatorInvoker.class.isAssignableFrom(
                          resourceInvoker.getClass())) {
                        ResourceLocatorInvoker locatorInvoker =
                            (ResourceLocatorInvoker) resourceInvoker;
                        if (clsName.equals(
                            locatorInvoker.getMethod().getDeclaringClass().getCanonicalName())) {
                          ResourceClass resClass =
                              ResourceBuilder.locatorFromAnnotations(
                                  locatorInvoker.getMethod().getReturnType());
                          JaxrsResourceLocatorDescription resLocatorDesc =
                              resLocatorDescription(
                                  resClass,
                                  contextPath,
                                  mapping,
                                  servletMappings,
                                  new ArrayList<Class<?>>());
                          resLocatorInvokers.add(resLocatorDesc);
                        }
                      }
                    }
                  }
                  Collections.sort(resMethodInvokers);
                  Collections.sort(resLocatorInvokers);
                  handleAttribute(
                      clsName, resMethodInvokers, resLocatorInvokers, servletMappings, response);
                  context.getResult().set(response);
                }
              },
              OperationContext.Stage.RUNTIME);
        }
      } catch (ServletException ex) {
        throw new RuntimeException(ex);
      } finally {
        handle.tearDown();
      }
    }