类javax.jws.HandlerChain源码实例Demo

下面列出了怎么用javax.jws.HandlerChain的API类实例代码及写法,或者点击链接到github查看源代码。

static InputStream getFileAsStream(Class clazz, HandlerChain chain) {
    URL url = clazz.getResource(chain.file());
    if (url == null) {
        url = Thread.currentThread().getContextClassLoader().
            getResource(chain.file());
    }
    if (url == null) {
        String tmp = clazz.getPackage().getName();
        tmp = tmp.replace('.', '/');
        tmp += "/" + chain.file();
        url =
            Thread.currentThread().getContextClassLoader().getResource(tmp);
    }
    if (url == null) {
        throw new UtilException("util.failed.to.find.handlerchain.file",
            clazz.getName(), chain.file());
    }
    try {
        return url.openStream();
    } catch (IOException e) {
        throw new UtilException("util.failed.to.parse.handlerchain.file",
            clazz.getName(), chain.file());
    }
}
 
源代码2 项目: jdk8u60   文件: HandlerAnnotationProcessor.java
static InputStream getFileAsStream(Class clazz, HandlerChain chain) {
    URL url = clazz.getResource(chain.file());
    if (url == null) {
        url = Thread.currentThread().getContextClassLoader().
            getResource(chain.file());
    }
    if (url == null) {
        String tmp = clazz.getPackage().getName();
        tmp = tmp.replace('.', '/');
        tmp += "/" + chain.file();
        url =
            Thread.currentThread().getContextClassLoader().getResource(tmp);
    }
    if (url == null) {
        throw new UtilException("util.failed.to.find.handlerchain.file",
            clazz.getName(), chain.file());
    }
    try {
        return url.openStream();
    } catch (IOException e) {
        throw new UtilException("util.failed.to.parse.handlerchain.file",
            clazz.getName(), chain.file());
    }
}
 
static InputStream getFileAsStream(Class clazz, HandlerChain chain) {
    URL url = clazz.getResource(chain.file());
    if (url == null) {
        url = Thread.currentThread().getContextClassLoader().
            getResource(chain.file());
    }
    if (url == null) {
        String tmp = clazz.getPackage().getName();
        tmp = tmp.replace('.', '/');
        tmp += "/" + chain.file();
        url =
            Thread.currentThread().getContextClassLoader().getResource(tmp);
    }
    if (url == null) {
        throw new UtilException("util.failed.to.find.handlerchain.file",
            clazz.getName(), chain.file());
    }
    try {
        return url.openStream();
    } catch (IOException e) {
        throw new UtilException("util.failed.to.parse.handlerchain.file",
            clazz.getName(), chain.file());
    }
}
 
static InputStream getFileAsStream(Class clazz, HandlerChain chain) {
    URL url = clazz.getResource(chain.file());
    if (url == null) {
        url = Thread.currentThread().getContextClassLoader().
            getResource(chain.file());
    }
    if (url == null) {
        String tmp = clazz.getPackage().getName();
        tmp = tmp.replace('.', '/');
        tmp += "/" + chain.file();
        url =
            Thread.currentThread().getContextClassLoader().getResource(tmp);
    }
    if (url == null) {
        throw new UtilException("util.failed.to.find.handlerchain.file",
            clazz.getName(), chain.file());
    }
    try {
        return url.openStream();
    } catch (IOException e) {
        throw new UtilException("util.failed.to.parse.handlerchain.file",
            clazz.getName(), chain.file());
    }
}
 
源代码5 项目: openjdk-jdk9   文件: HandlerAnnotationProcessor.java
static InputStream getFileAsStream(Class clazz, HandlerChain chain) {
    Package pkg = clazz.getPackage();
    String filename = chain.file();
    String fullpath = addPackagePath(filename, pkg);
    InputStream is;

    is = moduleResource(clazz, filename);
    if (is != null) return is;

    is = moduleResource(clazz, fullpath);
    if (is != null) return is;

    URL url = cpResource(clazz, filename);
    if (url == null) url = cpResource(clazz, fullpath);

    if (url == null) {
        throw new UtilException("util.failed.to.find.handlerchain.file",
                clazz.getName(), filename);
    }
    try {
        return url.openStream();
    } catch (IOException e) {
        throw new UtilException("util.failed.to.parse.handlerchain.file",
                clazz.getName(), filename);
    }
}
 
