public QName getServiceQName() { return getServiceQName(true); } public QName getServiceQName(boolean lookup) {
public void reset() { if (!dataBindingSet) { setDataBinding(null); } setService(null); }
public Endpoint createEndpoint(EndpointInfo ei) throws EndpointException { Endpoint ep = new EndpointImpl(getBus(), getService(), ei); sendEvent(Event.ENDPOINT_CREATED, ei, ep, getServiceClass()); return ep; }
protected boolean isFromWsdl() { return !populateFromClass && getWsdlURL() != null && !isEmptywsdl(getWsdlURL()); }
protected void buildServiceFromClass() { Object o = getBus().getProperty("requireExplicitContractLocation"); if (o != null && ("true".equals(o) || Boolean.TRUE.equals(o))) { throw new ServiceConstructionException(new Message("NO_WSDL_PROVIDED", LOG, getServiceClass().getName())); LOG.info("Creating Service " + getServiceQName() + " from class " + getServiceClass().getName()); if (Proxy.isProxyClass(this.getServiceClass())) { LOG.log(Level.WARNING, "USING_PROXY_FOR_SERVICE", getServiceClass()); sendEvent(Event.CREATE_FROM_CLASS, getServiceClass()); col.getXmlSchemaCollection().setSchemaResolver(new CatalogXmlSchemaURIResolver(this.getBus())); col.getExtReg().registerSerializer(MimeAttribute.class, new MimeSerializer()); setService(service); setServiceProperties(); serviceInfo.setName(getServiceQName()); serviceInfo.setTargetNamespace(serviceInfo.getName().getNamespaceURI()); sendEvent(Event.SERVICE_SET, getService()); createInterface(serviceInfo); Set<?> wrapperClasses = this.getExtraClass(); for (ServiceInfo si : getService().getServiceInfos()) { if (wrapperClasses != null && !wrapperClasses.isEmpty()) {
protected void buildServiceFromWSDL(String url) { sendEvent(Event.CREATE_FROM_WSDL, url); LOG.info("Creating Service " + getServiceQName() + " from WSDL: " + url); WSDLServiceFactory factory = new WSDLServiceFactory(getBus(), url, getServiceQName()); boolean setEPName = true; if (features != null) { factory.setEndpointName(getEndpointName(false)); sendEvent(Event.WSDL_LOADED, factory.getDefinition()); setService(factory.create()); setServiceProperties(); sendEvent(Event.SERVICE_SET, getService()); EndpointInfo epInfo = getEndpointInfo(); if (epInfo != null) { serviceConfigurations.add(new WSDLBasedServiceConfiguration(getEndpointInfo().getBinding())); initializeWSDLOperations(); Set<Class<?>> cls = getExtraClass(); if (cls != null && !cls.isEmpty()) { for (ServiceInfo si : getService().getServiceInfos()) { si.setProperty(EXTRA_CLASS, cls); initializeDataBindings();
protected void initializeServiceModel() { if (isFromWsdl()) { buildServiceFromWSDL(getWsdlURL()); } else if (getServiceClass() != null) { buildServiceFromClass(); } else { throw new ServiceConstructionException(new Message("NO_WSDL_NO_SERVICE_CLASS_PROVIDED", LOG, getWsdlURL())); } if (isValidate()) { validateServiceModel(); } }
sf.setAddress(address); if (getDataBinding() != null && getDataBinding() instanceof AegisDatabinding) { sf.getServiceFactory().setDataBinding(getDataBinding()); } else { sf.getServiceFactory().setDataBinding(new AegisDatabinding()); sf.getServiceFactory().setPopulateFromClass(true); sf.setStart(false); if (isUseJBIWrapper()) { server.getEndpoint().getOutInterceptors().add(new AttachmentOutInterceptor()); if (sf.getServiceFactory().getServiceQName() != null) { if (getPojoService() == null) { setPojoService(sf.getServiceFactory().getServiceQName()); setService(sf.getServiceFactory().getServiceQName()); if (sf.getServiceFactory().getEndpointInfo().getName() != null) { if (getPojoEndpoint() == null) { setPojoEndpoint(sf.getServiceFactory().getEndpointInfo().getName()); setEndpoint(sf.getServiceFactory().getEndpointInfo().getName().getLocalPart()); if (sf.getServiceFactory().getInterfaceName() != null) { setPojoInterfaceName(sf.getServiceFactory().getInterfaceName()); if (getInterfaceName() == null) { setInterfaceName(sf.getServiceFactory().getInterfaceName());
protected InterfaceInfo createInterface(ServiceInfo serviceInfo) { QName intfName = getInterfaceName(); InterfaceInfo intf = new InterfaceInfo(serviceInfo, intfName); Method[] methods = getServiceClass().getMethods(); // The BP profile states we can't have operations of the same name // so we have to append numbers to the name. Different JVMs sort methods // differently. // We need to keep them ordered so if we have overloaded methods, the // wsdl is generated the same every time across JVMs and across // client/servers. Arrays.sort(methods, new MethodComparator()); for (Method m : methods) { if (isValidMethod(m)) { createOperation(serviceInfo, intf, m); } } sendEvent(Event.INTERFACE_CREATED, intf, getServiceClass()); return intf; }
protected void createEndpoints() { Service service = getService(); BindingFactoryManager bfm = getBus().getExtension(BindingFactoryManager.class); for (ServiceInfo inf : service.getServiceInfos()) { for (EndpointInfo ei : inf.getEndpoints()) { for (BindingOperationInfo boi : ei.getBinding().getOperations()) { updateBindingOperation(boi); } try { bfm.getBindingFactory(ei.getBinding().getBindingId()); } catch (BusException e1) { continue; } try { Endpoint ep = createEndpoint(ei); service.getEndpoints().put(ei.getName(), ep); } catch (EndpointException e) { throw new ServiceConstructionException(e); } } } }
protected InterfaceInfo getInterfaceInfo() { if (getEndpointInfo() != null) { return getEndpointInfo().getInterface(); } QName qn = this.getInterfaceName(); for (ServiceInfo si : getService().getServiceInfos()) { if (qn.equals(si.getInterface().getName())) { return si.getInterface(); } } throw new ServiceConstructionException(new Message("COULD_NOT_FIND_PORTTYPE", LOG, qn)); }
public String getWsdlURL() { if (wsdlURL == null) { for (AbstractServiceConfiguration c : serviceConfigurations) { wsdlURL = c.getWsdlURL(); if (wsdlURL != null) { break; } } if (null == wsdlURL && getBus() != null) { ServiceContractResolverRegistry registry = getBus() .getExtension(ServiceContractResolverRegistry.class); if (null != registry) { URI uri = registry.getContractLocation(this.getServiceQName()); if (null != uri) { try { wsdlURL = uri.toURL().toString(); } catch (MalformedURLException e) { LOG.log(Level.FINE, "resolve qname failed", this.getServiceQName()); } } } } if (wsdlURL != null) { // create a unique string so if its an interned string (like // from an annotation), caches will clear wsdlURL = new String(wsdlURL); } } return wsdlURL; }
Class<? extends DataBinding> cls = null; if (getServiceClass() != null) { org.apache.cxf.annotations.DataBinding db = getServiceClass().getAnnotation(org.apache.cxf.annotations.DataBinding.class); if (db != null) { try { if (!StringUtils.isEmpty(db.ref())) { return getBus().getExtension(ResourceManager.class).resolveResource(db.ref(), db.value()); if (cls == null && getBus() != null) { obj = getBus().getProperty(DataBinding.class.getName()); cls = getJAXBClass();
public void validateServiceModel() { XmlSchemaValidationManager xsdValidator = getBus().getExtension(XmlSchemaValidationManager.class); for (ServiceInfo si : getService().getServiceInfos()) { if (xsdValidator != null) { validateSchemas(xsdValidator, si.getXmlSchemaCollection());
@Override public void init(ServletConfig pServletConfig) throws ServletException { ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); try { // set classloader to CXF bundle class loader to avoid OSGI classloader problems Thread.currentThread().setContextClassLoader(BusFactory.class.getClassLoader()); super.init(pServletConfig); ServerFactoryBean sf = new ServerFactoryBean(); sf.setBus(getBus()); sf.setAddress(getServletUrl() == null ? SoapRequestWrapper.VIRTUAL_PATH : getServletUrl()); sf.setServiceClass(getServerInterfaceType()); sf.getServiceFactory().setDataBinding(new AegisDatabinding()); sf.setServiceBean(this); sf.create(); } finally { Thread.currentThread().setContextClassLoader(oldClassLoader); } }
public EndpointInfo getEndpointInfo() { return getService().getEndpointInfo(getEndpointName()); }
@Override public Boolean isOperation(Method method) { if (getServiceFactory().getIgnoredClasses().contains(method.getDeclaringClass().getName())) { return Boolean.FALSE; } // Don't do m.equals(method) for (Method m : getServiceFactory().getIgnoredMethods()) { if (m.getName().equals(method.getName()) && Arrays.equals(method.getParameterTypes(), m.getParameterTypes()) && m.getReturnType() == method.getReturnType()) { return Boolean.FALSE; } } final int modifiers = method.getModifiers(); if (Modifier.isPublic(modifiers) && !Modifier.isStatic(modifiers) && !method.isSynthetic()) { return Boolean.TRUE; } return Boolean.FALSE; }
if (getServiceFactory().getWsdlURL() != null) Definition definition = getServiceFactory().getBus() .getExtension(WSDLManager.class) .getDefinition(getServiceFactory().getWsdlURL()); Service service = getServiceFromDefinition(definition); setServiceNamespace(service.getQName().getNamespaceURI());
/** * This method configures the {@link ReflectionServiceFactoryBean}. */ private void initServiceFactory(ReflectionServiceFactoryBean svcFac) { addIgnoredMethods(svcFac, Callable.class.getName()); addIgnoredMethods(svcFac, Initialisable.class.getName()); addIgnoredMethods(svcFac, Disposable.class.getName()); addIgnoredMethods(svcFac, ServiceAware.class.getName()); svcFac.getServiceConfigurations().add(0, new MuleServiceConfiguration(this)); svcFac.setServiceClass(getServiceClass()); for (AbstractServiceConfiguration c : svcFac.getServiceConfigurations()) { c.setServiceFactory(svcFac); } }
svcFac.setBus(bus); configurer.configureBean(svcFac.getEndpointName().toString(), sfb);