Search in sources :

Example 1 with ParamValueType

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

the class HandlerChainBuilder method configureHandler.

private void configureHandler(Handler<?> handler, PortComponentHandlerType h) {
    if (!handlerInitEnabled) {
        return;
    }
    if (h.getInitParam().isEmpty()) {
        return;
    }
    Map<String, String> params = new HashMap<>();
    for (ParamValueType param : h.getInitParam()) {
        params.put(trimString(param.getParamName() == null ? null : param.getParamName().getValue()), trimString(param.getParamValue() == null ? null : param.getParamValue().getValue()));
    }
    Method initMethod = getInitMethod(handler);
    if (initMethod != null) {
        initializeViaInitMethod(handler, params, initMethod);
    } else {
        initializeViaInjection(handler, params);
    }
}
Also used : HashMap(java.util.HashMap) ParamValueType(org.apache.cxf.jaxws.handler.types.ParamValueType) Method(java.lang.reflect.Method)

Example 2 with ParamValueType

use of org.apache.cxf.jaxws.handler.types.ParamValueType 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 3 with ParamValueType

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

the class HandlerChainBuilderTest method testBuilderCallsInit.

@Test
public void testBuilderCallsInit() {
    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);
    XsdStringType pValue = new XsdStringType();
    pValue.setValue("1");
    p.setParamValue(pValue);
    params.add(p);
    p = new ParamValueType();
    pName = new CString();
    pName.setValue("bar");
    p.setParamName(pName);
    pValue = new XsdStringType();
    pValue.setValue("2");
    p.setParamValue(pValue);
    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(2, cfg.keySet().size());
    assertEquals("1", cfg.get("foo"));
    assertEquals("2", cfg.get("bar"));
}
Also used : ParamValueType(org.apache.cxf.jaxws.handler.types.ParamValueType) XsdStringType(org.apache.cxf.jaxws.handler.types.XsdStringType) 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)

Aggregations

ParamValueType (org.apache.cxf.jaxws.handler.types.ParamValueType)3 Map (java.util.Map)2 Handler (javax.xml.ws.handler.Handler)2 LogicalHandler (javax.xml.ws.handler.LogicalHandler)2 CString (org.apache.cxf.jaxws.handler.types.CString)2 PortComponentHandlerType (org.apache.cxf.jaxws.handler.types.PortComponentHandlerType)2 Test (org.junit.Test)2 Method (java.lang.reflect.Method)1 HashMap (java.util.HashMap)1 XsdStringType (org.apache.cxf.jaxws.handler.types.XsdStringType)1