源代码6 项目: hottub   文件: HandlerAnnotationProcessor.java
static InputStream getFileAsStream(Class clazz, HandlerChain chain) {
    URL url = clazz.getResource(chain.file());
    if (url == null) {
        url = Thread.currentThread().getContextClassLoader().
            getResource(chain.file());
    }
    if (url == null) {
        String tmp = clazz.getPackage().getName();
        tmp = tmp.replace('.', '/');
        tmp += "/" + chain.file();
        url =
            Thread.currentThread().getContextClassLoader().getResource(tmp);
    }
    if (url == null) {
        throw new UtilException("util.failed.to.find.handlerchain.file",
            clazz.getName(), chain.file());
    }
    try {
        return url.openStream();
    } catch (IOException e) {
        throw new UtilException("util.failed.to.parse.handlerchain.file",
            clazz.getName(), chain.file());
    }
}
 
static InputStream getFileAsStream(Class clazz, HandlerChain chain) {
    URL url = clazz.getResource(chain.file());
    if (url == null) {
        url = Thread.currentThread().getContextClassLoader().
            getResource(chain.file());
    }
    if (url == null) {
        String tmp = clazz.getPackage().getName();
        tmp = tmp.replace('.', '/');
        tmp += "/" + chain.file();
        url =
            Thread.currentThread().getContextClassLoader().getResource(tmp);
    }
    if (url == null) {
        throw new UtilException("util.failed.to.find.handlerchain.file",
            clazz.getName(), chain.file());
    }
    try {
        return url.openStream();
    } catch (IOException e) {
        throw new UtilException("util.failed.to.parse.handlerchain.file",
            clazz.getName(), chain.file());
    }
}
 
源代码8 项目: openjdk-8   文件: HandlerAnnotationProcessor.java
static InputStream getFileAsStream(Class clazz, HandlerChain chain) {
    URL url = clazz.getResource(chain.file());
    if (url == null) {
        url = Thread.currentThread().getContextClassLoader().
            getResource(chain.file());
    }
    if (url == null) {
        String tmp = clazz.getPackage().getName();
        tmp = tmp.replace('.', '/');
        tmp += "/" + chain.file();
        url =
            Thread.currentThread().getContextClassLoader().getResource(tmp);
    }
    if (url == null) {
        throw new UtilException("util.failed.to.find.handlerchain.file",
            clazz.getName(), chain.file());
    }
    try {
        return url.openStream();
    } catch (IOException e) {
        throw new UtilException("util.failed.to.parse.handlerchain.file",
            clazz.getName(), chain.file());
    }
}
 
源代码9 项目: cxf   文件: HandlerConfigGenerator.java
public void generate(ToolContext penv) throws ToolException {
    this.env = penv;

    if (passthrough()) {
        return;
    }

    Element e = this.intf.getHandlerChains();
    List<Element> elemList = DOMUtils.findAllElementsByTagNameNS(e,
                                                                 ToolConstants.HANDLER_CHAINS_URI,
                                                                 ToolConstants.HANDLER_CHAIN);
    if (!elemList.isEmpty()) {
        String fName = ProcessorUtil.getHandlerConfigFileName(this.intf.getName());
        handlerChainAnnotation = new JAnnotation(HandlerChain.class);
        handlerChainAnnotation.addElement(new JAnnotationElement("name",
                                                                 HANDLER_CHAIN_NAME));
        handlerChainAnnotation.addElement(new JAnnotationElement("file", fName + ".xml"));
        generateHandlerChainFile(e, parseOutputName(this.intf.getPackageName(),
                                                    fName,
                                                    ".xml"));
    }
}
 
