|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface PluginContext
Interface that a plugin can use to request system services.
Field Summary | |
---|---|
static int |
ALLREQUESTS
Use in place of request ID to unrequest regardless of ID |
Method Summary | ||
---|---|---|
boolean |
dispatchExternalMessage(java.lang.Class<? extends Msg> message,
Msg m,
boolean immediate)
Dispatch a message that is controlled by a MessageOwner in another plugin. |
|
void |
dispatchMsgToTarget(Msg m,
java.lang.Object target)
Dispatch message to a specific target (useful for re-handling your own messages, basically just calls the right msg() method). |
|
MessageInfo |
getMessageInfo(java.lang.Class<? extends Msg> c)
Obtains information about any available message type. |
|
Plugin |
getPlugin()
|
|
|
getSingle(java.lang.Class<C> singletonInterface)
Returns singleton implementing the desired interface. |
|
java.lang.Object |
getSingleton(java.lang.Class<? extends Singleton> singletonInterface)
Deprecated. Replaced by getSingle(Class) |
|
void |
log(java.lang.String s)
Log something to the system log. |
|
void |
log(java.lang.String s,
java.lang.Throwable t)
Log something to the system log. |
|
void |
logDebug(java.lang.String s)
Log something to the system log if debug is turned on for this plugin. |
|
void |
logDebug(java.lang.String s,
java.lang.Throwable t)
Log something to the system log if debug is turned on for this plugin. |
|
|
newFactoryObject(java.lang.Class<C> objectInterface)
Get a new instance of a factory-created object. |
|
java.lang.Object |
newInstance(java.lang.Class<? extends FactoryObject> objectInterface)
Deprecated. Replaced by newFactoryObject(Class) |
|
void |
registerExtraMessageClass(java.lang.Class<? extends Msg> c)
Registers an additional message class (apart from the base type). |
|
void |
registerFactory(java.lang.Class<? extends FactoryObject> objectInterface,
Factory f)
Register an object as the factory creating objects of a given interface (which should be in the .api package) |
|
void |
registerMessageOwner(MsgOwner mo)
Registers a new message type provided by this plugin. |
|
|
registerSingleton(java.lang.Class<C> singletonInterface,
C s)
Register an object as the singleton implementing a given interface (which should be in the .api package) |
|
int |
requestMessages(java.lang.Class<? extends Msg> message,
java.lang.Object target)
Requests messages of a particular type, with no filter and PRIORITY_NORMAL. |
|
int |
requestMessages(java.lang.Class<? extends Msg> message,
java.lang.Object target,
int priority)
Requests messages of a particular type, with no filter. |
|
int |
requestMessages(java.lang.Class<? extends Msg> message,
java.lang.Object target,
MessageFilter mf)
Requests messages of a particular type, with PRIORITY_NORMAL. |
|
int |
requestMessages(java.lang.Class<? extends Msg> message,
java.lang.Object target,
MessageFilter mf,
int priority)
Requests messages of a particular type. |
|
void |
unrequestMessages(java.lang.Class<? extends Msg> message,
java.lang.Object target,
int requestID)
Cancels a request for messages. |
|
void |
yield(java.lang.Runnable r)
Runs the given runnable after all other messages are processed and the event queue is idle. |
Field Detail |
---|
static final int ALLREQUESTS
Method Detail |
---|
void registerMessageOwner(MsgOwner mo)
registerExtraMessageClass(Class)
for each subclass.
mo
- Owner that will generate messages of this typevoid registerExtraMessageClass(java.lang.Class<? extends Msg> c)
c
- Message subclass.int requestMessages(java.lang.Class<? extends Msg> message, java.lang.Object target, MessageFilter mf, int priority)
message
- Message classtarget
- Target that wants messagesmf
- Filter for messages (may be null)priority
- Priority for message (MessageTarget.PRIORITY_xxx)
int requestMessages(java.lang.Class<? extends Msg> message, java.lang.Object target, int priority)
message
- Message classtarget
- Target that wants messagespriority
- Priority for message (MessageTarget.PRIORITY_xxx)
int requestMessages(java.lang.Class<? extends Msg> message, java.lang.Object target, MessageFilter mf)
message
- Message classtarget
- Target that wants messagesmf
- Filter for messages
int requestMessages(java.lang.Class<? extends Msg> message, java.lang.Object target)
message
- Message classtarget
- Target that wants messages
void unrequestMessages(java.lang.Class<? extends Msg> message, java.lang.Object target, int requestID)
The system will automatically unrequest all messages when your plugin closes, so there is normally no need to call this method. You call this method only if, during your plugin's lifespan, there are some messages that you only need temporarily.
Does nothing if the plugin did not request messages with that ID.
message
- Message class (may be null for 'all')target
- Target that no longer wants messagesrequestID
- ID returned by original request (may be PluginContext.ALLREQUESTS)boolean dispatchExternalMessage(java.lang.Class<? extends Msg> message, Msg m, boolean immediate) throws GeneralException
Don't use this for your own messages; for those, use the MessageDispatch class to dispatch.
The MessageOwner may reject this message rather than permitting its dispatch; in that case, this call will return false.
message
- Class of messagem
- Message to dispatchimmediate
- True if message should be sent to all targets
immediately before this message returns; false if it should be queued
for later sending after other messages have been handled
GeneralException
- If the message is of invalid type or the
MessageOwner cannot be found<C extends Singleton> void registerSingleton(java.lang.Class<C> singletonInterface, C s) throws BugException
singletonInterface
- Interfaces
- Object implementing said interface
BugException
- If object doesn't implement interface, there's
already an implementor of that interface, etc.<C extends Singleton> C getSingle(java.lang.Class<C> singletonInterface)
singletonInterface
- Interface
BugException
- If singleton doesn't exist or is of wrong type, etc.java.lang.Object getSingleton(java.lang.Class<? extends Singleton> singletonInterface)
getSingle(Class)
singletonInterface
- Interface
BugException
- If singleton doesn't exist or is of wrong type, etc.void registerFactory(java.lang.Class<? extends FactoryObject> objectInterface, Factory f) throws BugException
objectInterface
- Interfacef
- Factory that can create objects of said interface
BugException
- If there's already a factory for that interface<C extends FactoryObject> C newFactoryObject(java.lang.Class<C> objectInterface) throws GeneralException
objectInterface
- Desired interface
GeneralException
- If there is a problem creating the objectjava.lang.Object newInstance(java.lang.Class<? extends FactoryObject> objectInterface) throws GeneralException
newFactoryObject(Class)
objectInterface
- Desired interface
GeneralException
- If there is a problem creating the objectvoid dispatchMsgToTarget(Msg m, java.lang.Object target) throws GeneralException
m
- Messagetarget
- Target to receive it
GeneralException
- E.g. if target doesn't have an appropriate msg()void log(java.lang.String s)
s
- String to logvoid log(java.lang.String s, java.lang.Throwable t)
s
- String to logt
- Exception to log (null for none)void logDebug(java.lang.String s)
s
- String to logvoid logDebug(java.lang.String s, java.lang.Throwable t)
s
- String to logt
- Exception to log (null for none)Plugin getPlugin()
void yield(java.lang.Runnable r)
r
- Task to runMessageInfo getMessageInfo(java.lang.Class<? extends Msg> c) throws BugException
c
- Class to request
BugException
- If the class isn't registered
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |