You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rw...@apache.org on 2011/11/26 00:18:30 UTC

svn commit: r1206372 [1/2] - in /incubator/stanbol/trunk: commons/solr/ commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/ commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/impl/ commons/solr/core/src/main/java/org/apache/st...

Author: rwesten
Date: Fri Nov 25 23:18:27 2011
New Revision: 1206372

URL: http://svn.apache.org/viewvc?rev=1206372&view=rev
Log:
### Removed the SolrServerProvider and SolrServerProviderManager services:

After the resent changes (especially STANBOL-354 and the implementation of Referenced- and ManagedSolrServer with STANBOL-375 and STANBOL-377 this two services had no longer really fitted.

Support for creating SolrServers for remote urls has been removed. The normal SolrJ API is anyway simple to use in such cases.
Support for locally managed SolrServer is now possible by using the RegisteredSolrServerTracker (an extension of the OSIG ServiceTracker).

* This makes STANBOL-376 obsolete.
* Adoptions to the Entityhub and Contenthub to use the RegisteredSolrServerTracker


### Added a Documentation for org.apache.stanbol.commons.solr

Currently the documentation is available by the README.md within /commons/solr.

This documentation also includes detailed information on how to use the replacements for the removed SolrServerProvider.

Added:
    incubator/stanbol/trunk/commons/solr/README.md
    incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/RegisteredSolrServerTracker.java   (with props)
Removed:
    incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrServerProvider.java
    incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrServerProviderManager.java
    incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrServerTypeEnum.java
    incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/impl/RESTfulSolrServerProvider.java
    incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/impl/RegisteredSolrServerProvider.java
    incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/impl/install/
Modified:
    incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/IndexReference.java
    incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrConstants.java
    incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/utils/ConfigUtils.java
    incubator/stanbol/trunk/commons/solr/managed/pom.xml
    incubator/stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/ManagedSolrServer.java
    incubator/stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/standalone/StandaloneEmbeddedSolrServerProvider.java
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/MainDataFileProvider.java
    incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/ContextHelper.java
    incubator/stanbol/trunk/contenthub/core/src/main/java/org/apache/stanbol/contenthub/core/store/SolrStoreImpl.java
    incubator/stanbol/trunk/contenthub/search/engines/solr/pom.xml
    incubator/stanbol/trunk/contenthub/search/engines/solr/src/main/java/org/apache/stanbol/contenthub/search/engines/solr/SolrSearchEngine.java
    incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/fragment/ContenthubWebFragment.java
    incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/ContenthubStoreResource.java
    incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/SearchResource.java
    incubator/stanbol/trunk/entityhub/indexing/destination/solryard/pom.xml
    incubator/stanbol/trunk/entityhub/indexing/genericrdf/pom.xml
    incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/SolrYard.java
    incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/SolrYardConfig.java

Added: incubator/stanbol/trunk/commons/solr/README.md
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/solr/README.md?rev=1206372&view=auto
==============================================================================
--- incubator/stanbol/trunk/commons/solr/README.md (added)
+++ incubator/stanbol/trunk/commons/solr/README.md Fri Nov 25 23:18:27 2011
@@ -0,0 +1,294 @@
+Stanbol Commons Solr
+====================
+
+Solr is used by several Apache Stanbol components. The Apache Stanbol Solr Commons artifacts provide a set of utilities that ease the use of Solr within OSGI, allow the initialization and management of Solr indexes as well as the publishing of Solrs RESTful interface on the OSGI HttpService.
+
+Although this utilities where implemented with the requirements of Apache Stanbol mind they say do not depend on other Stanbol components that are not themselves part of
+"stanbol.commons"
+
+
+Solr OSGI Bundle
+----------------
+
+The "org.apache.commons.solr.core" bundle currently includes all dependencies required by Solr and also exports the client as well as the server API. For details please have a look at the pom file of the "solr.core" artifact.
+
+Please note also the exclusion list, because some libraries currently not directly used by Stanbol are explicitly excluded. Using such features within a "solrConf.xml" or "schema.xml" will result in "ClassNotFoundException" and "ClassNotFoundErrors".
+
+If you require an additional Library that is currently not included please give us a short notice on the stanbol-dev mailing list.
+
+
+Solr Server Components
+----------------------
+
+This section provides information how to managed and get access to the server side CoreContainer and SolrCore components of Solr.
+
+### Accessing CoreContainers and SolrCores
+
+All CoreContainer and SolrCores initialized by the Stanbol Solr framework are registered with the OSGI Service Registry. This means that other Bundels can obtain them by using 
+
+    CoreContainer defaultSolrServer;
+    ServiceReference ref = bundleContext.getServiceReference(
+        CoreContainer.class.getName())
+    if(ref != null){
+        defaultSolrServer = (CoreContainer)bundleContext.getService(ref);
+    } else {
+        defaultSolrServer = null; //no SolrServer available
+    }
+
+It is also possible to track services by using the OSGI ServiceTracker utility.
+
+The above Code snippet would always return the SolrServer with the highest priority (the highest value for the "service.ranking" property). However the OSGI Service Registry allows also to obtain/track service by the usage of filters. For specifying such filters
+it is important to know what metadata are provided when services are registered with the OSGI Service Registry.
+
+#### Metadata for CoreContainer:
+
+* **org.apache.solr.core.CoreContainer.name**: The name of the SolrServer. The name MUST BE provided for each Solr CoreContainer registered with this framework. It is a required field for each configuration. If two CoreContainers are registered with the same name the "service.ranking" property shall be used to determine the current active CoreContainer for an request. However others registered for the same name may be used as fallbacks.
+* **org.apache.solr.core.CoreContainer.dir**: The directory of a CoreContainer. This is the directory containing the "solr.xml".
+* **org.apache.solr.core.CoreContainer.solrXml**: The name of the Solr CoreContainer configuration file. Currently always "sold.xml".
+* **org.apache.solr.core.CoreContainer.cores**: A read only collection of the names of all cores registered with the CoreContainer.
+* **service.ranking**: The OSGI "service.ranking" property is used to specify the ranking of a CoreContainer. The CoreContainer with the highest ranking is considered as the default server and will be returned by calls to bundleContext.getServiceReference(..) without the use of an filter.
+* **org.apache.solr.core.CoreContainer.publishREST**: Boolean switch that defines if the RESTful API of this CoreContainer should be published or not.
+
+#### Metadata for SolrCores:
+
+* **org.apache.solr.core.SolrCore.name**: The name of the SolrCore as registered with the CoreContainer
+* **org.apache.solr.core.SolrCore.dir**: The instance directory of the SolrCore
+* **org.apache.solr.core.SolrCore.dadadir**: The data directory of the SolrCore
+* **org.apache.solr.core.SolrCore.indexdir**: The directory of the index used by this SolrCore
+* **org.apache.solr.core.SolrCore.schema**: The name (excluding the directory) of the Solr schema used by this core
+* **org.apache.solr.core.SolrCore.solrconf**: The name (excluding the directory) of the Solr core configuration file
+
+In addition the following metadata of the CoreContainer for this SolrCore are also available
+
+* **org.apache.solr.core.CoreContainer.id**: The SERVICE_ID of the CoreContainer this SolrCore is registered with. This is usually the easiest way to obtain the ServiceReference to the CoreContainer of an SolrCore.
+* **org.apache.solr.core.CoreContainer.name**: The name of the CoreContainer this SolrCore is registered with. Note that multiple CoreContainers may be registered for the same name. Therefore this property MUST NOT be used to filter for the ServiceReference to the CoreContainer of an SolrCore. 
+* **org.apache.solr.core.CoreContainer.dir**: The Solr directory of the CoreContainer for this SolrCore.
+* **service.ranking**: The OSGI service.ranking of the CoreContainer this SolrCore is registered with. SolrCores do not define there own service.ranking but use the ranking of the CoreContainer they are registered with.
+
+The the mentioned keys used for metadata of registered CoreContainer and SolrCores are defined as public constants in the [SolrConstants](http://svn.apache.org/repos/asf/incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrConstants.java) class. 
+
+
+### ReferencedSolrServer
+
+This component allows to initialize an Solr server running within the same JVM as Stanbol based on indexes provided by a directory on the local file system. This does not support management capabilities, but it initializes a Solr CoreContainer based on the data in the file system and registers it (including all SolrCores) with the OSIG Service Registry as described above.
+
+The ReferencedSolrServer uses the ManagedServiceFactory pattern. This means that instances are created by parsing configurations to the OSGI ConfigurationAdmin service. Practically this means that 
+
+* users can create instances by using the Configuration tab of the Apache Felix Web Console
+* programmers can directly use the ConfigurationAdmin service to create/update and delete configurations
+* Configurations can also parsed via the Apache Sling [OSGI installer](http://sling.apache.org/site/osgi-installer.html) framework. Meaning configurations can be includes within the Stanbol launchers, Bundles or copied to a directory configured for the [File Provider](http://svn.apache.org/repos/asf/sling/trunk/installer/providers/file/)
+
+Configurations need to include the following properties (see also section "Metadata for CoreContainer" for details about such properties)
+
+* **org.apache.solr.core.CoreContainer.name**: The name for the Solr Server 
+* **org.apache.solr.core.CoreContainer.dir**: The path to the directory on the local file system that is used to initialize the CoreContainer
+* **service.ranking**: The OSGI service ranking used to register the CoreContainer and its SolrCores. If not specified '0' will be used as default. The value MUST BE an integer number.
+* **org.apache.solr.core.CoreContainer.publishREST**: Boolean switch that allows to enable/disable the publishing of the Solr RESTful API on "http://{host}:{port}/solr/{server-name}". Requires the "SolrServerPublishingComponent" to be active. 
+
+**NOTE:** Keep in mind that of the RESTful API of the SolrServer is published users might use the Admin Request handler to manipulate the SolrConfiguration. In such cases the metadata provided by the ServiceReferences for the CoreContainer and SolrCores might get out of sync with the actual configuration of the Server.
+
+### ManagedSolrServer
+
+This component allows to manage a multi core Solr server. It provides an API to create, update and remove SolrCores. In addition cores can be activated and deactivated. 
+
+#### Creating ManagedServerInstances
+
+The ManagedSolrServer uses the ManagedServiceFactory pattern. This means that instances are created by parsing configurations to the OSGI ConfigurationAdmin service. Practically this means that 
+
+* users can create instances by using the Configuration tab of the Apache Felix Web Console
+* programmers can directly use the ConfigurationAdmin service to create/update and delete configurations
+* Configurations can also parsed via the Apache Sling [OSGI installer](http://sling.apache.org/site/osgi-installer.html) framework. Meaning configurations can be includes within the Stanbol launchers, Bundles or copied to a directory configured for the [File Provider](http://svn.apache.org/repos/asf/sling/trunk/installer/providers/file/)
+
+Configurations need to include the following properties (see also section "Metadata for CoreContainer" for details about such properties). Although the properties are the same as for the ReferencedSolrServer there semantics differs in some aspects.
+
+* **org.apache.solr.core.CoreContainer.name**: The name for the Solr Server 
+* **org.apache.solr.core.CoreContainer.dir**: Optionally an directory to store the data. If not specified the data will be stored in an directory with the configured server-name at the default location (currently "${sling.home}/indexes/" or "indexes/" if the environment variable 'sling.home' is not present). Users that want to create multiple ManagedSolrServer with the same name need to specify the directory or servers will override each others data.
+* **service.ranking**: The OSGI service ranking used to register the CoreContainer and its SolrCores. If not specified '0' will be used as default. The value MUST BE an integer number. In scenarios where a single ManagedSolrServer is expected it is highly recommended to specify Integer.MAX_VALUE (2147483647) as service ranking. This will ensure that this server can not be overridden by others.
+* **org.apache.solr.core.CoreContainer.publishREST**: Boolean switch that allows to enable/disable the publishing of the Solr RESTful API on "http://{host}:{port}/solr/{server-name}". Requires the "SolrServerPublishingComponent" to be active. 
+
+**NOTE:** Keep in mind that of the RESTful API of the SolrServer is published users might use the Admin Request handler to manipulate the SolrConfiguration. In such cases the metadata provided by the ServiceReferences for the CoreContainer and SolrCores might get out of sync with the actual configuration of the Server.
+
+#### Managing Solr Indexes
+
+This describes how to manage (create, update, remove, activate, deactivate) Indexes on a ManagedSolrServer.
+
+Managed Indexes do not 1:1 correspond to SolrCores registered on the CoreContainer. However all SolrCores on the CoreContainer do have a 1:1 mapping with a managed index on the Managed SolrServer.
+
+Managed Index can be in one of the following States (defined by the ManagedIndexState enumeration):
+
+* **UNINITIALISED**: An index that was created but is still missing the configuration and/or index data is in that state. The ManagedSolrServer API allows to create indexes by referring to a Solr-Index-Archive. Such archives are than requested via the Stanbol DataFileProvider service. Usually users can provide them by copying the lined index to the "/sling/datafiles" folder.
+* **INACTIVE**: This indicated that an index is was deactivated via the ManagedSolrServer API. The data are still kept, but the SolrCore was removed from the CoreContainer.
+* **ACTIVE**: This indicates that an index is active and can be used. Only Indexes that are ACTIVE are registered with the CoreContainer.
+* **ERROR**: This state indicates some error during the the initialization. The stack trace of the error is available in the IndexMetadata.
+
+Indexes can not only be managed by calls to the API of the ManagedSolrServer. The "org.apache.stanbol.commons.solr.install" bundle provides also support for installing/uninstalling indexes by using the Apache Sling [OSGI installer](http://sling.apache.org/site/osgi-installer.html) framework. This allows to install indexes by providing Solr-Index-Archives or Solr-Index-Archive-References to any available Provider. By default Apache Stanbol includes Provider for the Launchers and Bundles. However the Sling Installer Framework also includes Providers for Directories on the File and JCR Repositories.
+
+Solr-Index-Archives do use the following name pattern:
+
+    {name}.solrindex[.zip|.gz|.bz2]
+
+* They are normal achieves starting with the instance directory of a Solr Core. 
+* The name of this instance directory MUST BE the same as the {name} of the archive.
+* The second extensions specifies the type of the archive. If no extension is specified the type of the Archive might still be detected by reading the first few bytes of the Archive.
+
+Solr-Index-Archive-References are normal Java properties files and do use the following name pattern:
+
+    {name}.solrindex.ref
+
+The following keys are used (see also org.apache.stanbol.commons.solr.managed.ManagedIndexConstants):
+
+* **Index-Archive**: Comma separated list of Solr-Index-Archives that can be used for initializing this index. The first index archive in the list has the highest priority. Higher priority archives will replace the data of lower priority once as soon as they become available. This feature is intended to be used to allow the replacement of a small sample dataset (e.g. shipped within a Bundle or the Launcher) with the full dataset.
+* **Index-Name**: The name of the Index. If not specified the {name} part of the first Index-Archive in the list will be used.
+* **Server-Name**: The name of the ManagedSolrServer this Solr index MUST BE deployed on. If not present it will be deployed on the default ManagedSolrServer (the ManagedSolrServer with the highest priority.
+* **Synchronized**: Boolean switch. If enabled the index will be synchronized with the referenced Solr-Index-Archives. That means the DataFileTracker service will be used to periodically track the states of referenced Solr-Index-Archives. This allows to initialize/update and uninitialise managed Solr indexes by simple making Solr-Index-Archives un-/available to the DataFileProvider infrastructure (such as Users copying/deleting files in the "/sling/datafiles" directory).
+* **other Properties**: All parsed properties are forwarded to the DataFileProvider/DataFileTracker service when looking for the referenced Solr-Index-Archives. This components might also define some special keys associated with specific functionalities. Please look at the documentation of this services for details.
+
+#### Other interesting Notes
+
+* SolrCore directory names created by the ManagedSolrServer use the current date as suffix. If a directory with that name already exists (e.g. because the same index was already updated on the very same day) than an additional "-{count}" suffix will be added to the end.
+* The Managed SolrServer stores its configuration within the persistent space of the Bundle provided by the OSGI environment. When using one of the default Stanbol launchers this is within "{sling.home}/felix/bundle{bundle-id}/data". The "{bundle-id}" of the "org.apache.stanbol.commons.solr.managed" bundle can be looked up the the [Bundle tab](http://localhost:8080/system/console/bundles) of the Apache Felix Webconsole. The actual configuration of a ManagedSolrServer is than in ".config/index-config/{service.pid}". The "{service.pid}" can be also looked up via the Apache Felix Web-console in the [Configuration Status tab](http://localhost:8080/system/console/config). Within this folder the Solr index reference files (normal java properties files) with all the information about the current state of the managed indexes are present. 
+* Errors that occur during the asynchronous initialization of SolrCores are stored within the IndexingProperties. They can therefore be requested via the API of the ManagedSolrServer but also be looked up within the persistent state of the ManagedSolrServer (see above where such files are located).
+
+
+Solr Client Components
+----------------------
+
+This sections describes how to use Solr servers and indexes referenced and managed by the "org.apache.stanbol.commons.solr" framework.
+Principally there are two possibilities: (1) to directly access Solr indexes via the SolrServer Java API and (2) to publish locally managed index on the OSGI HttpService and than use such indexes via the Solr RESTful API.
+
+The Stanbol Solr framework does not provide utilities for accessing remote Solr servers, because this is already easily possible by using SolrJ.
+
+### Java API
+
+This describes how to lookup and access a Solr Server initialized by the "org.apache.stanbol.commons.solr" framework. The client side Java API of Solr is defined by the SolrServer abstract class. The implementation used for accessing a SolrCore running in the same JVM is the EmbeddedSolrServer.
+
+All Solr server (CoreContainer) and Solr indexes (SolrCore) initialized by the ReferencedSolrServer and/or ManagedSolrServer are registered with the OSGI service registry. More information about this can be found in the first part of the "Solr Server Components" of this documentation.
+
+OSGI already provides APIs and utilities to lookup and track registered services. In the following I will provide some examples how to lookup SolrServers registered as OSGI services.
+
+#### IndexReference
+
+The IndexReference is a Java class that manages a reference to an Index. It defines a constructor that takes a serverName and coreName. In addition there is a static parse(String ref) method that takes
+
+* file URLs
+* file paths and
+* [server-name:]core-name like references.
+
+The IndexMetadata class also defines a getter to get the IndexReference.
+
+One feature of the IndexReference is also that it provides getters of Filters as used to lookup/track the referenced CoreContainer/SolrCore in the OSGI service Registry. The returned filter include the constraint for the registered interface (OBJECTCLASS). Therefore when using this filters one can parse NULL for the class parameter
+
+To lookup the CoreContainer of the referenced index:
+
+    bundleContext.getServiceReferences(null, indexReference.getServerFilter());
+
+To lookup the SolrCore for the referenced index:
+
+    bundleContext.getServiceReferences(null, indexReference.getIndexFilter());
+
+#### Lookup Solr Indexes
+
+This example shows how to lookup the default CoreContainer and create a SolrServer for the core "mydata".
+
+    ComponentContext context; //typical parsed to the activate method
+    BundleContext bc = context.getBundleContext();
+    ServiceReference coreContainerRef = 
+        bc.getServiceReference(CoreContainer.class.getName());
+    CoreContainer coreContainer = (CoreContainer) bc.getService(coreContainerRef)
+    SolrServer server = new EmbeddedSolrServer(coreContainer,"mydata");
+
+Now there might be cases where several CoreContainers are available and "mydata" is not available on the default one. The "default" refers to the one with the highest "service.ranking" value. In this case we need to know a available property we can use to filter for the right CoreContainer. In this case we assume the index is on a CoreContainer registered with the name "myserver".
+
+    ComponentContext context; //typical parsed to the activate method
+    BundleContext bc = context.getBundleContext();
+    //now lets use the IndexReference to create the filter
+    IndexReference indexRef = new IndexReference("myserver","mydata");
+    ServiceReference[] coreContainerRefs = bc.getServiceReferences(
+        null, indexRef.getServerFilter());
+    //TODO: check that coreContainerRefs != null AND not empty!
+    //now we have all References to CoreContainers with the name "myserver"
+    //Yes one can register several for the same name (e.g. to have fallbacks)
+    //let get the one with the highest service.ranking
+    Arrays.sort(coreContainerRefs,ServiceReferenceRankingComparator.INSTANCE);
+    
+    //create the SolrServer (same as above)
+    CoreContainer coreContainer = (CoreContainer) bc.getService(coreContainerRefs[0])
+    SolrServer server = new EmbeddedSolrServer(coreContainer,indexRef.getIndex());
+
+In cases where one only knows the name of the SolrCore (and not the CoreContainer) the initialization looks like this.
+
+    ComponentContext context; //typical parsed to the activate method
+    BundleContext bc = context.getBundleContext();
+    String nameFilter = String.format("(%s=%s)",SolrConstants.PROPERTY_CORE_NAME,"mydata");
+    ServiceReference[] solrCoreRefs = bc.getServiceReferences(
+        SolrCore.class.getName(), nameFilter);
+    //TODO: check that != null AND not empty!
+    //now we have all References to CoreContainer with a SolrCore "mydata"
+    //let get the one with the highest service.ranking
+    Arrays.sort(solrCoreRefs,ServiceReferenceRankingComparator.INSTANCE);
+    
+    //now get the SolrCore and create the SolrServer
+    SolrCore core = (SolrCore)bc.getService(solrCoreRefs[0]);
+    //core.getCoreDescriptor() might be null if SolrCore is not
+    //registered with a CoreContainer
+    SolrServer server = new EmbeddedSolrServer(
+        core.getCoreDescriptor().getCoreContainer(),
+        "mydata");
+
+#### Tracking Solr Indexes
+
+The above examples do a lookup at a single point in time. However because OSGI is an dynamic environment where services can come the go at every time in most cases users might rather want to track services. To do this OSGI provides the ServiceTracker utility.
+
+To ease the tracking of SolrServers the "org.apache.stanbol.commons.solr.core" bundle provides the RegisteredSolrServerTracker. The following examples show how to create a Managed SolrIndex and than track the SolrServer
+
+First during the activation we need to check if "mydata" is already create and create it if not. Than we can start tracking the index.
+
+    BundleContext bc;
+    IndexMetadata metadata = managedServer.getIndexMetadata("mydata");
+    if(metadata == null){ //no index with that name
+        //Asynchronously init the index as soon as the solrindex archvive is available
+        metadata = managedServer.createSolrIndex("mydata", "mydata.solrindex.zip",null);
+    }
+    RegisteredSolrServerTracker indexTracker = 
+        new RegisteredSolrServerTracker(bc, metadata.getIndexReference());
+    //do not forget to close the tracker while deactivating
+    indexTracker.open();
+
+Now every time we need the SolrServer we can retrieve it from the indexTracker
+
+    private SolrServer getServer(){
+        SolrServer server = indexTracker.getService();
+        if(server == null){ //report the missing server
+            throw new IllegalStateException("Server 'mydata' not active");
+        } else {
+            return server;
+        }
+    }
+
+The RegisteredSolrServerTracker does take "service.ranking" into account. So if there are more Services available that match the parsed IndexReference the Methods will always return the one with the highest "service.ranking". In case arrays are returned such arrays are sorted accordingly.
+
+### RESTful API
+
+This describes how to publish the RESTful API of CoreContainer registered as OSGI services on the OSGI HttpService. The functionality described in this section is provided by the "org.apache.stanbol.commons.solr.web" artifact.
+
+#### SolrServerPublishingComponent
+
+This is an OSGI component that starts immediate and does not require a configuration. Its main purpose is to track all CoreContainers with the property "org.apache.solr.core.CoreContainer.publishREST=true". For all such CoreContainers it publishes the RESTful API under the URL
+
+    http://{host}:{port}/solr/{server-name}
+
+If two CoreContainers with the same {server-name} (the value of the "org.apache.solr.core.CoreContainer.name" property) are registered the one with the highest "service.ranking" is published.
+
+The root-prefix ("/solr" by default) can be configured by setting the "org.apache.stanbol.commons.solr.web.dispatchfilter.prefix" property.
+
+#### SolrDispatchFilterComponent
+
+This Component provides the same functionality as the SolrServerPublishingComponent, but can be configured specifically for a CoreContainer. It is intended to be used if one wants to publish the RESTful API of a specific CoreContainer under a specific location. To deactivate the publishing of the same core on the SolrServerPublishingComponent users need to set the "org.apache.solr.core.CoreContainer.publishREST" to false.
+
+This component is configured by two properties
+
+* **org.apache.stanbl.commons.solr.web.dispatchfilter.name**: The {server-name} of the CoreContainer to publish ({server-name} refers to the value of the "org.apache.solr.core.CoreContainer.name" property).
+* **org.apache.stanbl.commons.solr.web.dispatchfilter.prefix**: The prefix path to publish the server. The {server-name} is NOT appended to the configured prefix. Note that a Servlet Filter with "{prefix}/.*" is registered with the OSGI HttpService.
+
+If two CoreContainers with the same {server-name} (the value of the "org.apache.solr.core.CoreContainer.name" property) are registered the one with the highest "service.ranking" is published.
+

Modified: incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/IndexReference.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/IndexReference.java?rev=1206372&r1=1206371&r2=1206372&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/IndexReference.java (original)
+++ incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/IndexReference.java Fri Nov 25 23:18:27 2011
@@ -9,12 +9,17 @@ import java.util.Arrays;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.io.IOUtils;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.core.SolrCore;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class IndexReference {
 
     private static final Logger log = LoggerFactory.getLogger(IndexReference.class);
+    private static final String CONSTRAINT = "(%s=%s)";
     
     public static IndexReference parse(String uriOrPathOrReference){
         String[] referencedCore = new String[2];
@@ -130,5 +135,52 @@ public class IndexReference {
     public boolean checkServer(String serverName) {
         return server == null || server.equals(serverName);
     }
-    
+ 
+    /**
+     * Getter for the {@link Filter} that can be used to track the
+     * {@link SolrCore} referenced by this IndexReference.
+     * @return the string representation of the OSGI {@link Filter}.
+     */
+    public String getIndexFilter(){
+        StringBuilder filterString = new StringBuilder("(&");
+        //first filter for the type
+        filterString.append(String.format(CONSTRAINT, Constants.OBJECTCLASS,SolrCore.class.getName()));
+        if(isFile){
+            filterString.append(String.format(CONSTRAINT, SolrConstants.PROPERTY_CORE_DIR,getIndex()));
+        } else { //isName
+            filterString.append(String.format(CONSTRAINT, SolrConstants.PROPERTY_CORE_NAME,getIndex()));
+        }
+        addServerFilterConstraint(filterString);
+        filterString.append(')');
+        return filterString.toString();
+    }
+    /**
+     * Getter for the {@link Filter} that can be used to track the
+     * {@link CoreContainer} referenced by this IndexReference. If no
+     * server is defined. This will track all {@link CoreContainer} instances.
+     * Note that the {@link CoreContainer} with the highest 
+     * {@link Constants#SERVICE_RANKING} is expected to be the default server
+     */
+    public String getServerFilter(){
+        StringBuilder filterString;
+        if(getServer() != null){ //add AND for class and name constraint
+            filterString = new StringBuilder("(&");
+        } else { //if no server is defined we have only one constraint
+            filterString = new StringBuilder();
+        }
+        filterString.append(String.format(CONSTRAINT, Constants.OBJECTCLASS,CoreContainer.class.getName()));
+        addServerFilterConstraint(filterString);
+        if(getServer() != null){
+            filterString.append(')');
+        }
+        return filterString.toString();
+    }
+    /**
+     * @param filterString
+     */
+    private void addServerFilterConstraint(StringBuilder filterString) {
+        if(getServer() != null){
+            filterString.append(String.format(CONSTRAINT, SolrConstants.PROPERTY_SERVER_NAME,getServer()));
+        }
+    }
 }

Added: incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/RegisteredSolrServerTracker.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/RegisteredSolrServerTracker.java?rev=1206372&view=auto
==============================================================================
--- incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/RegisteredSolrServerTracker.java (added)
+++ incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/RegisteredSolrServerTracker.java Fri Nov 25 23:18:27 2011
@@ -0,0 +1,152 @@
+package org.apache.stanbol.commons.solr;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.apache.solr.client.solrj.SolrServer;
+import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.core.CoreDescriptor;
+import org.apache.solr.core.SolrCore;
+import org.apache.stanbol.commons.solr.utils.ServiceReferenceRankingComparator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * Tracks the {@link CoreContainer} of the {@link SolrCore} referenced by the
+ * parsed {@link IndexReference}. All getService** and getServiceReference**
+ * methods do consider {@link Constants#SERVICE_RANKING}. <p>
+ * 
+ * @author Rupert Westenthaler
+ *
+ */
+public class RegisteredSolrServerTracker extends ServiceTracker {
+
+    /**
+     * In case <code>{@link IndexReference#isPath()} == true</code> than we need
+     * to track registered {@link SolrCore}s, because we do not know the
+     * {@link CoreContainer} in advance. In all other cases the
+     * {@link CoreContainer} is tracked. This variable avoids instanceof checks
+     */
+    private final boolean trackingSolrCore;
+    /**
+     * needed to create {@link EmbeddedSolrServer} instances
+     */
+    private final String coreName;
+    /**
+     * Creates a new Tracker for the parsed {@link IndexReference}
+     * @param context the BundleContext used for tracking
+     * @param reference the index reference
+     * @throws InvalidSyntaxException if the {@link Filter} could not be
+     * created for the parsed {@link IndexReference}.
+     * @throws IllegalArgumentException if the parsed {@link IndexReference} is 
+     * <code>null</code>
+     */
+    public RegisteredSolrServerTracker(BundleContext context, IndexReference reference) throws InvalidSyntaxException{
+        super(context,
+            reference != null ? 
+                    reference.isPath() ? context.createFilter(reference.getIndexFilter()) : 
+                        context.createFilter(reference.getServerFilter()) :
+                            null ,null);
+        if(reference == null){
+            throw new IllegalArgumentException("The parsed IndexReference MUST NOT be NULL!");
+        }
+        if(reference.isPath()){
+            trackingSolrCore = true;
+            coreName = null;
+        } else {
+            trackingSolrCore = false;
+            coreName = reference.getIndex();
+        }
+    }
+    
+    @Override
+    public SolrServer addingService(ServiceReference reference) {
+        String coreName;
+        CoreContainer server;
+        if(trackingSolrCore){
+            SolrCore core = (SolrCore)context.getService(reference);
+            coreName = core.getName();
+            CoreDescriptor descriptior = core.getCoreDescriptor();
+            if(descriptior == null){ //core not registered with a container!
+                context.ungetService(reference);
+                return null; //ignore
+            } else {
+                server = descriptior.getCoreContainer();
+            }
+        } else {
+            server = (CoreContainer)context.getService(reference);
+            coreName = this.coreName;
+        }
+        return new EmbeddedSolrServer(server, coreName);
+    }
+
+    /**
+     * Overrides to provides a Array sorted by {@link Constants#SERVICE_RANKING}
+     * @see ServiceTracker#getServiceReferences()
+     */
+    @Override
+    public ServiceReference[] getServiceReferences() {
+        ServiceReference[] refs = super.getServiceReferences();
+        if(refs != null && refs.length > 1){
+            Arrays.sort(refs,ServiceReferenceRankingComparator.INSTANCE);
+        }
+        return refs;
+    }
+    /**
+     * Overrides to provide the {@link ServiceReference} with the highest
+     * {@link Constants#SERVICE_RANKING}.
+     * @see ServiceTracker#getServiceReference()
+     */
+    @Override
+    public ServiceReference getServiceReference() {
+        ServiceReference[] refs = super.getServiceReferences();
+        if(refs != null && refs.length > 0){
+            return refs[0];
+        } else {
+            return null;
+        }
+    }
+    /**
+     * Overrides to provide the SolrServer with the highest 
+     * {@link Constants#SERVICE_RANKING}.
+     * @see ServiceTracker#getService()
+     */
+    @Override
+    public SolrServer getService() {
+        ServiceReference ref = getServiceReference();
+        return ref == null ? null : (SolrServer)getService(ref);
+    }
+    /**
+     * Overrides to provide a {@link SolrServer} instead of {@link Object}
+     * @see ServiceTracker#getService(ServiceReference)
+     */
+    @Override
+    public SolrServer getService(ServiceReference reference) {
+        return reference == null ? null : (SolrServer)super.getService(reference);
+    }
+    /**
+     * Overrides to provide a array of {@link SolrServer} that is sorted by
+     * {@link Constants#SERVICE_RANKING}.
+     * @see ServiceTracker#getServices()
+     */
+    @Override
+    public SolrServer[] getServices() {
+        ServiceReference[] refs = getServiceReferences();
+        Collection<SolrServer> servers = new ArrayList<SolrServer>(refs.length);
+        if(refs != null){
+            for(ServiceReference ref : refs){
+                SolrServer server = getService(ref);
+                if(server != null){
+                    servers.add(server);
+                } //else null ... ignore
+            }
+        }
+        return servers.isEmpty() ? null : servers.toArray(new SolrServer[servers.size()]);
+    }
+}

Propchange: incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/RegisteredSolrServerTracker.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrConstants.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrConstants.java?rev=1206372&r1=1206371&r2=1206372&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrConstants.java (original)
+++ incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrConstants.java Fri Nov 25 23:18:27 2011
@@ -112,9 +112,9 @@ public final class SolrConstants {
     public static final String PROPERTY_CORE_SOLR_CONF = PROPERTY_SOLR_CORE+".solrconf";
     /**
      * The {@link Constants#SERVICE_ID} of the {@link CoreContainer} this core
-     * is registered with
+     * is registered with. Values are of type {@link Long}.
      */
-    public static final String PROPERTY_CORE_SERVER_ID = PROPERTY_SOLR_CORE+".service.id";
+    public static final String PROPERTY_CORE_SERVER_ID = PROPERTY_SOLR_SERVER+".id";
     /**
      * The {@link Constants#SERVICE_RANKING service ranking} of the SolrCore. 
      * The ranking of the SolrServer is used as default if not defined. If also no 

Modified: incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/utils/ConfigUtils.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/utils/ConfigUtils.java?rev=1206372&r1=1206371&r2=1206372&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/utils/ConfigUtils.java (original)
+++ incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/utils/ConfigUtils.java Fri Nov 25 23:18:27 2011
@@ -21,7 +21,6 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
@@ -43,9 +42,7 @@ import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
-import org.apache.stanbol.commons.solr.impl.RegisteredSolrServerProvider;
 import org.osgi.framework.Bundle;
-import org.osgi.framework.Constants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

Modified: incubator/stanbol/trunk/commons/solr/managed/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/solr/managed/pom.xml?rev=1206372&r1=1206371&r2=1206372&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/solr/managed/pom.xml (original)
+++ incubator/stanbol/trunk/commons/solr/managed/pom.xml Fri Nov 25 23:18:27 2011
@@ -58,14 +58,14 @@
 				<configuration>
 					<instructions>
 						<Export-Package>
-							org.apache.stanbol.commons.solr.managed;version=${project.version}
+							org.apache.stanbol.commons.solr.managed;version=${project.version},
+                            org.apache.stanbol.commons.solr.managed.standalone;version=${project.version}
                         </Export-Package>
 						<Import-Package>
 							*
                         </Import-Package>
 						<Private-Package>
-							org.apache.stanbol.commons.solr.managed.impl;version=${project.version},
-							org.apache.stanbol.commons.solr.managed.standalone;version=${project.version}
+							org.apache.stanbol.commons.solr.managed.impl;version=${project.version}
                         </Private-Package>
 						<Embed-Dependency></Embed-Dependency>
 					</instructions>

Modified: incubator/stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/ManagedSolrServer.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/ManagedSolrServer.java?rev=1206372&r1=1206371&r2=1206372&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/ManagedSolrServer.java (original)
+++ incubator/stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/ManagedSolrServer.java Fri Nov 25 23:18:27 2011
@@ -25,9 +25,6 @@ import org.apache.commons.compress.archi
 import org.apache.solr.client.solrj.SolrServer;
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.core.SolrCore;
-import org.apache.stanbol.commons.solr.SolrConstants;
-import org.apache.stanbol.commons.solr.SolrServerProvider;
-import org.apache.stanbol.commons.solr.SolrServerTypeEnum;
 import org.apache.stanbol.commons.solr.utils.ConfigUtils;
 import org.apache.stanbol.commons.stanboltools.datafileprovider.DataFileProvider;
 import org.osgi.framework.BundleContext;

Modified: incubator/stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/standalone/StandaloneEmbeddedSolrServerProvider.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/standalone/StandaloneEmbeddedSolrServerProvider.java?rev=1206372&r1=1206371&r2=1206372&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/standalone/StandaloneEmbeddedSolrServerProvider.java (original)
+++ incubator/stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/standalone/StandaloneEmbeddedSolrServerProvider.java Fri Nov 25 23:18:27 2011
@@ -1,16 +1,12 @@
 package org.apache.stanbol.commons.solr.managed.standalone;
 
-import java.util.Collections;
 import java.util.ServiceLoader;
-import java.util.Set;
 
 import org.apache.solr.client.solrj.SolrServer;
 import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.core.SolrCore;
 import org.apache.stanbol.commons.solr.IndexReference;
-import org.apache.stanbol.commons.solr.SolrServerProvider;
-import org.apache.stanbol.commons.solr.SolrServerTypeEnum;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -25,25 +21,27 @@ import org.slf4j.LoggerFactory;
  * @author Rupert Westenthaler
  *
  */
-public class StandaloneEmbeddedSolrServerProvider implements SolrServerProvider {
+public class StandaloneEmbeddedSolrServerProvider {
+    
+    private static StandaloneEmbeddedSolrServerProvider instance;
+    
+    public static StandaloneEmbeddedSolrServerProvider getInstance(){
+        if(instance == null){
+            instance = new StandaloneEmbeddedSolrServerProvider();
+        }
+        return instance;
+    }
     
     private final Logger log = LoggerFactory.getLogger(StandaloneEmbeddedSolrServerProvider.class);
     /**
-     * Default constructor used by the {@link ServiceLoader} utility used
-     * outside of an OSGI environment to instantiate {@link SolrServerProvider}
-     * implementations for the different {@link SolrServerTypeEnum}. 
+     * Private constructor used to create the singleton.
      */
-    public StandaloneEmbeddedSolrServerProvider() {
-        
-    }
+    private StandaloneEmbeddedSolrServerProvider() {}
     
-    @Override
-    public SolrServer getSolrServer(SolrServerTypeEnum type, String uriOrPath, String... additional) throws IllegalArgumentException {
-        if(type != SolrServerTypeEnum.EMBEDDED){
-            throw new IllegalArgumentException("The parsed SolrServerType '"+
-                type+"' is not supported (supported: '"+SolrServerTypeEnum.EMBEDDED+"')");
+    public SolrServer getSolrServer(IndexReference indexRef){
+        if(indexRef == null){
+            throw new IllegalArgumentException("The parsed InexReference MUST NOT be NULL!");
         }
-        IndexReference indexRef = IndexReference.parse(uriOrPath);
         StandaloneManagedSolrServer server;
         log.debug("Create EmbeddedSolrServer for Server: {}, Index: {}",
             indexRef.getServer(),indexRef.getIndex());
@@ -73,14 +71,4 @@ public class StandaloneEmbeddedSolrServe
             return null;
         }
     }
-
-    /**
-     * Outside an OSGI environment this also is used as {@link SolrServerProvider}
-     * for the type {@link SolrServerTypeEnum#EMBEDDED}
-     * @see org.apache.stanbol.commons.solr.SolrServerProvider#supportedTypes()
-     */
-    @Override
-    public Set<SolrServerTypeEnum> supportedTypes() {
-        return Collections.singleton(SolrServerTypeEnum.EMBEDDED);
-    }
 }

Modified: incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/MainDataFileProvider.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/MainDataFileProvider.java?rev=1206372&r1=1206371&r2=1206372&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/MainDataFileProvider.java (original)
+++ incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/MainDataFileProvider.java Fri Nov 25 23:18:27 2011
@@ -38,6 +38,7 @@ import org.apache.felix.scr.annotations.
 import org.apache.stanbol.commons.stanboltools.datafileprovider.DataFileProvider;
 import org.apache.stanbol.commons.stanboltools.datafileprovider.DataFileProviderEvent;
 import org.apache.stanbol.commons.stanboltools.datafileprovider.DataFileProviderLog;
+import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.cm.ConfigurationException;

Modified: incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/ContextHelper.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/ContextHelper.java?rev=1206372&r1=1206371&r2=1206372&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/ContextHelper.java (original)
+++ incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/ContextHelper.java Fri Nov 25 23:18:27 2011
@@ -47,5 +47,14 @@ public class ContextHelper {
             return null;
         }
     }
+    /**
+     * Fetches the BundleContext
+     * @param context the {@link ServletContext}
+     * @return the BundleContext or <code>null</code> if not registered under
+     * <code>BundleContext.class.getName()</code>.
+     */
+    public static BundleContext getBundleContext(ServletContext context){
+        return (BundleContext) context.getAttribute(BundleContext.class.getName());
+    }
 
 }

Modified: incubator/stanbol/trunk/contenthub/core/src/main/java/org/apache/stanbol/contenthub/core/store/SolrStoreImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/core/src/main/java/org/apache/stanbol/contenthub/core/store/SolrStoreImpl.java?rev=1206372&r1=1206371&r2=1206372&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/core/src/main/java/org/apache/stanbol/contenthub/core/store/SolrStoreImpl.java (original)
+++ incubator/stanbol/trunk/contenthub/core/src/main/java/org/apache/stanbol/contenthub/core/store/SolrStoreImpl.java Fri Nov 25 23:18:27 2011
@@ -55,8 +55,8 @@ import org.apache.solr.client.solrj.resp
 import org.apache.solr.common.SolrDocument;
 import org.apache.solr.common.SolrDocumentList;
 import org.apache.solr.common.SolrInputDocument;
-import org.apache.stanbol.commons.solr.SolrServerProviderManager;
-import org.apache.stanbol.commons.solr.SolrServerTypeEnum;
+import org.apache.stanbol.commons.solr.IndexReference;
+import org.apache.stanbol.commons.solr.RegisteredSolrServerTracker;
 import org.apache.stanbol.commons.solr.managed.IndexMetadata;
 import org.apache.stanbol.commons.solr.managed.ManagedSolrServer;
 import org.apache.stanbol.contenthub.core.utils.ContentItemIDOrganizer;
@@ -71,6 +71,7 @@ import org.apache.stanbol.enhancer.servi
 import org.apache.stanbol.enhancer.servicesapi.EnhancementJobManager;
 import org.apache.stanbol.enhancer.servicesapi.helper.ContentItemHelper;
 import org.apache.stanbol.enhancer.servicesapi.rdf.Properties;
+import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.service.component.ComponentContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -87,9 +88,6 @@ public class SolrStoreImpl implements So
     private static final Logger logger = LoggerFactory.getLogger(SolrStoreImpl.class);
 
     @Reference
-    SolrServerProviderManager solrServerProviderManager;
-
-    @Reference
     private ManagedSolrServer solrDirectoryManager;
 
     @Reference
@@ -98,18 +96,37 @@ public class SolrStoreImpl implements So
     @Reference
     private EnhancementJobManager jobManager;
 
-    private SolrServer server = null;
+    private RegisteredSolrServerTracker serverTracker = null;
 
     public static final String SOLR_SERVER_NAME = "contenthub";
 
     @Activate
-    public void activate(ComponentContext context) throws IllegalArgumentException, IOException {
+    protected void activate(ComponentContext context) throws IllegalArgumentException, IOException, InvalidSyntaxException {
         if (!solrDirectoryManager.isManagedIndex(SOLR_SERVER_NAME)) {
             solrDirectoryManager.createSolrIndex(SOLR_SERVER_NAME, SOLR_SERVER_NAME,null);
         }
-        server = solrServerProviderManager.getSolrServer(SolrServerTypeEnum.EMBEDDED, SOLR_SERVER_NAME);
+        serverTracker = new RegisteredSolrServerTracker(context.getBundleContext(), 
+            new IndexReference(solrDirectoryManager.getServerName(), SOLR_SERVER_NAME));
+        serverTracker.open();
+    }
+
+    protected void deactivate(ComponentContext context) {
+        if(serverTracker != null){
+            serverTracker.close();
+            serverTracker = null;
+        }
+        solrDirectoryManager = null;
+    }
+    
+    protected SolrServer getServer(){
+        SolrServer server = serverTracker != null ? serverTracker.getService() : null;
+        if(server == null){
+            throw new IllegalStateException("The SolrServer for the Contenthub " +
+            		"is currently not available!");
+        } else {
+            return server;
+        }
     }
-
     @Override
     public SolrContentItem create(String id, byte[] content, String contentType) {
         return create(id, content, contentType, null);
@@ -227,13 +244,13 @@ public class SolrStoreImpl implements So
 
     @Override
     public String put(ContentItem ci) {
-
         if (ci.getId() == null || ci.getId().isEmpty()) {
             logger.debug("ID of the content item cannot be null while inserting to the SolrStore.");
             throw new IllegalArgumentException(
                     "ID of the content item cannot be null while inserting to the SolrStore.");
         }
 
+        SolrServer server = getServer();
         String content = null;
         try {
             content = IOUtils.toString(ci.getStream(), "UTF-8");
@@ -339,7 +356,7 @@ public class SolrStoreImpl implements So
     @Override
     public SolrContentItem get(String id) {
         id = ContentItemIDOrganizer.attachBaseURI(id);
-
+        SolrServer server = getServer();
         String content = null;
         String mimeType = null;
         Map<String,List<Object>> constraints = new HashMap<String,List<Object>>();
@@ -402,6 +419,7 @@ public class SolrStoreImpl implements So
     @Override
     public void deleteById(String id) {
 		if(id == null || id.isEmpty()) return;
+		SolrServer server = getServer();
         id = ContentItemIDOrganizer.attachBaseURI(id);
         removeEnhancements(id);
         try {
@@ -418,6 +436,7 @@ public class SolrStoreImpl implements So
 
     @Override
     public void deleteById(List<String> idList) {
+        SolrServer server = getServer();
         for (int i = 0; i < idList.size(); i++) {
             String id = ContentItemIDOrganizer.attachBaseURI(idList.get(i));
             idList.remove(i);

Modified: incubator/stanbol/trunk/contenthub/search/engines/solr/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/search/engines/solr/pom.xml?rev=1206372&r1=1206371&r2=1206372&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/search/engines/solr/pom.xml (original)
+++ incubator/stanbol/trunk/contenthub/search/engines/solr/pom.xml Fri Nov 25 23:18:27 2011
@@ -76,6 +76,10 @@
 			<groupId>org.apache.felix</groupId>
 			<artifactId>org.apache.felix.scr.annotations</artifactId>
 		</dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
 		<dependency>
 			<groupId>org.osgi</groupId>
 			<artifactId>org.osgi.compendium</artifactId>

Modified: incubator/stanbol/trunk/contenthub/search/engines/solr/src/main/java/org/apache/stanbol/contenthub/search/engines/solr/SolrSearchEngine.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/search/engines/solr/src/main/java/org/apache/stanbol/contenthub/search/engines/solr/SolrSearchEngine.java?rev=1206372&r1=1206371&r2=1206372&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/search/engines/solr/src/main/java/org/apache/stanbol/contenthub/search/engines/solr/SolrSearchEngine.java (original)
+++ incubator/stanbol/trunk/contenthub/search/engines/solr/src/main/java/org/apache/stanbol/contenthub/search/engines/solr/SolrSearchEngine.java Fri Nov 25 23:18:27 2011
@@ -17,7 +17,6 @@
 
 package org.apache.stanbol.contenthub.search.engines.solr;
 
-import java.io.File;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -25,6 +24,7 @@ import java.util.Map;
 
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.Service;
 import org.apache.solr.client.solrj.SolrQuery;
@@ -33,9 +33,8 @@ import org.apache.solr.client.solrj.Solr
 import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.common.SolrDocument;
 import org.apache.solr.common.SolrDocumentList;
-import org.apache.stanbol.commons.solr.SolrServerProviderManager;
-import org.apache.stanbol.commons.solr.SolrServerTypeEnum;
-import org.apache.stanbol.commons.solr.managed.IndexMetadata;
+import org.apache.stanbol.commons.solr.IndexReference;
+import org.apache.stanbol.commons.solr.RegisteredSolrServerTracker;
 import org.apache.stanbol.commons.solr.managed.ManagedSolrServer;
 import org.apache.stanbol.contenthub.core.search.execution.SearchContextImpl;
 import org.apache.stanbol.contenthub.servicesapi.search.engine.EngineProperties;
@@ -59,7 +58,6 @@ import com.hp.hpl.jena.rdf.model.ResIter
 import com.hp.hpl.jena.rdf.model.Resource;
 import com.hp.hpl.jena.rdf.model.Statement;
 import com.hp.hpl.jena.rdf.model.impl.Util;
-import com.hp.hpl.jena.sparql.lib.Metadata;
 import com.hp.hpl.jena.util.iterator.Filter;
 import com.hp.hpl.jena.vocabulary.RDF;
 
@@ -81,36 +79,40 @@ public class SolrSearchEngine implements
     }
 
     private final static String SERVER_NAME = "contenthub";
-    /**
-     * for EmbeddedSolr instance, it is tried to obtained EmbbeddedSolr at activator if it can get the
-     * instance, server becomes null and this SolrSearchEngine does not work
-     */
-    private SolrServer server;
-
-    @Reference
-    SolrServerProviderManager solrServerProviderManager;
 
+    protected RegisteredSolrServerTracker serverTracker;
     @Reference
     ManagedSolrServer solrDirectoryManager;
 
-    @Activate
     /**
      * Tries to connect EmbeddedSolr at startup, if can not, server becomes null and no query is executed on server
      * @param cc
      */
-    public void activate(ComponentContext cc) {
+    @Activate
+    protected void activate(ComponentContext cc) {
         try {
             if (!solrDirectoryManager.isManagedIndex(SERVER_NAME)) {
                 solrDirectoryManager.createSolrIndex(SERVER_NAME, SERVER_NAME, null);
             }
-            server = solrServerProviderManager.getSolrServer(SolrServerTypeEnum.EMBEDDED, SERVER_NAME);
-            logger.warn("Could not get the EmbeddedSolr Instance since there is no SolrDirectoryManager");
+            serverTracker = new RegisteredSolrServerTracker(cc.getBundleContext(),
+                new IndexReference(solrDirectoryManager.getServerName(), SERVER_NAME));
+            serverTracker.open();
         } catch (Exception e) {
             logger.warn("Could not get the EmbeddedSolr Instance at location : {}", SERVER_NAME, e);
-            server = null;
         }
     }
+    @Deactivate
+    protected void deactivate(ComponentContext cc) {
+        if(serverTracker != null){
+            serverTracker.close();
+            serverTracker = null;
+        }
+        solrDirectoryManager = null;
+    }
 
+    protected SolrServer getServer(){
+        return serverTracker != null ? serverTracker.getService() : null;
+    }
     @Override
     /**
      * gets the keywords from search context and then queries solr with these keywords and facet constraints,
@@ -118,13 +120,14 @@ public class SolrSearchEngine implements
      * After searching for all keywords, omits the results founded by other engines and having non matching field constraints 
      */
     public void search(SearchContext searchContext) throws SearchEngineException {
+        SolrServer server = getServer();
         if (server == null) {
             logger.warn("No EmbeddedSolr, so SolrSearchEngine does not work");
         } else {
             for (QueryKeyword qk : searchContext.getQueryKeyWords()) {
-                searchForKeyword(qk, searchContext);
+                searchForKeyword(server,qk, searchContext);
                 for (Keyword kw : qk.getRelatedKeywords()) {
-                    searchForKeyword(kw, searchContext);
+                    searchForKeyword(server, kw, searchContext);
                 }
             }
             
@@ -140,7 +143,7 @@ public class SolrSearchEngine implements
      *            the keyword to use in query
      * @param searchContext
      */
-    private void searchForKeyword(Keyword kw, SearchContext searchContext) {
+    private void searchForKeyword(SolrServer server, Keyword kw, SearchContext searchContext) {
         String keyword = kw.getKeyword();
         SolrQuery query = SolrSearchEngineHelper.keywordQueryWithFacets(keyword,
             searchContext.getConstraints());
@@ -225,7 +228,7 @@ public class SolrSearchEngine implements
     }
 
     @SuppressWarnings("unused")
-    private void omitNonMatchingResult(SearchContext searchContext) {
+    private void omitNonMatchingResult(SolrServer server, SearchContext searchContext) {
         OntModel contextModel = (SearchContextImpl) searchContext;
         ResIterator docResources = contextModel.listResourcesWithProperty(RDF.type,
             SearchVocabulary.DOCUMENT_RESOURCE);

Modified: incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/fragment/ContenthubWebFragment.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/fragment/ContenthubWebFragment.java?rev=1206372&r1=1206371&r2=1206372&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/fragment/ContenthubWebFragment.java (original)
+++ incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/fragment/ContenthubWebFragment.java Fri Nov 25 23:18:27 2011
@@ -119,8 +119,7 @@ public class ContenthubWebFragment imple
         resources.add(new ScriptResource("text/javascript", "scripts/prettify/prettify.js", this, 0));
         resources.add(new ScriptResource("text/javascript", "scripts/jit.js", this, 1));
         resources.add(new ScriptResource("text/javascript", "scripts/jquery-1.5.1.min.js", this, 2));
-        resources
-                .add(new ScriptResource("text/javascript", "scripts/jquery-ui-1.8.11.custom.min.js", this, 3));
+        resources.add(new ScriptResource("text/javascript", "scripts/jquery-ui-1.8.11.custom.min.js", this, 3));
         return resources;
     }
 

Modified: incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/ContenthubStoreResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/ContenthubStoreResource.java?rev=1206372&r1=1206371&r2=1206372&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/ContenthubStoreResource.java (original)
+++ incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/ContenthubStoreResource.java Fri Nov 25 23:18:27 2011
@@ -79,8 +79,8 @@ import org.apache.solr.client.solrj.Solr
 import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.common.SolrDocument;
 import org.apache.solr.common.params.ModifiableSolrParams;
-import org.apache.stanbol.commons.solr.SolrServerProviderManager;
-import org.apache.stanbol.commons.solr.SolrServerTypeEnum;
+import org.apache.stanbol.commons.solr.IndexReference;
+import org.apache.stanbol.commons.solr.RegisteredSolrServerTracker;
 import org.apache.stanbol.commons.solr.managed.IndexMetadata;
 import org.apache.stanbol.commons.solr.managed.ManagedSolrServer;
 import org.apache.stanbol.commons.web.base.ContextHelper;
@@ -95,6 +95,8 @@ import org.apache.stanbol.enhancer.jerse
 import org.apache.stanbol.enhancer.servicesapi.ContentItem;
 import org.apache.stanbol.enhancer.servicesapi.EngineException;
 import org.apache.stanbol.enhancer.servicesapi.helper.ContentItemHelper;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -124,8 +126,6 @@ public class ContenthubStoreResource ext
 
     private ManagedSolrServer solrDirectoryManager;
 
-    private SolrServerProviderManager solrServerProviderManager;
-
     protected TcManager tcManager;
 
     protected SolrStore store;
@@ -179,8 +179,7 @@ public class ContenthubStoreResource ext
                                    @QueryParam(value = "offset") int offset,
                                    @QueryParam(value = "pageSize") @DefaultValue("5") int pageSize) throws ParseException,
                                                                                                    IllegalArgumentException,
-                                                                                                   IOException {
-
+                                                                                                   IOException, InvalidSyntaxException {
         store = ContextHelper.getServiceFromContext(SolrStore.class, context);
         tcManager = ContextHelper.getServiceFromContext(TcManager.class, context);
         serializer = ContextHelper.getServiceFromContext(Serializer.class, context);
@@ -201,15 +200,21 @@ public class ContenthubStoreResource ext
         this.offset = offset;
         this.pageSize = pageSize;
 
-        solrServerProviderManager = ContextHelper.getServiceFromContext(SolrServerProviderManager.class,
-            context);
+        BundleContext bundleContext = (BundleContext) context.getAttribute(BundleContext.class.getName());
         solrDirectoryManager = ContextHelper.getServiceFromContext(ManagedSolrServer.class, context);
         SolrServer solrServer = null;
         if (solrDirectoryManager != null) {
+            //TODO: This should not be done on every single request
             if (!solrDirectoryManager.isManagedIndex("contenthub")) {
                 solrDirectoryManager.createSolrIndex("contenthub", "contenthub", null);
             }
-            solrServer = solrServerProviderManager.getSolrServer(SolrServerTypeEnum.EMBEDDED, "contenthub");
+            RegisteredSolrServerTracker tracker = new RegisteredSolrServerTracker(
+                bundleContext, new IndexReference(
+                    solrDirectoryManager.getServerName(), "contenthub"));
+            tracker.open();
+            solrServer = tracker.getService();
+            tracker.close();
+            tracker = null;
         }
 
         ModifiableSolrParams params = new ModifiableSolrParams();

Modified: incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/SearchResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/SearchResource.java?rev=1206372&r1=1206371&r2=1206372&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/SearchResource.java (original)
+++ incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/SearchResource.java Fri Nov 25 23:18:27 2011
@@ -47,8 +47,8 @@ import org.apache.solr.client.solrj.resp
 import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.common.SolrDocument;
 import org.apache.solr.common.SolrDocumentList;
-import org.apache.stanbol.commons.solr.SolrServerProviderManager;
-import org.apache.stanbol.commons.solr.SolrServerTypeEnum;
+import org.apache.stanbol.commons.solr.IndexReference;
+import org.apache.stanbol.commons.solr.RegisteredSolrServerTracker;
 import org.apache.stanbol.commons.solr.managed.IndexMetadata;
 import org.apache.stanbol.commons.solr.managed.ManagedSolrServer;
 import org.apache.stanbol.commons.web.base.ContextHelper;
@@ -66,6 +66,8 @@ import org.apache.stanbol.contenthub.ser
 import org.apache.stanbol.contenthub.web.search.model.EngineInfo;
 import org.apache.stanbol.contenthub.web.search.model.SearchInfo;
 import org.apache.stanbol.contenthub.web.search.model.TempSearchResult;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -88,15 +90,27 @@ public class SearchResource extends Base
     private Object facets = null;
 
     private ManagedSolrServer solrDirectoryManager;
-    private SolrServerProviderManager solrServerProviderManager;
 
-    public SearchResource(@Context ServletContext context) {
+    private SolrServer solrServer;
+
+    public SearchResource(@Context ServletContext context) throws IOException, InvalidSyntaxException {
         searcher = ContextHelper.getServiceFromContext(Search.class, context);
         tcManager = ContextHelper.getServiceFromContext(TcManager.class, context);
         processor = ContextHelper.getServiceFromContext(SearchProcessor.class, context);
-        solrServerProviderManager = ContextHelper.getServiceFromContext(SolrServerProviderManager.class,
-            context);
         solrDirectoryManager = ContextHelper.getServiceFromContext(ManagedSolrServer.class, context);
+        BundleContext bundleContext = ContextHelper.getBundleContext(context);
+        if (solrDirectoryManager != null) {
+            if (!solrDirectoryManager.isManagedIndex("contenthub")) {
+                solrDirectoryManager.createSolrIndex("contenthub", "contenthub", null);
+            }
+            RegisteredSolrServerTracker tracker = new RegisteredSolrServerTracker(
+                bundleContext, new IndexReference(
+                    solrDirectoryManager.getServerName(), "contenthub"));
+            //TODO: this is currently done for each request
+            tracker.open();
+            solrServer = tracker.getService();
+            tracker.close();
+        }
     }
 
     @GET
@@ -158,14 +172,6 @@ public class SearchResource extends Base
                                                    IllegalArgumentException,
                                                    IOException {
 
-        SolrServer server = null;
-        if (solrDirectoryManager != null) {
-            if (!solrDirectoryManager.isManagedIndex("contenthub")) {
-                solrDirectoryManager.createSolrIndex("contenthub", "contenthub", null);
-            }
-            server = solrServerProviderManager.getSolrServer(SolrServerTypeEnum.EMBEDDED, "contenthub");
-        }
-
         QueryKeyword queryKeywords = sc.getQueryKeyWords().get(0);
         List<DocumentResource> docList = queryKeywords.getRelatedDocumentResources();
         StringBuilder queryBuilder = new StringBuilder();
@@ -184,7 +190,7 @@ public class SearchResource extends Base
         }
         SolrQuery solrQuery = new SolrQuery();
         solrQuery.setQuery(query).setFacetMinCount(1);
-        SolrDocumentList sdl = server.query(solrQuery).getResults();
+        SolrDocumentList sdl = solrServer.query(solrQuery).getResults();
 
         Set<String> fields = new HashSet<String>();
         for (SolrDocument sd : sdl) {
@@ -202,7 +208,7 @@ public class SearchResource extends Base
         }
         solrQuery.setRows(0);
 
-        QueryResponse result = server.query(solrQuery);
+        QueryResponse result = solrServer.query(solrQuery);
         List<FacetField> facets = result.getFacetFields();
         logger.debug(facets.toString());
         return facets;

Modified: incubator/stanbol/trunk/entityhub/indexing/destination/solryard/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/indexing/destination/solryard/pom.xml?rev=1206372&r1=1206371&r2=1206372&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/indexing/destination/solryard/pom.xml (original)
+++ incubator/stanbol/trunk/entityhub/indexing/destination/solryard/pom.xml Fri Nov 25 23:18:27 2011
@@ -139,6 +139,11 @@
 			<artifactId>org.osgi.compendium</artifactId>
 			<scope>test</scope>
 		</dependency>
+	    <dependency>
+	      <groupId>org.osgi</groupId>
+	      <artifactId>org.osgi.core</artifactId>
+	      <scope>test</scope>
+	    </dependency>
 		<!--
             Solr/Lucene dependencies
         -->

Modified: incubator/stanbol/trunk/entityhub/indexing/genericrdf/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/indexing/genericrdf/pom.xml?rev=1206372&r1=1206371&r2=1206372&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/indexing/genericrdf/pom.xml (original)
+++ incubator/stanbol/trunk/entityhub/indexing/genericrdf/pom.xml Fri Nov 25 23:18:27 2011
@@ -190,6 +190,12 @@
             <artifactId>org.apache.stanbol.commons.solr.managed</artifactId>
             <scope>runtime</scope>
         </dependency>
+        
+        <dependency><!-- needed because the InvalidSyntax exceptions and Filter -->
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <scope>runtime</scope>
+        </dependency>
 		<dependency>
 			<!-- needed because the SolrYard uses ConfigurationExceptions -->
 			<groupId>org.osgi</groupId>