源代码10 项目: tomee   文件: WsDeployer.java
public static HandlerChains getHandlerChains(Class<?> declaringClass, final String serviceEndpoint, final ClassLoader classLoader) throws OpenEJBException {
    HandlerChain handlerChain = declaringClass.getAnnotation(HandlerChain.class);
    if (handlerChain == null && serviceEndpoint != null) {
        try {
            declaringClass = classLoader.loadClass(serviceEndpoint);
            handlerChain = declaringClass.getAnnotation(HandlerChain.class);
        } catch (final ClassNotFoundException ignored) {
            // no-op
        }
    }
    HandlerChains handlerChains = null;
    if (handlerChain != null) {
        try {
            final URL handlerFileURL = declaringClass.getResource(handlerChain.file());
            handlerChains = ReadDescriptors.readHandlerChains(handlerFileURL);
        } catch (final Throwable e) {
            throw new OpenEJBException("Unable to load handler chain file: " + handlerChain.file(), e);
        }
    }
    return handlerChains;
}
 
源代码11 项目: TencentKona-8   文件: GeneratorBase.java
protected void writeHandlerConfig(String className, JDefinedClass cls, WsimportOptions options) {
    Element e = options.getHandlerChainConfiguration();
    if (e == null) {
        return;
    }
    JAnnotationUse handlerChainAnn = cls.annotate(cm.ref(HandlerChain.class));
    NodeList nl = e.getElementsByTagNameNS(
        "http://java.sun.com/xml/ns/javaee", "handler-chain");
    if(nl.getLength() > 0){
        String fName = getHandlerConfigFileName(className);
        handlerChainAnn.param("file", fName);
        generateHandlerChainFile(e, className);
    }
}
 
源代码12 项目: jdk8u60   文件: GeneratorBase.java
protected void writeHandlerConfig(String className, JDefinedClass cls, WsimportOptions options) {
    Element e = options.getHandlerChainConfiguration();
    if (e == null) {
        return;
    }
    JAnnotationUse handlerChainAnn = cls.annotate(cm.ref(HandlerChain.class));
    NodeList nl = e.getElementsByTagNameNS(
        "http://java.sun.com/xml/ns/javaee", "handler-chain");
    if(nl.getLength() > 0){
        String fName = getHandlerConfigFileName(className);
        handlerChainAnn.param("file", fName);
        generateHandlerChainFile(e, className);
    }
}
 
源代码13 项目: openjdk-jdk8u   文件: GeneratorBase.java
protected void writeHandlerConfig(String className, JDefinedClass cls, WsimportOptions options) {
    Element e = options.getHandlerChainConfiguration();
    if (e == null) {
        return;
    }
    JAnnotationUse handlerChainAnn = cls.annotate(cm.ref(HandlerChain.class));
    NodeList nl = e.getElementsByTagNameNS(
        "http://java.sun.com/xml/ns/javaee", "handler-chain");
    if(nl.getLength() > 0){
        String fName = getHandlerConfigFileName(className);
        handlerChainAnn.param("file", fName);
        generateHandlerChainFile(e, className);
    }
}
 
源代码14 项目: openjdk-jdk8u-backup   文件: GeneratorBase.java
protected void writeHandlerConfig(String className, JDefinedClass cls, WsimportOptions options) {
    Element e = options.getHandlerChainConfiguration();
    if (e == null) {
        return;
    }
    JAnnotationUse handlerChainAnn = cls.annotate(cm.ref(HandlerChain.class));
    NodeList nl = e.getElementsByTagNameNS(
        "http://java.sun.com/xml/ns/javaee", "handler-chain");
    if(nl.getLength() > 0){
        String fName = getHandlerConfigFileName(className);
        handlerChainAnn.param("file", fName);
        generateHandlerChainFile(e, className);
    }
}
 
源代码15 项目: openjdk-jdk9   文件: GeneratorBase.java
protected void writeHandlerConfig(String className, JDefinedClass cls, WsimportOptions options) {
    Element e = options.getHandlerChainConfiguration();
    if (e == null) {
        return;
    }
    JAnnotationUse handlerChainAnn = cls.annotate(cm.ref(HandlerChain.class));
    NodeList nl = e.getElementsByTagNameNS(
        "http://java.sun.com/xml/ns/javaee", "handler-chain");
    if(nl.getLength() > 0){
        String fName = getHandlerConfigFileName(className);
        handlerChainAnn.param("file", fName);
        generateHandlerChainFile(e, className);
    }
}
 
