public ClientState newState(URI currentURI, MultivaluedMap<String, String> headers, MultivaluedMap<String, String> templates) { LocalClientState ls = (LocalClientState)getState().newState(currentURI, headers, templates); return new ThreadLocalClientState(ls, timeToKeepState); }
public void setTimeToKeepState(long timeToKeepState) { this.timeToKeepState = timeToKeepState; if (timeToKeepState > 0) { prepareCheckpointMap(); } }
public void reset() { removeThreadLocalState(Thread.currentThread()); }
public void setCurrentBuilder(UriBuilder currentBuilder) { getState().setCurrentBuilder(currentBuilder); }
protected ClientState getActualState() { if (threadSafe) { initialState = new ThreadLocalClientState(getAddress(), timeToKeepState); } if (initialState != null) { return headers != null ? initialState.newState(URI.create(getAddress()), headers, null) : initialState; } return null; }
public void setRequestHeaders(MultivaluedMap<String, String> requestHeaders) { getState().setRequestHeaders(requestHeaders); }
protected ClientState getActualState() { if (threadSafe) { initialState = new ThreadLocalClientState(getAddress(), timeToKeepState); } if (initialState != null) { return headers != null ? initialState.newState(URI.create(getAddress()), headers, null) : initialState; } return null; }
public MultivaluedMap<String, String> getTemplates() { return getState().getTemplates(); }
private ClientState getActualState() { if (threadSafe) { initialState = new ThreadLocalClientState(getAddress(), timeToKeepState); } if (initialState != null) { return headers != null ? initialState.newState(URI.create(getAddress()), headers, null) : initialState; } else { return null; } }
public ClientState newState(URI currentURI, MultivaluedMap<String, String> headers, MultivaluedMap<String, String> templates) { LocalClientState ls = (LocalClientState)getState().newState(currentURI, headers, templates); return new ThreadLocalClientState(ls, timeToKeepState); }
public void setTimeToKeepState(long timeToKeepState) { this.timeToKeepState = timeToKeepState; if (timeToKeepState > 0) { prepareCheckpointMap(); } }
public void reset() { removeThreadLocalState(Thread.currentThread()); }
public void setTemplates(MultivaluedMap<String, String> map) { getState().setTemplates(map); }
/** * Creates a thread safe WebClient * @param baseAddress baseURI * @param providers list of providers * @param timeToKeepState time to keep this thread safe state. */ public static WebClient create(String baseAddress, List<?> providers, long timeToKeepState) { JAXRSClientFactoryBean bean = getBean(baseAddress, null); bean.setProviders(providers); bean.setInitialState(new ThreadLocalClientState(baseAddress, timeToKeepState)); return bean.createWebClient(); }
public ClientState newState(URI currentURI, MultivaluedMap<String, String> headers, MultivaluedMap<String, String> templates) { LocalClientState ls = (LocalClientState)getState().newState(currentURI, headers, templates); return new ThreadLocalClientState(ls, timeToKeepState); }
public void setTimeToKeepState(long timeToKeepState) { this.timeToKeepState = timeToKeepState; if (timeToKeepState > 0) { prepareCheckpointMap(); } }
public void reset() { removeThreadLocalState(Thread.currentThread()); }
public URI getBaseURI() { return getState().getBaseURI(); }
/** * Creates a thread safe WebClient * @param baseAddress baseURI * @param providers list of providers * @param timeToKeepState time to keep this thread safe state. */ public static WebClient create(String baseAddress, List<?> providers, long timeToKeepState) { JAXRSClientFactoryBean bean = getBean(baseAddress, null); bean.setProviders(providers); bean.setInitialState(new ThreadLocalClientState(baseAddress, timeToKeepState)); return bean.createWebClient(); }
protected ClientState getState() { LocalClientState cs = state.get(Thread.currentThread()); if (cs == null) { cs = new LocalClientState(initialState); state.put(Thread.currentThread(), cs); if (timeToKeepState > 0) { prepareCheckpointMap(); long currentTime = System.currentTimeMillis(); checkpointMap.put(Thread.currentThread(), currentTime); Thread clThread = new CleanupThread(Thread.currentThread(), currentTime); clThread.setName("Client state cleanup thread " + clThread.hashCode()); clThread.start(); } } return cs; }