Package org.openhab.core.model.script
Class ScriptServiceUtil
java.lang.Object
org.openhab.core.model.script.ScriptServiceUtil
Utility class for providing easy access to script services.
- Author:
- Davy Vanherbergen - Initial contribution, Kai Kreuzer - renamed and removed interface, Ravi Nadahar - added additional registries for retrieval
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionScriptServiceUtil(ItemRegistry itemRegistry, ThingRegistry thingRegistry, EventPublisher eventPublisher, ModelRepository modelRepository, MetadataRegistry metadataRegistry, RuleRegistry ruleRegistry, ItemChannelLinkRegistry itemChannelLinkRegistry, TimeZoneProvider timeZoneProvider, LocaleProvider localeProvider, Scheduler scheduler) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddActionService(ActionService actionService) voidaddThingActions(ThingActions thingActions) voidstatic List<ActionService> static EventPublisherstatic <T> @Nullable TgetInstance(Class<T> clazz) Retrieve an OSGi instance of the specifiedClass, if it exists.static ItemChannelLinkRegistrystatic ItemRegistrystatic Localestatic LocaleProviderstatic MetadataRegistrystatic ModelRepositorystatic @Nullable RuleManager@Nullable RuleManagerstatic RuleRegistrystatic Schedulerstatic ScriptEnginestatic List<ThingActions> static ThingRegistrystatic TimeZonestatic TimeZoneProviderstatic ZoneIdvoidremoveActionService(ActionService actionService) voidremoveThingActions(ThingActions thingActions) voidsetScriptEngine(ScriptEngine scriptEngine) voidunsetScriptEngine(ScriptEngine scriptEngine)
-
Field Details
-
actionServices
-
thingActions
-
-
Constructor Details
-
ScriptServiceUtil
public ScriptServiceUtil(ItemRegistry itemRegistry, ThingRegistry thingRegistry, EventPublisher eventPublisher, ModelRepository modelRepository, MetadataRegistry metadataRegistry, RuleRegistry ruleRegistry, ItemChannelLinkRegistry itemChannelLinkRegistry, TimeZoneProvider timeZoneProvider, LocaleProvider localeProvider, Scheduler scheduler)
-
-
Method Details
-
deactivate
public void deactivate() -
getItemRegistry
- Returns:
- The
ItemRegistry.
-
getItemRegistryInstance
-
getThingRegistry
- Returns:
- The
ThingRegistryinstance.
-
getThingRegistryInstance
-
getEventPublisher
- Returns:
- The
EventPublisherinstance.
-
getModelRepository
- Returns:
- The
ModelRepositoryinstance.
-
getModelRepositoryInstance
-
getMetadataRegistry
- Returns:
- The
MetadataRegistryinstance.
-
getMetadataRegistryInstance
-
getRuleRegistry
- Returns:
- The
RuleRegistryinstance.
-
getRuleRegistryInstance
-
getItemChannelLinkRegistry
- Returns:
- The
ItemChannelLinkRegistryinstance.
-
getItemChannelLinkRegistryInstance
-
getTimeZone
- Returns:
- The currently openHAB configured
TimeZone.
-
getZoneId
- Returns:
- The currently openHAB configured
ZoneId.
-
getTimeZoneProvider
- Returns:
- The
TimeZoneProviderinstance.
-
getTimeZoneProviderInstance
-
getLocale
- Returns:
- The currently openHAB configured
Locale.
-
getLocaleProvider
- Returns:
- The
LocaleProviderinstance.
-
getLocaleProviderInstance
-
getRuleManager
- Returns:
- The
RuleManager/ rule engine instance ornullif it doesn't exist.
-
getRuleManagerInstance
-
getScheduler
- Returns:
- The
Schedulerinstance.
-
getSchedulerInstance
-
getScriptEngine
-
getActionServices
- Returns:
- A
Listof currently registeredActionServiceinstances.
-
getThingActions
- Returns:
- A
Listof currently registeredThingActionsinstances.
-
getActionServiceInstances
-
getThingActionsInstances
-
addActionService
-
removeActionService
-
addThingActions
-
removeThingActions
-
setScriptEngine
-
unsetScriptEngine
-
getInstance
Retrieve an OSGi instance of the specifiedClass, if it exists. The reference to the instance is unreserved, which means that the instance might stop being valid at any time, for example if the service or the containing bundle is stopped.Returning an unreserved service isn't kosher in the world of OSGi, but the only alternative is that the scripts that retrieve the instance are responsible for unregistering the reservation after use. That isn't a reasonable thing to expect from user scripts. The chance that a service is stopped while OH is running is quite small, so on balance, returning an unreserved service instance seems like the best way to do it. It isn't much different from returning an instance to a registry that is reserved by
ScriptServiceUtil- if theScriptServiceUtilitself is stopped, the instance might become invalid while the script is using it.- Type Parameters:
T- the class type.- Parameters:
clazz- the class of the instance to get.- Returns:
- The instance or
nullif the instance wasn't found.
-