Provides global platform functions like preferences, event bus or the command framework.
Method | Description |
---|---|
adapt() | Adapt object to target type. |
executeCommand() | Execute a command from the command framework. |
getService() | Get a platform service. |
getSystemProperty() | Get a system property or environment value. |
postEvent() | Post an event on the event broker. |
readPreferences() | Read a preferences value. |
runProcess() | Run an external process. |
waitForEvent() | Wait for a given event on the event bus. |
writePreferences() | Set a preferences value. |
Object adapt(Object source, Class<?> target)
Adapt object to target type. Try to get an adapter for an object.
adapted object or null
void executeCommand(String commandId, [Map<String, String> parameters]) throws ExecutionException, NotDefinedException, NotEnabledException, NotHandledException
Execute a command from the command framework. As we have no UI available, we do not pass a control to the command. Hence HandlerUtil.getActive... commands will very likely fail.
Object getService(Class<?> type)
Get a platform service.
service instance or null
String getSystemProperty(String key)
Get a system property or environment value. First we try to look up a system property. If not found we query the environment for the key.
system property/environment variable for key
void postEvent(String topic, [Object data], [long delay])
Post an event on the event broker. If delay is set, the event will be posted after the given amount of time asynchronously. In any case this method returns immediately.
Object readPreferences(String node, String key, [Object defaultValue])
Read a preferences value. The defaultValue is optional, but contains type information if used. Provide instances of Boolean, Integer, Double, Float, Long, byte[], or String to get the appropriate return value of same type.
preference value or null
Process runProcess(String name, [String[] args], [String output], [String error]) throws IOException
Run an external process. The process is started in the background and a Process object is returned. Query the result for finished state, output
and error streams of the executed process. Output and error streams need to be consumed, otherwise the running process may stall (or even die) in case
that the buffers are full. Setting parameters output and error to null
will automatically discard the produced data.
process object to track process execution
org.osgi.service.event.Event waitForEvent(String topic, [long timeout]) throws InterruptedException
Wait for a given event on the event bus.
posted event or null
in case of a timeout
void writePreferences(String node, String key, Object value)
Set a preferences value. Valid types for value are: Boolean, Integer, Double, Float, Long, byte[], and String.