Apache CXF Interceptor


Initialize the CXF Interceptor

Main Features


public class MainFeature extends AbstractFeature {

@Override
protected void initializeProvider(InterceptorProvider provider, Bus bus) {

PhaseInterceptor<Message> interceptor = null;

// Audit interceptors
interceptor = new SecurityInterceptorIn ();
provider.getInInterceptors().add(interceptor);
provider.getInFaultInterceptors().add(interceptor);

   }

}



CXF Interceptor Creation

Extend the AbstractPhaseInterceptor

public class SecurityInterceptorIn extends AbstractPhaseInterceptor<Message> {

@Override
public void handleMessage(Message message) throws Fault {
String msg = null;
String requestURL = (String) message.get(Message.REQUEST_URL);

  }

}


Initializing the JaxRs

@ApplicationPath("/fe")
public class JaxRsApiApplication extends Application {
@Inject
private PersonServiceImpl personServiceImpl;
@Override
public Set<Object> getSingletons() {
return new HashSet<Object>(Arrays.asList(personServiceImpl,new MainFeature()));
}
}

Comments

Popular posts from this blog

Apache Karaf + Pax CDI OSGI Service

Apache CXF CDI in Karaf (Using CXF and CDI 1.1 (JSR-346))

OSGI + PAX CDI + Drools + Karaf