源代码16 项目: hottub   文件: GeneratorBase.java
protected void writeHandlerConfig(String className, JDefinedClass cls, WsimportOptions options) {
    Element e = options.getHandlerChainConfiguration();
    if (e == null) {
        return;
    }
    JAnnotationUse handlerChainAnn = cls.annotate(cm.ref(HandlerChain.class));
    NodeList nl = e.getElementsByTagNameNS(
        "http://java.sun.com/xml/ns/javaee", "handler-chain");
    if(nl.getLength() > 0){
        String fName = getHandlerConfigFileName(className);
        handlerChainAnn.param("file", fName);
        generateHandlerChainFile(e, className);
    }
}
 
源代码17 项目: openjdk-8-source   文件: GeneratorBase.java
protected void writeHandlerConfig(String className, JDefinedClass cls, WsimportOptions options) {
    Element e = options.getHandlerChainConfiguration();
    if (e == null) {
        return;
    }
    JAnnotationUse handlerChainAnn = cls.annotate(cm.ref(HandlerChain.class));
    NodeList nl = e.getElementsByTagNameNS(
        "http://java.sun.com/xml/ns/javaee", "handler-chain");
    if(nl.getLength() > 0){
        String fName = getHandlerConfigFileName(className);
        handlerChainAnn.param("file", fName);
        generateHandlerChainFile(e, className);
    }
}
 
源代码18 项目: openjdk-8   文件: GeneratorBase.java
protected void writeHandlerConfig(String className, JDefinedClass cls, WsimportOptions options) {
    Element e = options.getHandlerChainConfiguration();
    if (e == null) {
        return;
    }
    JAnnotationUse handlerChainAnn = cls.annotate(cm.ref(HandlerChain.class));
    NodeList nl = e.getElementsByTagNameNS(
        "http://java.sun.com/xml/ns/javaee", "handler-chain");
    if(nl.getLength() > 0){
        String fName = getHandlerConfigFileName(className);
        handlerChainAnn.param("file", fName);
        generateHandlerChainFile(e, className);
    }
}
 
源代码19 项目: cxf   文件: CodeGenTest.java
@Test
public void testWSAddress() throws Exception {
    env.addNamespacePackageMap("http://cxf.apache.org/w2j/hello_world_soap_http", "ws.address");
    env.put(ToolConstants.CFG_BINDING, getLocation("/wsdl2java_wsdl/ws_address_binding.wsdl"));
    env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world_addr.wsdl"));

    processor.setContext(env);
    processor.execute();

    assertNotNull(output);

    File ws = new File(output, "ws");
    assertTrue(ws.exists());
    File address = new File(ws, "address");
    assertTrue(address.exists());

    File[] files = address.listFiles();
    assertEquals(Arrays.asList(address.listFiles()).toString(), 6, files.length);
    File handlerConfig = new File(address, "Greeter_handler.xml");
    assertTrue(handlerConfig.exists());

    Class<?> clz = classLoader.loadClass("ws.address.Greeter");
    HandlerChain handlerChainAnno = AnnotationUtil.getPrivClassAnnotation(clz, HandlerChain.class);
    assertEquals("Greeter_handler.xml", handlerChainAnno.file());
    assertNotNull("Handler chain xml generate fail!", classLoader
        .getResource("ws/address/Greeter_handler.xml"));
}
 
