Package org.servicemix.components.xbean

Examples of org.servicemix.components.xbean.EndpointSpec


    private Map xfServices = new ConcurrentHashMap();
   
    public XFireServiceUnit(XFireComponent component, String serviceUnitName, String serviceUnitRootPath) throws Exception {
        super(component, serviceUnitName, serviceUnitRootPath);
        for (Iterator iter = services.iterator(); iter.hasNext();) {
            EndpointSpec es = (EndpointSpec) iter.next();
            Service svc = component.getFactory().create(es.getPojo().getClass());
            component.getXFire().getServiceRegistry().register(svc);
            component.getXFire().getTransportManager().disableAll(svc.getName());
            Transport jbiT = component.getXFire().getTransportManager().getTransport(JbiTransport.JBI_BINDING);
            component.getXFire().getTransportManager().enable(jbiT, svc.getName());
           
            QName serviceName = svc.getServiceInfo().getName();
            String endpointName = null;
           
            if (es.getServiceName() == null) {
                es.setServiceName(serviceName);
            } else if (!es.getServiceName().equals(serviceName)) {
                logger.warn("The service name defined in the wsdl (" + serviceName +
                            ") does not match the service name defined in the endpoint spec (" + es.getServiceName() +
                            "). WSDL description may be unusable.");
            }
           
            // put service description
            try {
                SourceTransformer st = new SourceTransformer();
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                component.getXFire().generateWSDL(svc.getName(), baos);
                Node node = st.toDOMNode(new StreamSource(new ByteArrayInputStream(baos.toByteArray())));
                Definition d = WSDLFactory.newInstance().newWSDLReader().readWSDL(null, (Document) node);
                javax.wsdl.Service service = d.getService(serviceName);
                if (service != null) {
                    if (service.getPorts().values().size() == 1) {
                        endpointName = ((Port) service.getPorts().values().iterator().next()).getName();
                        // Check if this is the same as defined in endpoint spec
                        if (es.getEndpointName() == null) {
                            es.setEndpointName(endpointName);
                        } else if (!es.getEndpointName().equals(endpointName)) {
                            logger.warn("The endpoint name defined in the wsdl (" + endpointName +
                                    ") does not match the endpoint name defined in the endpoint spec (" + es.getEndpointName() +
                            "). WSDL description may be unusable.");
                        }
                    }
                }
                if (es.getEndpointName() == null) {
                    throw new IllegalArgumentException("endpointName should be provided on the endpointSpec");
                }
                component.setServiceDescription(es.getServiceName(), es.getEndpointName(), (Document) node);
                if (logger.isDebugEnabled()) {
                    logger.debug("WSDL: " + st.toString(node));
                }
            } catch (Exception e) {
                logger.warn("Could not set endpoint description", e);
View Full Code Here


    private static final Log logger = LogFactory.getLog(JAXWSServiceUnit.class);
   
    public JAXWSServiceUnit(AbstractComponent component, String serviceUnitName, String serviceUnitRootPath) throws Exception {
        super(component, serviceUnitName, serviceUnitRootPath);
        for (Iterator iter = services.iterator(); iter.hasNext();) {
            EndpointSpec es = (EndpointSpec) iter.next();
            RuntimeEndpointInfo rtEndpointInfo = new RuntimeEndpointInfo();
            rtEndpointInfo.setImplementor(es.getPojo());
            rtEndpointInfo.setImplementorClass(es.getPojo().getClass());
            rtEndpointInfo.setBinding(BindingImpl.getBinding(null, es.getPojo().getClass(), false));
            rtEndpointInfo.init();
            rtEndpointInfo.setWebServiceContext(new WebServiceContextImpl());
            rtEndpointInfo.injectContext();
            QName serviceName = rtEndpointInfo.getServiceName();
            String endpointName = rtEndpointInfo.getPortName().getLocalPart();
            if (es.getServiceName() == null) {
                es.setServiceName(serviceName);
            } else if (!es.getServiceName().equals(serviceName)) {
                logger.warn("The service name defined in the wsdl (" + serviceName +
                            ") does not match the service name defined in the endpoint spec (" + es.getServiceName() +
                            "). WSDL description may be unusable.");
            }
            if (es.getEndpointName() == null) {
                es.setEndpointName(endpointName);
            } else if (!es.getEndpointName().equals(endpointName)) {
                logger.warn("The endpoint name defined in the wsdl (" + endpointName +
                            ") does not match the endpoint name defined in the endpoint spec (" + es.getEndpointName() +
                            "). WSDL description may be unusable.");
            }
            if (rtEndpointInfo.needWSDLGeneration()) {
                rtEndpointInfo.generateWSDL();
            }
            // put service description
            try {
                SourceTransformer st = new SourceTransformer();
                Map<String, DocInfo> docs = rtEndpointInfo.getDocMetadata();
                Set<Entry<String, DocInfo>> entries = docs.entrySet();
                for (Entry<String, DocInfo> entry : entries) {
                    DocInfo docInfo = (DocInfo)entry.getValue();
                    DOC_TYPE docType = docInfo.getDocType();
                    if (docType == DOC_TYPE.WSDL) {
                        Node node = st.toDOMNode(new StreamSource(docInfo.getDoc()));
                        component.setServiceDescription(es.getServiceName(), es.getEndpointName(), (Document) node);
                        if (logger.isDebugEnabled()) {
                            logger.debug("WSDL: " + st.toString(node));
                        }
                    }
                }
View Full Code Here

    }

    @Override
    public void start() throws JBIException {
        for (Iterator iter = services.iterator(); iter.hasNext();) {
            EndpointSpec es = (EndpointSpec) iter.next();
            RuntimeEndpointInfo rtEndpointInfo = rtEndpointInfos.get(getKey(es));
            // start service
            rtEndpointInfo.beginService();
        }
        // activate endpoints
View Full Code Here

TOP

Related Classes of org.servicemix.components.xbean.EndpointSpec

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.