本文整理汇总了Java中org.apache.cxf.interceptor.Interceptor类的典型用法代码示例。如果您正苦于以下问题:Java Interceptor类的具体用法?Java Interceptor怎么用?Java Interceptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Interceptor类属于org.apache.cxf.interceptor包,在下文中一共展示了Interceptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInInterceptors
import org.apache.cxf.interceptor.Interceptor; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private List<Interceptor<Message>> getInInterceptors()
{
List<Interceptor<Message>> inInterceptors = new ArrayList<Interceptor<Message>>();
if (null != cxfSOAPCustProvider && null != cxfSOAPCustProvider.getInInterceptors())
{
List<Object> pInInterceptors = cxfSOAPCustProvider.getInInterceptors();
for (Object obj : pInInterceptors)
{
if (obj instanceof Interceptor<?>)
{
inInterceptors.add((Interceptor<Message>)obj);
}
}
}
return inInterceptors;
}
示例2: getOutInterceptors
import org.apache.cxf.interceptor.Interceptor; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private List<Interceptor<Message>> getOutInterceptors()
{
List<Interceptor<Message>> outInterceptors = new ArrayList<Interceptor<Message>>();
if (null != cxfSOAPCustProvider && null != cxfSOAPCustProvider.getOutInterceptors())
{
List<Object> pOutInterceptors = cxfSOAPCustProvider.getOutInterceptors();
for (Object obj : pOutInterceptors)
{
if (obj instanceof Interceptor<?>)
{
outInterceptors.add((Interceptor<Message>)obj);
}
}
}
return outInterceptors;
}
示例3: handleMessage
import org.apache.cxf.interceptor.Interceptor; //导入依赖的package包/类
/**
* This is the actual implementation for our interceptor - we define the necessary properties for doing the authentication
* and then iterate over the rest of the interceptor chain to find the WSS4J interceptor and configure it properly.
*/
public void handleMessage(Message message) throws Fault {
/*
* Define the configuration properties
*/
Map<String, Object> outProps = new HashMap<String, Object>();
outProps.put("action", "UsernameToken");
outProps.put("passwordType", "PasswordText");
/*
* The username ('admin') is provided as a literal, the corresponding password will be determined by the client
* password callback object.
*/
outProps.put("user", "admin");
outProps.put("passwordCallbackClass", ClientPasswordCallback.class.getName());
/*
* Find the WSS4J interceptor in the interceptor chain and set the configuration properties
*/
for (Interceptor interceptor : message.getInterceptorChain()) {
//set properties for WSS4JOutInterceptor
if (interceptor.getClass().getName().equals("org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor")) {
((WSS4JOutInterceptor) interceptor).setProperties(outProps);
}
}
}
示例4: createCXFClient
import org.apache.cxf.interceptor.Interceptor; //导入依赖的package包/类
protected static ReportIncidentEndpoint createCXFClient(String url) {
List<Interceptor<? extends Message>> outInterceptors = new ArrayList<Interceptor<? extends Message>>();
// Define WSS4j properties for flow outgoing
Map<String, Object> outProps = new HashMap<String, Object>();
outProps.put("action", "UsernameToken Timestamp");
outProps.put("passwordType", "PasswordDigest");
outProps.put("user", "charles");
outProps.put("passwordCallbackClass", "org.apache.camel.example.reportincident.UTPasswordCallback");
WSS4JOutInterceptor wss4j = new WSS4JOutInterceptor(outProps);
// Add LoggingOutInterceptor
LoggingOutInterceptor loggingOutInterceptor = new LoggingOutInterceptor();
outInterceptors.add(wss4j);
outInterceptors.add(loggingOutInterceptor);
// we use CXF to create a client for us as its easier than JAXWS and works
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setOutInterceptors(outInterceptors);
factory.setServiceClass(ReportIncidentEndpoint.class);
factory.setAddress(url);
return (ReportIncidentEndpoint) factory.create();
}
示例5: removeInterceptorWhichIsInThePhases
import org.apache.cxf.interceptor.Interceptor; //导入依赖的package包/类
protected void removeInterceptorWhichIsInThePhases(List<Interceptor<? extends Message>> interceptors, String[] phaseNames, Set<String> needToBeKept) {
for (Interceptor<? extends Message> i : interceptors) {
if (i instanceof PhaseInterceptor) {
PhaseInterceptor<? extends Message> p = (PhaseInterceptor<? extends Message>) i;
for (String phaseName : phaseNames) {
if (p.getPhase().equals(phaseName)) {
// To support the old API
if (needToBeKept == null) {
getLogger().info("removing the interceptor " + p);
interceptors.remove(p);
break;
} else if (!needToBeKept.contains(p.getClass().getName())) {
getLogger().info("removing the interceptor " + p);
interceptors.remove(p);
break;
}
}
}
}
}
}
示例6: removeInterceptorWhichIsOutThePhases
import org.apache.cxf.interceptor.Interceptor; //导入依赖的package包/类
protected void removeInterceptorWhichIsOutThePhases(List<Interceptor<? extends Message>> interceptors, String[] phaseNames, Set<String> needToBeKept) {
for (Interceptor<? extends Message> i : interceptors) {
boolean outside = false;
if (i instanceof PhaseInterceptor) {
PhaseInterceptor<? extends Message> p = (PhaseInterceptor<? extends Message>) i;
for (String phaseName : phaseNames) {
if (p.getPhase().equals(phaseName)) {
outside = true;
break;
}
}
if (!outside) {
// To support the old API
if (needToBeKept == null) {
getLogger().info("removing the interceptor " + p);
interceptors.remove(p);
} else if (!needToBeKept.contains(p.getClass().getName())) {
getLogger().info("removing the interceptor " + p);
interceptors.remove(p);
}
}
}
}
}
示例7: testBusInjectedBySpring
import org.apache.cxf.interceptor.Interceptor; //导入依赖的package包/类
@Test
public void testBusInjectedBySpring() throws Exception {
CamelContext camelContext = ctx.getBean("camel", CamelContext.class);
CxfEndpoint endpoint = camelContext.getEndpoint("cxf:bean:routerEndpoint", CxfEndpoint.class);
// verify the interceptor that is added by the logging feature
// Spring 3.0.0 has an issue of SPR-6589 which will call the BusApplicationListener twice for the same event,
// so we will get more one InInterceptors here
assertTrue(endpoint.getBus().getInInterceptors().size() >= 1);
for (Interceptor<?> i : endpoint.getBus().getInInterceptors()) {
if (i instanceof LoggingInInterceptor) {
return;
}
}
fail("Could not find the LoggingInInterceptor on the bus. " + endpoint.getBus().getInInterceptors());
}
示例8: createCXFClient
import org.apache.cxf.interceptor.Interceptor; //导入依赖的package包/类
protected static OrderEndpoint createCXFClient(String url, String user, String passwordCallbackClass) {
List<Interceptor<? extends Message>> outInterceptors = new ArrayList();
// Define WSS4j properties for flow outgoing
Map<String, Object> outProps = new HashMap<String, Object>();
outProps.put("action", "UsernameToken Timestamp");
outProps.put("user", user);
outProps.put("passwordCallbackClass", passwordCallbackClass);
WSS4JOutInterceptor wss4j = new WSS4JOutInterceptor(outProps);
// Add LoggingOutInterceptor
LoggingOutInterceptor loggingOutInterceptor = new LoggingOutInterceptor();
outInterceptors.add(wss4j);
outInterceptors.add(loggingOutInterceptor);
// we use CXF to create a client for us as its easier than JAXWS and works
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setOutInterceptors(outInterceptors);
factory.setServiceClass(OrderEndpoint.class);
factory.setAddress(url);
return (OrderEndpoint) factory.create();
}
示例9: getConfiguredInterceptors
import org.apache.cxf.interceptor.Interceptor; //导入依赖的package包/类
private static <T extends Interceptor<? extends Message>> List<T> getConfiguredInterceptors(InterceptorsModel interceptorsModel, ClassLoader loader) {
List<T> interceptors = new ArrayList<T>();
if (interceptorsModel != null) {
for (InterceptorModel interceptorModel : interceptorsModel.getInterceptors()) {
if (interceptorModel != null) {
@SuppressWarnings("unchecked")
Class<T> interceptorClass = (Class<T>)interceptorModel.getClazz(loader);
if (interceptorClass != null) {
PropertiesModel propertiesModel = interceptorModel.getProperties();
Map<String, String> properties = propertiesModel != null ? propertiesModel.toMap() : new HashMap<String, String>();
T interceptor = newInterceptor(interceptorClass, properties);
if (interceptor != null) {
if (interceptor instanceof SubjectCreatingInterceptor) {
((SubjectCreatingInterceptor)interceptor).setPropagateContext(true);
} else if (interceptor instanceof SubjectCreatingPolicyInterceptor) {
((SubjectCreatingPolicyInterceptor)interceptor).setPropagateContext(true);
}
interceptors.add(interceptor);
}
}
}
}
}
return interceptors;
}
示例10: getConfiguredInterceptors
import org.apache.cxf.interceptor.Interceptor; //导入依赖的package包/类
private static <T extends Interceptor<? extends Message>> List<T> getConfiguredInterceptors(InterceptorsModel interceptorsModel) {
List<T> interceptors = new ArrayList<T>();
if (interceptorsModel != null) {
for (InterceptorModel interceptorModel : interceptorsModel.getInterceptors()) {
if (interceptorModel != null) {
@SuppressWarnings("unchecked")
Class<T> interceptorClass = (Class<T>)interceptorModel.getClazz(Classes.getTCCL());
if (interceptorClass != null) {
PropertiesModel propertiesModel = interceptorModel.getProperties();
Map<String, String> properties = propertiesModel != null ? propertiesModel.toMap() : new HashMap<String, String>();
T interceptor = newInterceptor(interceptorClass, properties);
if (interceptor != null) {
interceptors.add(interceptor);
}
}
}
}
}
return interceptors;
}
示例11: getConstructor
import org.apache.cxf.interceptor.Interceptor; //导入依赖的package包/类
private static <T extends Interceptor<? extends Message>> Constructor<T> getConstructor(Class<T> interceptorClass) {
final Class<?>[][] constructorParameterTypes = new Class<?>[][]{
new Class<?>[]{Map.class},
new Class<?>[0]
};
Constructor<T> constructor = null;
for (Class<?>[] parameterTypes : constructorParameterTypes) {
try {
constructor = interceptorClass.getConstructor(parameterTypes);
if (constructor != null) {
break;
}
} catch (Throwable t) {
// keep checkstyle happy ("at least one statement")
t.getMessage();
}
}
return constructor;
}
示例12: testPortWithFeature
import org.apache.cxf.interceptor.Interceptor; //导入依赖的package包/类
private void testPortWithFeature(final Client client) {
assertNotNull(client);
assertEquals(4, client.getOutInterceptors().size());
assertEquals(3, client.getInInterceptors().size());
final Iterator<Interceptor<? extends Message>> Out = client.getOutInterceptors().iterator();
assertTrue(MAPAggregatorImpl.class.isInstance(Out.next()));
assertTrue(MAPCodec.class.isInstance(Out.next()));
assertTrue(LoggingOutInterceptor.class.isInstance(Out.next()));
final Interceptor<? extends Message> wss4jout = Out.next();
assertTrue(WSS4JOutInterceptor.class.isInstance(wss4jout));
final Iterator<Interceptor<? extends Message>> iteratorIn = client.getInInterceptors().iterator();
assertTrue(MAPAggregatorImpl.class.isInstance(iteratorIn.next()));
assertTrue(MAPCodec.class.isInstance(iteratorIn.next()));
assertTrue(WSS4JInInterceptor.class.isInstance(iteratorIn.next()));
}
示例13: loadBus
import org.apache.cxf.interceptor.Interceptor; //导入依赖的package包/类
@Override
protected void loadBus(ServletConfig sc)
{
Thread currentThread = Thread.currentThread();
ClassLoader oldLoader = currentThread.getContextClassLoader();
try
{
currentThread.setContextClassLoader(getClass().getClassLoader());
Bus bus = new ExtensionManagerBus();
setBus(bus);
List<Extension> exts = interceptorTracker.getExtensions();
List<Interceptor<? extends Message>> inInterceptors = bus.getInInterceptors();
for( Extension extension : exts )
{
Collection<Parameter> inParams = extension.getParameters("inBean");
for( Parameter inParam : inParams )
{
inInterceptors.add(interceptorTracker.getBeanByParameter(extension, inParam));
}
Collection<Parameter> outParams = extension.getParameters("outBean");
for( Parameter outParam : outParams )
{
bus.getOutInterceptors().add(interceptorTracker.getBeanByParameter(extension, outParam));
}
}
inInterceptors.add(new WebServiceContextIntercept());
bus.setProperty("org.apache.cxf.logging.FaultListener", new SoapFaultListener());
}
finally
{
currentThread.setContextClassLoader(oldLoader);
}
}
示例14: init
import org.apache.cxf.interceptor.Interceptor; //导入依赖的package包/类
@PostConstruct
public void init() {
List<Interceptor<? extends Message>> route = singletonList(new MediatorInInterceptor());
List<Interceptor<? extends Message>> interceptors = asList(new MessageIdInterceptor(), fromAddressInterceptor);
// Just a dummy service to route incoming messages to the appropriate service version
createOcppService(ocpp12Server, CONFIG.getRouterEndpointPath(), route);
createOcppService(ocpp12Server, "/CentralSystemServiceOCPP12", interceptors);
createOcppService(ocpp15Server, "/CentralSystemServiceOCPP15", interceptors);
}
示例15: createOcppService
import org.apache.cxf.interceptor.Interceptor; //导入依赖的package包/类
private void createOcppService(Object serviceBean, String address,
List<Interceptor<? extends Message>> interceptors) {
JaxWsServerFactoryBean f = new JaxWsServerFactoryBean();
f.setBus(springBus());
f.setServiceBean(serviceBean);
f.setAddress(address);
f.getInInterceptors().addAll(interceptors);
f.create();
}