javax.xml.ws.handler.Handler Java Examples

The following examples show how to use javax.xml.ws.handler.Handler. 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: GenericRequest.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public Handler<?>[] getHandlerchain() {
   Handler<?>[] result = new Handler[0];
   if (this.beforeSecurity != null && !this.beforeSecurity.isEmpty()) {
      result = (Handler[])((Handler[])ArrayUtils.addAll(result, this.beforeSecurity.toArray(new Handler[0])));
   }

   if (this.securityHandler != null) {
      result = (Handler[])((Handler[])ArrayUtils.addAll(result, this.securityHandler.toArray(new Handler[0])));
   }

   if (this.afterSecurity != null && !this.afterSecurity.isEmpty()) {
      result = (Handler[])((Handler[])ArrayUtils.addAll(result, this.afterSecurity.toArray(new Handler[0])));
   }

   if (this.featureHandlers != null && !this.featureHandlers.isEmpty()) {
      result = (Handler[])((Handler[])ArrayUtils.addAll(result, this.featureHandlers.toArray(new Handler[0])));
   }

   result = HandlersLoader.addingDefaultHandlers(result);
   return result;
}
 
Example #2
Source File: HandlerChainBuilder.java    From cxf with Apache License 2.0 6 votes vote down vote up
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);
    }
}
 
Example #3
Source File: ClientLogicalHandlerTube.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
void setUpProcessor() {
    if (handlers == null) {
            // Take a snapshot, User may change chain after invocation, Same chain
            // should be used for the entire MEP
            handlers = new ArrayList<Handler>();
            WSBinding binding = getBinding();
            List<LogicalHandler> logicalSnapShot= ((BindingImpl) binding).getHandlerConfig().getLogicalHandlers();
            if (!logicalSnapShot.isEmpty()) {
                handlers.addAll(logicalSnapShot);
                if (binding.getSOAPVersion() == null) {
                    processor = new XMLHandlerProcessor(this, binding,
                            handlers);
                } else {
                    processor = new SOAPHandlerProcessor(true, this, binding,
                            handlers);
                }
            }
    }
}
 
Example #4
Source File: LoggingUtil.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Adds the in out logger.
 *
 * @param bindingProvider the binding provider
 */
@SuppressWarnings("rawtypes")
public static void addInOutLoggerHandler(Object port, boolean soapfaultHandler) {
	if (port instanceof BindingProvider) {
		BindingProvider bindingProvider = (BindingProvider) port;
		List<Handler> handlerChain = new ArrayList<Handler>();
		handlerChain.addAll(bindingProvider.getBinding().getHandlerChain());
		handlerChain.add(new LoggingHandler());
		if(soapfaultHandler){
			handlerChain.add(new SoapFaultHandler());
		}
		bindingProvider.getBinding().setHandlerChain(handlerChain);
	} else {
		LOG.warn("BindingProvider provider expected, get a " + port);
	}
}
 
Example #5
Source File: WSEndpointImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public synchronized void dispose() {
    if (disposed) {
        return;
    }
    disposed = true;

    masterTubeline.preDestroy();

    for (Handler handler : binding.getHandlerChain()) {
        for (Method method : handler.getClass().getMethods()) {
            if (method.getAnnotation(PreDestroy.class) == null) {
                continue;
            }
            try {
                method.invoke(handler);
            } catch (Exception e) {
                logger.log(Level.WARNING, HandlerMessages.HANDLER_PREDESTROY_IGNORE(e.getMessage()), e);
            }
            break;
        }
    }
    closeManagedObjectManager();
    LazyMOMProvider.INSTANCE.unregisterEndpoint(this);
}
 
Example #6
Source File: HandlerChainBuilder.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected List<Handler> buildHandlerChain(PortComponentHandlerType ht, ClassLoader classLoader) {
    List<Handler> handlerChain = new ArrayList<>();
    try {
        final boolean fineLog = LOG.isLoggable(Level.FINE);
        if (fineLog) {
            LOG.log(Level.FINE, "loading handler", trimString(ht.getHandlerName().getValue()));
        }

        Class<? extends Handler> handlerClass = Class.forName(
                                                              trimString(ht.getHandlerClass()
                                                                  .getValue()), true, classLoader)
            .asSubclass(Handler.class);

        Handler<?> handler = handlerClass.newInstance();
        if (fineLog) {
            LOG.fine("adding handler to chain: " + handler);
        }
        configureHandler(handler, ht);
        handlerChain.add(handler);
    } catch (Exception e) {
        throw new WebServiceException(BUNDLE.getString("HANDLER_INSTANTIATION_EXC"), e);
    }
    return handlerChain;
}
 
Example #7
Source File: AnnotationHandlerChainBuilderTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testFindHandlerChainAnnotation() {
    HandlerTestImpl handlerTestImpl = new HandlerTestImpl();
    AnnotationHandlerChainBuilder chainBuilder = new AnnotationHandlerChainBuilder();
    @SuppressWarnings("rawtypes")
    List<Handler> handlers = chainBuilder
        .buildHandlerChainFromClass(handlerTestImpl.getClass(),
                                    null,
                                    null,
                                    null);
    assertNotNull(handlers);
    assertEquals(9, handlers.size());
    assertEquals(TestLogicalHandler.class, handlers.get(0).getClass());
    assertEquals(TestLogicalHandler.class, handlers.get(1).getClass());
    assertEquals(TestLogicalHandler.class, handlers.get(2).getClass());
    assertEquals(TestLogicalHandler.class, handlers.get(3).getClass());
    assertEquals(TestLogicalHandler.class, handlers.get(4).getClass());
    assertEquals(TestLogicalHandler.class, handlers.get(5).getClass());
    assertEquals(TestLogicalHandler.class, handlers.get(6).getClass());
    assertEquals(TestProtocolHandler.class, handlers.get(7).getClass());
    assertEquals(TestProtocolHandler.class, handlers.get(8).getClass());
}
 
Example #8
Source File: LoggingUtil.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public static void addInOutLoggerHandler(Object port, boolean soapfaultHandler) {
   if (port instanceof BindingProvider) {
      BindingProvider bindingProvider = (BindingProvider)port;
      List<Handler> handlerChain = new ArrayList();
      handlerChain.addAll(bindingProvider.getBinding().getHandlerChain());
      handlerChain.add(new LoggingHandler());
      if (soapfaultHandler) {
         handlerChain.add(new SoapFaultHandler());
      }

      bindingProvider.getBinding().setHandlerChain(handlerChain);
   } else {
      LOG.warn("BindingProvider provider expected, get a " + port);
   }

}
 
Example #9
Source File: LoggingUtil.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Adds the in out logger.
 *
 * @param bindingProvider the binding provider
 */
@SuppressWarnings("rawtypes")
public static void addInOutLoggerHandler(Object port, boolean soapfaultHandler) {
	if (port instanceof BindingProvider) {
		BindingProvider bindingProvider = (BindingProvider) port;
		List<Handler> handlerChain = new ArrayList<Handler>();
		handlerChain.addAll(bindingProvider.getBinding().getHandlerChain());
		handlerChain.add(new LoggingHandler());
		if(soapfaultHandler){
			handlerChain.add(new SoapFaultHandler());
		}
		bindingProvider.getBinding().setHandlerChain(handlerChain);
	} else {
		LOG.warn("BindingProvider provider expected, get a " + port);
	}
}
 
Example #10
Source File: GenericRequest.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public Handler<?>[] getHandlerchain() {
   Handler<?>[] result = new Handler[0];
   if (this.beforeSecurity != null && !this.beforeSecurity.isEmpty()) {
      result = (Handler[])((Handler[])ArrayUtils.addAll(result, this.beforeSecurity.toArray(new Handler[0])));
   }

   if (this.securityHandler != null) {
      result = (Handler[])((Handler[])ArrayUtils.addAll(result, this.securityHandler.toArray(new Handler[0])));
   }

   if (this.afterSecurity != null && !this.afterSecurity.isEmpty()) {
      result = (Handler[])((Handler[])ArrayUtils.addAll(result, this.afterSecurity.toArray(new Handler[0])));
   }

   if (this.featureHandlers != null && !this.featureHandlers.isEmpty()) {
      result = (Handler[])((Handler[])ArrayUtils.addAll(result, this.featureHandlers.toArray(new Handler[0])));
   }

   result = HandlersLoader.addingDefaultHandlers(result);
   return result;
}
 
Example #11
Source File: ClientLogicalHandlerTube.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
void setUpProcessor() {
    if (handlers == null) {
            // Take a snapshot, User may change chain after invocation, Same chain
            // should be used for the entire MEP
            handlers = new ArrayList<Handler>();
            WSBinding binding = getBinding();
            List<LogicalHandler> logicalSnapShot= ((BindingImpl) binding).getHandlerConfig().getLogicalHandlers();
            if (!logicalSnapShot.isEmpty()) {
                handlers.addAll(logicalSnapShot);
                if (binding.getSOAPVersion() == null) {
                    processor = new XMLHandlerProcessor(this, binding,
                            handlers);
                } else {
                    processor = new SOAPHandlerProcessor(true, this, binding,
                            handlers);
                }
            }
    }
}
 
Example #12
Source File: ClientLogicalHandlerTube.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
void setUpProcessor() {
    if (handlers == null) {
            // Take a snapshot, User may change chain after invocation, Same chain
            // should be used for the entire MEP
            handlers = new ArrayList<Handler>();
            WSBinding binding = getBinding();
            List<LogicalHandler> logicalSnapShot= ((BindingImpl) binding).getHandlerConfig().getLogicalHandlers();
            if (!logicalSnapShot.isEmpty()) {
                handlers.addAll(logicalSnapShot);
                if (binding.getSOAPVersion() == null) {
                    processor = new XMLHandlerProcessor(this, binding,
                            handlers);
                } else {
                    processor = new SOAPHandlerProcessor(true, this, binding,
                            handlers);
                }
            }
    }
}
 
Example #13
Source File: WSEndpointImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public synchronized void dispose() {
    if (disposed) {
        return;
    }
    disposed = true;

    masterTubeline.preDestroy();

    for (Handler handler : binding.getHandlerChain()) {
        for (Method method : handler.getClass().getMethods()) {
            if (method.getAnnotation(PreDestroy.class) == null) {
                continue;
            }
            try {
                method.invoke(handler);
            } catch (Exception e) {
                logger.log(Level.WARNING, HandlerMessages.HANDLER_PREDESTROY_IGNORE(e.getMessage()), e);
            }
            break;
        }
    }
    closeManagedObjectManager();
    LazyMOMProvider.INSTANCE.unregisterEndpoint(this);
}
 
Example #14
Source File: ServerMessageHandlerTube.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void setUpHandlersOnce() {
    handlers = new ArrayList<Handler>();
    HandlerConfiguration handlerConfig = ((BindingImpl) getBinding()).getHandlerConfig();
    List<MessageHandler> msgHandlersSnapShot= handlerConfig.getMessageHandlers();
    if (!msgHandlersSnapShot.isEmpty()) {
        handlers.addAll(msgHandlersSnapShot);
        roles = new HashSet<String>();
        roles.addAll(handlerConfig.getRoles());
    }
}
 
Example #15
Source File: HTTPBindingImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This method separates the logical and protocol handlers and
 * sets the HandlerConfiguration.
 * Only logical handlers are allowed with HTTPBinding.
 * Setting SOAPHandlers throws WebServiceException
 */
public void setHandlerChain(List<Handler> chain) {
    for (Handler handler : chain) {
        if (!(handler instanceof LogicalHandler)) {
            throw new WebServiceException(ClientMessages.NON_LOGICAL_HANDLER_SET(handler.getClass()));
        }
    }
    setHandlerConfig(new HandlerConfiguration(Collections.<String>emptySet(), chain));
}
 
Example #16
Source File: ServerLogicalHandlerTube.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void setUpHandlersOnce() {
    handlers = new ArrayList<Handler>();
    List<LogicalHandler> logicalSnapShot= ((BindingImpl) getBinding()).getHandlerConfig().getLogicalHandlers();
    if (!logicalSnapShot.isEmpty()) {
        handlers.addAll(logicalSnapShot);
    }
}
 
Example #17
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 #18
Source File: CampaignServiceInterfaceImpl.java    From googleads-java-lib with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("rawtypes")
public CampaignServiceInterfaceImpl() {
  binding = Mockito.mock(Binding.class);
  RequestInfoXPathSet requestInfoXPathSet = Mockito.mock(RequestInfoXPathSet.class);
  ResponseInfoXPathSet responseInfoXPathSet = Mockito.mock(ResponseInfoXPathSet.class);
  List<Handler> handlerList =
      Lists.<Handler>newArrayList(
          new JaxWsSoapContextHandler(requestInfoXPathSet, responseInfoXPathSet));
  when(binding.getHandlerChain()).thenReturn(handlerList);
}
 
Example #19
Source File: HandlerChainInvoker.java    From cxf with Apache License 2.0 5 votes vote down vote up
private boolean invokeThisHandler(Handler<?> h) {
    boolean ret = true;
    // when handler processing has been aborted, only invoke on
    // previously invoked handlers
    //Only invoke the next handler (take the reversed direction into account)
    if (messageDirectionReversed) {
        ret = invokedHandlers.contains(h) && !isTheLastInvokedHandler(h);
    }

    if (ret && LOG.isLoggable(Level.FINE)) {
        LOG.log(Level.FINE, "invoking handler of type " + h.getClass().getName());
    }
    return ret;
}
 
Example #20
Source File: HandlersLoader.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public DefaultHandlersPredicate(Handler<?>[] handlers) {
   Set<Class> handlerSet = new HashSet();
   Handler[] arr$ = handlers;
   int len$ = handlers.length;

   for(int i$ = 0; i$ < len$; ++i$) {
      Handler handler = arr$[i$];
      handlerSet.add(handler.getClass());
   }

   this.handlers = (Class[])handlerSet.toArray(new Class[handlerSet.size()]);
}
 
Example #21
Source File: ClientMessageHandlerTube.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
void setUpProcessor() {
    if (handlers == null) {
            // Take a snapshot, User may change chain after invocation, Same chain
            // should be used for the entire MEP
            handlers = new ArrayList<Handler>();
            HandlerConfiguration handlerConfig = ((BindingImpl) getBinding()).getHandlerConfig();
            List<MessageHandler> msgHandlersSnapShot= handlerConfig.getMessageHandlers();
            if (!msgHandlersSnapShot.isEmpty()) {
                handlers.addAll(msgHandlersSnapShot);
                roles = new HashSet<String>();
                roles.addAll(handlerConfig.getRoles());
                processor = new SOAPHandlerProcessor(true, this, getBinding(), handlers);
            }
    }
}
 
Example #22
Source File: HandlerConfiguration.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 * @return return a copy of handler chain
 */
public List<Handler> getHandlerChain() {
    if(handlerChain == null)
        return Collections.emptyList();
    return new ArrayList<Handler>(handlerChain);

}
 
Example #23
Source File: ServerSOAPHandlerTube.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void setUpHandlersOnce() {
    handlers = new ArrayList<Handler>();
    HandlerConfiguration handlerConfig = ((BindingImpl) getBinding()).getHandlerConfig();
    List<SOAPHandler> soapSnapShot= handlerConfig.getSoapHandlers();
    if (!soapSnapShot.isEmpty()) {
        handlers.addAll(soapSnapShot);
        roles = new HashSet<String>();
        roles.addAll(handlerConfig.getRoles());
    }
}
 
