⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 objectservicefactory.java

📁 Xfire文件 用于开发web service 的一个开源工具 很好用的
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    }        protected OperationInfo addOperation(Service endpoint, final Method method, String style)    {        ServiceInfo service = endpoint.getServiceInfo();        final String opName = getOperationName(service, method);        final OperationInfo op = service.addOperation(opName, method);        final Class[] paramClasses = method.getParameterTypes();        boolean isDoc = style.equals(SoapConstants.STYLE_DOCUMENT);        // Setup the input message        MessageInfo inMsg = op.createMessage(createInputMessageName(op));        op.setInputMessage(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.setDocumentation(getDocumentationProvider().getParamters(op, j));                part.setSchemaElement(isDoc || endpoint.getServiceInfo().isWrapped());            }        }        String mep = getMEP(method);        op.setMEP(mep);        if (hasOutMessage(mep))        {            // Setup the output message            MessageInfo outMsg = op.createMessage(createOutputMessageName(op));            op.setOutputMessage(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());                part.setIndex(-1);                part.setDocumentation(getDocumentationProvider().getResultDocumentation(op));                                part.setSchemaElement(isDoc || endpoint.getServiceInfo().isWrapped());            }                        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());                }            }        }        if (isCustomFaultsEnabled())            initializeFaults(endpoint, op);                op.setAsync(isAsync(method));        op.setDocumenation(documentationProvider.getOperationDoc(op));        return op;    }    protected boolean isOutParam(Method method, int j)    {        for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();)        {            ServiceConfiguration c = (ServiceConfiguration) 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();)        {            ServiceConfiguration c = (ServiceConfiguration) itr.next();            Boolean b = c.isInParam(method, j);            if (b != null) return b.booleanValue();        }        return true;    }        protected QName createInputMessageName(final OperationInfo op)    {        for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();)        {            ServiceConfiguration c = (ServiceConfiguration) 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();)        {            ServiceConfiguration c = (ServiceConfiguration) 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();)        {            ServiceConfiguration c = (ServiceConfiguration) itr.next();            Boolean b = c.hasOutMessage(mep);            if (b != null) return b.booleanValue();        }        return true;    }        protected void initializeFaults(final Service service,                                     final OperationInfo op)    {        // Set up the fault messages        final Class[] exceptionClasses = op.getMethod().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(XFireFault.class) ||                    exClazz.equals(Exception.class) ||                    exClazz.equals(RuntimeException.class) ||                    exClazz.equals(Throwable.class))            {                continue;            }                        addFault(service, op, exClazz);        }    }    protected FaultInfo addFault(final Service service, final OperationInfo op, Class exClass)    {        Class beanClass = exClass;        if (isFaultInfoClass(exClass))        {            Method method;            try            {                method = exClass.getMethod("getFaultInfo", new Class[0]);                beanClass = method.getReturnType();            }            catch (SecurityException e)            {                throw new XFireRuntimeException("Couldn't access getFaultInfo method.", e);            }            catch (NoSuchMethodException e)            {                beanClass = exClass;            }        }                QName name = getFaultName(service, op, exClass, beanClass);        FaultInfo info = op.addFault(name.getLocalPart());        info.setExceptionClass(exClass);        info.addMessagePart(name, beanClass);        info.setDocumentation(getDocumentationProvider().getExceptionDocumentation(op, exClass.getName()));                return info;    }    protected boolean isFaultInfoClass(Class exClass)    {        return FaultInfoException.class.isAssignableFrom(exClass);    }    protected QName getFaultName(Service service, OperationInfo o, Class exClass, Class beanClass)    {        for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();)        {            ServiceConfiguration c = (ServiceConfiguration) 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();)        {            ServiceConfiguration c = (ServiceConfiguration) 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();)        {            ServiceConfiguration c = (ServiceConfiguration) 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 <code>doSomething</code>, the first one will have an operation name of     * "doSomething" and the second "doSomething1".     *      * @param service     * @param method     */    protected String getOperationName(ServiceInfo service, Method method)    {        for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();)        {            ServiceConfiguration c = (ServiceConfiguration) itr.next();            String s = c.getOperationName(service, method);            if (s != null) return s;        }        throw new IllegalStateException("ServiceConfiguration must provide a value!");    }    protected String getMEP(final Method method)    {        for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();)        {            ServiceConfiguration c = (ServiceConfiguration) itr.next();            String s = c.getMEP(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();)        {            ServiceConfiguration c = (ServiceConfiguration) 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();)        {            ServiceConfiguration c = (ServiceConfiguration) itr.next();            QName q = c.getInParameterName(service, 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();)        {            ServiceConfiguration c = (ServiceConfiguration) itr.next();            QName q = c.getOutParameterName(service, op, method, paramNumber, doc);            if (q != null) return q;        }        throw new IllegalStateException("ServiceConfiguration must provide a value!");    }    public TransportManager getTransportManager()    {        return transportManager;    }    public void setTransportManager(TransportManager transportManager)    {        this.transportManager = transportManager;    }    public void setBindingProvider(BindingProvider bindingProvider)    {        this.bindingProvider = bindingProvider;    }    public String getStyle()    {        return style;    }    public void setStyle(String style)    {        this.style = style;    }    public String getUse()    {        return use;    }    public void setUse(String use)    {        this.use = use;    }    public boolean isVoidOneWay()    {        return voidOneWay;    }    public void setVoidOneWay(boolean voidOneWay)    {        this.voidOneWay = voidOneWay;    }    public WSDLBuilderFactory getWsdlBuilderFactory()    {        return wsdlBuilderFactory;    }    public void setWsdlBuilderFactory(WSDLBuilderFactory wsdlBuilderFactory)    {        this.wsdlBuilderFactory = wsdlBuilderFactory;    }    public boolean isCustomFaultsEnabled()    {        return customFaultsEnabled;    }    public void setCustomFaultsEnabled(boolean customFaultsEnabled)    {        this.customFaultsEnabled = customFaultsEnabled;    }    public boolean isBindingCreationEnabled()    {        return bindingCreationEnabled;    }    public void setBindingCreationEnabled(boolean bindingCreationEnabled)    {        this.bindingCreationEnabled = bindingCreationEnabled;    }    public Set getIgnoredClasses()    {        return ignoredClasses;    }    public List getServiceConfigurations()    {        return serviceConfigurations;    }    public void setServiceConfigurations(List serviceConfigurations)    {        this.serviceConfigurations = serviceConfigurations;    }    protected DocumentationProvider getDocumentationProvider()    {        return documentationProvider;    }    protected void setDocumentationProvider(DocumentationProvider documentationProvider)    {        this.documentationProvider = documentationProvider;    }            }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -