public void start() { // define a JSON provider and a mapping between REST and JSON namespace's JSONProvider<IngredientRESTService> jsonProvider = new JSONProvider<IngredientRESTService>(); Map<String, String> map = new HashMap<String, String>(); map.put("http://rest.ws.wfm", "{}"); jsonProvider.setNamespaceMap(map); JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); sf.setResourceClasses(IngredientRESTService.class); sf.setResourceProvider( IngredientRESTService.class, new SingletonResourceProvider(new IngredientRESTServiceImpl())); sf.setAddress("http://localhost:63083"); sf.getInFaultInterceptors().add(new LoggingInInterceptor()); sf.getOutFaultInterceptors().add(new LoggingOutInterceptor()); sf.getInInterceptors().add(new LoggingInInterceptor()); sf.getOutInterceptors().add(new LoggingOutInterceptor()); sf.setProvider(jsonProvider); BindingFactoryManager manager = sf.getBus().getExtension(BindingFactoryManager.class); JAXRSBindingFactory factory = new JAXRSBindingFactory(); factory.setBus(sf.getBus()); manager.registerBindingFactory(JAXRSBindingFactory.JAXRS_BINDING_ID, factory); // REST-Service this.restserver = sf.create(); this.restserver.start(); }
public static List<Object> setupProviders() { List<Object> providers = new ArrayList<Object>(); JSONProvider<OAuthAuthorizationData> jsonP = new JSONProvider<OAuthAuthorizationData>(); jsonP.setNamespaceMap( Collections.singletonMap("http://org.apache.cxf.rs.security.oauth", "ns2")); providers.add(jsonP); OAuthJSONProvider oauthProvider = new OAuthJSONProvider(); providers.add(oauthProvider); return providers; }