Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright 2013 Jeanfrancois Arcand
  *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of
  * the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package org.atmosphere.wasync;
Create a Client. By default, the org.atmosphere.wasync.impl.DefaultClient will be returned. To override the org.atmosphere.wasync.impl.DefaultClient, just specify the provider using the -Dwasync.client property.

Author(s):
Jeanfrancois Arcand
public class ClientFactory {
    private final static ClientFactory factory = new ClientFactory();
    private final String clientClassName;
    public ClientFactory() {
         = System.getProperty("wasync.client");
    }

    
Return the default Factory.

Returns:
this
    public final static ClientFactory getDefault() {
        return ;
    }

    
Return a new Client instance

Returns:
a new Client instance
    public Client<? extends Options, ? extends OptionsBuilder, ? extends RequestBuildernewClient() {
        if ( == null) {
            return new DefaultClient();
        } else {
            try {
                return (Client) Thread.currentThread().getContextClassLoader().loadClass().newInstance();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }

    
Return a new Client instance

Parameters:
clientClass the runtime instance class of Client instance that is returned
Returns:
a new Client instance
    public <T extends Client<? extends Options, ? extends OptionsBuilder, ? extends RequestBuilder>> T newClient(Class<? extends ClientclientClass) {
        Client client;
        try {
            client = clientClass.newInstance();
            return (T) client;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
New to GrepCode? Check out our FAQ X