/** * Builds the {@link Client} instance. * * @return a fully-configured {@link Client} */ public Client build(String name) { if ((environment == null) && ((executorService == null) || (objectMapper == null))) { throw new IllegalStateException( "Must have either an environment or both " + "an executor service and an object mapper"); } if (executorService == null && environment != null) { executorService = environment .lifecycle() .executorService("jersey-client-" + name + "-%d") .minThreads(configuration.getMinThreads()) .maxThreads(configuration.getMaxThreads()) .workQueue(new ArrayBlockingQueue<Runnable>(configuration.getWorkQueueSize())) .build(); } if (objectMapper == null && environment != null) { objectMapper = environment.getObjectMapper(); } if (environment != null) { validator = environment.getValidator(); } return build(name, executorService, objectMapper, validator); }
/** * Builds the {@link Client} instance. * * @return a fully-configured {@link Client} */ public Client build() { if ((environment == null) && (executorService == null) && (objectMapper == null)) { throw new IllegalStateException( "Must have either an environment or both " + "an executor service and an object mapper"); } if (environment == null) { return build(executorService, objectMapper); } return build( environment.managedExecutorService( "jersey-client-%d", configuration.getMinThreads(), configuration.getMaxThreads(), 60, TimeUnit.SECONDS), environment.getObjectMapperFactory().build()); }