Java Code Examples for javax.xml.ws.Binding#getHandlerChain()

The following examples show how to use javax.xml.ws.Binding#getHandlerChain() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JaxWSCxfHookIT.java    From uavstack with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
public <T> T create(T t,ClientFactoryBean clientFactoryBean) { 
    
    Binding binding = ((BindingProvider) t).getBinding();
    List<Handler> handlerChain = binding.getHandlerChain();
    handlerChain.add(this.handler);
    binding.setHandlerChain(handlerChain);
    
    String wsdlLocation = clientFactoryBean.getAddress();
    
    T tProxy = JDKProxyInvokeUtil.newProxyInstance(clientFactoryBean.getServiceClass().getClassLoader(),
            new Class[] { clientFactoryBean.getServiceClass() },
            new JDKProxyInvokeHandler<T>(t, new ClientStubProcessor(wsdlLocation.toString(), this.handler)));
    return tProxy;
}
 
Example 2
Source File: JaxWSHookIT.java    From uavstack with Apache License 2.0 5 votes vote down vote up
/**
 * this is for Client Stub Programming
 * 
 * @param t
 * @param s
 * @param args
 * @return
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public <T> T getPort(T t, Service s, Object[] args) {
    
    if (JDKProxyInvokeUtil.isJDKProxy(t)) {
        return t;
    }

    Class<T> clz = null;
    if (Class.class.isAssignableFrom(args[0].getClass())) {
        clz = (Class<T>) args[0];
    }
    else if (Class.class.isAssignableFrom(args[1].getClass())) {
        clz = (Class<T>) args[1];
    }

    if (clz == null) {
        return t;
    }

    Binding binding = ((BindingProvider) t).getBinding();
    List<Handler> handlerChain = binding.getHandlerChain();
    handlerChain.add(this.handler);
    binding.setHandlerChain(handlerChain);

    final String wsdlLocation = getServiceURL(s);

    T tProxy = JDKProxyInvokeUtil.newProxyInstance(clz.getClassLoader(), new Class[] { clz },
            new JDKProxyInvokeHandler<T>(t, new ClientStubProcessor(wsdlLocation.toString(), this.handler)));
    return tProxy;
}
 
Example 3
Source File: JaxWSHookIT.java    From uavstack with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("rawtypes")
public Dispatch createDispatch(Dispatch d, Service s, Object[] args) {

    Binding binding = ((BindingProvider) d).getBinding();
    List<Handler> handlerChain = binding.getHandlerChain();
    handlerChain.add(this.handler);
    binding.setHandlerChain(handlerChain);

    final String wsdlLocation = getServiceURL(s);

    Dispatch tProxy = JDKProxyInvokeUtil.newProxyInstance(this.getClass().getClassLoader(),
            new Class[] { Dispatch.class },
            new JDKProxyInvokeHandler<Dispatch>(d, new DispatchProcessor(wsdlLocation.toString(), this.handler)));
    return tProxy;
}
 
Example 4
Source File: AbstractUDDIClientTestCase.java    From juddi with Apache License 2.0 5 votes vote down vote up
protected void registerService(BindingProvider bindingProvider)
{
    Binding binding = bindingProvider.getBinding();
    List<Handler> handlerChain = binding.getHandlerChain();

    handlerChain.add(new LoggingHandler());

    // set the handler chain again for the changes to take effect
    binding.setHandlerChain(handlerChain);
}
 
Example 5
Source File: JUDDIServiceProvider.java    From juddi with Apache License 2.0 5 votes vote down vote up
private void registerService(BindingProvider bindingProvider) {
	Binding binding = bindingProvider.getBinding();
	List<Handler> handlerChain = binding.getHandlerChain();

	handlerChain.add(new LoggingHandler());

	// set the handler chain again for the changes to take effect
	binding.setHandlerChain(handlerChain);
}
 
Example 6
Source File: HandlerInvocationTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddingUnusedHandlersThroughConfigFile() {
    HandlerTestServiceWithAnnotation service1 = new HandlerTestServiceWithAnnotation(wsdl, serviceName);
    HandlerTest handlerTest1 = service1.getPort(portName, HandlerTest.class);

    BindingProvider bp1 = (BindingProvider)handlerTest1;
    Binding binding1 = bp1.getBinding();
    @SuppressWarnings("rawtypes")
    List<Handler> port1HandlerChain = binding1.getHandlerChain();
    assertEquals(1, port1HandlerChain.size());
}
 
Example 7
Source File: EjbInterceptor.java    From tomee with Apache License 2.0 4 votes vote down vote up
@AroundInvoke
public Object intercept(InvocationContext context) throws Exception {
    Endpoint endpoint = this.exchange.get(Endpoint.class);
    Service service = endpoint.getService();
    Binding binding = ((JaxWsEndpointImpl) endpoint).getJaxwsBinding();

    this.exchange.put(InvocationContext.class, context);

    if (binding.getHandlerChain() == null || binding.getHandlerChain().isEmpty()) {
        // no handlers so let's just directly invoke the bean
        log.debug("No handlers found.");

        EjbMethodInvoker invoker = (EjbMethodInvoker) service.getInvoker();
        return invoker.directEjbInvoke(this.exchange, this.method, this.params);

    } else {
        // have handlers so have to run handlers now and redo data binding
        // as handlers can change the soap message
        log.debug("Handlers found.");

        Message inMessage = exchange.getInMessage();
        PhaseInterceptorChain chain = new PhaseInterceptorChain(bus.getExtension(PhaseManager.class).getInPhases());

        chain.setFaultObserver(endpoint.getOutFaultObserver());

        /*
         * Since we have to re-do data binding and the XMLStreamReader
         * contents are already consumed by prior data binding step
         * we have to reinitialize the XMLStreamReader from the SOAPMessage
         * created by SAAJInInterceptor.
         */
        if (inMessage instanceof SoapMessage) {
            try {
                reserialize((SoapMessage) inMessage);
            } catch (Exception e) {
                throw new ServerRuntimeException("Failed to reserialize soap message", e);
            }
        } else {
            // TODO: how to handle XML/HTTP binding?
        }

        this.exchange.setOutMessage(null);

        // install default interceptors
        chain.add(new ServiceInvokerInterceptor());
        //chain.add(new OutgoingChainInterceptor()); // it is already in the enclosing chain, if we add it there we are in the tx so we write the message in the tx!

        // See http://cwiki.apache.org/CXF20DOC/interceptors.html
        // install Holder and Wrapper interceptors
        chain.add(new WrapperClassInInterceptor());
        chain.add(new HolderInInterceptor());

        // install interceptors for handler processing
        chain.add(new MustUnderstandInterceptor());
        chain.add(new LogicalHandlerInInterceptor(binding));
        chain.add(new SOAPHandlerInterceptor(binding));

        // install data binding interceptors - todo: check we need it
        copyDataBindingInterceptors(chain, inMessage.getInterceptorChain());

        InterceptorChain oldChain = inMessage.getInterceptorChain();
        inMessage.setInterceptorChain(chain);
        try {
            chain.doIntercept(inMessage);
        } finally {
            inMessage.setInterceptorChain(oldChain);
        }

        // TODO: the result should be deserialized from SOAPMessage
        Object result = getResult();

        return result;
    }
}