public HashSet<Object> getSingletons(){ ObjectMapper mapper = new ObjectMapper(); JacksonJaxbJsonProvider jaxbProvider = new JacksonJaxbJsonProvider(); jaxbProvider.setMapper(mapper); singletons.add(jaxbProvider); if(Activator.BUNDLE==null){ throw new IllegalArgumentException("WebSocketService.BUNDLE is null!"); } IGuicer guicer = Guicer.getInstance(Activator.BUNDLE); //create the rest object make sure dependencies are injected via guice. IRestWebSocket restWebSocket = guicer.createObject(IRestWebSocket.class); if(restWebSocket==null){ throw new IllegalArgumentException("restWebSocket is null!!!"); } //add it singletons.add(restWebSocket); return singletons; }
static ClientResponse getJSONResponse(String url, String content_type) { ClientConfig config = new DefaultClientConfig(); config.getClasses().add(JacksonJaxbJsonProvider.class); config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE); WebResource webResource = getWebResource(url,config,content_type); return webResource.accept(content_type).get(ClientResponse.class); }
static ClientResponse postJSONResponse(String url, String content_type,String body) { ClientConfig config = new DefaultClientConfig(); config.getClasses().add(JacksonJaxbJsonProvider.class); config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE); WebResource webResource = getWebResource(url,config,content_type); return webResource.accept(content_type).post(ClientResponse.class,body); }
protected TestModelBase(Class<?> clazz) throws Exception { super(); this.clazz = clazz; context = new JAXBContextResolver().getContext(clazz); mapper = new JacksonJaxbJsonProvider().locateMapper(clazz, MediaType.APPLICATION_JSON_TYPE); }
/** * Returns a reference to the Data Quality service (proxy) to be used. * * @return A reference to the Data Quality service (proxy) to be used */ public DataQualityService getService() { DataQualityService retVal = null; // set up providers List<Object> providers = new ArrayList<Object>(); JacksonJaxbJsonProvider jsonProvider = new JacksonJaxbJsonProvider(new CustomObjectMapper(), DEFAULT_ANNOTATIONS); ErrorResponseExceptionMapper srvExMapper = new ErrorResponseExceptionMapper(); providers.add(jsonProvider); providers.add(srvExMapper); if (endPoint != null) { // initialize proxy retVal = JAXRSClientFactory.create(endPoint, DataQualityService.class, providers); } else // fall-back (local or non-NEO runtime env) { // TODO - remove hard-coded URL String remoteProxy = MessageFormat.format("https://dqaas{0}.hanatrial.ondemand.com/dq", System.getenv("HC_ACCOUNT")); retVal = JAXRSClientFactory.create(remoteProxy, DataQualityService.class, providers); } return retVal; }
@Override protected <T> T createRESTClientProxy(String apiUrl, Class<T> proxy) { URI i = null; try { i = new URI(apiUrl); } catch (URISyntaxException ex) { throw new RuntimeException(ex); } ResteasyClientBuilder builder = new ResteasyClientBuilder(); builder.connectionCheckoutTimeout(CONNECTION_SETUP_TO, TimeUnit.SECONDS); builder.socketTimeout(CONNECTION_SETUP_TO, TimeUnit.SECONDS); builder.httpEngine(new URLConnectionEngine()); ResteasyProviderFactory.getInstance().register(builder); ResteasyClient client = builder.build(); client.register(new ClientRequestFilter() { @Override public void filter(ClientRequestContext requestContext) throws IOException { requestContext.getHeaders().add("User-Agent", getImplementationName() + "=" + getVersion()); } }); ObjectMapper mapper = new ObjectMapper(); JacksonJaxbJsonProvider jaxbProvider = new JacksonJaxbJsonProvider(mapper, JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS); mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector()); mapper.configure(Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); builder.register(jaxbProvider); builder.register(proxy); ResteasyWebTarget resteasyWebTarget = client.target(i); return resteasyWebTarget.proxy(proxy); }
@Override public HashSet<Object> getSingletons(){ ObjectMapper mapper = new ObjectMapper(); JacksonJaxbJsonProvider jaxbProvider = new JacksonJaxbJsonProvider(); jaxbProvider.setMapper(mapper); singletons.add(jaxbProvider); if(Activator.bundle==null){ throw new IllegalArgumentException("WebSocketService.BUNDLE is null!"); } IGuicer guicer = Guicer.getInstance(Activator.bundle); //create the rest object make sure dependencies are injected via guice. IRestWebSocket restWebSocket = guicer.createObject(IRestWebSocket.class); if(restWebSocket==null){ throw new IllegalArgumentException("restWebSocket is null!!!"); } //add it singletons.add(restWebSocket); return singletons; }
public JiraRestAccess(String url, String user, String password) { this.restHome = url + JIRA_REST_API_SUFFIX; String userAndPassword = user + ':' + password; this.authentification = new String(Base64.getEncoder().encode(userAndPassword.getBytes())); JacksonJsonProvider jacksonJsonProvider = new JacksonJaxbJsonProvider().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); objectMapper = jacksonJsonProvider.locateMapper(Object.class, MediaType.APPLICATION_JSON_TYPE); ClientConfig cfg = new DefaultClientConfig(); cfg.getSingletons().add(jacksonJsonProvider); this.client = Client.create(cfg); // this.client.addFilter(new LoggingFilter(System.out)); }
@Override protected void configureServlets() { bind(ClustersResource.class); bind(ConfigurationResource.class); bind(SchedulerStateResource.class); bind(ControllerResource.class); bind(ArtifactsResource.class); bind(GuiceContainer.class); bind(JacksonJaxbJsonProvider.class).in(Scopes.SINGLETON); serve("/api/*").with(GuiceContainer.class); }
@Override public Set<Class<?>> getClasses() { final Set<Class<?>> classes = new HashSet<Class<?>>(); classes.add(JacksonJaxbJsonProvider.class); classes.addAll(getRestRegistrationService().getClasses()); return classes; }
@Before public void setUp() throws Exception { HippoRepositoryFactory.setDefaultRepository(background); super.setUp(); startServer(); client = WebClient.create(HTTP_ENDPOINT_ADDRESS, Collections.singletonList(new JacksonJaxbJsonProvider()), "admin", "admin", null); }
private static void startServer() throws Exception { Object jacksonJaxbJsonProvider = new JacksonJaxbJsonProvider(); Object crossOriginResourceSharingFilter = new CrossOriginResourceSharingFilter(); Object customWebApplicationExceptionMapper = new CustomWebApplicationExceptionMapper(); Object hippoAuthenticationRequestHandler = new HippoAuthenticationRequestHandler(); Object apiDeclarationProvider = new ApiDeclarationProvider(); Object resourceListingProvider = new ResourceListingProvider(); Object customJacksonConfig = new CustomJacksonConfig(); List<Object> providers = new ArrayList<Object>(); providers.add(customJacksonConfig); providers.add(jacksonJaxbJsonProvider); providers.add(crossOriginResourceSharingFilter); providers.add(customWebApplicationExceptionMapper); providers.add(hippoAuthenticationRequestHandler); providers.add(apiDeclarationProvider); providers.add(resourceListingProvider); List<Class<?>> serviceClasses = new ArrayList<Class<?>>(); serviceClasses.add(ApiListingResourceJSON.class); serviceClasses.add(RootResource.class); serviceClasses.add(SystemResource.class); serviceClasses.add(NodesResource.class); serviceClasses.add(PropertiesResource.class); serviceClasses.add(QueryResource.class); serviceClasses.add(StatsResource.class); serviceClasses.add(UsersResource.class); serviceClasses.add(GroupsResource.class); JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); sf.setProviders(providers); sf.setResourceClasses(serviceClasses); sf.setAddress(HTTP_ENDPOINT_ADDRESS); cxfServer = sf.create(); }
public JerseyConnector(Logger logger) { if (logger != null) this.logger = new JerseyLoggingFilter(logger); ClientConfig clientConfig = new DefaultClientConfig(); clientConfig.getClasses().add(JacksonJaxbJsonProvider.class); clientConfig.getClasses().add(OpenStackObjectMapper.class); client = Client.create(clientConfig); }
@Inject public RESTApplication(ServiceLocator serviceLocator) { log.info("Initialisation de l'application"); classes.add(LdapResource.class); classes.add(NameNotFoundMapper.class); classes.add(MultiPartFeature.class); JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider(); singletons.add(provider); ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(SPRING_CONFIG); Rest2LdapConfig config = ctx.getBean("rest2ldapConfig", Rest2LdapConfig.class); ILdapDAO ldapDAO = ctx.getBean(ILdapDAO.class); DynamicConfiguration dc = Injections.getConfiguration(serviceLocator); Injections.addBinding( Injections.newBinder(ctx).to(ApplicationContext.class), dc); Injections.addBinding( Injections.newBinder(config).to(Rest2LdapConfig.class), dc); Injections.addBinding( Injections.newBinder(ldapDAO).to(ILdapDAO.class), dc); dc.commit(); testLdapConnection(ctx); }
public HashSet<Object> getSingletons(){ ObjectMapper mapper = new ObjectMapper(); JacksonJaxbJsonProvider jaxbProvider = new JacksonJaxbJsonProvider(); jaxbProvider.setMapper(mapper); singletons.add(jaxbProvider); if(WebshellServiceActivator.BUNDLE==null){ throw new IllegalArgumentException("WebshellServiceActivator.BUNDLE is null!"); } IGuicer guicer = Guicer.getInstance(WebshellServiceActivator.BUNDLE); //create the rest object make sure dependencies are injected via guice. IRestWebshell restWebshell = (IRestWebshell) guicer.createObject(IRestWebshell.class); RestSimple restSimple = (RestSimple) guicer.createObject(RestSimple.class); if(restWebshell==null){ throw new IllegalArgumentException("restWebshell is null!!!"); } //add it singletons.add(restWebshell); singletons.add(restSimple); return singletons; }
public HashSet<Object> getSingletons(){ ObjectMapper mapper = new ObjectMapper(); JacksonJaxbJsonProvider jaxbProvider = new JacksonJaxbJsonProvider(); jaxbProvider.setMapper(mapper); singletons.add(jaxbProvider); if(APNActivator.BUNDLE==null){ throw new IllegalArgumentException("APNActivator.BUNDLE is null!"); } IGuicer guicer = Guicer.getInstance(APNActivator.BUNDLE); //create the rest object make sure dependencies are injected via guice. IRestApn restPush = (IRestApn) guicer.createObject(IRestApn.class); RestSimple restSimple = (RestSimple)guicer.createObject(RestSimple.class); if(restPush==null){ throw new IllegalArgumentException("restPush is null!!!"); } //add it singletons.add(restPush); singletons.add(restSimple); return singletons; }
@Bean public JacksonJaxbJsonProvider jacksonJaxbJsonProvider() { return new JacksonJaxbJsonProvider(); }
public JerseyConnector() { ClientConfig clientConfig = new DefaultClientConfig(); clientConfig.getClasses().add(JacksonJaxbJsonProvider.class); clientConfig.getClasses().add(OpenStackObjectMapper.class); client = Client.create(clientConfig); }
private void bindJackson() { bind(JacksonJaxbJsonProvider.class).asEagerSingleton(); bind(MessageBodyReader.class).to(JacksonJsonProvider.class); bind(MessageBodyWriter.class).to(JacksonJsonProvider.class); }
protected ClientConfig getClientConfig() { ClientConfig clientConfig = new DefaultClientConfig(); clientConfig.getClasses().add(JacksonJaxbJsonProvider.class); clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE); return clientConfig; }
private ClientConfig getClientConfig() { final ClientConfig clientConfig = new DefaultClientConfig(); clientConfig.getClasses().add(JacksonJaxbJsonProvider.class); clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE); return clientConfig; }