org.atmosphere.cpr
Class DefaultAtmosphereResourceFactory

java.lang.Object
  extended by org.atmosphere.cpr.DefaultAtmosphereResourceFactory
All Implemented Interfaces:
AtmosphereResourceFactory, AtmosphereConfigAware

public class DefaultAtmosphereResourceFactory
extends Object
implements AtmosphereResourceFactory

A Factory used to manage AtmosphereResource instances. You can use this factory to create, remove and find AtmosphereResource instances that are associated with one or several Broadcasters.

Author:
Jeanfrancois Arcand

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.atmosphere.cpr.AtmosphereResourceFactory
AtmosphereResourceFactory.Async
 
Constructor Summary
DefaultAtmosphereResourceFactory()
           
 
Method Summary
 Set<Broadcaster> broadcasters(String uuid)
          Deprecated. Use AtmosphereResourceFactory.find(String).broadcasters() instead
 void configure(AtmosphereConfig config)
          Configure an AtmosphereFramework object.
 AtmosphereResource create(AtmosphereConfig config, AtmosphereRequest request, AtmosphereResponse response, AsyncSupport<?> a)
          Create an AtmosphereResourceImpl
 AtmosphereResource create(AtmosphereConfig config, AtmosphereResponse response, AsyncSupport<?> a)
          Create an AtmosphereResourceImpl.
 AtmosphereResource create(AtmosphereConfig config, Broadcaster broadcaster, AtmosphereRequest request, AtmosphereResponse response, AsyncSupport<?> a, AtmosphereHandler handler)
          Create an AtmosphereResourceImpl.
 AtmosphereResource create(AtmosphereConfig config, Broadcaster broadcaster, AtmosphereRequest request, AtmosphereResponse response, AsyncSupport<?> a, AtmosphereHandler handler, AtmosphereResource.TRANSPORT t)
          Create an AtmosphereResourceImpl.
 AtmosphereResource create(AtmosphereConfig config, Broadcaster broadcaster, AtmosphereResponse response, AsyncSupport<?> a, AtmosphereHandler handler)
          Create an AtmosphereResourceImpl.
 AtmosphereResource create(AtmosphereConfig config, Broadcaster broadcaster, AtmosphereResponse response, AsyncSupport<?> a, AtmosphereHandler handler, AtmosphereResource.TRANSPORT t)
           
 AtmosphereResource create(AtmosphereConfig config, String uuid)
          Create an AtmosphereResource associated with the uuid.
 AtmosphereResource create(AtmosphereConfig config, String uuid, AtmosphereRequest request)
          Create an AtmosphereResource associated with the uuid.
 void destroy()
           
 AtmosphereResource find(String uuid)
          Find an AtmosphereResource based on its AtmosphereResource.uuid().
 Collection<AtmosphereResource> findAll()
           
 void locate(String uuid, AtmosphereResourceFactory.Async async)
          Locate an AtmosphereResource, based on its AtmosphereResource.uuid(), in a cluster.
 void registerUuidForFindCandidate(AtmosphereResource r)
          Register an AtmosphereResource for being a candidate to find(String) operation.
 AtmosphereResource remove(String uuid)
          Remove the AtmosphereResource from all instances of Broadcaster.
 ConcurrentMap<String,AtmosphereResource> resources()
           
 void unRegisterUuidForFindCandidate(AtmosphereResource r)
          Un register an AtmosphereResource for being a candidate to find(String) operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultAtmosphereResourceFactory

public DefaultAtmosphereResourceFactory()
Method Detail

configure

public void configure(AtmosphereConfig config)
Description copied from interface: AtmosphereConfigAware
Configure an AtmosphereFramework object.

Specified by:
configure in interface AtmosphereResourceFactory
Specified by:
configure in interface AtmosphereConfigAware
Parameters:
config - AtmosphereConfig

create

public AtmosphereResource create(AtmosphereConfig config,
                                 AtmosphereRequest request,
                                 AtmosphereResponse response,
                                 AsyncSupport<?> a)
Create an AtmosphereResourceImpl

Specified by:
create in interface AtmosphereResourceFactory
Parameters:
config - an AtmosphereConfig
request - an AtmosphereResponse
a - AsyncSupport
Returns:
an AtmosphereResourceImpl

create

public AtmosphereResource create(AtmosphereConfig config,
                                 Broadcaster broadcaster,
                                 AtmosphereRequest request,
                                 AtmosphereResponse response,
                                 AsyncSupport<?> a,
                                 AtmosphereHandler handler)
Create an AtmosphereResourceImpl.

Specified by:
create in interface AtmosphereResourceFactory
Parameters:
config - an AtmosphereConfig
broadcaster - a Broadcaster
response - an AtmosphereResponse
a - AsyncSupport
handler - an AtmosphereHandler
Returns:
an AtmosphereResourceImpl

create

public AtmosphereResource create(AtmosphereConfig config,
                                 Broadcaster broadcaster,
                                 AtmosphereRequest request,
                                 AtmosphereResponse response,
                                 AsyncSupport<?> a,
                                 AtmosphereHandler handler,
                                 AtmosphereResource.TRANSPORT t)
Create an AtmosphereResourceImpl.