Example #24
Source File: ClientMessageHandlerTube.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
void setUpProcessor() {
    if (handlers == null) {
            // Take a snapshot, User may change chain after invocation, Same chain
            // should be used for the entire MEP
            handlers = new ArrayList<Handler>();
            HandlerConfiguration handlerConfig = ((BindingImpl) getBinding()).getHandlerConfig();
            List<MessageHandler> msgHandlersSnapShot= handlerConfig.getMessageHandlers();
            if (!msgHandlersSnapShot.isEmpty()) {
                handlers.addAll(msgHandlersSnapShot);
                roles = new HashSet<String>();
                roles.addAll(handlerConfig.getRoles());
                processor = new SOAPHandlerProcessor(true, this, getBinding(), handlers);
            }
    }
}
 
Example #25
Source File: AbstractWsSender.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
private static void executeHandlers(Handler[] handlers, SOAPMessageContext ctx) throws TechnicalConnectorException {
   Handler[] arr$ = handlers;
   int len$ = handlers.length;

   for(int i$ = 0; i$ < len$; ++i$) {
      Handler handler = arr$[i$];
      if (!handler.handleMessage(ctx)) {
         TechnicalConnectorExceptionValues errorValue = TechnicalConnectorExceptionValues.ERROR_WS;
         LOG.error(MessageFormat.format(errorValue.getMessage(), "Error while executing handler " + handler.getClass()));
         throw new TechnicalConnectorException(errorValue, new Object[]{"Error while executing handler."});
      }
   }

}
 
Example #26
Source File: HandlerConfiguration.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 * @return return a copy of handler chain
 */
public List<Handler> getHandlerChain() {
    if(handlerChain == null)
        return Collections.emptyList();
    return new ArrayList<Handler>(handlerChain);

}
 
Example #27
Source File: BindingImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
protected BindingImpl(BindingID bindingId, WebServiceFeature ... features) {
    this.bindingId = bindingId;
    handlerConfig = new HandlerConfiguration(Collections.<String>emptySet(), Collections.<Handler>emptyList());
    if (handlerConfig.getHandlerKnownHeaders() != null)
        knownHeaders.addAll(handlerConfig.getHandlerKnownHeaders());
    this.features = new WebServiceFeatureList(features);
    this.features.validate();
}
 
Example #28
Source File: ClientMessageHandlerTube.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
void setUpProcessor() {
    if (handlers == null) {
            // Take a snapshot, User may change chain after invocation, Same chain
            // should be used for the entire MEP
            handlers = new ArrayList<Handler>();
            HandlerConfiguration handlerConfig = ((BindingImpl) getBinding()).getHandlerConfig();
            List<MessageHandler> msgHandlersSnapShot= handlerConfig.getMessageHandlers();
            if (!msgHandlersSnapShot.isEmpty()) {
                handlers.addAll(msgHandlersSnapShot);
                roles = new HashSet<String>();
                roles.addAll(handlerConfig.getRoles());
                processor = new SOAPHandlerProcessor(true, this, getBinding(), handlers);
            }
    }
}
 
Example #29
Source File: ServerMessageHandlerTube.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void setUpHandlersOnce() {
    handlers = new ArrayList<Handler>();
    HandlerConfiguration handlerConfig = ((BindingImpl) getBinding()).getHandlerConfig();
    List<MessageHandler> msgHandlersSnapShot= handlerConfig.getMessageHandlers();
    if (!msgHandlersSnapShot.isEmpty()) {
        handlers.addAll(msgHandlersSnapShot);
        roles = new HashSet<String>();
        roles.addAll(handlerConfig.getRoles());
    }
}
 
Example #30
Source File: ServerSOAPHandlerTube.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private void setUpHandlersOnce() {
    handlers = new ArrayList<Handler>();
    HandlerConfiguration handlerConfig = ((BindingImpl) getBinding()).getHandlerConfig();
    List<SOAPHandler> soapSnapShot= handlerConfig.getSoapHandlers();
    if (!soapSnapShot.isEmpty()) {
        handlers.addAll(soapSnapShot);
        roles = new HashSet<String>();
        roles.addAll(handlerConfig.getRoles());
    }
}