Java Code Examples for org.jboss.resteasy.spi.ResteasyProviderFactory#getInstance()

The following examples show how to use org.jboss.resteasy.spi.ResteasyProviderFactory#getInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SchedulerClient.java    From scheduling with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void init(ConnectionInfo connectionInfo) throws Exception {
    HttpClient client = new HttpClientBuilder().insecure(connectionInfo.isInsecure()).useSystemProperties().build();
    SchedulerRestClient restApiClient = new SchedulerRestClient(connectionInfo.getUrl(),
                                                                new ApacheHttpClient4Engine(client));

    ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance();
    factory.register(new WildCardTypeReader());
    factory.register(new OctetStreamReader());
    factory.register(new TaskResultReader());
    SchedulerRestClient.registerGzipEncoding(factory);

    setApiClient(restApiClient);

    this.connectionInfo = connectionInfo;
    this.initialized = true;

    renewSession();
}
 
Example 2
Source File: MyResteasyBootstrap.java    From scheduling with GNU Affero General Public License v3.0 6 votes vote down vote up
public void contextInitialized(ServletContextEvent event) {
    super.contextInitialized(event);

    ResteasyProviderFactory dispatcher = ResteasyProviderFactory.getInstance();

    dispatcher.registerProvider(OctetStreamWriter.class, false);
    dispatcher.registerProvider(PlainTextReader.class, false);

    restRuntime = new RestRuntime();

    initPortalConfiguration(event);

    restRuntime.start(dispatcher,
                      findConfigurationFile(event.getServletContext(), "log4j.properties"),
                      findConfigurationFile(event.getServletContext(),
                                            File.separator + "config" + File.separator + "network" +
                                                                       File.separator + "server.ini"));
}
 
Example 3
Source File: HttpClient.java    From syndesis with Apache License 2.0 5 votes vote down vote up
private static Client createClient() {
    final ObjectMapper mapper = new ObjectMapper().registerModules(new Jdk8Module());
    final ResteasyJackson2Provider resteasyJacksonProvider = new ResteasyJackson2Provider();

    resteasyJacksonProvider.setMapper(mapper);

    final ResteasyProviderFactory providerFactory = ResteasyProviderFactory.getInstance();
    providerFactory.register(resteasyJacksonProvider);

    return ClientBuilder.newBuilder()
        .withConfig(providerFactory)
        .connectTimeout(CONNECT_TIMEOUT, TimeUnit.SECONDS)
        .readTimeout(READ_TIMEOUT, TimeUnit.SECONDS)
        .build();
}
 
Example 4
Source File: DataSpaceClient.java    From scheduling with GNU Affero General Public License v3.0 5 votes vote down vote up
public void init(String restServerUrl, ISchedulerClient client) {
    this.httpEngine = new ApacheHttpClient4Engine(new HttpClientBuilder().disableContentCompression()
                                                                         .insecure(client.getConnectionInfo()
                                                                                         .isInsecure())
                                                                         .useSystemProperties()
                                                                         .build());
    this.providerFactory = ResteasyProviderFactory.getInstance();
    SchedulerRestClient.registerGzipEncoding(providerFactory);
    this.restDataspaceUrl = restDataspaceUrl(restServerUrl);
    this.sessionId = client.getSession();
    if (log.isDebugEnabled()) {
        log.debug("Error : trying to retrieve session from disconnected client.");
    }
    this.schedulerClient = client;
}
 
Example 5
Source File: SchedulerStateRest.java    From scheduling with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public String submitPlannings(String sessionId, PathSegment pathSegment, Map<String, String> jobContentXmlString)
        throws JobCreationRestException, NotConnectedRestException, IOException {

    checkAccess(sessionId, "plannings");

    Map<String, String> jobVariables = workflowVariablesTransformer.getWorkflowVariablesFromPathSegment(pathSegment);

    if (jobContentXmlString == null || jobContentXmlString.size() != 1) {
        throw new JobCreationRestException("Cannot find job body: code " + HttpURLConnection.HTTP_BAD_REQUEST);
    }

    Map<String, Object> requestBody = new HashMap<>(2);
    requestBody.put("variables", jobVariables);
    requestBody.put("xmlContentString", jobContentXmlString.entrySet().iterator().next().getValue());

    Response response = null;
    try {
        ResteasyProviderFactory providerFactory = ResteasyProviderFactory.getInstance();
        SchedulerRestClient.registerGzipEncoding(providerFactory);
        ResteasyClient client = new ResteasyClientBuilder().providerFactory(providerFactory).build();
        ResteasyWebTarget target = client.target(PortalConfiguration.JOBPLANNER_URL.getValueAsString());
        response = target.request()
                         .header("sessionid", sessionId)
                         .post(Entity.entity(requestBody, "application/json"));

        if (HttpURLConnection.HTTP_OK != response.getStatus()) {
            throw new IOException(String.format("Cannot access resource %s: code %d",
                                                PortalConfiguration.JOBPLANNER_URL.getValueAsString(),
                                                response.getStatus()));
        }
        return response.readEntity(String.class);
    } finally {
        if (response != null) {
            response.close();
        }
    }

}
 
