public class PluginImpl extends Object implements Plugin, org.osgi.service.event.EventHandler
Modifier and Type | Field and Description |
---|---|
private org.osgi.framework.BundleContext |
bundleContext |
private CoreServiceImpl |
dmx |
private org.osgi.service.event.EventAdmin |
eventService |
private StaticResourcesPublication |
fileSystemResources |
private Map<Class<?>,InjectableService> |
injectableServices |
private Logger |
logger |
private ModelFactory |
mf |
private static String |
PLUGIN_ACTIVATED |
private static String |
PLUGIN_CONFIG_FILE |
private static String |
PLUGIN_DEFAULT_PACKAGE |
private org.osgi.framework.Bundle |
pluginBundle |
private PluginContext |
pluginContext |
private List<String> |
pluginDependencies |
private PluginInfo |
pluginInfo |
private String |
pluginPackage |
private Properties |
pluginProperties |
private Topic |
pluginTopic |
private String |
pluginUri |
private String |
providedServiceInterface |
private RestResourcesPublication |
restResources |
private List<org.osgi.util.tracker.ServiceTracker> |
serviceTrackers |
private StaticResourcesPublication |
webResources |
Constructor and Description |
---|
PluginImpl(PluginContext pluginContext) |
Modifier and Type | Method and Description |
---|---|
(package private) void |
activate()
Activates this plugin and then posts the PLUGIN_ACTIVATED OSGi event.
|
private void |
addService(Object service,
Class serviceInterface) |
private void |
checkRequirementsForActivation()
Checks if this plugin's requirements are met, and if so, activates this plugin.
|
private void |
closeServiceTrackers() |
private void |
createCoreServiceTrackers() |
private List<InjectableService> |
createInjectableServices() |
private void |
createInjectedServiceTrackers() |
private Topic |
createPluginTopic()
Creates a Plugin topic in the DB.
|
private boolean |
createPluginTopicIfNotExists() |
private org.osgi.util.tracker.ServiceTracker |
createServiceTracker(Class serviceInterface) |
(package private) void |
deactivate() |
private boolean |
dependenciesAvailable() |
private void |
dispatchEvent(DMXEvent event,
Object... params)
Checks weather this plugin is a listener for the given event, and if so, dispatches the event to this plugin.
|
private String |
entryPathToClassName(String entryPath) |
private Topic |
fetchPluginTopic() |
private URL |
getBundleEntry(String path) |
(package private) String |
getConfigProperty(String key)
Returns a plugin configuration property (as read from file "plugin.properties")
or
null if no such property exists. |
(package private) String |
getConfigProperty(String key,
String defaultValue) |
(package private) PluginContext |
getContext() |
private List<DMXEvent> |
getEvents()
Returns the events this plugin is listening to.
|
(package private) PluginInfo |
getInfo() |
(package private) static List<Field> |
getInjectableFields(Class<?> clazz) |
(package private) Object |
getInjectedService(Class<?> serviceInterface) |
private List<Class<?>> |
getInterfaces(String suffix) |
(package private) String |
getMigrationClassName(int migrationNr)
Returns the migration class name for the given migration number.
|
private Enumeration<String> |
getPluginPaths(String relativePath) |
(package private) Topic |
getPluginTopic() |
(package private) String |
getProvidedServiceInterface() |
private List<Class<?>> |
getProviderClasses() |
private List<Object> |
getRootResources() |
InputStream |
getStaticResource(String name)
Accesses a static resource of the plugin.
|
String |
getUri() |
private String |
getWebResourcesNamespace() |
void |
handleEvent(org.osgi.service.event.Event event) |
private boolean |
hasDependency(String pluginUri) |
boolean |
hasStaticResource(String name)
Checks if this plugin bundle contains a static resource with the given name.
|
private boolean |
injectedServicesAvailable() |
private void |
installPluginInDB()
Installs the plugin in the database.
|
private void |
introduceAssociationTypesToPlugin() |
private void |
introduceTopicTypesToPlugin() |
private void |
invokeInitHook() |
private void |
invokePreInstallHook() |
private void |
invokeShutdownHook() |
private boolean |
isListenerInterface(Class interfaze)
Returns true if the specified interface is an event listener interface.
|
private boolean |
isPluginActivated(String pluginUri) |
(package private) Class |
loadClass(String className)
Uses the plugin bundle's class loader to load a class by name.
|
private void |
openServiceTrackers() |
private List<String> |
pluginDependencies() |
private String |
pluginName() |
private void |
postPluginActivatedEvent() |
private String |
providedServiceInterface() |
void |
publishFileSystem(String uriNamespace,
String path)
Publishes a directory of the server's file system.
|
private void |
publishRestResources()
Publishes this plugin's REST resources (via WebPublishingService).
|
private void |
publishWebResources()
Publishes this plugin's web resources (via WebPublishingService).
|
private Properties |
readConfigFile() |
private void |
registerListeners() |
private void |
registerPluginActivatedEventListener() |
private void |
registerProvidedService()
Registers the provided service at the OSGi framework.
|
private void |
removeService(Object service,
Class serviceInterface) |
private List<String> |
scanPackage(String relativePath) |
private void |
setCoreService(CoreServiceImpl dmx) |
(package private) void |
setMigrationNr(int migrationNr) |
void |
start() |
void |
stop() |
String |
toString() |
private void |
unpublishFileSystem() |
private void |
unpublishRestResources() |
private void |
unpublishWebResources() |
private void |
unregisterListeners() |
private static final String PLUGIN_DEFAULT_PACKAGE
private static final String PLUGIN_CONFIG_FILE
private static final String PLUGIN_ACTIVATED
private PluginContext pluginContext
private org.osgi.framework.BundleContext bundleContext
private org.osgi.framework.Bundle pluginBundle
private Properties pluginProperties
private String pluginPackage
private PluginInfo pluginInfo
private List<String> pluginDependencies
private Topic pluginTopic
private CoreServiceImpl dmx
private ModelFactory mf
private org.osgi.service.event.EventAdmin eventService
private Map<Class<?>,InjectableService> injectableServices
private List<org.osgi.util.tracker.ServiceTracker> serviceTrackers
private String providedServiceInterface
private StaticResourcesPublication webResources
private StaticResourcesPublication fileSystemResources
private RestResourcesPublication restResources
public PluginImpl(PluginContext pluginContext)
public void start()
public void stop()
public void publishFileSystem(String uriNamespace, String path)
path
- An absolute path to the directory to be published.public InputStream getStaticResource(String name)
Plugin
getStaticResource
in interface Plugin
name
- The resource name: a "/"-separated path name, relative to the plugin bundle's root directory.
It may or may not begin with "/" (it makes no difference).public boolean hasStaticResource(String name)
Plugin
hasStaticResource
in interface Plugin
name
- The resource name: a "/"-separated path name, relative to the plugin bundle's root directory.
It may or may not begin with "/" (it makes no difference).PluginInfo getInfo()
PluginContext getContext()
Topic getPluginTopic()
String getProvidedServiceInterface()
String getConfigProperty(String key)
null
if no such property exists.String getConfigProperty(String key, String defaultValue)
String getMigrationClassName(int migrationNr)
null
if the migration package is unknown.
This is the case if the plugin bundle contains no Plugin subclass and the "dmx.plugin.main_package"
config property is not set.void setMigrationNr(int migrationNr)
Class loadClass(String className)
null
if the class is not found.private Properties readConfigFile()
private void createCoreServiceTrackers()
private void createInjectedServiceTrackers()
private List<InjectableService> createInjectableServices()
private boolean injectedServicesAvailable()
static List<Field> getInjectableFields(Class<?> clazz)
Object getInjectedService(Class<?> serviceInterface)
private org.osgi.util.tracker.ServiceTracker createServiceTracker(Class serviceInterface)
private void openServiceTrackers()
private void closeServiceTrackers()
private void addService(Object service, Class serviceInterface)
private void removeService(Object service, Class serviceInterface)
private void setCoreService(CoreServiceImpl dmx)
private void checkRequirementsForActivation()
void activate()
void deactivate()
private void installPluginInDB()
CoreEvent.INTRODUCE_TOPIC_TYPE
and
CoreEvent.INTRODUCE_ASSOCIATION_TYPE
events)private boolean createPluginTopicIfNotExists()
private Topic createPluginTopic()
A Plugin topic represents an installed plugin and is used to track its version.
private Topic fetchPluginTopic()
private void introduceTopicTypesToPlugin()
private void introduceAssociationTypesToPlugin()
private void invokePreInstallHook()
private void invokeInitHook()
private void invokeShutdownHook()
private void registerListeners()
private void unregisterListeners()
private void dispatchEvent(DMXEvent event, Object... params)
Called internally to dispatch the INTRODUCE_TOPIC_TYPE and INTRODUCE_ASSOCIATION_TYPE events.
private boolean isListenerInterface(Class interfaze)
EventListener
.private void registerProvidedService()
private String providedServiceInterface()
private void publishWebResources()
private void unpublishWebResources()
private String getWebResourcesNamespace()
private URL getBundleEntry(String path)
private void unpublishFileSystem()
private void publishRestResources()
private void unpublishRestResources()
private List<Object> getRootResources()
private List<Class<?>> getProviderClasses() throws IOException
IOException
private List<String> pluginDependencies()
private boolean hasDependency(String pluginUri)
private boolean dependenciesAvailable()
private boolean isPluginActivated(String pluginUri)
private void registerPluginActivatedEventListener()
private void postPluginActivatedEvent()
public void handleEvent(org.osgi.service.event.Event event)
handleEvent
in interface org.osgi.service.event.EventHandler
private String pluginName()
private List<Class<?>> getInterfaces(String suffix)
private List<String> scanPackage(String relativePath)
private Enumeration<String> getPluginPaths(String relativePath)
private String entryPathToClassName(String entryPath)
Copyright © 2018. All Rights Reserved.