源代码20 项目: cxf   文件: SEIGenerator.java
public void generate(ToolContext penv) throws ToolException {
    this.env = penv;
    if (passthrough()) {
        return;
    }

    Map<QName, JavaModel> map = CastUtils.cast((Map<?, ?>)penv.get(WSDLToJavaProcessor.MODEL_MAP));
    for (JavaModel javaModel : map.values()) {

        Map<String, JavaInterface> interfaces = javaModel.getInterfaces();

        if (interfaces.isEmpty()) {
            ServiceInfo serviceInfo = env.get(ServiceInfo.class);
            String wsdl = serviceInfo.getDescription().getBaseURI();
            Message msg = new Message("CAN_NOT_GEN_SEI", LOG, wsdl);
            if (penv.isVerbose()) {
                System.out.println(msg.toString());
            }
            continue;
        }
        for (JavaInterface intf : interfaces.values()) {

            if (hasHandlerConfig(intf)) {
                HandlerConfigGenerator handlerGen = new HandlerConfigGenerator();
                // REVISIT: find a better way to handle Handler gen, should not
                // pass JavaInterface around.
                handlerGen.setJavaInterface(intf);
                handlerGen.generate(getEnvironment());

                JAnnotation annot = handlerGen.getHandlerAnnotation();
                if (handlerGen.getHandlerAnnotation() != null) {
                    boolean existHandlerAnno = false;
                    for (JAnnotation jann : intf.getAnnotations()) {
                        if (jann.getType() == HandlerChain.class) {
                            existHandlerAnno = true;
                        }
                    }
                    if (!existHandlerAnno) {
                        intf.addAnnotation(annot);
                        intf.addImport("javax.jws.HandlerChain");
                    }
                }
            }
            if (penv.containsKey(ToolConstants.RUNTIME_DATABINDING_CLASS)) {
                JAnnotation ann = new JAnnotation(DataBinding.class);
                JAnnotationElement el
                    = new JAnnotationElement(null,
                                             penv.get(ToolConstants.RUNTIME_DATABINDING_CLASS),
                                             true);
                ann.addElement(el);
                intf.addAnnotation(ann);
            }
            clearAttributes();
            setAttributes("intf", intf);
            String seiSc = "";
            for (String s : intf.getSuperInterfaces()) {
                if (!seiSc.isEmpty()) {
                    seiSc += ", ";
                } else {
                    seiSc = "extends ";
                }
                seiSc += s;
            }
            if (!StringUtils.isEmpty(seiSc)) {
                seiSc += " ";
            }
            setAttributes("seiSuperinterfaceString", seiSc);
            setCommonAttributes();

            doWrite(SEI_TEMPLATE, parseOutputName(intf.getPackageName(), intf.getName()));

        }
    }
}
 
源代码21 项目: cxf   文件: AnnotationHandlerChainBuilder.java
private HandlerChainAnnotation findHandlerChainAnnotation(Class<?> clz, boolean searchSEI) {
    if (clz == null) {
        return null;
    }
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("Checking for HandlerChain annotation on " + clz.getName());
    }
    HandlerChainAnnotation hcAnn = null;
    HandlerChain ann = clz.getAnnotation(HandlerChain.class);
    if (ann == null) {
        if (searchSEI) {
            /* HandlerChain annotation can be specified on the SEI
             * but the implementation bean might not implement the SEI.
             */
            WebService ws = clz.getAnnotation(WebService.class);
            if (ws != null && !StringUtils.isEmpty(ws.endpointInterface())) {
                String seiClassName = ws.endpointInterface().trim();
                Class<?> seiClass = null;
                try {
                    seiClass = ClassLoaderUtils.loadClass(seiClassName, clz);
                } catch (ClassNotFoundException e) {
                    throw new WebServiceException(BUNDLE.getString("SEI_LOAD_FAILURE_EXC"), e);
                }

                // check SEI class and its interfaces for HandlerChain annotation
                hcAnn = findHandlerChainAnnotation(seiClass, false);
            }
        }
        if (hcAnn == null) {
            // check interfaces for HandlerChain annotation
            for (Class<?> iface : clz.getInterfaces()) {
                if (LOG.isLoggable(Level.FINE)) {
                    LOG.fine("Checking for HandlerChain annotation on " + iface.getName());
                }
                ann = iface.getAnnotation(HandlerChain.class);
                if (ann != null) {
                    hcAnn = new HandlerChainAnnotation(ann, iface);
                    break;
                }
            }
            if (hcAnn == null) {
                hcAnn = findHandlerChainAnnotation(clz.getSuperclass(), false);
            }
        }
    } else {
        hcAnn = new HandlerChainAnnotation(ann, clz);
    }

    return hcAnn;
}
 
源代码22 项目: cxf   文件: AnnotationHandlerChainBuilder.java
HandlerChainAnnotation(HandlerChain hc, Class<?> clz) {
    ann = hc;
    declaringClass = clz;
}