Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source.
   * Copyright 2013, Red Hat, Inc., and individual contributors
   * as indicated by the @author tags. See the copyright.txt file in the
   * distribution for a full listing of individual contributors.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
 package org.jboss.as.webservices.service;
 
 import static org.jboss.as.webservices.WSLogger.ROOT_LOGGER;
 
 import java.util.List;
 
 
 import  org.jboss.metadata.web.jboss.JBossWebMetaData;
WS endpoint service; this is meant for setting the lazy deployment time info into the Endpoint (stuff coming from dependencies upon other AS services that are started during the deployment)

Author(s):
alessio.soldano@jboss.com
Richard Opalka
Jim Ma
 
 public final class EndpointService implements Service<Endpoint> {
 
     private final Endpoint endpoint;
     private final ServiceName name;
 
     private EndpointService(final Endpoint endpointfinal ServiceName name) {
         this. = endpoint;
         this. = name;
     }
 
     @Override
     public Endpoint getValue() {
         return ;
     }
 
     public static ServiceName getServiceName(final DeploymentUnit unitfinal String endpointName) {
        if (unit.getParent() != null) {
            return ..append(unit.getParent().getName()).append(unit.getName()).append(endpointName);
        } else {
            return ..append(unit.getName()).append(endpointName);
        }
    }
    @Override
    public void start(final StartContext contextthrows StartException {
        .starting();
        if (..equals(.getType())) {
            final EJBViewMethodSecurityAttributesService ejbMethodSecurityAttributeService = .getValue();
            .addAttachment(EJBMethodSecurityAttributeProvider.classnew EJBMethodSecurityAttributesAdaptor(ejbMethodSecurityAttributeService));
        }
        final List<RecordProcessorprocessors = .getRecordProcessors();
        for (final RecordProcessor processor : processors) {
            registerRecordProcessor(processor);
        }
        final EndpointMetricsFactory factory = SPIProvider.getInstance().getSPI(EndpointMetricsFactory.class);
        registerEndpoint();
    }
    @Override
    public void stop(final StopContext context) {
        .stopping();
        .setSecurityDomainContext(null);
        final List<RecordProcessorprocessors = .getRecordProcessors();
        for (final RecordProcessor processor : processors) {
            unregisterRecordProcessor(processor);
        }
    }
    private void registerEndpoint(final Endpoint ep) {
        MBeanServer mbeanServer = .getValue().getMbeanServer();
        if (mbeanServer != null) {
            try {
                ManagedEndpoint jmxEndpoint = new ManagedEndpoint(mbeanServer);
                mbeanServer.registerMBean(jmxEndpoint.getName());
            } catch (final JMException ex) {
                .trace("Cannot register endpoint in JMX server"ex);
                .cannotRegisterEndpoint(.getShortName());
            }
        } else {
        }
    }
    private void unregisterEndpoint(final Endpoint ep) {
        MBeanServer mbeanServer = .getValue().getMbeanServer();
        if (mbeanServer != null) {
            try {
                mbeanServer.unregisterMBean(.getName());
            } catch (final JMException ex) {
                .trace("Cannot unregister endpoint from JMX server"ex);
                .cannotUnregisterEndpoint(.getShortName());
            }
        } else {
        }
    }
    private void registerRecordProcessor(final RecordProcessor processorfinal Endpoint ep) {
        MBeanServer mbeanServer = .getValue().getMbeanServer();
        if (mbeanServer != null) {
            try {
                mbeanServer.registerMBean(processor,
                        ObjectNameFactory.create(ep.getName() + ",recordProcessor=" + processor.getName()));
            } catch (final JMException ex) {
                .trace("Cannot register endpoint in JMX server, trying with the default ManagedRecordProcessor"ex);
                try {
                    mbeanServer.registerMBean(new ManagedRecordProcessor(processor),
                            ObjectNameFactory.create(ep.getName() + ",recordProcessor=" + processor.getName()));
                } catch (final JMException e) {
                    .cannotRegisterRecordProcessor();
                }
            }
        } else {
            .mBeanServerNotAvailable(processor);
        }
    }
    private void unregisterRecordProcessor(final RecordProcessor processorfinal Endpoint ep) {
        MBeanServer mbeanServer = .getValue().getMbeanServer();
        if (mbeanServer != null) {
            try {
                mbeanServer.unregisterMBean(ObjectNameFactory.create(ep.getName() + ",recordProcessor=" + processor.getName()));
            } catch (final JMException e) {
                .cannotUnregisterRecordProcessor();
            }
        } else {
            .mBeanServerNotAvailable(processor);
        }
    }
        return ;
    }
        return ;
    }
    }
    public static void install(final ServiceTarget serviceTargetfinal Endpoint endpointfinal DeploymentUnit unit) {
        final ServiceName serviceName = getServiceName(unitendpoint.getShortName());
        final String propContext = endpoint.getName().getKeyProperty(.);
        final String propEndpoint = endpoint.getName().getKeyProperty(.);
        final StringBuilder context = new StringBuilder(.).append("=").append(propContext);
        final EndpointService service = new EndpointService(endpointserviceName);
        final ServiceBuilder<Endpointbuilder = serviceTarget.addService(serviceNameservice);
        final ServiceName alias = ..append(context.toString()).append(propEndpoint);
        builder.addAliases(alias);
        builder.addDependency(.,
                SecurityDomainContext.classservice.getSecurityDomainContextInjector());
                service.getAbstractServerConfigInjector());
        if (..equals(endpoint.getType())) {
                    EJBViewMethodSecurityAttributesService.classservice.getEJBMethodSecurityAttributeServiceInjector());
        }
        builder.setInitialMode(.);
        builder.install();
        //add a dependency on the endpoint service to web deployments, so that the
        //endpoint servlet is not started before the endpoint is actually available
        unit.addToAttachmentList(.serviceName);
    }
    public static void uninstall(final Endpoint endpointfinal DeploymentUnit unit) {
        final ServiceName serviceName = getServiceName(unitendpoint.getShortName());
        final ServiceController<?> endpointService = currentServiceContainer().getService(serviceName);
        if (endpointService != null) {
            endpointService.setMode(.);
        }
    }
    private static String getDeploymentSecurityDomainName(final Endpoint ep) {
        JBossWebMetaData metadata = ep.getService().getDeployment().getAttachment(JBossWebMetaData.class);
        String metaDataSecurityDomain = metadata != null ? metadata.getSecurityDomain() : null;
        return metaDataSecurityDomain == null ? . : SecurityUtil
                .unprefixSecurityDomain(metaDataSecurityDomain.trim());
    }
    private static ServiceName getEJBViewMethodSecurityAttributesServiceName(final DeploymentUnit unitfinal Endpoint endpoint) {
        for (EJBEndpoint ep : ASHelper.getJaxwsEjbs(unit)) {
            if (ep.getClassName().equals(endpoint.getTargetBeanName())) {
                return ep.getEJBViewMethodSecurityAttributesService();
            }
        }
        return null;
    }

    
Returns the name of the endpoint services that are to be installed for a given deployment unit

Parameters:
unit
Returns:
    public static List<ServiceNamegetServiceNamesFromDeploymentUnit(final DeploymentUnit unit) {
        final List<ServiceNameendpointServiceNames = new ArrayList<ServiceName>();
        Deployment deployment = unit.getAttachment(.);
        for (Endpoint ep : deployment.getService().getEndpoints()) {
            endpointServiceNames.add(EndpointService.getServiceName(unitep.getShortName()));
        }
        return endpointServiceNames;
    }
    private static ServiceContainer currentServiceContainer() {
        if(System.getSecurityManager() == null) {
            return CurrentServiceContainer.getServiceContainer();
        }
        return AccessController.doPrivileged(.);
    }
New to GrepCode? Check out our FAQ X