Return-Path: Delivered-To: apmail-incubator-cxf-commits-archive@locus.apache.org Received: (qmail 88578 invoked from network); 25 Aug 2006 13:19:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 25 Aug 2006 13:19:30 -0000 Received: (qmail 79839 invoked by uid 500); 25 Aug 2006 13:19:23 -0000 Delivered-To: apmail-incubator-cxf-commits-archive@incubator.apache.org Received: (qmail 79744 invoked by uid 500); 25 Aug 2006 13:19:22 -0000 Mailing-List: contact cxf-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cxf-dev@incubator.apache.org Delivered-To: mailing list cxf-commits@incubator.apache.org Received: (qmail 79644 invoked by uid 99); 25 Aug 2006 13:19:22 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Aug 2006 06:19:22 -0700 X-ASF-Spam-Status: No, hits=-8.6 required=10.0 tests=ALL_TRUSTED,INFO_TLD,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Aug 2006 06:19:08 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 76FE81A9830; Fri, 25 Aug 2006 06:18:24 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r436785 [13/18] - in /incubator/cxf/trunk: ./ api/ api/src/main/java/org/apache/cxf/buslifecycle/ api/src/main/java/org/apache/cxf/databinding/ api/src/main/java/org/apache/cxf/endpoint/ api/src/main/java/org/apache/cxf/interceptor/ api/src... Date: Fri, 25 Aug 2006 13:17:37 -0000 To: cxf-commits@incubator.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060825131824.76FE81A9830@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java?rev=436785&r1=436784&r2=436785&view=diff ============================================================================== --- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java (original) +++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java Fri Aug 25 06:16:36 2006 @@ -1,114 +1,114 @@ -package org.apache.cxf.service.factory; - -import java.lang.reflect.Method; -import java.net.URL; - -import javax.xml.namespace.QName; - -import org.apache.cxf.service.Service; -import org.apache.cxf.service.model.InterfaceInfo; -import org.apache.cxf.service.model.OperationInfo; - -public abstract class AbstractServiceConfiguration { - private ReflectionServiceFactoryBean serviceFactory; - - public ReflectionServiceFactoryBean getServiceFactory() { - return serviceFactory; - } - - public void setServiceFactory(ReflectionServiceFactoryBean serviceFactory) { - this.serviceFactory = serviceFactory; - } - - public URL getWsdlURL() { - return null; - } - - public String getServiceName() { - return null; - } - - public String getServiceNamespace() { - return null; - } - - public Boolean isOperation(final Method method) { - return null; - } - - public Boolean isOutParam(Method method, int j) { - return null; - } - - public Boolean isInParam(Method method, int j) { - return null; - } - - public QName getInputMessageName(final OperationInfo op) { - return null; - } - - public QName getOutputMessageName(final OperationInfo op) { - return null; - } - - public Boolean hasOutMessage(String mep) { - return null; - } - - public QName getFaultName(Service service, OperationInfo o, Class exClass, Class beanClass) { - return null; - } - - public String getAction(OperationInfo op) { - return null; - } - - public Boolean isHeader(Method method, int j) { - return null; - } - - /** - * Creates a name for the operation from the method name. If an operation - * with that name already exists, a name is create by appending an integer - * to the end. I.e. if there is already two methods named - * doSomething, the first one will have an operation name of - * "doSomething" and the second "doSomething1". - * - * @param service - * @param method - */ - public QName getOperationName(InterfaceInfo service, Method method) { - return null; - } - - public String getMEP(final Method method) { - return null; - } - - public Boolean isAsync(final Method method) { - return null; - } - - public QName getInParameterName(final OperationInfo op, final Method method, - final int paramNumber, final boolean doc) { - return null; - } - - public QName getOutParameterName(final OperationInfo op, final Method method, - final int paramNumber, final boolean doc) { - return null; - } - - public QName getPortType(Class clazz) { - return null; - } - - public Class getResponseWrapper(Method selected) { - return null; - } - - public Class getRequestWrapper(Method selected) { - return null; - } -} +package org.apache.cxf.service.factory; + +import java.lang.reflect.Method; +import java.net.URL; + +import javax.xml.namespace.QName; + +import org.apache.cxf.service.Service; +import org.apache.cxf.service.model.InterfaceInfo; +import org.apache.cxf.service.model.OperationInfo; + +public abstract class AbstractServiceConfiguration { + private ReflectionServiceFactoryBean serviceFactory; + + public ReflectionServiceFactoryBean getServiceFactory() { + return serviceFactory; + } + + public void setServiceFactory(ReflectionServiceFactoryBean serviceFactory) { + this.serviceFactory = serviceFactory; + } + + public URL getWsdlURL() { + return null; + } + + public String getServiceName() { + return null; + } + + public String getServiceNamespace() { + return null; + } + + public Boolean isOperation(final Method method) { + return null; + } + + public Boolean isOutParam(Method method, int j) { + return null; + } + + public Boolean isInParam(Method method, int j) { + return null; + } + + public QName getInputMessageName(final OperationInfo op) { + return null; + } + + public QName getOutputMessageName(final OperationInfo op) { + return null; + } + + public Boolean hasOutMessage(String mep) { + return null; + } + + public QName getFaultName(Service service, OperationInfo o, Class exClass, Class beanClass) { + return null; + } + + public String getAction(OperationInfo op) { + return null; + } + + public Boolean isHeader(Method method, int j) { + return null; + } + + /** + * Creates a name for the operation from the method name. If an operation + * with that name already exists, a name is create by appending an integer + * to the end. I.e. if there is already two methods named + * doSomething, the first one will have an operation name of + * "doSomething" and the second "doSomething1". + * + * @param service + * @param method + */ + public QName getOperationName(InterfaceInfo service, Method method) { + return null; + } + + public String getMEP(final Method method) { + return null; + } + + public Boolean isAsync(final Method method) { + return null; + } + + public QName getInParameterName(final OperationInfo op, final Method method, + final int paramNumber, final boolean doc) { + return null; + } + + public QName getOutParameterName(final OperationInfo op, final Method method, + final int paramNumber, final boolean doc) { + return null; + } + + public QName getPortType(Class clazz) { + return null; + } + + public Class getResponseWrapper(Method selected) { + return null; + } + + public Class getRequestWrapper(Method selected) { + return null; + } +} Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AbstractServiceFactoryBean.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AbstractServiceFactoryBean.java?rev=436785&r1=436784&r2=436785&view=diff ============================================================================== --- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AbstractServiceFactoryBean.java (original) +++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AbstractServiceFactoryBean.java Fri Aug 25 06:16:36 2006 @@ -1,64 +1,64 @@ -package org.apache.cxf.service.factory; - -import org.apache.cxf.Bus; -import org.apache.cxf.databinding.DataReaderFactory; -import org.apache.cxf.databinding.DataWriterFactory; -import org.apache.cxf.interceptor.MessageSenderInterceptor; -import org.apache.cxf.interceptor.OutgoingChainInterceptor; -import org.apache.cxf.interceptor.OutgoingChainSetupInterceptor; -import org.apache.cxf.interceptor.ServiceInvokerInterceptor; -import org.apache.cxf.service.Service; - -public abstract class AbstractServiceFactoryBean { - private Bus bus; - private DataReaderFactory dataReaderFactory; - private DataWriterFactory dataWriterFactory; - private Service service; - - public abstract Service create(); - - protected void initializeDefaultInterceptors() { - service.getInInterceptors().add(new ServiceInvokerInterceptor()); - service.getInInterceptors().add(new OutgoingChainSetupInterceptor()); - service.getInInterceptors().add(new OutgoingChainInterceptor()); - service.getOutInterceptors().add(new MessageSenderInterceptor()); - } - - protected void initializeDataBindings() { - service.setDataReaderFactory(dataReaderFactory); - service.setDataWriterFactory(dataWriterFactory); - } - - public Bus getBus() { - return bus; - } - - public void setBus(Bus bus) { - this.bus = bus; - } - - public DataReaderFactory getDataReaderFactory() { - return dataReaderFactory; - } - - public void setDataReaderFactory(DataReaderFactory dataReaderFactory) { - this.dataReaderFactory = dataReaderFactory; - } - - public DataWriterFactory getDataWriterFactory() { - return dataWriterFactory; - } - - public void setDataWriterFactory(DataWriterFactory dataWriterFactory) { - this.dataWriterFactory = dataWriterFactory; - } - - public Service getService() { - return service; - } - - protected void setService(Service service) { - this.service = service; - } - -} +package org.apache.cxf.service.factory; + +import org.apache.cxf.Bus; +import org.apache.cxf.databinding.DataReaderFactory; +import org.apache.cxf.databinding.DataWriterFactory; +import org.apache.cxf.interceptor.MessageSenderInterceptor; +import org.apache.cxf.interceptor.OutgoingChainInterceptor; +import org.apache.cxf.interceptor.OutgoingChainSetupInterceptor; +import org.apache.cxf.interceptor.ServiceInvokerInterceptor; +import org.apache.cxf.service.Service; + +public abstract class AbstractServiceFactoryBean { + private Bus bus; + private DataReaderFactory dataReaderFactory; + private DataWriterFactory dataWriterFactory; + private Service service; + + public abstract Service create(); + + protected void initializeDefaultInterceptors() { + service.getInInterceptors().add(new ServiceInvokerInterceptor()); + service.getInInterceptors().add(new OutgoingChainSetupInterceptor()); + service.getInInterceptors().add(new OutgoingChainInterceptor()); + service.getOutInterceptors().add(new MessageSenderInterceptor()); + } + + protected void initializeDataBindings() { + service.setDataReaderFactory(dataReaderFactory); + service.setDataWriterFactory(dataWriterFactory); + } + + public Bus getBus() { + return bus; + } + + public void setBus(Bus bus) { + this.bus = bus; + } + + public DataReaderFactory getDataReaderFactory() { + return dataReaderFactory; + } + + public void setDataReaderFactory(DataReaderFactory dataReaderFactory) { + this.dataReaderFactory = dataReaderFactory; + } + + public DataWriterFactory getDataWriterFactory() { + return dataWriterFactory; + } + + public void setDataWriterFactory(DataWriterFactory dataWriterFactory) { + this.dataWriterFactory = dataWriterFactory; + } + + public Service getService() { + return service; + } + + protected void setService(Service service) { + this.service = service; + } + +} Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AbstractServiceFactoryBean.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AbstractServiceFactoryBean.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/DefaultServiceConfiguration.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/DefaultServiceConfiguration.java?rev=436785&r1=436784&r2=436785&view=diff ============================================================================== --- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/DefaultServiceConfiguration.java (original) +++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/DefaultServiceConfiguration.java Fri Aug 25 06:16:36 2006 @@ -1,16 +1,16 @@ -package org.apache.cxf.service.factory; - -import java.lang.reflect.Method; - -import javax.xml.namespace.QName; - -import org.apache.cxf.service.model.InterfaceInfo; - -public class DefaultServiceConfiguration extends AbstractServiceConfiguration { - - @Override - public QName getOperationName(InterfaceInfo service, Method method) { - return new QName(service.getName().getNamespaceURI(), method.getName()); - } - -} +package org.apache.cxf.service.factory; + +import java.lang.reflect.Method; + +import javax.xml.namespace.QName; + +import org.apache.cxf.service.model.InterfaceInfo; + +public class DefaultServiceConfiguration extends AbstractServiceConfiguration { + + @Override + public QName getOperationName(InterfaceInfo service, Method method) { + return new QName(service.getName().getNamespaceURI(), method.getName()); + } + +} Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/DefaultServiceConfiguration.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/DefaultServiceConfiguration.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/Messages.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/Messages.properties ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/Messages.properties ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?rev=436785&r1=436784&r2=436785&view=diff ============================================================================== --- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java (original) +++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java Fri Aug 25 06:16:36 2006 @@ -1,515 +1,515 @@ -package org.apache.cxf.service.factory; - -import java.lang.reflect.Method; -import java.net.URL; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import java.util.ResourceBundle; -import java.util.concurrent.Executor; -import java.util.logging.Logger; - -import javax.xml.namespace.QName; - -import org.apache.cxf.common.i18n.BundleUtils; -import org.apache.cxf.common.i18n.Message; -import org.apache.cxf.helpers.MethodComparator; -import org.apache.cxf.service.Service; -import org.apache.cxf.service.ServiceImpl; -import org.apache.cxf.service.invoker.Invoker; -import org.apache.cxf.service.model.FaultInfo; -import org.apache.cxf.service.model.InterfaceInfo; -import org.apache.cxf.service.model.OperationInfo; -import org.apache.cxf.service.model.ServiceInfo; -import org.apache.cxf.wsdl11.WSDLServiceFactory; - -public class ReflectionServiceFactoryBean extends AbstractServiceFactoryBean { - private static final Logger LOG = Logger.getLogger(ReflectionServiceFactoryBean.class.getName()); - private static final ResourceBundle BUNDLE = BundleUtils.getBundle(ReflectionServiceFactoryBean.class); - - private Class serviceClass; - private URL wsdlURL; - private List serviceConfigurations = - new ArrayList(); - private QName serviceName; - private Invoker invoker; - private Executor executor; - - public ReflectionServiceFactoryBean() { - getServiceConfigurations().add(new DefaultServiceConfiguration()); - } - - @Override - public Service create() { - initializeServiceConfigurations(); - - initializeServiceModel(); - - initializeDataBindings(); - - initializeDefaultInterceptors(); - - getService().setInvoker(getInvoker()); - if (getExecutor() != null) { - getService().setExecutor(getExecutor()); - } else { - getService().setExecutor(new Executor() { - public void execute(Runnable r) { - r.run(); - } - }); - } - - return getService(); - } - - protected void initializeServiceConfigurations() { - for (AbstractServiceConfiguration c : serviceConfigurations) { - c.setServiceFactory(this); - } - } - - protected void initializeServiceModel() { - URL url = getWsdlURL(); - - if (url != null) { - LOG.info("Creating Service " + getServiceQName() + " from WSDL."); - WSDLServiceFactory factory = new WSDLServiceFactory(getBus(), url, getServiceQName()); - - setService(factory.create()); - - initializeWSDLOperations(); - } else { - ServiceInfo serviceInfo = new ServiceInfo(); - serviceInfo.setName(getServiceQName()); - - createInterface(serviceInfo); - - ServiceImpl service = new ServiceImpl(serviceInfo); - setService(service); - - // TODO Add hooks to create default bindings - } - } - - protected void initializeWSDLOperations() { - Method[] methods = serviceClass.getMethods(); - Arrays.sort(methods, new MethodComparator()); - - InterfaceInfo intf = getService().getServiceInfo().getInterface(); - - for (OperationInfo o : intf.getOperations()) { - Method selected = null; - for (Method m : methods) { - if (isValidMethod(m)) { - QName opName = getOperationName(intf, m); - - if (o.getName().equals(opName)) { - selected = m; - o.setProperty(Method.class.getName(), m); - break; - } - } - } - - if (selected == null) { - throw new ServiceConstructionException(new Message("NO_METHOD_FOR_OP", BUNDLE, o.getName())); - } - - initializeWSDLOperation(intf, o, selected); - } - } - - protected void initializeWSDLOperation(InterfaceInfo intf, OperationInfo o, Method selected) { - // TODO Auto-generated method stub - - } - - protected ServiceInfo createServiceInfo(InterfaceInfo intf) { - ServiceInfo svcInfo = new ServiceInfo(); - svcInfo.setInterface(intf); - - return svcInfo; - } - - protected InterfaceInfo createInterface(ServiceInfo serviceInfo) { - QName intfName = getInterfaceName(); - InterfaceInfo intf = new InterfaceInfo(serviceInfo, intfName); - - Method[] methods = serviceClass.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 : serviceClass.getMethods()) { - if (isValidMethod(m)) { - createOperation(serviceInfo, intf, m); - } - } - return intf; - } - - protected OperationInfo createOperation(ServiceInfo serviceInfo, InterfaceInfo intf, Method m) { - OperationInfo info = intf.addOperation(getOperationName(intf, m)); - - createMessageParts(intf, info, m); - - return info; - } - - protected void createMessageParts(InterfaceInfo intf, OperationInfo op, Method method) { - // - // final Class[] paramClasses = method.getParameterTypes(); - // - // // Setup the input message - // MessageInfo inMsg = op.createMessage(getInputMessageName(op)); - // op.setInput(inMsg.getName().getLocalPart(), inMsg); - // - // for (int j = 0; j < paramClasses.length; j++) - // { - // if (!paramClasses[j].equals(MessageContext.class) && - // !isHeader(method, j) && - // isInParam(method, j)) - // { - // final QName q = getInParameterName(endpoint, op, method, j, isDoc); - // MessagePartInfo part = inMsg.addMessagePart(q, paramClasses[j]); - // part.setIndex(j); - // part.setSchemaElement(isDoc || - // endpoint.getServiceInfo().isWrapped()); - // } - // } - // - // if (hasOutMessage(mep)) - // { - // // Setup the output message - // MessageInfo outMsg = op.createMessage(createOutputMessageName(op)); - // op.setOutput(outMsg.getName().getLocalPart(), outMsg); - // - // final Class returnType = method.getReturnType(); - // if (!returnType.isAssignableFrom(void.class) && !isHeader(method, - // -1)) - // { - // final QName q = getOutParameterName(endpoint, op, method, -1, isDoc); - // MessagePartInfo part = outMsg.addMessagePart(q, - // method.getReturnType()); - // } - // - // for (int j = 0; j < paramClasses.length; j++) - // { - // if (!paramClasses[j].equals(MessageContext.class) && - // !isHeader(method, j) && - // isOutParam(method, j)) - // { - // final QName q = getInParameterName(endpoint, op, method, j, isDoc); - // MessagePartInfo part = outMsg.addMessagePart(q, paramClasses[j]); - // part.setIndex(j); - // part.setSchemaElement(isDoc || - // endpoint.getServiceInfo().isWrapped()); - // } - // } - // } - // - // initializeFaults(intf, op, method); - } - - protected QName getServiceQName() { - if (serviceName == null) { - serviceName = new QName(getServiceNamespace(), getServiceName()); - } - - return serviceName; - } - - protected QName getInterfaceName() { - // TODO Auto-generated method stub - return null; - } - - protected String getServiceName() { - for (AbstractServiceConfiguration c : serviceConfigurations) { - String name = c.getServiceName(); - if (name != null) { - return name; - } - } - throw new IllegalStateException("ServiceConfiguration must provide a value!"); - } - - protected String getServiceNamespace() { - for (AbstractServiceConfiguration c : serviceConfigurations) { - String name = c.getServiceNamespace(); - if (name != null) { - return name; - } - } - throw new IllegalStateException("ServiceConfiguration must provide a value!"); - } - - protected boolean isValidMethod(final Method method) { - for (AbstractServiceConfiguration c : serviceConfigurations) { - Boolean b = c.isOperation(method); - if (b != null) { - return b.booleanValue(); - } - } - return true; - } - - protected boolean isOutParam(Method method, int j) { - for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) { - AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next(); - Boolean b = c.isOutParam(method, j); - if (b != null) { - return b.booleanValue(); - } - } - return true; - } - - protected boolean isInParam(Method method, int j) { - for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) { - AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next(); - Boolean b = c.isInParam(method, j); - if (b != null) { - return b.booleanValue(); - } - } - return true; - } - - protected QName getInputMessageName(final OperationInfo op) { - for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) { - AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next(); - QName q = c.getInputMessageName(op); - if (q != null) { - return q; - } - } - throw new IllegalStateException("ServiceConfiguration must provide a value!"); - } - - protected QName createOutputMessageName(final OperationInfo op) { - for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) { - AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next(); - QName q = c.getOutputMessageName(op); - if (q != null) { - return q; - } - } - throw new IllegalStateException("ServiceConfiguration must provide a value!"); - } - - protected boolean hasOutMessage(String mep) { - for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) { - AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next(); - Boolean b = c.hasOutMessage(mep); - if (b != null) { - return b.booleanValue(); - } - } - return true; - } - - protected void initializeFaults(final InterfaceInfo service, - final OperationInfo op, - final Method method) { - // Set up the fault messages - final Class[] exceptionClasses = method.getExceptionTypes(); - for (int i = 0; i < exceptionClasses.length; i++) { - Class exClazz = exceptionClasses[i]; - - // Ignore XFireFaults because they don't need to be declared - if (exClazz.equals(Exception.class) || exClazz.equals(RuntimeException.class) - || exClazz.equals(Throwable.class)) { - continue; - } - - addFault(service, op, exClazz); - } - } - - protected FaultInfo addFault(final InterfaceInfo service, final OperationInfo op, Class exClass) { - // TODO - return null; - } - - protected QName getFaultName(Service service, OperationInfo o, Class exClass, Class beanClass) { - for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) { - AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next(); - QName q = c.getFaultName(service, o, exClass, beanClass); - if (q != null) { - return q; - } - } - throw new IllegalStateException("ServiceConfiguration must provide a value!"); - } - - protected String getAction(OperationInfo op) { - for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) { - AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next(); - String s = c.getAction(op); - if (s != null) { - return s; - } - } - throw new IllegalStateException("ServiceConfiguration must provide a value!"); - } - - protected boolean isHeader(Method method, int j) { - for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) { - AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next(); - Boolean b = c.isHeader(method, j); - if (b != null) { - return b.booleanValue(); - } - } - return true; - } - - /** - * Creates a name for the operation from the method name. If an operation - * with that name already exists, a name is create by appending an integer - * to the end. I.e. if there is already two methods named - * doSomething, the first one will have an operation name of - * "doSomething" and the second "doSomething1". - * - * @param service - * @param method - */ - protected QName getOperationName(InterfaceInfo service, Method method) { - for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) { - AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next(); - QName s = c.getOperationName(service, method); - if (s != null) { - return s; - } - } - throw new IllegalStateException("ServiceConfiguration must provide a value!"); - } - - protected boolean isAsync(final Method method) { - for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) { - AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next(); - Boolean b = c.isAsync(method); - if (b != null) { - return b.booleanValue(); - } - } - return true; - } - - protected QName getInParameterName(final Service service, final OperationInfo op, final Method method, - final int paramNumber, final boolean doc) { - if (paramNumber == -1) { - throw new RuntimeException(); - } - for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) { - AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next(); - QName q = c.getInParameterName(op, method, paramNumber, doc); - if (q != null) { - return q; - } - } - throw new IllegalStateException("ServiceConfiguration must provide a value!"); - } - - protected QName getOutParameterName(final Service service, final OperationInfo op, final Method method, - final int paramNumber, final boolean doc) { - for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) { - AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next(); - QName q = c.getOutParameterName(op, method, paramNumber, doc); - if (q != null) { - return q; - } - } - throw new IllegalStateException("ServiceConfiguration must provide a value!"); - } - - - protected Class getResponseWrapper(Method selected) { - for (AbstractServiceConfiguration c : serviceConfigurations) { - Class cls = c.getResponseWrapper(selected); - if (cls != null) { - return cls; - } - } - return null; - } - protected Class getRequestWrapper(Method selected) { - for (AbstractServiceConfiguration c : serviceConfigurations) { - Class cls = c.getRequestWrapper(selected); - if (cls != null) { - return cls; - } - } - return null; - } - - - - public List getConfigurations() { - return serviceConfigurations; - } - - public void setConfigurations(List configurations) { - this.serviceConfigurations = configurations; - } - - public Class getServiceClass() { - return serviceClass; - } - - public void setServiceClass(Class serviceClass) { - this.serviceClass = serviceClass; - } - - public URL getWsdlURL() { - if (wsdlURL == null) { - for (AbstractServiceConfiguration c : serviceConfigurations) { - wsdlURL = c.getWsdlURL(); - if (wsdlURL != null) { - break; - } - } - } - return wsdlURL; - } - - public void setWsdlURL(URL wsdlURL) { - this.wsdlURL = wsdlURL; - } - - public List getServiceConfigurations() { - return serviceConfigurations; - } - - public void setServiceConfigurations(List serviceConfigurations) { - this.serviceConfigurations = serviceConfigurations; - } - - public void setServiceName(QName serviceName) { - this.serviceName = serviceName; - } - - public Invoker getInvoker() { - return invoker; - } - - public void setInvoker(Invoker invoker) { - this.invoker = invoker; - } - - public Executor getExecutor() { - return executor; - } - - public void setExecutor(Executor executor) { - this.executor = executor; - } -} +package org.apache.cxf.service.factory; + +import java.lang.reflect.Method; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.ResourceBundle; +import java.util.concurrent.Executor; +import java.util.logging.Logger; + +import javax.xml.namespace.QName; + +import org.apache.cxf.common.i18n.BundleUtils; +import org.apache.cxf.common.i18n.Message; +import org.apache.cxf.helpers.MethodComparator; +import org.apache.cxf.service.Service; +import org.apache.cxf.service.ServiceImpl; +import org.apache.cxf.service.invoker.Invoker; +import org.apache.cxf.service.model.FaultInfo; +import org.apache.cxf.service.model.InterfaceInfo; +import org.apache.cxf.service.model.OperationInfo; +import org.apache.cxf.service.model.ServiceInfo; +import org.apache.cxf.wsdl11.WSDLServiceFactory; + +public class ReflectionServiceFactoryBean extends AbstractServiceFactoryBean { + private static final Logger LOG = Logger.getLogger(ReflectionServiceFactoryBean.class.getName()); + private static final ResourceBundle BUNDLE = BundleUtils.getBundle(ReflectionServiceFactoryBean.class); + + private Class serviceClass; + private URL wsdlURL; + private List serviceConfigurations = + new ArrayList(); + private QName serviceName; + private Invoker invoker; + private Executor executor; + + public ReflectionServiceFactoryBean() { + getServiceConfigurations().add(new DefaultServiceConfiguration()); + } + + @Override + public Service create() { + initializeServiceConfigurations(); + + initializeServiceModel(); + + initializeDataBindings(); + + initializeDefaultInterceptors(); + + getService().setInvoker(getInvoker()); + if (getExecutor() != null) { + getService().setExecutor(getExecutor()); + } else { + getService().setExecutor(new Executor() { + public void execute(Runnable r) { + r.run(); + } + }); + } + + return getService(); + } + + protected void initializeServiceConfigurations() { + for (AbstractServiceConfiguration c : serviceConfigurations) { + c.setServiceFactory(this); + } + } + + protected void initializeServiceModel() { + URL url = getWsdlURL(); + + if (url != null) { + LOG.info("Creating Service " + getServiceQName() + " from WSDL."); + WSDLServiceFactory factory = new WSDLServiceFactory(getBus(), url, getServiceQName()); + + setService(factory.create()); + + initializeWSDLOperations(); + } else { + ServiceInfo serviceInfo = new ServiceInfo(); + serviceInfo.setName(getServiceQName()); + + createInterface(serviceInfo); + + ServiceImpl service = new ServiceImpl(serviceInfo); + setService(service); + + // TODO Add hooks to create default bindings + } + } + + protected void initializeWSDLOperations() { + Method[] methods = serviceClass.getMethods(); + Arrays.sort(methods, new MethodComparator()); + + InterfaceInfo intf = getService().getServiceInfo().getInterface(); + + for (OperationInfo o : intf.getOperations()) { + Method selected = null; + for (Method m : methods) { + if (isValidMethod(m)) { + QName opName = getOperationName(intf, m); + + if (o.getName().equals(opName)) { + selected = m; + o.setProperty(Method.class.getName(), m); + break; + } + } + } + + if (selected == null) { + throw new ServiceConstructionException(new Message("NO_METHOD_FOR_OP", BUNDLE, o.getName())); + } + + initializeWSDLOperation(intf, o, selected); + } + } + + protected void initializeWSDLOperation(InterfaceInfo intf, OperationInfo o, Method selected) { + // TODO Auto-generated method stub + + } + + protected ServiceInfo createServiceInfo(InterfaceInfo intf) { + ServiceInfo svcInfo = new ServiceInfo(); + svcInfo.setInterface(intf); + + return svcInfo; + } + + protected InterfaceInfo createInterface(ServiceInfo serviceInfo) { + QName intfName = getInterfaceName(); + InterfaceInfo intf = new InterfaceInfo(serviceInfo, intfName); + + Method[] methods = serviceClass.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 : serviceClass.getMethods()) { + if (isValidMethod(m)) { + createOperation(serviceInfo, intf, m); + } + } + return intf; + } + + protected OperationInfo createOperation(ServiceInfo serviceInfo, InterfaceInfo intf, Method m) { + OperationInfo info = intf.addOperation(getOperationName(intf, m)); + + createMessageParts(intf, info, m); + + return info; + } + + protected void createMessageParts(InterfaceInfo intf, OperationInfo op, Method method) { + // + // final Class[] paramClasses = method.getParameterTypes(); + // + // // Setup the input message + // MessageInfo inMsg = op.createMessage(getInputMessageName(op)); + // op.setInput(inMsg.getName().getLocalPart(), inMsg); + // + // for (int j = 0; j < paramClasses.length; j++) + // { + // if (!paramClasses[j].equals(MessageContext.class) && + // !isHeader(method, j) && + // isInParam(method, j)) + // { + // final QName q = getInParameterName(endpoint, op, method, j, isDoc); + // MessagePartInfo part = inMsg.addMessagePart(q, paramClasses[j]); + // part.setIndex(j); + // part.setSchemaElement(isDoc || + // endpoint.getServiceInfo().isWrapped()); + // } + // } + // + // if (hasOutMessage(mep)) + // { + // // Setup the output message + // MessageInfo outMsg = op.createMessage(createOutputMessageName(op)); + // op.setOutput(outMsg.getName().getLocalPart(), outMsg); + // + // final Class returnType = method.getReturnType(); + // if (!returnType.isAssignableFrom(void.class) && !isHeader(method, + // -1)) + // { + // final QName q = getOutParameterName(endpoint, op, method, -1, isDoc); + // MessagePartInfo part = outMsg.addMessagePart(q, + // method.getReturnType()); + // } + // + // for (int j = 0; j < paramClasses.length; j++) + // { + // if (!paramClasses[j].equals(MessageContext.class) && + // !isHeader(method, j) && + // isOutParam(method, j)) + // { + // final QName q = getInParameterName(endpoint, op, method, j, isDoc); + // MessagePartInfo part = outMsg.addMessagePart(q, paramClasses[j]); + // part.setIndex(j); + // part.setSchemaElement(isDoc || + // endpoint.getServiceInfo().isWrapped()); + // } + // } + // } + // + // initializeFaults(intf, op, method); + } + + protected QName getServiceQName() { + if (serviceName == null) { + serviceName = new QName(getServiceNamespace(), getServiceName()); + } + + return serviceName; + } + + protected QName getInterfaceName() { + // TODO Auto-generated method stub + return null; + } + + protected String getServiceName() { + for (AbstractServiceConfiguration c : serviceConfigurations) { + String name = c.getServiceName(); + if (name != null) { + return name; + } + } + throw new IllegalStateException("ServiceConfiguration must provide a value!"); + } + + protected String getServiceNamespace() { + for (AbstractServiceConfiguration c : serviceConfigurations) { + String name = c.getServiceNamespace(); + if (name != null) { + return name; + } + } + throw new IllegalStateException("ServiceConfiguration must provide a value!"); + } + + protected boolean isValidMethod(final Method method) { + for (AbstractServiceConfiguration c : serviceConfigurations) { + Boolean b = c.isOperation(method); + if (b != null) { + return b.booleanValue(); + } + } + return true; + } + + protected boolean isOutParam(Method method, int j) { + for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) { + AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next(); + Boolean b = c.isOutParam(method, j); + if (b != null) { + return b.booleanValue(); + } + } + return true; + } + + protected boolean isInParam(Method method, int j) { + for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) { + AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next(); + Boolean b = c.isInParam(method, j); + if (b != null) { + return b.booleanValue(); + } + } + return true; + } + + protected QName getInputMessageName(final OperationInfo op) { + for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) { + AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next(); + QName q = c.getInputMessageName(op); + if (q != null) { + return q; + } + } + throw new IllegalStateException("ServiceConfiguration must provide a value!"); + } + + protected QName createOutputMessageName(final OperationInfo op) { + for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) { + AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next(); + QName q = c.getOutputMessageName(op); + if (q != null) { + return q; + } + } + throw new IllegalStateException("ServiceConfiguration must provide a value!"); + } + + protected boolean hasOutMessage(String mep) { + for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) { + AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next(); + Boolean b = c.hasOutMessage(mep); + if (b != null) { + return b.booleanValue(); + } + } + return true; + } + + protected void initializeFaults(final InterfaceInfo service, + final OperationInfo op, + final Method method) { + // Set up the fault messages + final Class[] exceptionClasses = method.getExceptionTypes(); + for (int i = 0; i < exceptionClasses.length; i++) { + Class exClazz = exceptionClasses[i]; + + // Ignore XFireFaults because they don't need to be declared + if (exClazz.equals(Exception.class) || exClazz.equals(RuntimeException.class) + || exClazz.equals(Throwable.class)) { + continue; + } + + addFault(service, op, exClazz); + } + } + + protected FaultInfo addFault(final InterfaceInfo service, final OperationInfo op, Class exClass) { + // TODO + return null; + } + + protected QName getFaultName(Service service, OperationInfo o, Class exClass, Class beanClass) { + for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) { + AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next(); + QName q = c.getFaultName(service, o, exClass, beanClass); + if (q != null) { + return q; + } + } + throw new IllegalStateException("ServiceConfiguration must provide a value!"); + } + + protected String getAction(OperationInfo op) { + for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) { + AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next(); + String s = c.getAction(op); + if (s != null) { + return s; + } + } + throw new IllegalStateException("ServiceConfiguration must provide a value!"); + } + + protected boolean isHeader(Method method, int j) { + for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) { + AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next(); + Boolean b = c.isHeader(method, j); + if (b != null) { + return b.booleanValue(); + } + } + return true; + } + + /** + * Creates a name for the operation from the method name. If an operation + * with that name already exists, a name is create by appending an integer + * to the end. I.e. if there is already two methods named + * doSomething, the first one will have an operation name of + * "doSomething" and the second "doSomething1". + * + * @param service + * @param method + */ + protected QName getOperationName(InterfaceInfo service, Method method) { + for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) { + AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next(); + QName s = c.getOperationName(service, method); + if (s != null) { + return s; + } + } + throw new IllegalStateException("ServiceConfiguration must provide a value!"); + } + + protected boolean isAsync(final Method method) { + for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) { + AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next(); + Boolean b = c.isAsync(method); + if (b != null) { + return b.booleanValue(); + } + } + return true; + } + + protected QName getInParameterName(final Service service, final OperationInfo op, final Method method, + final int paramNumber, final boolean doc) { + if (paramNumber == -1) { + throw new RuntimeException(); + } + for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) { + AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next(); + QName q = c.getInParameterName(op, method, paramNumber, doc); + if (q != null) { + return q; + } + } + throw new IllegalStateException("ServiceConfiguration must provide a value!"); + } + + protected QName getOutParameterName(final Service service, final OperationInfo op, final Method method, + final int paramNumber, final boolean doc) { + for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) { + AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next(); + QName q = c.getOutParameterName(op, method, paramNumber, doc); + if (q != null) { + return q; + } + } + throw new IllegalStateException("ServiceConfiguration must provide a value!"); + } + + + protected Class getResponseWrapper(Method selected) { + for (AbstractServiceConfiguration c : serviceConfigurations) { + Class cls = c.getResponseWrapper(selected); + if (cls != null) { + return cls; + } + } + return null; + } + protected Class getRequestWrapper(Method selected) { + for (AbstractServiceConfiguration c : serviceConfigurations) { + Class cls = c.getRequestWrapper(selected); + if (cls != null) { + return cls; + } + } + return null; + } + + + + public List getConfigurations() { + return serviceConfigurations; + } + + public void setConfigurations(List configurations) { + this.serviceConfigurations = configurations; + } + + public Class getServiceClass() { + return serviceClass; + } + + public void setServiceClass(Class serviceClass) { + this.serviceClass = serviceClass; + } + + public URL getWsdlURL() { + if (wsdlURL == null) { + for (AbstractServiceConfiguration c : serviceConfigurations) { + wsdlURL = c.getWsdlURL(); + if (wsdlURL != null) { + break; + } + } + } + return wsdlURL; + } + + public void setWsdlURL(URL wsdlURL) { + this.wsdlURL = wsdlURL; + } + + public List getServiceConfigurations() { + return serviceConfigurations; + } + + public void setServiceConfigurations(List serviceConfigurations) { + this.serviceConfigurations = serviceConfigurations; + } + + public void setServiceName(QName serviceName) { + this.serviceName = serviceName; + } + + public Invoker getInvoker() { + return invoker; + } + + public void setInvoker(Invoker invoker) { + this.invoker = invoker; + } + + public Executor getExecutor() { + return executor; + } + + public void setExecutor(Executor executor) { + this.executor = executor; + } +} Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/ServiceConstructionException.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/ServiceConstructionException.java?rev=436785&r1=436784&r2=436785&view=diff ============================================================================== --- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/ServiceConstructionException.java (original) +++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/ServiceConstructionException.java Fri Aug 25 06:16:36 2006 @@ -1,20 +1,20 @@ -package org.apache.cxf.service.factory; - -import org.apache.cxf.common.i18n.Message; -import org.apache.cxf.common.i18n.UncheckedException; - -public class ServiceConstructionException extends UncheckedException { - - public ServiceConstructionException(Message msg, Throwable t) { - super(msg, t); - } - - public ServiceConstructionException(Message msg) { - super(msg); - } - - public ServiceConstructionException(Throwable cause) { - super(cause); - } - -} +package org.apache.cxf.service.factory; + +import org.apache.cxf.common.i18n.Message; +import org.apache.cxf.common.i18n.UncheckedException; + +public class ServiceConstructionException extends UncheckedException { + + public ServiceConstructionException(Message msg, Throwable t) { + super(msg, t); + } + + public ServiceConstructionException(Message msg) { + super(msg); + } + + public ServiceConstructionException(Throwable cause) { + super(cause); + } + +} Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/ServiceConstructionException.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/ServiceConstructionException.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/SimpleMethodInvoker.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/SimpleMethodInvoker.java?rev=436785&r1=436784&r2=436785&view=diff ============================================================================== --- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/SimpleMethodInvoker.java (original) +++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/SimpleMethodInvoker.java Fri Aug 25 06:16:36 2006 @@ -1,37 +1,37 @@ -package org.apache.cxf.service.invoker; - -import java.lang.reflect.Method; -import java.util.Arrays; -import java.util.List; - -import org.apache.cxf.interceptor.Fault; -import org.apache.cxf.message.Exchange; -import org.apache.cxf.service.model.BindingOperationInfo; - -/** - * An invoker which invokes a bean method. Will be replaced soon with something better. - */ -public class SimpleMethodInvoker implements Invoker { - private Object bean; - - public SimpleMethodInvoker(Object bean) { - super(); - this.bean = bean; - } - - public Object invoke(Exchange exchange, Object o) { - BindingOperationInfo bop = exchange.get(BindingOperationInfo.class); - - Method m = (Method)bop.getOperationInfo().getProperty(Method.class.getName()); - List params = (List) o; - - Object res; - try { - res = m.invoke(bean, params.toArray()); - return Arrays.asList(res); - } catch (Exception e) { - throw new Fault(e); - } - } - -} +package org.apache.cxf.service.invoker; + +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.List; + +import org.apache.cxf.interceptor.Fault; +import org.apache.cxf.message.Exchange; +import org.apache.cxf.service.model.BindingOperationInfo; + +/** + * An invoker which invokes a bean method. Will be replaced soon with something better. + */ +public class SimpleMethodInvoker implements Invoker { + private Object bean; + + public SimpleMethodInvoker(Object bean) { + super(); + this.bean = bean; + } + + public Object invoke(Exchange exchange, Object o) { + BindingOperationInfo bop = exchange.get(BindingOperationInfo.class); + + Method m = (Method)bop.getOperationInfo().getProperty(Method.class.getName()); + List params = (List) o; + + Object res; + try { + res = m.invoke(bean, params.toArray()); + return Arrays.asList(res); + } catch (Exception e) { + throw new Fault(e); + } + } + +} Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/SimpleMethodInvoker.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/SimpleMethodInvoker.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java?rev=436785&r1=436784&r2=436785&view=diff ============================================================================== --- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java (original) +++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java Fri Aug 25 06:16:36 2006 @@ -1,204 +1,204 @@ -package org.apache.cxf.test; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.Reader; -import java.util.HashMap; -import java.util.Map; - -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import junit.framework.TestCase; - -import org.apache.cxf.Bus; -import org.apache.cxf.bus.CXFBusFactory; -import org.apache.cxf.helpers.DOMUtils; -import org.apache.cxf.message.Message; -import org.apache.cxf.message.MessageImpl; -import org.apache.cxf.service.model.EndpointInfo; -import org.apache.cxf.transport.Conduit; -import org.apache.cxf.transport.ConduitInitiator; -import org.apache.cxf.transport.ConduitInitiatorManager; -import org.apache.cxf.transport.MessageObserver; -import org.xmlsoap.schemas.wsdl.http.AddressType; - -/** - * A basic test case meant for helping users unit test their services. - */ -public class AbstractCXFTest extends TestCase { - - private static String basedirPath; - - /** - * Namespaces for the XPath expressions. - */ - private Map namespaces = new HashMap(); - - private Bus bus; - - public void setUp() throws Exception { - bus = createBus(); - - namespaces.put("s", "http://schemas.xmlsoap.org/soap/envelope/"); - } - - public Bus getBus() { - return bus; - } - - protected Bus createBus() { - return new CXFBusFactory().createBus(); - } - - protected Node invoke(String address, - String transport, - String message) throws Exception { - EndpointInfo ei = new EndpointInfo(null, "http://schemas.xmlsoap.org/soap/http"); - AddressType a = new AddressType(); - a.setLocation(address); - ei.addExtensor(a); - - ConduitInitiatorManager conduitMgr = getBus().getExtension(ConduitInitiatorManager.class); - ConduitInitiator conduitInit = conduitMgr.getConduitInitiator(transport); - Conduit conduit = conduitInit.getConduit(ei); - - TestMessageObserver obs = new TestMessageObserver(); - conduit.setMessageObserver(obs); - - Message m = new MessageImpl(); - conduit.send(m); - - OutputStream os = m.getContent(OutputStream.class); - InputStream is = getResourceAsStream(message); - copy(is, os, 8096); - - byte[] bs = obs.getResponseStream().toByteArray(); - if (bs.length == 0) { - throw new RuntimeException("No response was received!"); - } - ByteArrayInputStream input = new ByteArrayInputStream(bs); - return DOMUtils.readXml(input); - } - - private void copy(final InputStream input, final OutputStream output, final int bufferSize) - throws IOException { - try { - final byte[] buffer = new byte[bufferSize]; - - int n = input.read(buffer); - while (-1 != n) { - output.write(buffer, 0, n); - n = input.read(buffer); - } - } finally { - input.close(); - output.close(); - } - } - - /** - * Assert that the following XPath query selects one or more nodes. - * - * @param xpath - * @throws Exception - */ - public NodeList assertValid(String xpath, Node node) throws Exception { - return XPathAssert.assertValid(xpath, node, namespaces); - } - - /** - * Assert that the following XPath query selects no nodes. - * - * @param xpath - */ - public NodeList assertInvalid(String xpath, Node node) throws Exception { - return XPathAssert.assertInvalid(xpath, node, namespaces); - } - - /** - * Asser that the text of the xpath node retrieved is equal to the value - * specified. - * - * @param xpath - * @param value - * @param node - */ - public void assertXPathEquals(String xpath, String value, Node node) throws Exception { - XPathAssert.assertXPathEquals(xpath, value, node, namespaces); - } - - public void assertNoFault(Node node) throws Exception { - XPathAssert.assertNoFault(node); - } - - /** - * Add a namespace that will be used for XPath expressions. - * - * @param ns Namespace name. - * @param uri The namespace uri. - */ - public void addNamespace(String ns, String uri) { - namespaces.put(ns, uri); - } - - protected InputStream getResourceAsStream(String resource) { - return getClass().getResourceAsStream(resource); - } - - protected Reader getResourceAsReader(String resource) { - return new InputStreamReader(getResourceAsStream(resource)); - } - - public File getTestFile(String relativePath) { - return new File(getBasedir(), relativePath); - } - - public static String getBasedir() { - if (basedirPath != null) { - return basedirPath; - } - - basedirPath = System.getProperty("basedir"); - - if (basedirPath == null) { - basedirPath = new File("").getAbsolutePath(); - } - - return basedirPath; - } - - class TestMessageObserver implements MessageObserver { - ByteArrayOutputStream response = new ByteArrayOutputStream(); - boolean written; - - public ByteArrayOutputStream getResponseStream() throws Exception { - synchronized (this) { - if (!written) { - wait(1000000000); - } - } - return response; - } - - - public void onMessage(Message message) { - try { - copy(message.getContent(InputStream.class), response, 1024); - } catch (IOException e) { - e.printStackTrace(); - fail(); - } finally { - synchronized (this) { - written = true; - notifyAll(); - } - } - } - } -} +package org.apache.cxf.test; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.Reader; +import java.util.HashMap; +import java.util.Map; + +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import junit.framework.TestCase; + +import org.apache.cxf.Bus; +import org.apache.cxf.bus.CXFBusFactory; +import org.apache.cxf.helpers.DOMUtils; +import org.apache.cxf.message.Message; +import org.apache.cxf.message.MessageImpl; +import org.apache.cxf.service.model.EndpointInfo; +import org.apache.cxf.transport.Conduit; +import org.apache.cxf.transport.ConduitInitiator; +import org.apache.cxf.transport.ConduitInitiatorManager; +import org.apache.cxf.transport.MessageObserver; +import org.xmlsoap.schemas.wsdl.http.AddressType; + +/** + * A basic test case meant for helping users unit test their services. + */ +public class AbstractCXFTest extends TestCase { + + private static String basedirPath; + + /** + * Namespaces for the XPath expressions. + */ + private Map namespaces = new HashMap(); + + private Bus bus; + + public void setUp() throws Exception { + bus = createBus(); + + namespaces.put("s", "http://schemas.xmlsoap.org/soap/envelope/"); + } + + public Bus getBus() { + return bus; + } + + protected Bus createBus() { + return new CXFBusFactory().createBus(); + } + + protected Node invoke(String address, + String transport, + String message) throws Exception { + EndpointInfo ei = new EndpointInfo(null, "http://schemas.xmlsoap.org/soap/http"); + AddressType a = new AddressType(); + a.setLocation(address); + ei.addExtensor(a); + + ConduitInitiatorManager conduitMgr = getBus().getExtension(ConduitInitiatorManager.class); + ConduitInitiator conduitInit = conduitMgr.getConduitInitiator(transport); + Conduit conduit = conduitInit.getConduit(ei); + + TestMessageObserver obs = new TestMessageObserver(); + conduit.setMessageObserver(obs); + + Message m = new MessageImpl(); + conduit.send(m); + + OutputStream os = m.getContent(OutputStream.class); + InputStream is = getResourceAsStream(message); + copy(is, os, 8096); + + byte[] bs = obs.getResponseStream().toByteArray(); + if (bs.length == 0) { + throw new RuntimeException("No response was received!"); + } + ByteArrayInputStream input = new ByteArrayInputStream(bs); + return DOMUtils.readXml(input); + } + + private void copy(final InputStream input, final OutputStream output, final int bufferSize) + throws IOException { + try { + final byte[] buffer = new byte[bufferSize]; + + int n = input.read(buffer); + while (-1 != n) { + output.write(buffer, 0, n); + n = input.read(buffer); + } + } finally { + input.close(); + output.close(); + } + } + + /** + * Assert that the following XPath query selects one or more nodes. + * + * @param xpath + * @throws Exception + */ + public NodeList assertValid(String xpath, Node node) throws Exception { + return XPathAssert.assertValid(xpath, node, namespaces); + } + + /** + * Assert that the following XPath query selects no nodes. + * + * @param xpath + */ + public NodeList assertInvalid(String xpath, Node node) throws Exception { + return XPathAssert.assertInvalid(xpath, node, namespaces); + } + + /** + * Asser that the text of the xpath node retrieved is equal to the value + * specified. + * + * @param xpath + * @param value + * @param node + */ + public void assertXPathEquals(String xpath, String value, Node node) throws Exception { + XPathAssert.assertXPathEquals(xpath, value, node, namespaces); + } + + public void assertNoFault(Node node) throws Exception { + XPathAssert.assertNoFault(node); + } + + /** + * Add a namespace that will be used for XPath expressions. + * + * @param ns Namespace name. + * @param uri The namespace uri. + */ + public void addNamespace(String ns, String uri) { + namespaces.put(ns, uri); + } + + protected InputStream getResourceAsStream(String resource) { + return getClass().getResourceAsStream(resource); + } + + protected Reader getResourceAsReader(String resource) { + return new InputStreamReader(getResourceAsStream(resource)); + } + + public File getTestFile(String relativePath) { + return new File(getBasedir(), relativePath); + } + + public static String getBasedir() { + if (basedirPath != null) { + return basedirPath; + } + + basedirPath = System.getProperty("basedir"); + + if (basedirPath == null) { + basedirPath = new File("").getAbsolutePath(); + } + + return basedirPath; + } + + class TestMessageObserver implements MessageObserver { + ByteArrayOutputStream response = new ByteArrayOutputStream(); + boolean written; + + public ByteArrayOutputStream getResponseStream() throws Exception { + synchronized (this) { + if (!written) { + wait(1000000000); + } + } + return response; + } + + + public void onMessage(Message message) { + try { + copy(message.getContent(InputStream.class), response, 1024); + } catch (IOException e) { + e.printStackTrace(); + fail(); + } finally { + synchronized (this) { + written = true; + notifyAll(); + } + } + } + } +} Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/XPathAssert.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/XPathAssert.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractCachedOutputStream.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ChainInitiationObserver.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ChainInitiationObserver.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ConduitInitiatorManagerImpl.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/Messages.properties ------------------------------------------------------------------------------ svn:keywords = Rev Date Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLBindingFactory.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLBindingFactory.java?rev=436785&r1=436784&r2=436785&view=diff ============================================================================== --- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLBindingFactory.java (original) +++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLBindingFactory.java Fri Aug 25 06:16:36 2006 @@ -1,11 +1,11 @@ -package org.apache.cxf.wsdl11; - -import javax.wsdl.Binding; - -import org.apache.cxf.binding.BindingFactory; -import org.apache.cxf.service.model.BindingInfo; -import org.apache.cxf.service.model.ServiceInfo; - -public interface WSDLBindingFactory extends BindingFactory { - BindingInfo createBindingInfo(ServiceInfo serviceInfo, Binding binding); -} +package org.apache.cxf.wsdl11; + +import javax.wsdl.Binding; + +import org.apache.cxf.binding.BindingFactory; +import org.apache.cxf.service.model.BindingInfo; +import org.apache.cxf.service.model.ServiceInfo; + +public interface WSDLBindingFactory extends BindingFactory { + BindingInfo createBindingInfo(ServiceInfo serviceInfo, Binding binding); +} Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLBindingFactory.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLBindingFactory.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLManagerImpl.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/buslifecycle/CXFBusLifeCycleManagerTest.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Modified: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/interceptor/OutgoingChainInterceptorTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/interceptor/OutgoingChainInterceptorTest.java?rev=436785&r1=436784&r2=436785&view=diff ============================================================================== --- incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/interceptor/OutgoingChainInterceptorTest.java (original) +++ incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/interceptor/OutgoingChainInterceptorTest.java Fri Aug 25 06:16:36 2006 @@ -1,87 +1,87 @@ -package org.apache.cxf.interceptor; - -import java.util.ArrayList; -import java.util.List; - -import junit.framework.TestCase; - -import org.apache.cxf.Bus; -import org.apache.cxf.endpoint.Endpoint; -import org.apache.cxf.message.Exchange; -import org.apache.cxf.message.ExchangeImpl; -import org.apache.cxf.message.MessageImpl; -import org.apache.cxf.phase.Phase; -import org.apache.cxf.phase.PhaseManager; -import org.apache.cxf.service.Service; -import org.apache.cxf.service.model.BindingMessageInfo; -import org.apache.cxf.service.model.BindingOperationInfo; -import org.apache.cxf.service.model.MessageInfo; -import org.apache.cxf.service.model.OperationInfo; -import org.easymock.IMocksControl; -import org.easymock.classextension.EasyMock; - -public class OutgoingChainInterceptorTest extends TestCase { - - private IMocksControl control; - private Bus bus; - private Service service; - private Endpoint endpoint; - private BindingOperationInfo bopInfo; - private OperationInfo opInfo; - private BindingMessageInfo bmInfo; - private MessageInfo mInfo; - private List phases; - private List empty; - - protected void setUp() throws Exception { - super.setUp(); - - control = EasyMock.createNiceControl(); - - phases = new ArrayList(); - phases.add(new Phase(Phase.SEND, 1000)); - empty = new ArrayList(); - - bus = control.createMock(Bus.class); - PhaseManager pm = control.createMock(PhaseManager.class); - EasyMock.expect(bus.getExtension(PhaseManager.class)).andReturn(pm); - EasyMock.expect(pm.getOutPhases()).andReturn(phases); - - service = control.createMock(Service.class); - endpoint = control.createMock(Endpoint.class); - EasyMock.expect(endpoint.getService()).andReturn(service); - EasyMock.expect(endpoint.getOutInterceptors()).andReturn(empty); - EasyMock.expect(service.getOutInterceptors()).andReturn(empty); - - bopInfo = control.createMock(BindingOperationInfo.class); - opInfo = control.createMock(OperationInfo.class); - mInfo = control.createMock(MessageInfo.class); - bmInfo = control.createMock(BindingMessageInfo.class); - EasyMock.expect(bopInfo.getOperationInfo()).andReturn(opInfo).times(2); - EasyMock.expect(opInfo.getOutput()).andReturn(mInfo); - EasyMock.expect(bopInfo.getOutput()).andReturn(bmInfo); - - control.replay(); - - } - - public void tearDown() { - control.verify(); - } - - public void testInterceptor() throws Exception { - OutgoingChainSetupInterceptor setupIntc = new OutgoingChainSetupInterceptor(); - OutgoingChainInterceptor intc = new OutgoingChainInterceptor(); - - MessageImpl m = new MessageImpl(); - Exchange exchange = new ExchangeImpl(); - m.setExchange(exchange); - exchange.setOutMessage(m); - exchange.put(Bus.class, bus); - exchange.put(Endpoint.class, endpoint); - exchange.put(BindingOperationInfo.class, bopInfo); - setupIntc.handleMessage(m); - intc.handleMessage(m); - } - -} +package org.apache.cxf.interceptor; + +import java.util.ArrayList; +import java.util.List; + +import junit.framework.TestCase; + +import org.apache.cxf.Bus; +import org.apache.cxf.endpoint.Endpoint; +import org.apache.cxf.message.Exchange; +import org.apache.cxf.message.ExchangeImpl; +import org.apache.cxf.message.MessageImpl; +import org.apache.cxf.phase.Phase; +import org.apache.cxf.phase.PhaseManager; +import org.apache.cxf.service.Service; +import org.apache.cxf.service.model.BindingMessageInfo; +import org.apache.cxf.service.model.BindingOperationInfo; +import org.apache.cxf.service.model.MessageInfo; +import org.apache.cxf.service.model.OperationInfo; +import org.easymock.IMocksControl; +import org.easymock.classextension.EasyMock; + +public class OutgoingChainInterceptorTest extends TestCase { + + private IMocksControl control; + private Bus bus; + private Service service; + private Endpoint endpoint; + private BindingOperationInfo bopInfo; + private OperationInfo opInfo; + private BindingMessageInfo bmInfo; + private MessageInfo mInfo; + private List phases; + private List empty; + + protected void setUp() throws Exception { + super.setUp(); + + control = EasyMock.createNiceControl(); + + phases = new ArrayList(); + phases.add(new Phase(Phase.SEND, 1000)); + empty = new ArrayList(); + + bus = control.createMock(Bus.class); + PhaseManager pm = control.createMock(PhaseManager.class); + EasyMock.expect(bus.getExtension(PhaseManager.class)).andReturn(pm); + EasyMock.expect(pm.getOutPhases()).andReturn(phases); + + service = control.createMock(Service.class); + endpoint = control.createMock(Endpoint.class); + EasyMock.expect(endpoint.getService()).andReturn(service); + EasyMock.expect(endpoint.getOutInterceptors()).andReturn(empty); + EasyMock.expect(service.getOutInterceptors()).andReturn(empty); + + bopInfo = control.createMock(BindingOperationInfo.class); + opInfo = control.createMock(OperationInfo.class); + mInfo = control.createMock(MessageInfo.class); + bmInfo = control.createMock(BindingMessageInfo.class); + EasyMock.expect(bopInfo.getOperationInfo()).andReturn(opInfo).times(2); + EasyMock.expect(opInfo.getOutput()).andReturn(mInfo); + EasyMock.expect(bopInfo.getOutput()).andReturn(bmInfo); + + control.replay(); + + } + + public void tearDown() { + control.verify(); + } + + public void testInterceptor() throws Exception { + OutgoingChainSetupInterceptor setupIntc = new OutgoingChainSetupInterceptor(); + OutgoingChainInterceptor intc = new OutgoingChainInterceptor(); + + MessageImpl m = new MessageImpl(); + Exchange exchange = new ExchangeImpl(); + m.setExchange(exchange); + exchange.setOutMessage(m); + exchange.put(Bus.class, bus); + exchange.put(Endpoint.class, endpoint); + exchange.put(BindingOperationInfo.class, bopInfo); + setupIntc.handleMessage(m); + intc.handleMessage(m); + } + +} Propchange: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/interceptor/OutgoingChainInterceptorTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/interceptor/OutgoingChainInterceptorTest.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Modified: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/interceptor/ServiceInvokerInterceptorTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/interceptor/ServiceInvokerInterceptorTest.java?rev=436785&r1=436784&r2=436785&view=diff ============================================================================== --- incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/interceptor/ServiceInvokerInterceptorTest.java (original) +++ incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/interceptor/ServiceInvokerInterceptorTest.java Fri Aug 25 06:16:36 2006 @@ -1,78 +1,78 @@ -package org.apache.cxf.interceptor; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.Executor; - -import junit.framework.TestCase; - -import org.apache.cxf.endpoint.Endpoint; -import org.apache.cxf.message.Exchange; -import org.apache.cxf.message.ExchangeImpl; -import org.apache.cxf.message.MessageImpl; -import org.apache.cxf.service.ServiceImpl; -import org.apache.cxf.service.invoker.Invoker; -import org.easymock.IMocksControl; - -import static org.easymock.EasyMock.createNiceControl; -import static org.easymock.EasyMock.expect; - -public class ServiceInvokerInterceptorTest extends TestCase { - public void testInterceptor() throws Exception { - ServiceInvokerInterceptor intc = new ServiceInvokerInterceptor(); - - MessageImpl m = new MessageImpl(); - Exchange exchange = new ExchangeImpl(); - m.setExchange(exchange); - exchange.setInMessage(m); - - exchange.setOutMessage(new MessageImpl()); - - TestInvoker i = new TestInvoker(); - Endpoint endpoint = createEndpoint(i); - exchange.put(Endpoint.class, endpoint); - Object input = new Object(); - List lst = new ArrayList(); - lst.add(input); - m.setContent(List.class, lst); - - intc.handleMessage(m); - - assertTrue(i.invoked); - - List list = exchange.getOutMessage().getContent(List.class); - assertEquals(input, list.get(0)); - } - - Endpoint createEndpoint(Invoker i) throws Exception { - IMocksControl control = createNiceControl(); - Endpoint endpoint = control.createMock(Endpoint.class); - - ServiceImpl service = new ServiceImpl(null); - service.setInvoker(i); - service.setExecutor(new SimpleExecutor()); - expect(endpoint.getService()).andReturn(service).anyTimes(); - - control.replay(); - - return endpoint; - } - - static class TestInvoker implements Invoker { - boolean invoked; - public Object invoke(Exchange exchange, Object o) { - invoked = true; - assertNotNull(exchange); - assertNotNull(o); - return o; - } - } - - static class SimpleExecutor implements Executor { - - public void execute(Runnable command) { - command.run(); - } - - } -} +package org.apache.cxf.interceptor; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.Executor; + +import junit.framework.TestCase; + +import org.apache.cxf.endpoint.Endpoint; +import org.apache.cxf.message.Exchange; +import org.apache.cxf.message.ExchangeImpl; +import org.apache.cxf.message.MessageImpl; +import org.apache.cxf.service.ServiceImpl; +import org.apache.cxf.service.invoker.Invoker; +import org.easymock.IMocksControl; + +import static org.easymock.EasyMock.createNiceControl; +import static org.easymock.EasyMock.expect; + +public class ServiceInvokerInterceptorTest extends TestCase { + public void testInterceptor() throws Exception { + ServiceInvokerInterceptor intc = new ServiceInvokerInterceptor(); + + MessageImpl m = new MessageImpl(); + Exchange exchange = new ExchangeImpl(); + m.setExchange(exchange); + exchange.setInMessage(m); + + exchange.setOutMessage(new MessageImpl()); + + TestInvoker i = new TestInvoker(); + Endpoint endpoint = createEndpoint(i); + exchange.put(Endpoint.class, endpoint); + Object input = new Object(); + List lst = new ArrayList(); + lst.add(input); + m.setContent(List.class, lst); + + intc.handleMessage(m); + + assertTrue(i.invoked); + + List list = exchange.getOutMessage().getContent(List.class); + assertEquals(input, list.get(0)); + } + + Endpoint createEndpoint(Invoker i) throws Exception { + IMocksControl control = createNiceControl(); + Endpoint endpoint = control.createMock(Endpoint.class); + + ServiceImpl service = new ServiceImpl(null); + service.setInvoker(i); + service.setExecutor(new SimpleExecutor()); + expect(endpoint.getService()).andReturn(service).anyTimes(); + + control.replay(); + + return endpoint; + } + + static class TestInvoker implements Invoker { + boolean invoked; + public Object invoke(Exchange exchange, Object o) { + invoked = true; + assertNotNull(exchange); + assertNotNull(o); + return o; + } + } + + static class SimpleExecutor implements Executor { + + public void execute(Runnable command) { + command.run(); + } + + } +} Propchange: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/interceptor/ServiceInvokerInterceptorTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/interceptor/ServiceInvokerInterceptorTest.java ------------------------------------------------------------------------------ svn:keywords = Rev Date