Package org.apache.cxf.service

Examples of org.apache.cxf.service.Service


                    val = ep.getEndpointInfo().getBinding().getProperty(key);
                }

            }
            if (val == null) {
                Service sv = ex.get(Service.class);
                if (sv != null) {
                    val = sv.get(key);
                }
                if (val == null) {
                    Bus bus = ex.get(Bus.class);
                    if (bus != null) {
                        val = bus.getProperty(key);
View Full Code Here


        }
        return endedHeader;
    }      
   
    protected DataWriter<XMLStreamWriter> getDataWriter(Message message) {
        Service service = ServiceModelUtil.getService(message.getExchange());
        DataWriter<XMLStreamWriter> dataWriter = service.getDataBinding().createWriter(XMLStreamWriter.class);
        if (dataWriter == null) {
            throw new Fault(new org.apache.cxf.common.i18n.Message("NO_DATAWRITER", BUNDLE, service
                .getName()));
        }
        dataWriter.setAttachments(message.getAttachments());
        setDataWriterValidation(service, message, dataWriter);
        return dataWriter;
View Full Code Here

       
        if (null == cr) {
            LOG.log(Level.WARNING, "NO_COUNTER_REPOSITORY");
            return;
        } else {
            Service service = ex.get(Service.class);           
            Endpoint endpoint = ex.get(Endpoint.class);
           
            String serviceName = "\"" + escapePatternChars(service.getName().toString()) + "\"";           
            String portName = "\"" + endpoint.getEndpointInfo().getName().getLocalPart() + "\"";
           
            OperationInfo opInfo = ex.get(OperationInfo.class);
            String operationName = opInfo == null ? null : "\"" + opInfo.getName().getLocalPart() + "\"";
           
View Full Code Here

     * @param server the server.
     * @return the definition.
     * @throws WSDLException
     */
    public Definition getWSDLDefinition(Server server) throws WSDLException {
        Service service = server.getEndpoint().getService();

        ServiceWSDLBuilder wsdlBuilder = new ServiceWSDLBuilder(bus, service.getServiceInfos().get(0));
        wsdlBuilder.setUseSchemaImports(false);
        return wsdlBuilder.build();
    }
View Full Code Here

    }

    public Server getServerForService(QName serviceName) throws WSDLException {
        ServerRegistry svrMan = bus.getExtension(ServerRegistry.class);
        for (Server s : svrMan.getServers()) {
            Service svc = s.getEndpoint().getService();
            if (svc.getName().equals(serviceName)) {
                return s;
            }
        }
        return null;
    }
View Full Code Here

       
        if (endpointName != null) {
            serviceFactory.setEndpointName(endpointName);   
        }
       
        Service service = serviceFactory.getService();
       
        if (service == null) {
            initializeServiceFactory();
            service = serviceFactory.create();
        }
       
        if (endpointName == null) {
            endpointName = serviceFactory.getEndpointName();
        }
        EndpointInfo ei = service.getEndpointInfo(endpointName);
       
        if (ei != null) {
            if (transportId != null
                && !ei.getTransportId().equals(transportId)) {
                ei = null;
            } else {
                BindingFactoryManager bfm = getBus().getExtension(BindingFactoryManager.class);
                bindingFactory = bfm.getBindingFactory(ei.getBinding().getBindingId());
            }
        }
       
        if (ei == null) {
            if (getAddress() == null) {
                ei = ServiceModelUtil.findBestEndpointInfo(serviceFactory.getInterfaceName(), service
                    .getServiceInfos());
            }
            if (ei == null && !serviceFactory.isPopulateFromClass()) {
                ei = ServiceModelUtil.findBestEndpointInfo(serviceFactory.getInterfaceName(), service
                                                           .getServiceInfos());

                if (ei != null) {
                    BindingFactoryManager bfm = getBus().getExtension(BindingFactoryManager.class);
                    bindingFactory = bfm.getBindingFactory(ei.getBinding().getBindingId());
                }

                if (ei == null) {
                    LOG.warning("Could not find endpoint/port for "
                                + endpointName + " in wsdl. Creating default.");
                } else if (!ei.getName().equals(endpointName)) {
                    LOG.warning("Could not find endpoint/port for "
                                + endpointName + " in wsdl. Using "
                                + ei.getName() + ".");                       
                }
            }
            if (ei == null) {
                ei = createEndpointInfo(null);
            } else if (transportId != null
                    && !ei.getTransportId().equals(transportId)) {
                LOG.warning("Transport for endpoint/port "
                    + endpointName + " in wsdl doesn't match " + transportId + ".");
                BindingInfo bi = ei.getBinding();
                ei = createEndpointInfo(bi);
            } else if (getAddress() != null) {
                ei.setAddress(getAddress());
                if (ei.getAddress().startsWith("camel")
                        || ei.getAddress().startsWith("local")) {
                    modifyTransportIdPerAddress(ei);
                }
               
            }
        } else if (getAddress() != null) {
            ei.setAddress(getAddress());
        }

        if (publishedEndpointUrl != null && !"".equals(publishedEndpointUrl)) {
            ei.setProperty("publishedEndpointUrl", publishedEndpointUrl);
        }
       
        if (endpointReference != null) {
            ei.setAddress(endpointReference);
        }
        Endpoint ep = service.getEndpoints().get(ei.getName());
       
        if (ep == null) {
            ep = serviceFactory.createEndpoint(ei);
            ((EndpointImpl)ep).initializeActiveFeatures(getFeatures());
        } else {
            serviceFactory.setEndpointName(ei.getName());
            if (ep.getActiveFeatures() == null) {
                ((EndpointImpl)ep).initializeActiveFeatures(getFeatures());
            }
        }
       
        if (properties != null) {
            ep.putAll(properties);
        }
       
        service.getEndpoints().put(ep.getEndpointInfo().getName(), ep);
       
        if (getInInterceptors() != null) {
            ep.getInInterceptors().addAll(getInInterceptors());
            ep.getInInterceptors().add(WSDLGetInterceptor.INSTANCE);
        }
View Full Code Here

            && getAddress().startsWith("jms:") && !"jms://".equals(getAddress())) {
            // Set the transportId to be soap over jms transport
            transportId = SoapJMSConstants.SOAP_JMS_SPECIFICIATION_TRANSPORTID;
        }
        // Get the Service from the ServiceFactory if specified
        Service service = serviceFactory.getService();
        if (bindingInfo == null) {
            // SOAP nonsense
            bindingInfo = createBindingInfo();
            if (bindingInfo instanceof SoapBindingInfo
                && (((SoapBindingInfo) bindingInfo).getTransportURI() == null
                || LocalTransportFactory.TRANSPORT_ID.equals(transportId))) {
                ((SoapBindingInfo) bindingInfo).setTransportURI(transportId);
                transportId = "http://schemas.xmlsoap.org/wsdl/soap/";
            }
            service.getServiceInfos().get(0).addBinding(bindingInfo);
        }
        if (transportId == null) {
            if (bindingInfo instanceof SoapBindingInfo) {
                transportId = ((SoapBindingInfo)bindingInfo).getTransportURI();
            }
            if (transportId == null
                && getAddress() != null
                && getAddress().contains("://")) {
                transportId = detectTransportIdFromAddress(getAddress());
            }
            if (transportId == null) {
                transportId = "http://schemas.xmlsoap.org/wsdl/http/";
            }
        }

        setTransportId(transportId);
       
        WSDLEndpointFactory wsdlEndpointFactory = getWSDLEndpointFactory();
        EndpointInfo ei;
        if (wsdlEndpointFactory != null) {
            ei = wsdlEndpointFactory.createEndpointInfo(service.getServiceInfos().get(0), bindingInfo, null);
            ei.setTransportId(transportId);
        } else {
            ei = new EndpointInfo(service.getServiceInfos().get(0), transportId);
        }
        int count = 1;
        while (service.getEndpointInfo(endpointName) != null) {
            endpointName = new QName(endpointName.getNamespaceURI(),
                                     endpointName.getLocalPart() + count);
            count++;
        }
        ei.setName(endpointName);
        ei.setAddress(getAddress());
        ei.setBinding(bindingInfo);
       
        if (wsdlEndpointFactory != null) {
            wsdlEndpointFactory.createPortExtensors(ei, service);
        }
        service.getServiceInfos().get(0).addEndpoint(ei);
       
        serviceFactory.sendEvent(FactoryBeanListener.Event.ENDPOINTINFO_CREATED, ei);
        return ei;
    }
View Full Code Here

        LOG.log(Level.FINE, "Creating client from WSDL " + wsdlUrl);

        WSDLServiceFactory sf = (service == null)
            ? (new WSDLServiceFactory(bus, wsdlUrl)) : (new WSDLServiceFactory(bus, wsdlUrl, service));
        sf.setAllowElementRefs(allowRefs);
        Service svc = sf.create();

        ClientImpl client = new ClientImpl(bus, svc, port,
                                           getEndpointImplFactory());

        //all SI's should have the same schemas
        SchemaCollection schemas = svc.getServiceInfos().get(0).getXmlSchemaCollection();

        SchemaCompiler compiler = createSchemaCompiler();
       
        InnerErrorListener listener = new InnerErrorListener(wsdlUrl);
        Object elForRun = ReflectionInvokationHandler
            .createProxyWrapper(listener,
                                JAXBUtils.getParamClass(compiler, "setErrorListener"));
       
        compiler.setErrorListener(elForRun);
       
        OASISCatalogManager catalog = bus.getExtension(OASISCatalogManager.class);
        hackInNewInternalizationLogic(compiler, catalog);

        addSchemas(compiler.getOptions(), compiler, svc.getServiceInfos(), schemas);
        addBindingFiles(bindingFiles, compiler);
        S2JJAXBModel intermediateModel = compiler.bind();
       
        listener.throwException();
       
        JCodeModel codeModel = intermediateModel.generateCode(null, elForRun);
        StringBuilder sb = new StringBuilder();
        boolean firstnt = false;

        for (Iterator<JPackage> packages = codeModel.packages(); packages.hasNext();) {
            JPackage jpackage = packages.next();
            if (!isValidPackage(jpackage)) {
                continue;
            }
            if (firstnt) {
                sb.append(':');
            } else {
                firstnt = true;
            }
            sb.append(jpackage.name());
        }
        JAXBUtils.logGeneratedClassNames(LOG, codeModel);
       
        String packageList = sb.toString();

        // our hashcode + timestamp ought to be enough.
        String stem = toString() + "-" + System.currentTimeMillis();
        File src = new File(tmpdir, stem + "-src");
        if (!src.mkdir()) {
            throw new IllegalStateException("Unable to create working directory " + src.getPath());
        }
        try {
            Object writer = JAXBUtils.createFileCodeWriter(src);
            codeModel.build(writer);
        } catch (Exception e) {
            throw new IllegalStateException("Unable to write generated Java files for schemas: "
                                            + e.getMessage(), e);
        }
        File classes = new File(tmpdir, stem + "-classes");
        if (!classes.mkdir()) {
            throw new IllegalStateException("Unable to create working directory " + classes.getPath());
        }
        StringBuilder classPath = new StringBuilder();
        try {
            setupClasspath(classPath, classLoader);
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
       
        List<File> srcFiles = FileUtils.getFilesRecurse(src, ".+\\.java$");
        if (!compileJavaSrc(classPath.toString(), srcFiles, classes.toString())) {
            LOG.log(Level.SEVERE , new Message("COULD_NOT_COMPILE_SRC", LOG, wsdlUrl).toString());
        }
        FileUtils.removeDir(src);
        URL[] urls = null;
        try {
            urls = new URL[] {classes.toURI().toURL()};
        } catch (MalformedURLException mue) {
            throw new IllegalStateException("Internal error; a directory returns a malformed URL: "
                                            + mue.getMessage(), mue);
        }
        ClassLoader cl = ClassLoaderUtils.getURLClassLoader(urls, classLoader);

        JAXBContext context;
        Map<String, Object> contextProperties = jaxbContextProperties;
       
        if (contextProperties == null) {
            contextProperties = Collections.emptyMap();
        }
       
        try {
            if (StringUtils.isEmpty(packageList)) {
                context = JAXBContext.newInstance(new Class[0], contextProperties);
            } else {
                context = JAXBContext.newInstance(packageList, cl, contextProperties);
            }
        } catch (JAXBException jbe) {
            throw new IllegalStateException("Unable to create JAXBContext for generated packages: "
                                            + jbe.getMessage(), jbe);
        }
        
        JAXBDataBinding databinding = new JAXBDataBinding();
        databinding.setContext(context);
        svc.setDataBinding(databinding);

        ServiceInfo svcfo = client.getEndpoint().getEndpointInfo().getService();

        // Setup the new classloader!
        ClassLoaderUtils.setThreadContextClassloader(cl);
View Full Code Here

                        faultOccurred = true;
                                           
                        StringBuilder description = new StringBuilder();
                        if (message.getExchange() != null) {
                            Exchange exchange = message.getExchange();
                            Service service = exchange.get(Service.class);
                            if (service != null) {
                                description.append('\'');
                                description.append(service.getName());
                                OperationInfo opInfo = exchange.get(OperationInfo.class);
                                if (opInfo != null) {
                                    description.append("#").append(opInfo.getName());
                                }
                                description.append("\' ");
View Full Code Here

            }
        }
        if (faultWanted == null) {
            return;
        }
        Service s = msg.getExchange().get(Service.class);
        DataBinding dataBinding = s.getDataBinding();

        Object e = null;
        if (isDOMSupported(dataBinding)) {
            DataReader<Node> reader = this.getNodeDataReader(msg);
            reader.setProperty(DataReader.FAULT, fault);
View Full Code Here

TOP

Related Classes of org.apache.cxf.service.Service

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.