Example 6
Source File: ExternalVerifierService.java    From syndesis with Apache License 2.0 5 votes vote down vote up
@PostConstruct
public void init() {
    if (this.client == null) {
        final ObjectMapper mapper = new ObjectMapper().registerModules(new Jdk8Module());
        final ResteasyJackson2Provider resteasyJacksonProvider = new ResteasyJackson2Provider();

        resteasyJacksonProvider.setMapper(mapper);

        final ResteasyProviderFactory providerFactory = ResteasyProviderFactory.getInstance();
        providerFactory.register(resteasyJacksonProvider);

        this.client = ClientBuilder.newClient(providerFactory);
    }

}
 
Example 7
Source File: ApiClient.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Build the Client used to make HTTP requests.
 */
private Client buildHttpClient(boolean debugging) {
  final ClientConfiguration clientConfig = new ClientConfiguration(ResteasyProviderFactory.getInstance());
  clientConfig.register(json);
  if(debugging){
    clientConfig.register(Logger.class);
  }
  return ClientBuilder.newClient(clientConfig);
}
 
Example 8
Source File: Resteasy3Provider.java    From spring-security-oauth with MIT License 4 votes vote down vote up
@Override
public void pushContext(Class type, Object instance) {
	ResteasyProviderFactory.getInstance();
	ResteasyProviderFactory.pushContext(type, instance);
}
 
Example 9
Source File: Resteasy3Provider.java    From spring-security-oauth with MIT License 4 votes vote down vote up
@Override
public void clearContextData() {
	ResteasyProviderFactory.getInstance();
	ResteasyProviderFactory.clearContextData();
}
 
Example 10
Source File: Resteasy3Provider.java    From spring-security-oauth with MIT License 4 votes vote down vote up
@Override
public <R> R getContextData(Class<R> type) {
	ResteasyProviderFactory.getInstance();
	return ResteasyProviderFactory.getContextData(type);
}
 
Example 11
Source File: Resteasy3Provider.java    From spring-security-oauth with MIT License 4 votes vote down vote up
@Override
public void pushDefaultContextObject(Class type, Object instance) {
	ResteasyProviderFactory.getInstance();
	ResteasyProviderFactory.getContextData(Dispatcher.class).getDefaultContextObjects().put(type, instance);
}
 
Example 12
Source File: Resteasy3Provider.java    From spring-security-oauth with MIT License 4 votes vote down vote up
@Override
public void pushContext(Class type, Object instance) {
	ResteasyProviderFactory.getInstance();
	ResteasyProviderFactory.pushContext(type, instance);
}
 
Example 13
Source File: Resteasy3Provider.java    From spring-security-oauth with MIT License 4 votes vote down vote up
@Override
public void clearContextData() {
	ResteasyProviderFactory.getInstance();
	ResteasyProviderFactory.clearContextData();
}
 
Example 14
Source File: Resteasy3Provider.java    From spring-security-oauth with MIT License 4 votes vote down vote up
@Override
public <R> R getContextData(Class<R> type) {
	ResteasyProviderFactory.getInstance();
	return ResteasyProviderFactory.getContextData(type);
}
 
Example 15
Source File: Resteasy3Provider.java    From spring-security-oauth with MIT License 4 votes vote down vote up
@Override
public void pushDefaultContextObject(Class type, Object instance) {
	ResteasyProviderFactory.getInstance();
	ResteasyProviderFactory.getContextData(Dispatcher.class).getDefaultContextObjects().put(type, instance);
}
 
Example 16
Source File: Resteasy3Provider.java    From spring-security-oauth with MIT License 4 votes vote down vote up
@Override
public void pushContext(Class type, Object instance) {
	ResteasyProviderFactory.getInstance();
	ResteasyProviderFactory.pushContext(type, instance);
}
 
Example 17
Source File: Resteasy3Provider.java    From spring-security-oauth with MIT License 4 votes vote down vote up
@Override
public void clearContextData() {
	ResteasyProviderFactory.getInstance();
	ResteasyProviderFactory.clearContextData();
}
 
Example 18
Source File: Resteasy3Provider.java    From spring-boot-keycloak-server-example with Apache License 2.0 4 votes vote down vote up
private ResteasyProviderFactory resteasyProviderFactory() {
    return ResteasyProviderFactory.getInstance();
}
 
Example 19
Source File: Resteasy3Provider.java    From spring-security-oauth with MIT License 4 votes vote down vote up
@Override
public void pushDefaultContextObject(Class type, Object instance) {
	ResteasyProviderFactory.getInstance();
	ResteasyProviderFactory.getContextData(Dispatcher.class).getDefaultContextObjects().put(type, instance);
}
 
Example 20
Source File: Resteasy3Provider.java    From spring-security-oauth with MIT License 4 votes vote down vote up
@Override
public <R> R getContextData(Class<R> type) {
	ResteasyProviderFactory.getInstance();
	return ResteasyProviderFactory.getContextData(type);
}