On Fri, Jun 1, 2012 at 10:53 AM, Probie <cheah....@gmail.com> wrote:
> Hi Simon,
>
> Map<String, Object> options = new HashMap<String, Object>();
> LongPollingTransport transport = new LongPollingTransport(
> options, httpClient) {
>
> @Override
> protected void customize(ContentExchange exchange) {
> if(isHTTPS){
> exchange.setURL(urls);
> } else {
> exchange.setURL(url);
> }
> super.customize(exchange);
>
> }
> };
>
> I think this might be the best possible way to solved the problem.
> Anyway I might be wrong. So if the boolean isHTTPS I set it to true
> for certain function I want to use HTTPS, it will override the url in
> customize to secure url, otherwise use back url. Problem solved.
Not really.
If "isHTTPS" is a field, then the code above is not thread-safe.
You have to have some kind of logic like the one you wrote above, but
must be thread safe.