Specified by:
create in interface AtmosphereResourceFactory
Parameters:
config - an AtmosphereConfig
broadcaster - a Broadcaster
response - an AtmosphereResponse
a - AsyncSupport
handler - an AtmosphereHandler
t - an AtmosphereResource.TRANSPORT
Returns:
an AtmosphereResourceImpl

create

public AtmosphereResource create(AtmosphereConfig config,
                                 Broadcaster broadcaster,
                                 AtmosphereResponse response,
                                 AsyncSupport<?> a,
                                 AtmosphereHandler handler)
Create an AtmosphereResourceImpl.

Specified by:
create in interface AtmosphereResourceFactory
Parameters:
config - an AtmosphereConfig
broadcaster - a Broadcaster
response - an AtmosphereResponse
a - AsyncSupport
handler - an AtmosphereHandler
Returns:
an AtmosphereResourceImpl

create

public AtmosphereResource create(AtmosphereConfig config,
                                 Broadcaster broadcaster,
                                 AtmosphereResponse response,
                                 AsyncSupport<?> a,
                                 AtmosphereHandler handler,
                                 AtmosphereResource.TRANSPORT t)
Specified by:
create in interface AtmosphereResourceFactory

create

public AtmosphereResource create(AtmosphereConfig config,
                                 AtmosphereResponse response,
                                 AsyncSupport<?> a)
Create an AtmosphereResourceImpl.

Specified by:
create in interface AtmosphereResourceFactory
Parameters:
config - an AtmosphereConfig
response - an AtmosphereResponse
a - AsyncSupport
Returns:
an AtmosphereResourceImpl

create

public AtmosphereResource create(AtmosphereConfig config,
                                 String uuid)
Create an AtmosphereResource associated with the uuid.

Specified by:
create in interface AtmosphereResourceFactory
Parameters:
config - an AtmosphereConfig
uuid - a String representing a UUID
Returns:

create

public AtmosphereResource create(AtmosphereConfig config,
                                 String uuid,
                                 AtmosphereRequest request)
Create an AtmosphereResource associated with the uuid.

Specified by:
create in interface AtmosphereResourceFactory
Parameters:
config - an AtmosphereConfig
uuid - a String representing a UUID
request - a AtmosphereRequest
Returns:

remove

public AtmosphereResource remove(String uuid)
Remove the AtmosphereResource from all instances of Broadcaster.

Specified by:
remove in interface AtmosphereResourceFactory
Parameters:
uuid - the AtmosphereResource.uuid()
Returns:
the AtmosphereResource, or null if not found.

find

public AtmosphereResource find(String uuid)
Find an AtmosphereResource based on its AtmosphereResource.uuid().

Specified by:
find in interface AtmosphereResourceFactory
Parameters:
uuid - the AtmosphereResource.uuid()
Returns:
the AtmosphereResource, or null if not found.

locate

public void locate(String uuid,
                   AtmosphereResourceFactory.Async async)
Description copied from interface: AtmosphereResourceFactory
Locate an AtmosphereResource, based on its AtmosphereResource.uuid(), in a cluster. If the AtmosphereResource is available in the cluster, the AtmosphereResourceFactory.Async.available(org.atmosphere.cpr.AtmosphereResource) callback will be invoked. If not, the org.atmosphere.cpr.AtmosphereResourceFactory.Async#notAvailable

Specified by:
locate in interface AtmosphereResourceFactory
Parameters:
uuid - the AtmosphereResource.uuid()
async - an AtmosphereResourceFactory.Async

broadcasters

@Deprecated
public Set<Broadcaster> broadcasters(String uuid)
Deprecated. Use AtmosphereResourceFactory.find(String).broadcasters() instead

Return all Broadcaster associated with a AtmosphereResource.uuid(), e.g for which Broadcaster.addAtmosphereResource(AtmosphereResource) has been called. Note that this method is not synchronized and may not return all the Broadcaster in case Broadcaster.addAtmosphereResource(AtmosphereResource) is being called concurrently.

Specified by:
broadcasters in interface AtmosphereResourceFactory
Parameters:
uuid - the AtmosphereResource.uuid()
Returns:
all Broadcaster associated with a AtmosphereResource.uuid()

registerUuidForFindCandidate

public void registerUuidForFindCandidate(AtmosphereResource r)
Register an AtmosphereResource for being a candidate to find(String) operation.

Specified by:
registerUuidForFindCandidate in interface AtmosphereResourceFactory
Parameters:
r - AtmosphereResource

unRegisterUuidForFindCandidate

public void unRegisterUuidForFindCandidate(AtmosphereResource r)
Un register an AtmosphereResource for being a candidate to find(String) operation.

Specified by:
unRegisterUuidForFindCandidate in interface AtmosphereResourceFactory
Parameters:
r - AtmosphereResource

destroy

public void destroy()
Specified by:
destroy in interface AtmosphereResourceFactory

resources

public ConcurrentMap<String,AtmosphereResource> resources()
Specified by:
resources in interface AtmosphereResourceFactory

findAll

public Collection<AtmosphereResource> findAll()
Specified by:
findAll in interface AtmosphereResourceFactory


Copyright © 2015. All Rights Reserved.