本文整理汇总了Java中org.apache.cxf.interceptor.InterceptorChain类的典型用法代码示例。如果您正苦于以下问题:Java InterceptorChain类的具体用法?Java InterceptorChain怎么用?Java InterceptorChain使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InterceptorChain类属于org.apache.cxf.interceptor包,在下文中一共展示了InterceptorChain类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: copyDataBindingInterceptors
import org.apache.cxf.interceptor.InterceptorChain; //导入依赖的package包/类
private static void copyDataBindingInterceptors(PhaseInterceptorChain newChain, InterceptorChain oldChain) {
for (Interceptor interceptor : oldChain) {
if (interceptor instanceof AbstractInDatabindingInterceptor) {
log.debug("Added data binding interceptor: " + interceptor);
newChain.add(interceptor);
}
}
}
开发者ID:apache,项目名称:tomee,代码行数:9,代码来源:EjbInterceptor.java
示例2: handleMessage
import org.apache.cxf.interceptor.InterceptorChain; //导入依赖的package包/类
public final void handleMessage(SoapMessage message) {
String schemaNamespace = "";
InterceptorChain chain = message.getInterceptorChain();
// Scan the incoming message for its schema namespace
try {
// Create a buffered stream so that we get back the original stream after scanning
InputStream is = message.getContent(InputStream.class);
BufferedInputStream bis = new BufferedInputStream(is);
bis.mark(bis.available());
message.setContent(InputStream.class, bis);
String encoding = (String) message.get(Message.ENCODING);
XMLStreamReader reader = xmlInputFactory.createXMLStreamReader(bis, encoding);
DepthXMLStreamReader xmlReader = new DepthXMLStreamReader(reader);
if (xmlReader.nextTag() == XMLStreamConstants.START_ELEMENT) {
String ns = xmlReader.getNamespaceURI();
SoapVersion soapVersion = SoapVersionFactory.getInstance().getSoapVersion(ns);
// Advance just past header
StaxUtils.toNextTag(xmlReader, soapVersion.getBody());
// Past body
xmlReader.nextTag();
}
schemaNamespace = xmlReader.getName().getNamespaceURI();
bis.reset();
} catch (IOException | XMLStreamException ex) {
log.error("Exception happened", ex);
}
// Init the lookup, when the first message ever arrives
if (actualServers.isEmpty()) {
initServerLookupMap(message);
}
// We redirect the message to the actual OCPP service
Server targetServer = actualServers.get(schemaNamespace);
// Redirect the request
if (targetServer != null) {
MessageObserver mo = targetServer.getDestination().getMessageObserver();
mo.onMessage(message);
}
// Now the response has been put in the message, abort the chain
chain.abort();
}
开发者ID:RWTH-i5-IDSG,项目名称:steve-plugsurfing,代码行数:49,代码来源:MediatorInInterceptor.java
示例3: intercept
import org.apache.cxf.interceptor.InterceptorChain; //导入依赖的package包/类
@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;
}
}
开发者ID:apache,项目名称:tomee,代码行数:75,代码来源:EjbInterceptor.java
注:本文中的org.apache.cxf.interceptor.InterceptorChain类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论