Example #1
0
 @Override
 public ResteasyClientBuilder withConfig(Configuration config) {
   providerFactory = new ResteasyProviderFactory();
   providerFactory.setProperties(config.getProperties());
   for (Class clazz : config.getClasses()) {
     Map<Class<?>, Integer> contracts = config.getContracts(clazz);
     try {
       register(clazz, contracts);
     } catch (RuntimeException e) {
       throw new RuntimeException("failed on registering class: " + clazz.getName(), e);
     }
   }
   for (Object obj : config.getInstances()) {
     Map<Class<?>, Integer> contracts = config.getContracts(obj.getClass());
     register(obj, contracts);
   }
   return this;
 }
Example #2
0
    @Override
    public Builder request() {
      checkClosed();

      initTargetClientIfNeeded();

      ClientProviderFactory pf =
          ClientProviderFactory.getInstance(WebClient.getConfig(targetClient).getEndpoint());
      List<Object> providers = new LinkedList<Object>();
      Configuration cfg = configImpl.getConfiguration();
      for (Object p : cfg.getInstances()) {
        if (!(p instanceof Feature)) {
          Map<Class<?>, Integer> contracts = cfg.getContracts(p.getClass());
          if (contracts == null || contracts.isEmpty()) {
            providers.add(p);
          } else {
            providers.add(new FilterProviderInfo<Object>(p, pf.getBus(), contracts));
          }
        }
      }

      pf.setUserProviders(providers);
      WebClient.getConfig(targetClient)
          .getRequestContext()
          .putAll(getConfiguration().getProperties());
      WebClient.getConfig(targetClient)
          .getRequestContext()
          .put(Client.class.getName(), ClientImpl.this);
      WebClient.getConfig(targetClient)
          .getRequestContext()
          .put(Configuration.class.getName(), getConfiguration());
      // TLS
      TLSClientParameters tlsParams = secConfig.getTlsClientParams();
      if (tlsParams.getSSLSocketFactory() != null || tlsParams.getTrustManagers() != null) {
        WebClient.getConfig(targetClient).getHttpConduit().setTlsClientParameters(tlsParams);
      }

      // start building the invocation
      return new InvocationBuilderImpl(WebClient.fromClient(targetClient));
    }