Pepper  3.6.0
A highly extensible plattform for conversion and manipulationoflinguisticdata.
org.corpus_tools.pepper.connectors.impl.PepperOSGiConnector Class Reference

This class is an implementation of Pepper. More...

Inherits org.corpus_tools.pepper.common.Pepper, and org.corpus_tools.pepper.connectors.PepperConnector.

Public Member Functions

boolean isInitialized ()
 Returns whether this object has been initialized. More...
 
void init ()
 Starts the OSGi environment and installs and starts all bundles located in the plugin directory. More...
 
void stopOSGi () throws Exception
 Stops the OSGi environment. More...
 
PepperConfiguration getConfiguration ()
 {@inheritDoc Pepper::getConfiguration()}
 
PepperStarterConfiguration getPepperStarterConfiguration ()
 
void setConfiguration (PepperConfiguration configuration)
 Sets the configuration for Pepper. More...
 
BundleContext getBundleContext ()
 Returns the BundleContext object used for this PepperConnector. More...
 
void setBundleContext (BundleContext bundleContext)
 Sets the BundleContext object used for this connector. More...
 
void addSharedPackage (String packageName, String packageVersion)
 Adds a package to the list of shared packages. More...
 
Long getBundleId (URI location)
 Returns the bundle id to an already installed bundle from the passed location.
 
Bundle installAndCopy (URI bundleURI) throws BundleException, IOException
 Installs the given bundle and copies it to the plugin path, but does not start it. More...
 
Bundle install (URI bundleURI) throws BundleException
 Installs the given bundle, but does not start it. More...
 
void uninstall (Long bundleId) throws BundleException
 Uninstalls a bundle from OSGi context. More...
 
void uninstall (URI location) throws BundleException
 Uninstalls a bundle from OSGi context. More...
 
boolean remove (String bundleName) throws BundleException, IOException
 Removes the passed bundle from the OSGi content and removes its jar file and folder if exist. More...
 
void start (Long bundleId)
 Starts the passed bundle. More...
 
String createJob ()
 {@inheritDoc Pepper::createJob()}
 
PepperJob getJob (String id) throws JobNotFoundException
 {@inheritDoc Pepper::getJob(String)}
 
boolean removeJob (String id) throws JobNotFoundException
 {@inheritDoc Pepper::removeJob(String)}
 
Collection< PepperModuleDescgetRegisteredModules ()
 {@inheritDoc Pepper::getRegisteredModules()}
 
String getRegisteredModulesAsString ()
 Returns a string representation of the method getRegisteredModules(). More...
 
Collection< String > selfTest ()
 Checks if the Pepper framework is ready to run. More...
 
boolean update (String groupId, String artifactId, String repositoryUrl, boolean isSnapshot, boolean ignoreFrameworkVersion)
 This method checks the pepperModules in the modules.xml for updates and triggers the installation process if a newer version is available.
 
String getFrameworkVersion ()
 returns the version of pepper-framework read from the pepper-framework OSGi Bundle. More...
 
String getBlacklist ()
 
Bundle getBundle (String groupId, String artifactId, String version)
 This method returns the bundle matching the specified maven project. More...
 
boolean isSingleton (Bundle bundle)
 Returns whether the given bundle is a singleton.
 
String printDependencies (String bundleId)
 prints all transitive dependencies of the specified bundle, if the bundle can be related to a maven project More...
 
String printDependencies (String groupId, String artifactId, String version, String repositoryUrl)
 prints all transitive dependencies of the specified maven project More...
 
Set< String > findAppropriateImporters (org.eclipse.emf.common.util.URI corpusPath) throws FileNotFoundException
 
Collection< PepperModuleDescgetRegisteredImporters ()
 Returns all PepperModuleDesc corresponding to a registered importer. More...
 
Collection< ModuleFitnesscheckFitness ()
 Checks the fitness of each registered Pepper module. More...
 
- Public Member Functions inherited from org.corpus_tools.pepper.common.Pepper
Set< String > findAppropriateImporters (final URI corpusPath) throws FileNotFoundException
 Returns the names of importers which can import the data located at the specified corpusPath. More...
 

Static Public Attributes

static final String PROP_OSGI_BUNDLES = "osgi.bundles"
 name of system property to determine the locations of OSGi bundles
 

Protected Member Functions

BundleContext startEquinox () throws Exception
 Starts the OSGi Equinox environment. More...
 
Pepper getPepper ()
 Returns an instance of Pepper, which is running inside OSGi. More...
 
String getSharedPackages ()
 Returns a String, containing a formatted list of packages to be shared between current classloader and OSGi classloaders. More...
 
Collection< Bundle > installBundles (URI pluginPath, List< URI > dropinPaths) throws BundleException, URISyntaxException, IOException
 Tries to install all jar-files, of the given pluginPath. More...
 
