public class ApplicationService extends Object
DelegatedResource
,
GeneratedTextResource
,
ApplicationTask
Modifier | Constructor and Description |
---|---|
protected |
ApplicationService(Application application)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
<T> Future<T> |
codeTask(String applicationName,
String code,
Object context,
int delay,
int repeatEvery,
boolean fixedRepeat)
Submits or schedules an
ApplicationTask on the the shared
executor service. |
static ApplicationService |
create()
Constructor using the current application.
|
static ApplicationService |
create(Application application)
Constructor.
|
<T> Future<T> |
executeTask(String applicationName,
String documentName,
String entryPointName,
Object context,
int delay,
int repeatEvery,
boolean fixedRepeat)
Submits or schedules an
ApplicationTask on the the shared
executor service. |
Application |
getApplication()
The underlying application.
|
Component |
getComponent()
The underlying component.
|
File |
getContainerRoot()
The container root directory.
|
ExecutorService |
getExecutor()
Gets the shared executor service, creating one if it doesn't exist.
|
Object |
getGlobal(String name,
Object defaultValue)
Gets a value global to the current application, atomically setting it to
a default value if it doesn't exist.
|
ConcurrentMap<String,Object> |
getGlobals()
A map of all values global to the current application.
|
ReentrantLock |
getLock(String name)
Gets a lock for the current application.
|
ConcurrentMap<String,ReentrantLock> |
getLocks()
Get the locks for the current application.
|
Logger |
getLogger()
The application's logger.
|
MediaType |
getMediaTypeByExtension(String extension)
Get a media type by its extension.
|
MediaType |
getMediaTypeByName(String name)
Get a media type by its MIME type name.
|
File |
getRoot()
The application root directory.
|
Scheduler |
getScheduler()
Gets the shared scheduler.
|
Object |
getSharedGlobal(String name,
Object defaultValue)
Gets a value global to all running applications, atomically setting it to
a default value if it doesn't exist.
|
ConcurrentMap<String,Object> |
getSharedGlobals()
A map of all values global to all running applications.
|
ReentrantLock |
getSharedLock(String name)
Gets a lock shared by all running applications.
|
ConcurrentMap<String,ReentrantLock> |
getSharedLocks()
Get the locks shared by all running applications.
|
Logger |
getSubLogger(String name)
A logger with a name appended with a "." to the application's logger
name.
|
ApplicationTaskCollector |
getTaskCollector()
Gets the task collector, if there is one.
|
protected ApplicationService(Application application)
application
- The applicationpublic static ApplicationService create()
Application.getCurrent()
public static ApplicationService create(Application application)
application
- The applicationpublic Application getApplication()
public Component getComponent()
Note: for this to work, the component must have been explicitly set as
attribute com.threecrickets.prudence.component
in the
application's context.
public ConcurrentMap<String,Object> getGlobals()
public Object getGlobal(String name, Object defaultValue)
name
- The name of the globaldefaultValue
- The default valuepublic ConcurrentMap<String,ReentrantLock> getLocks()
public ReentrantLock getLock(String name)
name
- The lock namepublic ConcurrentMap<String,Object> getSharedGlobals()
Note that this could be null if shared globals are not set up.
getComponent()
public Object getSharedGlobal(String name, Object defaultValue)
If shared globals are not set up, does nothing and returns null.
name
- The name of the shared globaldefaultValue
- The default valuegetComponent()
public ConcurrentMap<String,ReentrantLock> getSharedLocks()
public ReentrantLock getSharedLock(String name)
name
- The shared lock namepublic Logger getLogger()
getSubLogger(String)
public Logger getSubLogger(String name)
name
- The sub-logger namegetLogger()
public File getRoot()
public File getContainerRoot()
public MediaType getMediaTypeByName(String name)
name
- The MIME type namepublic MediaType getMediaTypeByExtension(String extension)
extension
- The extensionpublic ExecutorService getExecutor()
If shared globals are not set up, gets the application's executor service.
This setting can be configured by setting an attribute named
com.threecrickets.prudence.executor
in the component's
Context
.
public ApplicationTaskCollector getTaskCollector()
This setting can be configured by setting an attribute named
com.threecrickets.prudence.taskCollector
in the
application's Context
.
public Scheduler getScheduler()
This setting can be configured by setting an attribute named
com.threecrickets.prudence.scheduler
in the component's
Context
.
public <T> Future<T> executeTask(String applicationName, String documentName, String entryPointName, Object context, int delay, int repeatEvery, boolean fixedRepeat)
ApplicationTask
on the the shared
executor service.T
- The task result classapplicationName
- The application's full name, or null to default to current
application's namedocumentName
- The document nameentryPointName
- The entry point name or nullcontext
- The context made available to the taskdelay
- Initial delay in milliseconds, or zero for ASAPrepeatEvery
- Repeat delay in milliseconds, or zero for no repetitionfixedRepeat
- Whether repetitions are at fixed times, or if the repeat delay
begins when the task endsgetExecutor()
public <T> Future<T> codeTask(String applicationName, String code, Object context, int delay, int repeatEvery, boolean fixedRepeat)
ApplicationTask
on the the shared
executor service.T
- The task result classapplicationName
- The application's full name, or null to default to current
application's namecode
- The code to executecontext
- The context made available to the taskdelay
- Initial delay in milliseconds, or zero for ASAPrepeatEvery
- Repeat delay in milliseconds, or zero for no repetitionfixedRepeat
- Whether repetitions are at fixed times, or if the repeat delay
begins when the task endsgetExecutor()
Copyright © 2009-2016 Three Crickets LLC.