Search in sources :

Example 1 with PortComponentHandlerType

use of org.apache.cxf.jaxws.handler.types.PortComponentHandlerType in project cxf by apache.

the class AnnotationHandlerChainBuilder method processHandlerElement.

private void processHandlerElement(Element el, List<Handler> chain) {
    try {
        JAXBContext ctx = getContextForPortComponentHandlerType();
        PortComponentHandlerType pt = JAXBUtils.unmarshall(ctx, el, PortComponentHandlerType.class).getValue();
        chain.addAll(buildHandlerChain(pt, classLoader));
    } catch (JAXBException e) {
        throw new IllegalArgumentException("Could not unmarshal handler chain", e);
    }
}
Also used : JAXBException(javax.xml.bind.JAXBException) JAXBContext(javax.xml.bind.JAXBContext) PortComponentHandlerType(org.apache.cxf.jaxws.handler.types.PortComponentHandlerType)

Example 2 with PortComponentHandlerType

use of org.apache.cxf.jaxws.handler.types.PortComponentHandlerType in project jbossws-cxf by jbossws.

the class CXFHandlerResolverImpl method processHandlerElement.

private void processHandlerElement(Element el, @SuppressWarnings("rawtypes") List<Handler> chain) {
    try {
        JAXBContext ctx = Holder.context;
        PortComponentHandlerType pt = ctx.createUnmarshaller().unmarshal(el, PortComponentHandlerType.class).getValue();
        chain.addAll(buildHandlerChain(pt, classLoader));
    } catch (JAXBException e) {
        DEPLOYMENT_LOGGER.unableToProcessHandlerElement(el, e);
    }
}
Also used : JAXBException(javax.xml.bind.JAXBException) JAXBContext(javax.xml.bind.JAXBContext) PortComponentHandlerType(org.apache.cxf.jaxws.handler.types.PortComponentHandlerType)

Example 3 with PortComponentHandlerType

use of org.apache.cxf.jaxws.handler.types.PortComponentHandlerType in project cxf by apache.

the class HandlerChainBuilderTest method testBuilderCallsInitWithNoInitParamValues.

@Test
public void testBuilderCallsInitWithNoInitParamValues() {
    List<PortComponentHandlerType> hc = createHandlerChainType();
    hc.remove(3);
    hc.remove(2);
    hc.remove(1);
    PortComponentHandlerType h = hc.get(0);
    List<ParamValueType> params = h.getInitParam();
    ParamValueType p = new ParamValueType();
    CString pName = new CString();
    pName.setValue("foo");
    p.setParamName(pName);
    params.add(p);
    List<Handler> chain = builder.buildHandlerChainFromConfiguration(hc);
    assertEquals(1, chain.size());
    TestLogicalHandler tlh = (TestLogicalHandler) chain.get(0);
    assertTrue(tlh.initCalled);
    Map cfg = tlh.config;
    assertNotNull(tlh.config);
    assertEquals(1, cfg.keySet().size());
}
Also used : ParamValueType(org.apache.cxf.jaxws.handler.types.ParamValueType) LogicalHandler(javax.xml.ws.handler.LogicalHandler) Handler(javax.xml.ws.handler.Handler) PortComponentHandlerType(org.apache.cxf.jaxws.handler.types.PortComponentHandlerType) Map(java.util.Map) CString(org.apache.cxf.jaxws.handler.types.CString) Test(org.junit.Test)

Example 4 with PortComponentHandlerType

use of org.apache.cxf.jaxws.handler.types.PortComponentHandlerType in project cxf by apache.

the class HandlerChainBuilderTest method createHandlerChainType.

private List<PortComponentHandlerType> createHandlerChainType() {
    List<PortComponentHandlerType> handlers = new ArrayList<>();
    PortComponentHandlerType h = new PortComponentHandlerType();
    CString name = new CString();
    name.setValue("lh1");
    h.setHandlerName(name);
    FullyQualifiedClassType type = new FullyQualifiedClassType();
    type.setValue(TestLogicalHandler.class.getName());
    h.setHandlerClass(type);
    handlers.add(h);
    h = new PortComponentHandlerType();
    name = new CString();
    name.setValue("ph1");
    h.setHandlerName(name);
    type = new FullyQualifiedClassType();
    type.setValue(TestProtocolHandler.class.getName());
    h.setHandlerClass(type);
    handlers.add(h);
    h = new PortComponentHandlerType();
    name = new CString();
    name.setValue("ph2");
    h.setHandlerName(name);
    type = new FullyQualifiedClassType();
    type.setValue(TestProtocolHandler.class.getName());
    h.setHandlerClass(type);
    handlers.add(h);
    h = new PortComponentHandlerType();
    name = new CString();
    name.setValue("lh2");
    h.setHandlerName(name);
    type = new FullyQualifiedClassType();
    type.setValue(TestLogicalHandler.class.getName());
    h.setHandlerClass(type);
    handlers.add(h);
    return handlers;
}
Also used : FullyQualifiedClassType(org.apache.cxf.jaxws.handler.types.FullyQualifiedClassType) ArrayList(java.util.ArrayList) PortComponentHandlerType(org.apache.cxf.jaxws.handler.types.PortComponentHandlerType) CString(org.apache.cxf.jaxws.handler.types.CString)

Example 5 with PortComponentHandlerType

use of org.apache.cxf.jaxws.handler.types.PortComponentHandlerType in project cxf by apache.

the class HandlerChainBuilderTest method testBuilderCannotLoadHandlerClass.

@Test
public void testBuilderCannotLoadHandlerClass() {
    List<PortComponentHandlerType> hc = createHandlerChainType();
    hc.remove(3);
    hc.remove(2);
    hc.remove(1);
    FullyQualifiedClassType type = new FullyQualifiedClassType();
    type.setValue("no.such.class");
    hc.get(0).setHandlerClass(type);
    try {
        builder.buildHandlerChainFromConfiguration(hc);
        fail("did not get expected exception");
    } catch (WebServiceException ex) {
        // ex.printStackTrace();
        assertNotNull(ex.getCause());
        assertEquals(ClassNotFoundException.class, ex.getCause().getClass());
    }
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) FullyQualifiedClassType(org.apache.cxf.jaxws.handler.types.FullyQualifiedClassType) PortComponentHandlerType(org.apache.cxf.jaxws.handler.types.PortComponentHandlerType) Test(org.junit.Test)

Aggregations

PortComponentHandlerType (org.apache.cxf.jaxws.handler.types.PortComponentHandlerType)7 JAXBContext (javax.xml.bind.JAXBContext)3 JAXBException (javax.xml.bind.JAXBException)3 CString (org.apache.cxf.jaxws.handler.types.CString)3 Test (org.junit.Test)3 Map (java.util.Map)2 Handler (javax.xml.ws.handler.Handler)2 LogicalHandler (javax.xml.ws.handler.LogicalHandler)2 FullyQualifiedClassType (org.apache.cxf.jaxws.handler.types.FullyQualifiedClassType)2 ParamValueType (org.apache.cxf.jaxws.handler.types.ParamValueType)2 ArrayList (java.util.ArrayList)1 WebServiceException (javax.xml.ws.WebServiceException)1 XsdStringType (org.apache.cxf.jaxws.handler.types.XsdStringType)1