void startBundles (Collection< Bundle > bundles) throws BundleException
 Starts all bundle being contained in the given list of bundles. More...
 

Detailed Description

This class is an implementation of Pepper.

It acts as a bridge between the pure java environment and the Pepper universe inside the OSGi environment. This class should help not dealing with OSGi issues when using Pepper and therefore enables it to use Pepper as an embedded library.

Author
Florian Zipser
Martin Klotz
Stephan Druskat

Member Function Documentation

◆ addSharedPackage()

void org.corpus_tools.pepper.connectors.impl.PepperOSGiConnector.addSharedPackage ( String  packageName,
String  packageVersion 
)

Adds a package to the list of shared packages.

The shared packages are necessary to bridge the OSGi container. In OSGi each bundle has its own classloader, which is a different one than in a standard Java application. In Java classes needs to be load by the same class loader to have a unique identification. For instance to share Salt objects between Pepper modules and the application outside OSGi they need to be added to shared packeges.

Parameters
packageNamename of the package
packageVersionversion of the package (normally the bundle's version)

◆ checkFitness()

Collection<ModuleFitness> org.corpus_tools.pepper.connectors.impl.PepperOSGiConnector.checkFitness ( )

Checks the fitness of each registered Pepper module.

The fitness of a module indicates in what way a module is docking to the Pepper interface. For instance it checks whether a module provides a contact address of the module'supplier. Or when the module is an importer whether it supports the PepperImporterImpl#isImportable(URI) method.
Further the fitness says whether a module is ready to start.

Returns
a list of fitness entries, one per module, if no module is registered an empty list is returned

Implements org.corpus_tools.pepper.common.Pepper.

◆ getBlacklist()

String org.corpus_tools.pepper.connectors.impl.PepperOSGiConnector.getBlacklist ( )
Returns
the Blacklist of already installed dependencies

◆ getBundle()

Bundle org.corpus_tools.pepper.connectors.impl.PepperOSGiConnector.getBundle ( String  groupId,
String  artifactId,
String  version 
)

This method returns the bundle matching the specified maven project.

Parameters
groupId– the project's group id
artifactId– the project's artifact id
version– the project's version
Returns
the bundle, if it exists and can be determined, otherwise null

◆ getBundleContext()

BundleContext org.corpus_tools.pepper.connectors.impl.PepperOSGiConnector.getBundleContext ( )

Returns the BundleContext object used for this PepperConnector.

Returns

◆ getFrameworkVersion()

String org.corpus_tools.pepper.connectors.impl.PepperOSGiConnector.getFrameworkVersion ( )

returns the version of pepper-framework read from the pepper-framework OSGi Bundle.

Returns
the version String

◆ getPepper()

Pepper org.corpus_tools.pepper.connectors.impl.PepperOSGiConnector.getPepper ( )
protected

Returns an instance of Pepper, which is running inside OSGi.

This class will be resolved via the BundleContext. If it was resolved once, a singleton instance of this object is returned.

Returns
Pepper from inside the OSGi environment.

◆ getPepperStarterConfiguration()

PepperStarterConfiguration org.corpus_tools.pepper.connectors.impl.PepperOSGiConnector.getPepperStarterConfiguration ( )
Returns
configuration as PepperStarterConfiguration

◆ getRegisteredImporters()

Collection<PepperModuleDesc> org.corpus_tools.pepper.connectors.impl.PepperOSGiConnector.getRegisteredImporters ( )

Returns all PepperModuleDesc corresponding to a registered importer.

When no importer is registered returns an empty collection, not null.

Returns
all importer fingerprints

Implements org.corpus_tools.pepper.common.Pepper.

◆ getRegisteredModulesAsString()

String org.corpus_tools.pepper.connectors.impl.PepperOSGiConnector.getRegisteredModulesAsString ( )

Returns a string representation of the method getRegisteredModules().

Returns
a string representation of all registered modules

Implements org.corpus_tools.pepper.common.Pepper.

◆ getSharedPackages()

String org.corpus_tools.pepper.connectors.impl.PepperOSGiConnector.getSharedPackages ( )
protected

Returns a String, containing a formatted list of packages to be shared between current classloader and OSGi classloaders.

The list is formatted as it could be taken of the property Constants#FRAMEWORK_SYSTEMPACKAGES_EXTRA.

◆ init()

void org.corpus_tools.pepper.connectors.impl.PepperOSGiConnector.init ( )

Starts the OSGi environment and installs and starts all bundles located in the plugin directory.


Sets property PepperOSGiRunner#PROP_TEST_DISABLED to true.

Implements org.corpus_tools.pepper.connectors.PepperConnector.

◆ install()

Bundle org.corpus_tools.pepper.connectors.impl.PepperOSGiConnector.install ( URI  bundleURI) throws BundleException

Installs the given bundle, but does not start it.

Parameters
bundleURI
Returns
Exceptions
BundleException

◆ installAndCopy()

Bundle org.corpus_tools.pepper.connectors.impl.PepperOSGiConnector.installAndCopy ( URI  bundleURI) throws BundleException, IOException

Installs the given bundle and copies it to the plugin path, but does not start it.


If the the URI is of scheme http or https, the file will be downloaded.
If the URI points to a zip file, it will be extracted and copied.

Parameters
bundleURI
Returns
Exceptions
BundleException
IOException

◆ installBundles()

Collection<Bundle> org.corpus_tools.pepper.connectors.impl.PepperOSGiConnector.installBundles ( URI  pluginPath,
List< URI >  dropinPaths 
) throws BundleException, URISyntaxException, IOException
protected

Tries to install all jar-files, of the given pluginPath.


Each installed jar will be added to system property {@value PROP_OSGI_BUNDLES} as reference:file:JAR_FILE.

Parameters
pluginPathpath where the bundles are
bundleActiona flag, which shows if bundle has to be started or just installed
dropinPathsA list of additionally paths to load bundles from
Exceptions
BundleException
URISyntaxException
IOException

◆ isInitialized()

boolean org.corpus_tools.pepper.connectors.impl.PepperOSGiConnector.isInitialized ( )

Returns whether this object has been initialized.

Returns
true, if object has been initialized, false otherwise

Implements org.corpus_tools.pepper.connectors.PepperConnector.

◆ printDependencies() [1/2]

String org.corpus_tools.pepper.connectors.impl.PepperOSGiConnector.printDependencies ( String  bundleId)

prints all transitive dependencies of the specified bundle, if the bundle can be related to a maven project

Parameters
bundleId– the bundle's id
Returns
all dependencies as printable tree string

◆ printDependencies() [2/2]

String org.corpus_tools.pepper.connectors.impl.PepperOSGiConnector.printDependencies ( String  groupId,
String  artifactId,
String  version,
String  repositoryUrl 
)

prints all transitive dependencies of the specified maven project

Parameters
groupId– the project's group id
artifactId– the project's artifact id
version– the project's version
Returns
all dependencies as printable tree string

◆ remove()

boolean org.corpus_tools.pepper.connectors.impl.PepperOSGiConnector.remove ( String  bundleName) throws BundleException, IOException

Removes the passed bundle from the OSGi content and removes its jar file and folder if exist.

Exceptions
BundleException
IOException

◆ selfTest()

Collection<String> org.corpus_tools.pepper.connectors.impl.PepperOSGiConnector.selfTest ( )

Checks if the Pepper framework is ready to run.

This means, it checks if everything necessary is given and if all registered modules could be ran. This method can be used as a kind of integration test.

Returns
returns an empty list, if check was positive; if list is not empty, each entry describes a single problem.

Implements org.corpus_tools.pepper.common.Pepper.

◆ setBundleContext()

void org.corpus_tools.pepper.connectors.impl.PepperOSGiConnector.setBundleContext ( BundleContext  bundleContext)

Sets the BundleContext object used for this connector.

Parameters
bundleContextthe object to be set

◆ setConfiguration()

void org.corpus_tools.pepper.connectors.impl.PepperOSGiConnector.setConfiguration ( PepperConfiguration  configuration)

Sets the configuration for Pepper.

Parameters
configuration

Implements org.corpus_tools.pepper.common.Pepper.

◆ start()

void org.corpus_tools.pepper.connectors.impl.PepperOSGiConnector.start ( Long  bundleId)

Starts the passed bundle.

Parameters
bundle

◆ startBundles()

void org.corpus_tools.pepper.connectors.impl.PepperOSGiConnector.startBundles ( Collection< Bundle >  bundles) throws BundleException
protected

Starts all bundle being contained in the given list of bundles.

Parameters
bundlesa list of bundles to start
Exceptions
BundleException

◆ startEquinox()

BundleContext org.corpus_tools.pepper.connectors.impl.PepperOSGiConnector.startEquinox ( ) throws Exception
protected

Starts the OSGi Equinox environment.

Returns
Exceptions
Exception

◆ stopOSGi()

void org.corpus_tools.pepper.connectors.impl.PepperOSGiConnector.stopOSGi ( ) throws Exception

Stops the OSGi environment.

Exceptions
Exception

◆ uninstall() [1/2]

void org.corpus_tools.pepper.connectors.impl.PepperOSGiConnector.uninstall ( Long  bundleId) throws BundleException

Uninstalls a bundle from OSGi context.

Exceptions
BundleException

◆ uninstall() [2/2]

void org.corpus_tools.pepper.connectors.impl.PepperOSGiConnector.uninstall ( URI  location) throws BundleException

Uninstalls a bundle from OSGi context.

Exceptions
BundleException