public class DefaultResourceManager extends Object implements ResourceManagerProviderServices
Constructor and Description |
---|
DefaultResourceManager() |
Modifier and Type | Method and Description |
---|---|
void |
addObserver(Observer o) |
void |
closeResources()
Close all register resources.
|
void |
collectResources()
Iterates over the resources and frees them if they are ready to be freed
or try to close them if they are idle.
|
ResourceProvider |
createAddResource(ResourceParameters params) |
ResourceProvider |
createAddResource(String type,
Object[] params) |
DataParameters |
createParameters(String type) |
DataParameters |
createParameters(String type,
Object[] args) |
ResourceProvider |
createResource(ResourceParameters params) |
ResourceProvider |
createResource(String type,
Object[] params) |
void |
deleteObserver(Observer o) |
void |
deleteObservers() |
void |
dispose() |
Logger |
getLogger() |
Resource |
getResource(String key) |
List |
getResourceProviders() |
int |
getTimeToBeIdle()
Returns the wait time to consider that a resource is idle in seconds.
|
Iterator<Resource> |
iterator()
Returns an iterator over the available resources.
|
boolean |
register(String type,
String description,
Class resourceHandler,
Class resourceParams) |
void |
remove(Resource resource) |
void |
remove(String name) |
void |
setTimeToBeIdle(int seconds)
Sets the wait time to consider that a resource is idle.
|
void |
startResourceCollector(long milis,
Observer observer)
Initializes the resource collection background process.
|
void |
stopResourceCollector()
Stops successive executions of the resource collector process.
|
public Logger getLogger()
public void remove(Resource resource) throws DataException
remove
in interface ResourceManagerProviderServices
DataException
public void remove(String name) throws DataException
remove
in interface ResourceManagerProviderServices
DataException
public Resource getResource(String key)
getResource
in interface ResourceManager
public Iterator<Resource> iterator()
ResourceManager
iterator
in interface Iterable<Resource>
iterator
in interface ResourceManager
public void addObserver(Observer o)
addObserver
in interface Observable
public void deleteObserver(Observer o)
deleteObserver
in interface Observable
public void deleteObservers()
deleteObservers
in interface Observable
public void collectResources() throws DataException
ResourceManager
collectResources
in interface ResourceManager
DataException
ResourceManager#getTimeToBeIdle()}
{@link ResourceManager#setTimeToBeIdle(int)}
public void startResourceCollector(long milis, Observer observer)
ResourceManager
startResourceCollector
in interface ResourceManager
milis
- delay between each execution of the resource collection process, in milliseconds.observer
- an observer that will be notified on each execution of the resource collection process.public void stopResourceCollector()
ResourceManager
stopResourceCollector
in interface ResourceManager
public DataParameters createParameters(String type, Object[] args) throws InitializeException
InitializeException
public DataParameters createParameters(String type) throws InitializeException
createParameters
in interface ResourceManagerProviderServices
InitializeException
public ResourceProvider createAddResource(String type, Object[] params) throws InitializeException
createAddResource
in interface ResourceManagerProviderServices
InitializeException
public ResourceProvider createResource(String type, Object[] params) throws InitializeException
createResource
in interface ResourceManagerProviderServices
InitializeException
public ResourceProvider createResource(ResourceParameters params) throws InitializeException
createResource
in interface ResourceManagerProviderServices
InitializeException
public ResourceProvider createAddResource(ResourceParameters params) throws InitializeException
createAddResource
in interface ResourceManagerProviderServices
InitializeException
public boolean register(String type, String description, Class resourceHandler, Class resourceParams)
register
in interface ResourceManagerProviderServices
public List getResourceProviders()
getResourceProviders
in interface ResourceManagerProviderServices
public void closeResources() throws DataException
ResourceManager
closeResources
in interface ResourceManager
DataException
public void dispose() throws DisposeResorceManagerException
dispose
in interface ResourceManager
DisposeResorceManagerException
public int getTimeToBeIdle()
ResourceManager
getTimeToBeIdle
in interface ResourceManager
ResourceManager#collectResources()}
,
ResourceManager#startResourceCollector(long, Observer)}
public void setTimeToBeIdle(int seconds)
ResourceManager
setTimeToBeIdle
in interface ResourceManager
ResourceManager#collectResources()}
,
ResourceManager#startResourceCollector(long, Observer)}