Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
PETALS - PETALS Services Platform. Copyright (c) 2005 EBM Websourcing, http://www.ebmwebsourcing.com/ This library 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 library 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 library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ------------------------------------------------------------------------- $Id$ -------------------------------------------------------------------------
 
 
 package org.ow2.petals.component.framework.su;
 
 import java.io.File;
 import java.net.URL;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
 
 
 import static org.ow2.petals.component.framework.Constants.Component.AUTOGENERATED_ENDPOINT_NAME;
 import static org.ow2.petals.component.framework.Constants.Component.JBI_XML;
 import static org.ow2.petals.component.framework.Constants.Component.META_INF;

The common part of the ServiceUnitManager. It handles service units JBI descriptor during their deployment, life-cycle and undeployment.

Author(s):
ofabre - EBM Websourcing
alouis - EBM Websourcing
 
 public abstract class ServiceUnitManager implements javax.jbi.component.ServiceUnitManager {

    
The component's Logger
 
     protected Logger logger;

    
The service unit data handlers. Each service unit is linked to a datahandler. Key is the service unit name.
 
 
     protected final AbstractComponent component;

    
Creates a new instance of ServiceUnitManager

Parameters:
component
 
    public ServiceUnitManager(final AbstractComponent component) {
        super();
        this. = component;
        this. = component.getLogger();
    }
    /*
     * (non-Javadoc)
     * 
     * @see javax.jbi.component.ServiceUnitManager#init(java.lang.String,
     * java.lang.String)
     */
    public void init(final String serviceUnitNamefinal String suRootPath)
            throws DeploymentException {
        this..log(."init  serviceUnitName  " + serviceUnitName
                + "  serviceUnitRootPath " + suRootPath);
    }

    
    public String deploy(final String serviceUnitNamefinal String suRootPath)
            throws DeploymentException {
        if (this..getContext() == null) {
            // the component has not been initialized for the first time...
            throw new DeploymentException(
                    "Can not deploy a service unit on a component which has not been initialized");
        }
        this..log(."deploy  serviceUnitName  " + serviceUnitName
                + "serviceUnitRootPath" + suRootPath);
        final File jbiXmlFile = new File(suRootPath + . +  + .
                + );
        Jbi jbiDescriptor;
        try {
            final InputStream jbiInputStream = new FileInputStream(jbiXmlFile);
            try {
                jbiDescriptor = JBIDescriptorBuilder.buildJavaJBIDescriptor(jbiInputStream);
            } finally {
                try {
                    jbiInputStream.close();
                } catch (final IOException e) {
                    throw new DeploymentException(e);
                }
            }
        } catch (final CDKJBIDescriptorException e) {
            throw new DeploymentException(e);
        } catch (FileNotFoundException e) {
            throw new DeploymentException(e);
        }
        ServiceUnitDataHandler handler = null;
        try {
            if (this..getComponentConfiguration().getPropertiesFile() != null
                    && !StringHelper.isNullOrEmpty(this..getComponentConfiguration()
                            .getPropertiesFile().getValue())) {
                handler = new ServiceUnitDataHandler(serviceUnitNamesuRootPathjbiDescriptor,
                        this..getComponentConfiguration().getPropertiesFile().getValue());
            }
        } catch (PEtALSCDKException e1) {
            this.
                    .warning("Failed to initialize the SU parameters against the component properties file at '"
                            + this..getComponentConfiguration().getPropertiesFile()
                            + "'. Ignore the properties.");
        }
        if (handler == null) {
            handler = new ServiceUnitDataHandler(serviceUnitNamesuRootPathjbiDescriptor);
        }
        // validate the SU extensions if validator is available.
        // TODO : Deprecated when the component specific XSD validation
        // would be available
        if (this..getServiceUnitExtensionsValidator() != null) {
            try {
                this.validateExtensions(jbiDescriptor);
            } catch (final PEtALSCDKException e) {
                throw new DeploymentException(
                        "Failed to validate at least one SU extensions for SU " + serviceUnitName,
                        e);
            }
        }
        try {
            this.processConsumesNodes(handler);
        } catch (final JBIException ex) {
            throw new DeploymentException("Failed to process consumes nodes for SU "
                    + serviceUnitNameex);
        }
        // Now we can register the service unit
        synchronized (this.) {
            if (this..containsKey(serviceUnitName)) {
                throw new DeploymentException(
                        "A service unit with the given name is already registered : "
                                + serviceUnitName);
            } else {
                this.
                        .log(."Register a data handler for SU : " + serviceUnitName);
                this..put(serviceUnitNamehandler);
                // additional deployment by component implementation
                if (this..getServiceUnitListener() != null) {
                    try {
                        this..getServiceUnitListener().onSUDeployed(serviceUnitName,
                                suRootPathjbiDescriptor);
                    } catch (final Throwable e) {
                        // clean cache if any exception
                        this..log(."Unregister a data handler for SU : "
                                + serviceUnitName);
                        this..remove(serviceUnitName);
                        throw new DeploymentException(
                                "The ServiceUnit listener failed to process for SU "
                                        + serviceUnitNamee);
                    }
                }
            }
        }
        final String result = ManagementMessageUtil.getComponentTaskResult(this.
                .getContext().getComponentName(), "deploy",
                .);
        return result;
    }
    /*
     * (non-Javadoc)
     * 
     * @see javax.jbi.component.ServiceUnitManager#start(java.lang.String)
     */
    public void start(final String serviceUnitNamethrows DeploymentException {
        if (this..getContext() == null) {
            // the component has not been initialized for the first time...
            throw new DeploymentException(
                    "Can not start a service unit on a component which has not been initialized");
        }
        this..log(."start serviceUnitName  " + serviceUnitName);
        // No synchronization on serviceUnitDataHandlers is needed because
        // it's a ConcurrentMap
        final ServiceUnitDataHandler handler = this..get(serviceUnitName);
        try {
            this.processProvidesNodes(handler);
        } catch (final JBIException ex) {
            final String msg = "Failed to start SU " + serviceUnitName;
            this..log(.msgex);
            throw new DeploymentException(msgex);
        }
        // call the Service Unit Listener if any
        if (this..getServiceUnitListener() != null) {
            try {
                this..getServiceUnitListener().onSUStarted(serviceUnitName);
            } catch (final PEtALSCDKException e) {
                throw new DeploymentException("The ServiceUnit listener failed to process for SU "
                        + serviceUnitNamee);
            }
        }
    }
    /*
     * (non-Javadoc)
     * 
     * @see javax.jbi.component.ServiceUnitManager#stop(java.lang.String)
     */
    public void stop(final String serviceUnitNamethrows DeploymentException {
        if (this..getContext() == null) {
            // the component has not been initialized for the first time...
            throw new DeploymentException(
                    "Can not stop a service unit on a component which has not been initialized");
        }
        this..log(."stop  serviceUnitName  " + serviceUnitName);
        if (this..getServiceUnitListener() != null) {
            try {
                this..getServiceUnitListener().onSUStopped(serviceUnitName);
            } catch (final PEtALSCDKException e) {
                throw new DeploymentException("The ServiceUnit listener failed to process for SU "
                        + serviceUnitNamee);
            }
        }
    }
    /*
     * (non-Javadoc)
     * 
     * @see javax.jbi.component.ServiceUnitManager#shutDown(java.lang.String)
     */
    public void shutDown(final String serviceUnitNamethrows DeploymentException {
        // stop the providing of services for the given SU, as said in the JBI
        // specifications
        if (this..getContext() == null) {
            // the component has not been initialized for the first time...
            throw new DeploymentException(
                    "Can not shutdown a service unit on a component which has not been initialized");
        }
        this..log(."shutdown  serviceUnitName  " + serviceUnitName);
        try {
            // No synchronization on serviceUnitDataHandlers is needed because
            // it's a ConcurrentMap
            final ServiceUnitDataHandler handler = this.
                    .get(serviceUnitName);
            final Iterator<ServiceEndpointendpoints = handler.getServiceEndpoints().values()
                    .iterator();
            while (endpoints.hasNext()) {
                final ServiceEndpoint endpoint = endpoints.next();
                this..getContext().deactivateEndpoint(endpoint);
                // The endpoint removing must be done on the Iterator, not on
                // the Map.
                // Otherwise a ConcurrentModificationException will occurs when
                // shutdowning a SA containing a SU containing more than one
                // service.
                endpoints.remove();
            }
        } catch (final JBIException e) {
            throw new DeploymentException("Deactivate endpoint failed for SU " + serviceUnitNamee);
        }
    }
    /*
     * (non-Javadoc)
     * 
     * @see javax.jbi.component.ServiceUnitManager#undeploy(java.lang.String,
     * java.lang.String)
     */
    public String undeploy(final String serviceUnitNamefinal String serviceUnitRootPath)
            throws DeploymentException {
        if (this..getContext() == null) {
            // the component has not been initialized for the first time...
            throw new DeploymentException(
                    "Can not undeploy a service unit on a component which has not been initialized");
        }
        synchronized (this.) {
            final ServiceUnitDataHandler handler = this.
                    .get(serviceUnitName);
            if (handler != null) {
                try {
                    if (this..getServiceUnitListener() != null) {
                        this..getServiceUnitListener().onSUUndeployed(serviceUnitName,
                                serviceUnitRootPathhandler.getDescriptor());
                    }
                } catch (final PEtALSCDKException e) {
                    // instead of throwing an exception, return an error message
                    return ManagementMessageUtil.getComponentTaskResult(this..getContext()
                            .getComponentName(), "undeploy",
                            .,
                            ."ERROR",
                            "The ServiceUnit manager failed to process"new String[] {
                                    serviceUnitNameserviceUnitRootPath }, e.getMessage());
                } finally {
                    this..log(."Unregister a data handler for SU "
                            + serviceUnitName);
                    this..remove(serviceUnitName);
                }
        
                return ManagementMessageUtil.getComponentTaskResult(this..getContext()
                        .getComponentName(), "undeploy".);
            } else {
                return ManagementMessageUtil.getComponentTaskResult(this..getContext()
                        .getComponentName(), "undeploy".,
                        ."ERROR",
                        "The ServiceUnit manager failed to process"new String[] { serviceUnitName,
                                serviceUnitRootPath }, "Unknown service unit");
            }
        }
    }

    
Return all ServiceUnitDataHandlers as a Map

Returns:
all ServiceUnitDataHandlers as a Map
        return this.;
    }

    
Retrieve the Provides node that has activated the given jbi Endpoint

Parameters:
serviceEndpoint the previously activated jbi Endpoint
Returns:
the org.ow2.petals.component.framework.jbidescriptor.generated.Provides element
    public Provides getProvidesFromEndpoint(final ServiceEndpoint serviceEndpoint) {
        if (serviceEndpoint != null) {
            final ServiceEndpointKey serviceEndpointKey = new ServiceEndpointKey(serviceEndpoint
                    .getServiceName(), serviceEndpoint.getEndpointName());
            // No synchronization on serviceUnitDataHandlers is needed because
            // it's a ConcurrentMap
            for (final ServiceUnitDataHandler dataHandler : this..values()) {
                final Provides provides = dataHandler.getEpJBIDesc().get(serviceEndpointKey);
                if (provides != null) {
                    return provides;
                }
            }
        }
        return null;
    }

    
Retrieve the Consumes node matching the given destination information (endpoint name, service name, interface name). Search order is by ascending priority : endpointName, serviceName, interfaceName. If there are many consumes matching information, return the first one found.

Parameters:
endpointName an endpoint name, can be null
serviceName a service javax.xml.namespace.QName, can be null
interfaceName an interface javax.xml.namespace.QName, can be null
Returns:
the org.ow2.petals.component.framework.jbidescriptor.generated.Consumes element matching information, can be null
    public Consumes getConsumesFromDestination(final String endpointNamefinal QName serviceName,
            final QName interfaceName) {
        Consumes result = null;
        if (endpointName != null) {
            result = this.getConsumesForEndpoint(endpointName);
        }
        if (result == null) {
            if (serviceName != null) {
                result = this.getConsumesForService(serviceName);
            }
            if (result == null) {
                if (interfaceName != null) {
                    result = this.getConsumesForInterface(interfaceName);
                }
            }
        }
        return result;
    }

    
Retrieve the Service description (as DOM Document) of the given jbi Endpoint

Parameters:
serviceEndpoint the jbi Endpoint
Returns:
the service description as Dom Document
    public Document getServiceDescription(final ServiceEndpoint serviceEndpoint) {
        // No synchronization on serviceUnitDataHandlers is needed because
        // it's a ConcurrentMap
        for (ServiceUnitDataHandler dataHandler : this..values()) {
            Document serviceDescription = dataHandler.getEndpointDescription(serviceEndpoint);
            if (serviceDescription != null) {
                return serviceDescription;
            }
        }
        return null;
    }

    
Get the SU Data Handler matching the given Consumes/Provides service.

Parameters:
consumes The @ code Consumes} instance
Returns:
    public ServiceUnitDataHandler getSUDataHandlerForService(final Object service) {
        ServiceUnitDataHandler suDataHandler = null;
        if (service instanceof Consumes) {
            suDataHandler = this.getSUDataHandlerForConsumes((Consumesservice);
        } else if (service instanceof Provides) {
            suDataHandler = this.getSUDataHandlerForProvides((Providesservice);
        }
        return suDataHandler;
    }

    
Get the SU Data Handler matching the given Provides.

Parameters:
consumes The @ code Consumes} instance
Returns:
    public ServiceUnitDataHandler getSUDataHandlerForConsumes(final Consumes consumes) {
        // No synchronization on serviceUnitDataHandlers is needed because
        // it's a ConcurrentMap
        for (ServiceUnitDataHandler dataHandler : this..values()) {
            for (Consumes consumesElement : dataHandler.getDescriptor().getServices().getConsumes()) {
                if (consumes.equals(consumesElement)) {
                    return dataHandler;
                }
            }
        }
        return null;
    }

    
Get the SU Data Handler matching the given Consumes.

Parameters:
provides The @ code Provides} instance
Returns:
    public ServiceUnitDataHandler getSUDataHandlerForProvides(final Provides provides) {
        // No synchronization on serviceUnitDataHandlers is needed because
        // it's a ConcurrentMap
        for (ServiceUnitDataHandler dataHandler : this..values()) {
            for (Provides providesElement : dataHandler.getDescriptor().getServices().getProvides()) {
                if (provides.equals(providesElement)) {
                    return dataHandler;
                }
            }
        }
        return null;
    }

    
Search the wsdl description of the activated endpoint in the Provides extensions. If no wsdl description can be found, it creates a light weight Wsdl description from Provides Interface, Service and Endpoint names. No generation of endpoint is processed to know after the generated name to update the provides too.

Parameters:
wsdlLocation the location of the wsdl document. Can be null
provides the Provides node
Returns:
the WSDL description as DOM Document
Throws:
org.ow2.petals.component.framework.api.exception.PEtALSCDKException
    protected Document getWsdlDescription(final URL wsdlLocationfinal Provides provides)
            throws PEtALSCDKException {
        
        final Settableboolean wsdlImportsDownload = provides.getWsdlImportsDownload();
        boolean isWsdlImportsDownload = wsdlImportsDownload == null ? true : wsdlImportsDownload
                .isValue();
        
        if (wsdlLocation != null) {
            return WSDLHelper.createDocumentFromWSDL(wsdlLocation,
                    isWsdlImportsDownload);
        } else {
            // if the WSDL field is null, generate a basic WSDL
            return WSDLHelper.createLightWSDL20(provides.getInterfaceName(), provides
                    .getServiceName(), provides.getEndpointName());
        }
    }

    
Get the location of the wsdl file.

Parameters:
installRoot the root install used to search locally the file if needed
provides the provides read to get the wsdl file name
Returns:
the valid URL of the Wsdl file, or null
Throws:
org.ow2.petals.component.framework.api.exception.PEtALSCDKException
    protected URL getWsdlLocation(final String installRootfinal Provides provides)
            throws PEtALSCDKException {
        
        URL wsdlLocation = null;
        final String declaredWsdlPath = provides.getWsdl();
        if (StringHelper.isNullOrEmpty(declaredWsdlPath)) {
            wsdlLocation = null;
        }
        else {
            try {
                wsdlLocation = new URL(declaredWsdlPath);
            } catch (final MalformedURLException e) {
                // Can be a local file
                final File wsdlFile = new File(installRootdeclaredWsdlPath);
                if (!wsdlFile.exists()) {
                    // Try using the classloader
                    wsdlLocation = Thread.currentThread().getContextClassLoader().getResource(declaredWsdlPath);
                    if (wsdlLocation == null) {
                        throw new PEtALSCDKException("Can not retrieve WSDL document from location : "
                            + declaredWsdlPath);
                    }
                }
                else {
                    try {
                        wsdlLocation = wsdlFile.toURI().toURL();
                    } catch (final MalformedURLException e1) {
                        // not possible
                    }
                }
            }
        }
        return wsdlLocation;
    }
    
    
Process the interceptors for a consumes/provides service.

Parameters:
handler
service the Provides or Consumes service
Throws:
javax.jbi.JBIException
    protected void processInterceptors(final ServiceUnitDataHandler handlerfinal Object service)
            throws JBIException {
        SUInterceptors suInterceptors = null;
        if (service instanceof Consumes) {
            suInterceptors = ((Consumesservice).getSuInterceptors();
        } else if (service instanceof Provides) {
            suInterceptors = ((Providesservice).getSuInterceptors();
        }
        // create the manager for this extension element. Each element has a
        // linked manager with preloaded interceptors.
        final MessageInterceptorManager interceptorManager;
        if (this..getComponentConfiguration().getPropertiesFile() != null
                && !StringHelper.isNullOrEmpty(this..getComponentConfiguration()
                        .getPropertiesFile().getValue())) {
            interceptorManager = new MessageInterceptorManager(this.
                    .getComponentConfiguration().getPropertiesFile().getValue(), this.);
        } else {
            interceptorManager = new MessageInterceptorManager(this.);
        }
        List<SUInterceptorsendSUInterceptors = null;
        List<SUInterceptorsendResponseSUInterceptors = null;
        List<SUInterceptoracceptSUInterceptors = null;
        List<SUInterceptoracceptResponseSUInterceptors = null;
        if (suInterceptors != null) {
            if (suInterceptors.getSend() != null) {
                sendSUInterceptors = suInterceptors.getSend().getInterceptor();
            }
            if (suInterceptors.getSendResponse() != null) {
                sendResponseSUInterceptors = suInterceptors.getSendResponse().getInterceptor();
            }
            if (suInterceptors.getAccept() != null) {
                acceptSUInterceptors = suInterceptors.getAccept().getInterceptor();
            }
            if (suInterceptors.getAcceptResponse() != null) {
                acceptResponseSUInterceptors = suInterceptors.getAcceptResponse().getInterceptor();
            }
        }
        interceptorManager.init(this..getInterceptors(), acceptSUInterceptors,
                sendSUInterceptorsacceptResponseSUInterceptorssendResponseSUInterceptors);
        handler.addMessageInterceptorManager(serviceinterceptorManager);
    }

    

Parameters:
handler
Throws:
javax.jbi.JBIException
    protected void processConsumesNodes(final ServiceUnitDataHandler handlerthrows JBIException {
        final Jbi descriptor = handler.getDescriptor();
        final List<ConsumesconsumesList = descriptor.getServices().getConsumes();
        for (final Consumes consumes : consumesList) {
            this.processInterceptors(handlerconsumes);
        }
    }

    
Process the given provides node.

Parameters:
handler
provides
Returns:
The resulted Service Endpoint
Throws:
javax.jbi.JBIException
            final Provides providesthrows JBIException {
        final URL wsdlLocation = this.getWsdlLocation(handler.getInstallRoot(),
                provides);
        final Document wsdlDescription = this.getWsdlDescription(wsdlLocationprovides);
        
        String endpointName = provides.getEndpointName();
        
        if (.equals(endpointName)) {
            endpointName = IDGenerator.getInstance().getNewID();
            // update the provides object to set the real endpoint
            provides.setEndpointName(endpointName);
            final File jbiXmlFile = new File(handler.getInstallRoot() + . + 
                    + . + );
            
            // If the wsdl is loaded from a Jar file we must externalized the
            // WSDL
            URL locationToSaveWSDL;
            if ("jar".equals(wsdlLocation.getProtocol())) {
                // WSDL loaded from a JAR File
                final String filename = new File(wsdlLocation.getFile()).getName();
                try {
                    locationToSaveWSDL = new File(handler.getInstallRoot(), filename).toURI()
                            .toURL();
                    provides.setWsdl(filename);
                } catch (final MalformedURLException e1) {
                    this..log(."The following error has not to occur"e1);
                    locationToSaveWSDL = wsdlLocation;
                }
            } else {
                locationToSaveWSDL = wsdlLocation;
            }
            
            // update the descriptor of the SU to set the real endpoint
            // then, if the SU is restarted, the real endpoint is
            // used
            try {
                JBIDescriptorBuilder.buildXmlJBIdescriptor(handler.getDescriptor(),
                        new FileOutputStream(jbiXmlFile));
            } catch (FileNotFoundException e) {
                throw new JBIException("Failed to persist the auto-generated endpoint name"e);
            } catch (CDKJBIDescriptorException e) {
                throw new JBIException("Failed to persist the auto-generated endpoint name"e);
            }
            
            // Update WSDL to set the endpoint name
            this.updateWSDLWithEndpointName(wsdlDescriptionprovides.getServiceName(),
                    endpointName);
            
            // Save the updated WSDL
            if (wsdlLocation != null) {
                
                try {
                    final File wsdlSavedFile = new File(locationToSaveWSDL.getFile());
                    final OutputStream wsdlOutputStream = new FileOutputStream(wsdlSavedFile);
                    try {
                        WSDLHelper.saveWSDLImports(wsdlDescriptionwsdlSavedFile.getParentFile());
                        WSDLHelper.printWSDL(WSDLHelper.removeImportedDocuments(wsdlDescription), wsdlOutputStream);
                        
                    } finally {
                        wsdlOutputStream.close();
                    }
                } catch (final FileNotFoundException e) {
                    this..severe("Unable to persist updated service description (WSDL) '"
                            + locationToSaveWSDL + "' (" + e.getMessage() + ").");
                } catch (final IOException e) {
                    this..severe("Unable to persist updated service description (WSDL) '"
                            + locationToSaveWSDL + "' (" + e.getMessage() + ").");
                }
                
            }
        }
        handler.addEndpointDescription(provides.getServiceName(), endpointNamewsdlDescription);
        handler.addJBIDescription(provides.getServiceName(), endpointNameprovides);
        final ServiceEndpoint ep = this..getContext().activateEndpoint(
                provides.getServiceName(), endpointName);
        handler.addServiceEndpoint(ep);
        
        this.processInterceptors(handlerprovides);
        return ep;
    }
    
    private void updateWSDLWithEndpointName(final Document wsdlfinal QName service,
            final String newEndpointName) {
        final Element rootElement = wsdl.getDocumentElement();
        // Retrieve the service
        final NodeList services = rootElement.getElementsByTagNameNS(
                "http://schemas.xmlsoap.org/wsdl/""service");
        if (services.getLength() > 0) {
            for (int i = 0; i < services.getLength(); i++) {
                final Element serviceElement = (Elementservices.item(i);
                if (serviceElement.getAttribute("name").equals(service.getLocalPart())) {
                    // Retrieve the endpoint name to update the first one.
                    final NodeList endpoints = serviceElement.getElementsByTagNameNS(
                            "http://schemas.xmlsoap.org/wsdl/""port");
                    if (endpoints.getLength() > 0) {
                        ((Elementendpoints.item(0)).setAttribute("name"newEndpointName);
                    }
                    break;
                }
            }
        }
    }

    

Parameters:
handler
Throws:
javax.jbi.JBIException
    protected void processProvidesNodes(final ServiceUnitDataHandler handlerthrows JBIException {
        final Jbi descriptor = handler.getDescriptor();
        final List<ProvidesprovidesList = descriptor.getServices().getProvides();
        for (final Provides provides : providesList) {
            ServiceEndpoint sep = this.processProvidesNode(handlerprovides);
            this..log(."New Service Endpoint has been deployed : " + sep);
        }
    }

    
Validate the SU extensions.

Parameters:
descriptor the service unit descriptor
Throws:
org.ow2.petals.component.framework.api.exception.PEtALSCDKException if at least an extension block is not valid. It is the role of the developer to specify which extension is not valid.
    protected void validateExtensions(final Jbi descriptorthrows PEtALSCDKException {
        // validate the provides
        // TODO : Deprecated when the component specific XSD validation would be
        // available
        final List<ProvidesprovidesList = descriptor.getServices().getProvides();
        for (final Provides provides : providesList) {
                    new ConfigurationExtensions(provides.getAny()));
        }
        // validate the consumes
        // TODO : Deprecated when the component specific XSD validation would be
        // available
        final List<ConsumesconsumesList = descriptor.getServices().getConsumes();
        for (final Consumes consumes : consumesList) {
                    new ConfigurationExtensions(consumes.getAny()));
        }
    }

    
Retrieve the install root of the Service Unit that has activated the given endpoint

Parameters:
endpoint The activated endpoint
Returns:
the Service unit install root
    protected String getSUInstallRootForActivatedEp(final ServiceEndpoint endpoint) {
        return this.getSUDataHandlerForEndpoint(endpoint).getInstallRoot();
    }

    
Retrieve the data handler of the Service Unit that has activated the given endpoint.

Parameters:
endpoint the
Returns:
the ServiceUnitDataHandler
        final ServiceEndpointKey key = new ServiceEndpointKey(endpoint.getServiceName(), endpoint
                .getEndpointName());
        // No synchronization on serviceUnitDataHandlers is needed because
        // it's a ConcurrentMap
        for (final ServiceUnitDataHandler dataHandler : this..values()) {
            for (final ServiceEndpointKey k : dataHandler.getEpJBIDesc().keySet()) {
                if (key.equals(k)) {
                    return dataHandler;
                }
            }
        }
        return null;
    }

    
Get the consumes matching the given endpoint name.

Parameters:
serviceName The endpoint name to match
Returns:
The Consumes instance if matched, @ null} otherwise
    public Consumes getConsumesForEndpoint(final String endpointName) {
        // No synchronization on serviceUnitDataHandlers is needed because
        // it's a ConcurrentMap
        for (ServiceUnitDataHandler dataHandler : .values()) {
            for (Consumes consumes : dataHandler.getDescriptor().getServices().getConsumes()) {
                if (endpointName.equals(consumes.getEndpointName())) {
                    return consumes;
                }
            }
        }
        return null;
    }

    
Get the consumes matching the given service name.

Parameters:
serviceName The service qualified name to match
Returns:
The Consumes instance if matched, @ null} otherwise
    public Consumes getConsumesForService(final QName serviceName) {
        // No synchronization on serviceUnitDataHandlers is needed because
        // it's a ConcurrentMap
        for (ServiceUnitDataHandler dataHandler : .values()) {
            for (Consumes consumes : dataHandler.getDescriptor().getServices().getConsumes()) {
                if (serviceName.equals(consumes.getServiceName())) {
                    return consumes;
                }
            }
        }
        return null;
    }

    
Get the consumes matching the given service name.

Parameters:
serviceName The service qualified name to match
Returns:
The Consumes instance if matched, @ null} otherwise
    public Consumes getConsumesForInterface(final QName interfaceName) {
        // No synchronization on serviceUnitDataHandlers is needed because
        // it's a ConcurrentMap
        for (ServiceUnitDataHandler dataHandler : .values()) {
            for (Consumes consumes : dataHandler.getDescriptor().getServices().getConsumes()) {
                if (interfaceName.equals(consumes.getInterfaceName())) {
                    return consumes;
                }
            }
        }
        return null;
    }

    
Get the set of endpoints exposed by the given Service Unit.

Parameters:
serviceUnitName The name of the Service Unit
Returns:
a set of ServiceEndpoint
    public Set<ServiceEndpointgetEndpointsForServiceUnit(final String serviceUnitName) {
        // No synchronization on serviceUnitDataHandlers is needed because
        // it's a ConcurrentMap
        final Set<ServiceEndpointresult = new HashSet<ServiceEndpoint>();
        for (final ServiceEndpointKey key : this..get(serviceUnitName)
                .getServiceEndpoints().keySet()) {
            result.add(this..get(serviceUnitName).getServiceEndpoints().get(
                    key));
        }
        return result;
    }
New to GrepCode? Check out our FAQ X