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/23 10:02:04 UTC

svn commit: r1205331 [1/7] - in /incubator/stanbol/trunk: commons/installer/bundleprovider/src/main/java/org/apache/stanbol/commons/installer/provider/bundle/impl/ commons/opennlp/src/test/java/org/apache/commons/opennlp/ commons/solr/ commons/solr/cor...

Author: rwesten
Date: Wed Nov 23 09:01:33 2011
New Revision: 1205331

URL: http://svn.apache.org/viewvc?rev=1205331&view=rev
Log:
This commit contains implementations for STANBOL-374, STANBOL-375, STANBOL-377 and STANBOL-380 and fixes STANBOL-381 and STANBOL-385

I will write a summary of this statement also on the stanbol-dev mailing list.

DataFileProvider and DataFileTracker
------------------------------------

The DataFileProvider allows to load data files needed by Stanbol Components without the need to know how this files are provided ( '/datafiles' folder, via the Classpath, from a Bundle …)
The DataFileTracker uses the DataFileProvider infrastructure to allow the tracking of files.
Components can register as DataFileListeners and get notified if a DataFile becomes available/unavailable (STANBOL-347).

* Tracking is implemented as an own service with a dependency to a DataFileProvider.
* Tracking is implemented by periodically (default 5sec) checking for registered Datafiles.
* After a restart of the DataFileTracker service listeners MUST re-register themselves.
* Added an isAvailable(...) method to the DataFileProvider to avoid opening InputStreams while checking for DataFiles.

*TODO's*

The current Apache Felix Webconsole plugin that shows Requested Datafiles as Events needs to be updated, because all requests for DataFiles generated by the DataFileTracker show up as Events in this interface. My suggestion would be to create a new Interface that is based on requested Datafiles identified based on "name" and "bundleSymbolocName".


ManagedSolrServer 
-----------------

Added support for multiple managed Solr server. This Component replaces the SolrDirectoryManager and also includes some functionalities formally part of the EmbeddedSolrServerProvider.

* Identified by name. If multiple Servers share the same name service rankings are used. This allows to configure fallback servers. Names are shared between Managed- and Referenced- SolrServer instances.
* The ManagedSolrServer with the highest service ranking is used as default. It is best practice to configure an default instance with service ranking Integer.MAX_VALUE.
* Full CRUD operation on managed indexes (SolrCores). The state of the managed indexes are saved within the data directory of the Bundle. This allows also to manage indexes with missing data (Solr index archives). (fixes STANBOL-375)
* The CoreContainer (the managed Solr server) and all SolrCores (Solr indexes) are registered as OSGI services.
* Support for loading and tracking SolrIndexArchives via the DataFileProvider and DataFileTracker services (fixes STANBOL-380)
* A boolean switch for the ManagedSolrServer allows to specify of indexes of this server are published via the Stanbol RESTful interface under /solr/{server-name}/{index-name}
* ManagedSolrServer instances can be specified by providing configurations via the Sling installer framework (e.g. by the launcher or within a bundle). However it is also possible to create them by directly adding a new configuration the the OSGI ConfigurationAdmin service. In addition Users may provide configurations by using the Configuration tab of the Apache Felix Web Console.
* SolrCore directory names now include the date of the creation as an 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).

ReferencedSolrServer
--------------------

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 the created CoreContainer (the Solr server) and the SolrCores (Solr indexes) are registers as OSGI services. NOTE that indexes and data might still be changesd by using the normal Solr Admin interface.

* ReferencedSolrServer are identified by a user provided name. Names are shared between Managed- and Referenced- SolrServer instances.
* A boolean switch for the ManagedSolrServer allows to specify of indexes of this server are published via the Stanbol RESTful interface under /solr/{server-name}/{index-name}
* ReferencedSolrServer will be typically configured by users by using the Configuration tab of the Apache Felix Web Console. However it is also possible to configure ReferencedSolrServers by directly registering a configuration on the OSGI ConfigurationAdmin service, or by providing a Configuration within a Bundle or the Sling launcher.

CoreContainer and SolrCore registration
---------------------------------------

Both the ManagedSolrServer and the ReferencedSolrServer register CoreContainers and SolrCores as
OSGI services. For more information about the metadata provided for registered components see the Javadoc of [SolrConstants](http://svn.apache.org/repos/asf/incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrConstants.java). Note that registered SolrCores also include the properties for the server (CoreContainer) they are registered with.


SolrServerProvider
------------------

The SolrServerProvider is used by Components that want to use a Solr index to obtain SolrServer (client interface of Solr - SolrJ). Stabol supports both remote Solr server (accessed via the RESTful API) and embedded sold servers (running within the same JVM).

The new RegisteredSolrServerProvider replaces the EmbeddedSolrServerProvider that formally used for embedded SolrServers. The new implementation uses CoreContainer and SolrCore instances registered as OSGI services. (fixes STANBOL-376)

The following types of links can be used:

* URLs: http(s)://host:port/path for external SolrServers; file:/path for embedded Solr Servers
* File paths for embedded SolrServers
* [{server-name}:]{index-name} for embedded Solr Servers. If the server-name is not specified the
default server is assumed.

*NOTES* 

* Solr indexes even referenced by file URLs or file paths need first to be registered/configured as ReferencedSolr! The direct initialization of a SolrServer (as formally implemented by the EmbeddedSolrServer) is no longer supported!
* The "[{server-name}:]{index-name}" syntax is preferred over file URLs and file paths, because is allows to refer to a Solr index by configureable names and is not depended on the actual location of the index on the local file system.

*Future plan*

The current updates still keeps the previous interface and only adds support for the new "[{server-name}:]{index-name}" syntax. However in a future update the whole SolrServerProvider infrastructure could adopt the Whiteboard pattern (Solr indexes are registered as OSGI services) as already internally used by the new RegisteredSolrServerProvider.

DBPedia.org default configuration
---------------------------------

The artifact Addition "org.apache.stanbol.data.site.dbpedia.default" that previously provided the default dbpedia data was removed.

The new "org.apache.stanbol.data.site.dbpedia" artifact uses the new functionality specified by STANBOL-380 to refer to the same default data by adding an additional "Index-Archive" with a low priority. Now if users want to upgrade to a bigger DBPedia index they need only to download/create a dbpedia index and copy the "dbpedia.solrindex.zip" file to the "/datafile" directory. This will automatically replace the default data that ship with Stanbol.
After the new Index is initialized the "dbpedia.solrindex.zip" can be removed from the "/datafile" folder.

To upgrade from one big "dbpedia.solrindex.zip" version to an other users need to copy the new "dbpedia.solrindex.zip" to the "/datafiles" directory and than stop/start the "org.apache.stanbol.data.site.dbpedia" bundle. Stopping the bundle will cause the dbpedia index to be removed. Restarting it will trigger the same initialization as by the first start. So if no "dbpedia.solrindex.zip" is preset the default data set for dbpedia will be used for the re-initialisation.

For users that used already the "http://host:port/solr/default/{index}" URLs to directly access
Solr indexes of the Entityhub please not the with this change both the small default data index as well as the full index (as soon as initialized from the user provided dbpedia.solrindex.zip file) will be available under "http://host:port/solr/default/dbpedia".
The previously used index name "dbpedia_43k" is no longer used because now indexes are always deployed on the name "dbpedia" in that case.

Entityhub Indexing Utilities
----------------------------

The "Syncronized" feature introduces by STANBOL-280 is now supported by the Indexing Utilities.
Within the main configuration file ("/indexing/config/indexing.properties") the Key "Synchronized" can be used to configure if this feature is used or not. By default this feature is enabled. However for the dbpedia indexing tool it is deactivated by default.

If the bundle for the indexed dataset is active and "Synchronized" is enabled the data for the ReferencedSite will be kept in sync with the "{name}.solrindex.zip" files within the "/datafiles" folder. So if the solrindex.zip-file is deleted the data of the local indexed are removed. If a new version is copied to the "/datafiles" folder the updated data are installed.
Note the the old file needs first to be deleted and after some seconds (after the deletion was detected) the new file can be copied. Simple replacing the file will not work, because currently the DataFileProvider/DataFileTracker does not detect updates to data files.

If "Synchronized" is disabled one need to stop/reactivate the Bundle to trigger the new data to be loaded.


Other changes
-------------

* Adaptions to the SolrYard, Indexing utilities and the Contenthub to support/use the new functionalities
* Fix for STANBOL-381
* Corrected some issues with the @Property annotations for ReferencedSites.
* Added a default ManagedSolrServer configuration the the Stanbol launchers
* changed the index location for the ManagedSolrServer to {sling.home}/indexes/{server-name}
* Updated the java script for the /find example in the RESTful service documentation of the entityhub service endpoints that support /find to work regardless if the user adds the tailing '/' to the URL in the Browser.
* Increased the start level for the org.apache.stanbol.data.site.dbpedia bundle from 19 to 30. Bundles the include configurations for OSGI components MUST start after the components they provide configurations for.
* Switched back to SNAPSHOT versions for all /data artifacts as [discussed](fixes STANBOL-385)
* Corrected a Bug that cause an IllegalArgumentException in the RESTful interface of "/entityhub/site/{name}" if the accessUri or queryUrl of the referenced site where an empty string (defaults). Now this URIs are correctly set to NULL if en empty string is provided by the OSGI configuration.
 

Added:
    incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/IndexReference.java   (with props)
    incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrServerAdapter.java   (contents, props changed)
      - copied, changed from r1195450, incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/ManagedSolrServer.java
    incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/impl/RESTfulSolrServerProvider.java   (contents, props changed)
      - copied, changed from r1195389, incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/impl/DefaultSolrServerProvider.java
    incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/impl/RegisteredSolrServerProvider.java   (contents, props changed)
      - copied, changed from r1195450, incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/impl/EmbeddedSolrPorovider.java
    incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/utils/ServiceReferenceRankingComparator.java   (contents, props changed)
      - copied, changed from r1196547, incubator/stanbol/trunk/commons/solr/web/src/main/java/org/apache/stanbol/commons/solr/web/utils/ServiceReferenceRankingComparator.java
    incubator/stanbol/trunk/commons/solr/managed/   (with props)
    incubator/stanbol/trunk/commons/solr/managed/src/
    incubator/stanbol/trunk/commons/solr/managed/src/main/
    incubator/stanbol/trunk/commons/solr/managed/src/main/java/
    incubator/stanbol/trunk/commons/solr/managed/src/main/java/org/
    incubator/stanbol/trunk/commons/solr/managed/src/main/java/org/apache/
    incubator/stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/
    incubator/stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/
    incubator/stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/
    incubator/stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/
    incubator/stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/impl/
    incubator/stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/impl/ClassPathSolrIndexConfigProvider.java   (with props)
    incubator/stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/impl/DefaultSolrDirectoryManager.java   (with props)
    incubator/stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/impl/ManagedIndexMetadata.java   (with props)
    incubator/stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/impl/ManagedSolrServerImpl.java   (with props)
    incubator/stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/impl/ManagementUtils.java   (with props)
    incubator/stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/impl/ReferencedSolrServer.java   (with props)
    incubator/stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/standalone/
    incubator/stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/standalone/DefaultStandaloneManagedSolrServerWrapper.java   (with props)
    incubator/stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/standalone/StandaloneEmbeddedSolrServerProvider.java   (with props)
    incubator/stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/standalone/StandaloneManagedSolrServer.java   (with props)
    incubator/stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/standalone/package.html   (with props)
    incubator/stanbol/trunk/commons/solr/managed/src/main/resources/
    incubator/stanbol/trunk/commons/solr/managed/src/main/resources/META-INF/
    incubator/stanbol/trunk/commons/solr/managed/src/main/resources/META-INF/services/
    incubator/stanbol/trunk/commons/solr/managed/src/main/resources/OSGI-INF/
    incubator/stanbol/trunk/commons/solr/managed/src/main/resources/OSGI-INF/metatype/
    incubator/stanbol/trunk/commons/solr/managed/src/main/resources/solr/
    incubator/stanbol/trunk/commons/solr/managed/src/main/resources/solr/README.md
    incubator/stanbol/trunk/commons/solr/managed/src/main/resources/solr/conf/
    incubator/stanbol/trunk/commons/solr/managed/src/main/resources/solr/conf/solr.xml   (with props)
    incubator/stanbol/trunk/commons/solr/managed/src/test/
    incubator/stanbol/trunk/commons/solr/managed/src/test/java/
    incubator/stanbol/trunk/commons/solr/managed/src/test/java/org/
    incubator/stanbol/trunk/commons/solr/managed/src/test/java/org/apache/
    incubator/stanbol/trunk/commons/solr/managed/src/test/java/org/apache/stanbol/
    incubator/stanbol/trunk/commons/solr/managed/src/test/java/org/apache/stanbol/commons/
    incubator/stanbol/trunk/commons/solr/managed/src/test/java/org/apache/stanbol/commons/solr/
    incubator/stanbol/trunk/commons/solr/managed/src/test/java/org/apache/stanbol/commons/solr/managed/
    incubator/stanbol/trunk/commons/solr/managed/src/test/resources/
    incubator/stanbol/trunk/commons/solr/managed/src/test/resources/solr/
    incubator/stanbol/trunk/commons/solr/managed/src/test/resources/solr/core/
    incubator/stanbol/trunk/commons/solr/managed/src/test/resources/solr/core/test.solrindex.zip   (with props)
    incubator/stanbol/trunk/commons/solr/web/src/main/java/org/apache/stanbol/commons/solr/web/impl/SolrServerPublishingComponent.java   (with props)
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/DataFileListener.java   (with props)
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/DataFileTracker.java   (with props)
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/tracking/
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/tracking/DataFileReference.java   (with props)
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/tracking/DataFileTrackerImpl.java   (with props)
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/tracking/STATE.java   (with props)
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/tracking/TrackingState.java   (with props)
    incubator/stanbol/trunk/data/sites/dbpedia/README.md
      - copied, changed from r1196547, incubator/stanbol/trunk/data/sites/dbpediadefault/README.md
    incubator/stanbol/trunk/data/sites/dbpedia/download_index.xml   (props changed)
      - copied unchanged from r1196547, incubator/stanbol/trunk/data/sites/dbpediadefault/download_index.xml
    incubator/stanbol/trunk/data/sites/dbpedia/pom.xml   (contents, props changed)
      - copied, changed from r1196547, incubator/stanbol/trunk/data/sites/dbpediadefault/pom.xml
    incubator/stanbol/trunk/data/sites/dbpedia/src/
      - copied from r1196547, incubator/stanbol/trunk/data/sites/dbpediadefault/src/
    incubator/stanbol/trunk/data/sites/dbpedia/src/main/resources/org/apache/stanbol/data/site/dbpedia/default/config/dbpedia.solrindex.ref
    incubator/stanbol/trunk/launchers/full-war/src/main/webapp/WEB-INF/resources/config/org.apache.stanbol.commons.solr.managed.impl.ManagedSolrServerImpl-default.config
    incubator/stanbol/trunk/launchers/full/src/main/resources/resources/config/org.apache.stanbol.commons.solr.managed.impl.ManagedSolrServerImpl-default.config
    incubator/stanbol/trunk/launchers/kres/src/main/resources/resources/config/org.apache.stanbol.commons.solr.managed.impl.ManagedSolrServerImpl-default.config
    incubator/stanbol/trunk/launchers/stable/src/main/resources/resources/config/org.apache.stanbol.commons.solr.managed.impl.ManagedSolrServerImpl-default.config
Removed:
    incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/ManagedSolrServer.java
    incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrDirectoryManager.java
    incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/impl/ClassPathSolrIndexConfigProvider.java
    incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/impl/DefaultSolrDirectoryManager.java
    incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/impl/DefaultSolrServerProvider.java
    incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/impl/EmbeddedSolrPorovider.java
    incubator/stanbol/trunk/commons/solr/core/src/main/resources/META-INF/services/org.apache.stanbol.commons.solr.SolrDirectoryManager
    incubator/stanbol/trunk/commons/solr/core/src/test/java/org/
    incubator/stanbol/trunk/commons/solr/web/src/main/java/org/apache/stanbol/commons/solr/web/utils/ServiceReferenceRankingComparator.java
    incubator/stanbol/trunk/data/sites/dbpedia/src/main/resources/org/apache/stanbol/data/site/dbpedia/default/config/dbpedia_43k.solrindex.ref
    incubator/stanbol/trunk/data/sites/dbpediadefault/
    incubator/stanbol/trunk/launchers/full-war/src/main/webapp/WEB-INF/resources/config/org.apache.stanbol.commons.solr.impl.DefaultSolrDirectoryManager.cfg
    incubator/stanbol/trunk/launchers/full/src/main/resources/resources/config/org.apache.stanbol.commons.solr.impl.DefaultSolrDirectoryManager.cfg
    incubator/stanbol/trunk/launchers/kres/src/main/resources/resources/config/org.apache.stanbol.commons.solr.impl.DefaultSolrDirectoryManager.cfg
    incubator/stanbol/trunk/launchers/stable/src/main/resources/resources/config/org.apache.stanbol.commons.solr.impl.DefaultSolrDirectoryManager.cfg
    incubator/stanbol/trunk/launchers/stable/src/main/resources/resources/config/org.apache.stanbol.commons.solr.web.impl.SolrDispatchFilterComponent-default.config
Modified:
    incubator/stanbol/trunk/commons/installer/bundleprovider/src/main/java/org/apache/stanbol/commons/installer/provider/bundle/impl/BundleInstaller.java
    incubator/stanbol/trunk/commons/opennlp/src/test/java/org/apache/commons/opennlp/ClasspathDataFileProvider.java
    incubator/stanbol/trunk/commons/solr/core/pom.xml
    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/core/src/main/resources/META-INF/services/org.apache.stanbol.commons.solr.SolrServerProvider
    incubator/stanbol/trunk/commons/solr/install/pom.xml
    incubator/stanbol/trunk/commons/solr/install/src/main/java/org/apache/stanbol/commons/solr/IndexInstallerConstants.java
    incubator/stanbol/trunk/commons/solr/install/src/main/java/org/apache/stanbol/commons/solr/install/impl/IndexInstallTask.java
    incubator/stanbol/trunk/commons/solr/install/src/main/java/org/apache/stanbol/commons/solr/install/impl/IndexRemoveTask.java
    incubator/stanbol/trunk/commons/solr/install/src/main/java/org/apache/stanbol/commons/solr/install/impl/SolrIndexInstaller.java
    incubator/stanbol/trunk/commons/solr/pom.xml
    incubator/stanbol/trunk/commons/solr/web/pom.xml
    incubator/stanbol/trunk/commons/solr/web/src/main/java/org/apache/stanbol/commons/solr/web/dispatch/DelegatingSolrDispatchFilter.java
    incubator/stanbol/trunk/commons/solr/web/src/main/java/org/apache/stanbol/commons/solr/web/dispatch/ReferencedSolrDispatchFilter.java
    incubator/stanbol/trunk/commons/solr/web/src/main/java/org/apache/stanbol/commons/solr/web/dispatch/SolrServiceDispatchFilter.java
    incubator/stanbol/trunk/commons/solr/web/src/main/java/org/apache/stanbol/commons/solr/web/impl/SolrDispatchFilterComponent.java
    incubator/stanbol/trunk/commons/stanboltools/bundledatafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/bundle/impl/BundleDataFileProvider.java
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/DataFileProvider.java
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/DataFileProviderEvent.java
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/MainDataFileProvider.java
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/WebConsolePlugin.java
    incubator/stanbol/trunk/contenthub/core/pom.xml
    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/pom.xml
    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/data/bundlelist/src/main/bundles/list.xml
    incubator/stanbol/trunk/data/opennlp/lang/da/pom.xml
    incubator/stanbol/trunk/data/opennlp/lang/de/pom.xml
    incubator/stanbol/trunk/data/opennlp/lang/en/pom.xml
    incubator/stanbol/trunk/data/opennlp/lang/nl/pom.xml
    incubator/stanbol/trunk/data/opennlp/lang/pt/pom.xml
    incubator/stanbol/trunk/data/opennlp/lang/sv/pom.xml
    incubator/stanbol/trunk/data/opennlp/ner/en/pom.xml
    incubator/stanbol/trunk/data/opennlp/ner/es/pom.xml
    incubator/stanbol/trunk/data/opennlp/ner/nl/pom.xml
    incubator/stanbol/trunk/data/pom.xml
    incubator/stanbol/trunk/data/sites/dbpedia/src/main/resources/org/apache/stanbol/data/site/dbpedia/default/config/org.apache.stanbol.entityhub.core.site.CacheImpl-dbpedia.config
    incubator/stanbol/trunk/data/sites/dbpedia/src/main/resources/org/apache/stanbol/data/site/dbpedia/default/config/org.apache.stanbol.entityhub.site.referencedSite-dbpedia.config
    incubator/stanbol/trunk/data/sites/dbpedia/src/main/resources/org/apache/stanbol/data/site/dbpedia/default/config/org.apache.stanbol.entityhub.yard.solr.impl.SolrYard-dbpedia.config
    incubator/stanbol/trunk/data/sites/dbpediacached/pom.xml
    incubator/stanbol/trunk/data/sites/geonames/pom.xml
    incubator/stanbol/trunk/enhancer/engines/keywordextraction/src/main/java/org/apache/stanbol/enhancer/engines/keywordextraction/engine/KeywordLinkingEngine.java
    incubator/stanbol/trunk/enhancer/engines/keywordextraction/src/test/java/org/apache/stanbol/enhancer/engines/keywordextraction/impl/ClasspathDataFileProvider.java
    incubator/stanbol/trunk/enhancer/engines/opennlp-ner/src/test/java/org/apache/stanbol/enhancer/engines/opennlp/impl/ClasspathDataFileProvider.java
    incubator/stanbol/trunk/entityhub/generic/core/src/main/java/org/apache/stanbol/entityhub/core/impl/DefaultSiteConfiguration.java
    incubator/stanbol/trunk/entityhub/indexing/dblp/pom.xml
    incubator/stanbol/trunk/entityhub/indexing/dbpedia/README.md
    incubator/stanbol/trunk/entityhub/indexing/dbpedia/pom.xml
    incubator/stanbol/trunk/entityhub/indexing/dbpedia/src/main/resources/indexing/config/indexing.properties
    incubator/stanbol/trunk/entityhub/indexing/destination/solryard/pom.xml
    incubator/stanbol/trunk/entityhub/indexing/destination/solryard/src/main/java/org/apache/stanbol/entityhub/indexing/destination/solryard/SolrYardIndexingDestination.java
    incubator/stanbol/trunk/entityhub/indexing/destination/solryard/src/test/java/org/apache/stanbol/entityhub/indexing/destination/solryard/SolrYardIndexingDestinationTest.java
    incubator/stanbol/trunk/entityhub/indexing/genericrdf/pom.xml
    incubator/stanbol/trunk/entityhub/indexing/genericrdf/src/main/assembly/assembly.xml
    incubator/stanbol/trunk/entityhub/indexing/genericrdf/src/main/resources/indexing/config/indexing.properties
    incubator/stanbol/trunk/entityhub/indexing/source/vcard/src/main/java/org/apache/stanbol/entityhub/indexing/source/vcard/VcardIndexingSource.java
    incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/inc_find.ftl
    incubator/stanbol/trunk/entityhub/yard/solr/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
    incubator/stanbol/trunk/entityhub/yard/solr/src/test/java/org/apache/stanbol/entityhub/yard/solr/SolrYardTest.java
    incubator/stanbol/trunk/integration-tests/pom.xml
    incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/commons/solr/web/it/DefaultDataDispatchFilterTest.java
    incubator/stanbol/trunk/launchers/basebundlelist/src/main/bundles/list.xml
    incubator/stanbol/trunk/launchers/full-war/pom.xml
    incubator/stanbol/trunk/launchers/full-war/src/main/webapp/WEB-INF/README
    incubator/stanbol/trunk/launchers/full/pom.xml
    incubator/stanbol/trunk/launchers/full/src/main/resources/README
    incubator/stanbol/trunk/launchers/stable/pom.xml
    incubator/stanbol/trunk/launchers/stable/src/main/resources/README
    incubator/stanbol/trunk/parent/pom.xml

Modified: incubator/stanbol/trunk/commons/installer/bundleprovider/src/main/java/org/apache/stanbol/commons/installer/provider/bundle/impl/BundleInstaller.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/installer/bundleprovider/src/main/java/org/apache/stanbol/commons/installer/provider/bundle/impl/BundleInstaller.java?rev=1205331&r1=1205330&r2=1205331&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/installer/bundleprovider/src/main/java/org/apache/stanbol/commons/installer/provider/bundle/impl/BundleInstaller.java (original)
+++ incubator/stanbol/trunk/commons/installer/bundleprovider/src/main/java/org/apache/stanbol/commons/installer/provider/bundle/impl/BundleInstaller.java Wed Nov 23 09:01:33 2011
@@ -169,14 +169,24 @@ public class BundleInstaller implements 
         activated.put(bundle, path);
         if (path != null) {
             log.info(" ... process configuration within path {} for bundle {}",path,bundle.getSymbolicName());
-            ArrayList<InstallableResource> updated = new ArrayList<InstallableResource>();
-            for (Enumeration<URL> resources = (Enumeration<URL>) bundle.findEntries(path, null, true); resources.hasMoreElements();) {
-                InstallableResource resource = createInstallableResource(bundle, path, resources.nextElement());
-                if (resource != null) {
-                    updated.add(resource);
+            Enumeration<URL> resources = (Enumeration<URL>) bundle.findEntries(path, null, true);
+            if(resources != null){
+                ArrayList<InstallableResource> updated = new ArrayList<InstallableResource>();
+                while (resources.hasMoreElements()) {
+                    URL url = resources.nextElement();
+                    if(url != null){
+                        log.debug("  > installable Resource {}",url);
+                        InstallableResource resource = createInstallableResource(bundle, path, url);
+                        if (resource != null) {
+                            updated.add(resource);
+                        }
+                    }
                 }
+                installer.updateResources(PROVIDER_SCHEME, updated.toArray(new InstallableResource[updated.size()]), new String[]{});
+            } else {
+                log.warn(" ... no Entries found in path '{}' configured for Bundle '{}' with Manifest header field '{}'!",
+                    new Object[]{path,bundle.getSymbolicName(),BUNDLE_INSTALLER_HEADER});
             }
-            installer.updateResources(PROVIDER_SCHEME, updated.toArray(new InstallableResource[updated.size()]), new String[]{});
         } else {
             log.debug("  ... no Configuration to process");
         }

Modified: incubator/stanbol/trunk/commons/opennlp/src/test/java/org/apache/commons/opennlp/ClasspathDataFileProvider.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/opennlp/src/test/java/org/apache/commons/opennlp/ClasspathDataFileProvider.java?rev=1205331&r1=1205330&r2=1205331&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/opennlp/src/test/java/org/apache/commons/opennlp/ClasspathDataFileProvider.java (original)
+++ incubator/stanbol/trunk/commons/opennlp/src/test/java/org/apache/commons/opennlp/ClasspathDataFileProvider.java Wed Nov 23 09:01:33 2011
@@ -18,6 +18,7 @@ package org.apache.commons.opennlp;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.URL;
 import java.util.Map;
 
 import org.apache.stanbol.commons.stanboltools.datafileprovider.DataFileProvider;
@@ -45,6 +46,19 @@ public class ClasspathDataFileProvider i
     public InputStream getInputStream(String bundleSymbolicName,
             String filename, Map<String, String> comments) 
     throws IOException {
+        URL dataFile = getDataFile(bundleSymbolicName, filename);
+        
+        // Returning null is fine - if we don't have the data file, another
+        // provider might supply it
+        return dataFile != null ? dataFile.openStream() : null;
+    }
+
+    /**
+     * @param bundleSymbolicName
+     * @param filename
+     * @return
+     */
+    private URL getDataFile(String bundleSymbolicName, String filename) {
         //If the symbolic name is not null check that is equals to the symbolic
         //name used to create this classpath data file provider
         if(bundleSymbolicName != null && !symbolicName.equals(bundleSymbolicName)) {
@@ -55,11 +69,13 @@ public class ClasspathDataFileProvider i
         
         // load default OpenNLP models from classpath (embedded in the defaultdata bundle)
         final String resourcePath = RESOURCE_BASE_PATH + filename;
-        final InputStream in = getClass().getClassLoader().getResourceAsStream(resourcePath);
-        log.debug("Resource {} found: {}", (in == null ? "NOT" : ""), resourcePath);
-        
-        // Returning null is fine - if we don't have the data file, another
-        // provider might supply it
-        return in;
+        //final InputStream in = getClass().getClassLoader().getResourceAsStream(resourcePath);
+        URL dataFile = getClass().getClassLoader().getResource(resourcePath);
+        //log.debug("Resource {} found: {}", (dataFile == null ? "NOT" : ""), resourcePath);
+        return dataFile;
+    }
+    @Override
+    public boolean isAvailable(String bundleSymbolicName, String filename, Map<String,String> comments) {
+        return getDataFile(bundleSymbolicName, filename) != null;
     }
 }

Modified: incubator/stanbol/trunk/commons/solr/core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/solr/core/pom.xml?rev=1205331&r1=1205330&r2=1205331&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/solr/core/pom.xml (original)
+++ incubator/stanbol/trunk/commons/solr/core/pom.xml Wed Nov 23 09:01:33 2011
@@ -65,6 +65,7 @@
               org.apache.solr.client.solrj.request,
               org.apache.solr.client.solrj.response,
               org.apache.solr.client.solrj.util,
+              org.apache.solr.client.solrj.embedded,
               org.apache.solr.common,
               org.apache.solr.common.luke,
               org.apache.solr.common.params,

Added: 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=1205331&view=auto
==============================================================================
--- incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/IndexReference.java (added)
+++ incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/IndexReference.java Wed Nov 23 09:01:33 2011
@@ -0,0 +1,134 @@
+package org.apache.stanbol.commons.solr;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Arrays;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class IndexReference {
+
+    private static final Logger log = LoggerFactory.getLogger(IndexReference.class);
+    
+    public static IndexReference parse(String uriOrPathOrReference){
+        String[] referencedCore = new String[2];
+        boolean isFile;
+        if(uriOrPathOrReference.startsWith("file:")){ //file URL
+            isFile = true;
+            File file = null; 
+            try {
+                file = FileUtils.toFile(new URL(uriOrPathOrReference));
+            }catch (MalformedURLException e) {
+                log.error("Unable to parse file URL '"+uriOrPathOrReference+"'!",e);
+                file = null;
+            }
+            referencedCore[0] = null; //no server name for such values
+            if(file != null){
+                referencedCore[1] = FilenameUtils.normalize(file.getAbsolutePath()+File.separatorChar);
+            } else {
+                return null;
+            }
+        } else if(uriOrPathOrReference.indexOf(File.separatorChar) >=0 ||
+                uriOrPathOrReference.indexOf('/') >=0){ //also support UNIX style on Windows
+            //we assume a File Reference
+            isFile= true;
+            File file = new File(FilenameUtils.separatorsToSystem(uriOrPathOrReference));
+            referencedCore[0] = null;
+            referencedCore[1] = FilenameUtils.normalize(file.getAbsolutePath()+File.separatorChar);
+        } else { //reference in the style [{server-name}:]{core-name}
+            isFile = false;
+            int index = uriOrPathOrReference.indexOf(':');
+            if(index < 0){
+                referencedCore[0] = null;
+                referencedCore[1] = uriOrPathOrReference;
+            } else {
+                referencedCore[0] = uriOrPathOrReference.substring(0,index);
+                referencedCore[1] = uriOrPathOrReference.substring(index+1);
+                validateIndexName(referencedCore[1],uriOrPathOrReference);
+            }
+        }
+        return new IndexReference(referencedCore[0],referencedCore[1],isFile);
+    }
+    /**
+     * Validates the indexName
+     * @param indexName the name to validate
+     * @param indexRef the parsed indexRef
+     * @throws IllegalArgumentException if the validation fails
+     */
+    private static void validateIndexName(String indexName, String indexRef) {
+        if(indexName == null){
+            throw new IllegalArgumentException("The index name MUST NOT be NULL!");
+        }
+        if(indexName.isEmpty()){
+            throw new IllegalArgumentException("The parsed index reference '"+
+                indexRef+"' MUST NOT contain an empty index name" +
+                "(e.g. such as ending with ':')!");
+        }
+        if(indexName.indexOf('\\')>=0 ||
+                indexName.indexOf('/')>=0 ||
+                indexName.indexOf(':')>=0 ||
+                indexName.indexOf('.')>=0){
+            throw new IllegalArgumentException("The index name '"+
+                indexName+"' of the prased index reference '"+
+                indexRef+"' MUST NOT contain any of the " +
+                "following chars '"+Arrays.toString(
+                    new char[]{'\\','/',':',':','.'})+"'!");
+        }
+    }
+    
+    private final String server;
+    private final String index;
+    private final boolean isFile;
+    /**
+     * Creates a new IndexReference for the parsed server and index
+     * @param server the server or <code>null</code> if not known
+     * @param index the index. MUST NOT be <code>null</code> nor empty
+     */
+    public IndexReference(String server,String index) {
+        validateIndexName(index, server+':'+index);
+        this.server = server;
+        this.index = index;
+        this.isFile = false;
+    }
+    public IndexReference(String server,String index,boolean isFile) {
+        this.server = server;
+        this.index = index;
+        this.isFile = isFile;
+    }
+    
+    /**
+     * @return the server
+     */
+    public final String getServer() {
+        return server;
+    }
+    /**
+     * @return the index
+     */
+    public final String getIndex() {
+        return index;
+    }
+
+    public boolean isPath(){
+        return isFile;
+    }
+    
+    public boolean isName(){
+        return !isFile;
+    }
+    /**
+     * Checks if the referenced index could be on the parsed server
+     * @param serverName
+     * @return
+     */
+    public boolean checkServer(String serverName) {
+        return server == null || server.equals(serverName);
+    }
+    
+}

Propchange: incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/IndexReference.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=1205331&r1=1205330&r2=1205331&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 Wed Nov 23 09:01:33 2011
@@ -33,11 +33,11 @@ public final class SolrConstants {
     /**
      * Used as prefix for all {@link CoreContainer} related properties
      */
-    private static final String PROPERTY_SOLR_SERVER = CoreContainer.class.getName();
+    private static final String PROPERTY_SOLR_SERVER = "org.apache.solr.core.CoreContainer";
     /**
      * Used as prefix for all {@link SolrCore} related properties
      */
-    private static final String PROPERTY_SOLR_CORE = SolrCore.class.getName();
+    private static final String PROPERTY_SOLR_CORE = "org.apache.solr.core.SolrCore";
     /**
      * Property used for the human readable name of a SolrServer. This will be used
      * as alternative to the absolute file path of the solr.xml file used for the
@@ -69,8 +69,18 @@ public final class SolrConstants {
      */
     public static final String PROPERTY_SERVER_RANKING = Constants.SERVICE_RANKING;
     /**
+     * Allows to enable/disable the publishing of the RESTful interface of Solr
+     * on the OSGI HttpService by using the value of the {@link #PROPERTY_SERVER_NAME}
+     * as path.
+     */
+    public static final String PROPERTY_SERVER_PUBLISH_REST = PROPERTY_SOLR_SERVER+".publishREST";
+    /**
+     * By default the RESTful API of a SolrServer is published
+     */
+    public static final boolean DEFAULT_PUBLISH_REST = true;
+    /**
      * Property used for the name of a solr core. This is typically set by the
-     * {@link ManagedSolrServer} implementation based on the name of the 
+     * {@link SolrServerAdapter} implementation based on the name of the 
      * cores registered with a SolrServer.
      */
     public static final String PROPERTY_CORE_NAME = PROPERTY_SOLR_CORE+".name";
@@ -81,12 +91,12 @@ public final class SolrConstants {
      */
     public static final String PROPERTY_CORE_DIR = PROPERTY_SOLR_CORE+".dir";
     /**
-     * The data directory of a core. Set by the {@link ManagedSolrServer} when
+     * The data directory of a core. Set by the {@link SolrServerAdapter} when
      * registering a SolrCore based on {@link SolrCore#getDataDir()}
      */
     public static final String PROPERTY_CORE_DATA_DIR = PROPERTY_SOLR_CORE+".dadadir";
     /**
-     * The index directory of a core. Set by the {@link ManagedSolrServer} when
+     * The index directory of a core. Set by the {@link SolrServerAdapter} when
      * registering a SolrCore based on {@link SolrCore#getIndexDir()}
      */
     public static final String PROPERTY_CORE_INDEX_DIR = PROPERTY_SOLR_CORE+".indexdir";
@@ -101,6 +111,11 @@ 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
+     */
+    public static final String PROPERTY_CORE_SERVER_ID = PROPERTY_SOLR_CORE+".service.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 
      * ServiceRanking is defined for the server than '0' is used.<p>

Copied: incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrServerAdapter.java (from r1195450, incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/ManagedSolrServer.java)
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrServerAdapter.java?p2=incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrServerAdapter.java&p1=incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/ManagedSolrServer.java&r1=1195450&r2=1205331&rev=1205331&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/ManagedSolrServer.java (original)
+++ incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrServerAdapter.java Wed Nov 23 09:01:33 2011
@@ -17,10 +17,13 @@
 package org.apache.stanbol.commons.solr;
 
 import static org.apache.stanbol.commons.solr.SolrConstants.*;
+import static org.osgi.framework.Constants.SERVICE_ID;
+import static org.osgi.framework.Constants.SERVICE_PID;
 
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Dictionary;
@@ -28,13 +31,14 @@ import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Hashtable;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 import java.util.Map.Entry;
 
 import javax.xml.parsers.ParserConfigurationException;
 
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.FilenameUtils;
 import org.apache.solr.client.solrj.SolrServer;
 import org.apache.solr.core.CloseHook;
 import org.apache.solr.core.CoreContainer;
@@ -49,10 +53,12 @@ import org.slf4j.LoggerFactory;
 import org.xml.sax.SAXException;
 
 /**
- * This Class wraps a Solr {@link CoreContainer} (representing a SolrServer)
- * with one ore more {@link SolrCore}s and takes care that the 
- * {@link CoreContainer} and all its {@link SolrCore}s are registered as OSGI 
- * services.<p>
+ * This Class 'wraps' a Solr {@link CoreContainer} with all its registered 
+ * {@link SolrCore}s and registers them as OSGI services. It therefore adapts
+ * the components framework as used by Apache Solr to the OSGI.<p>
+ * This class itself is no OSGI component, but is intended to be used by
+ * other classes that allow to register/manage Solr {@link CoreContainer}
+ * running within the same JVM.<p>
  * Properties set for CoreContainers are: <ul>
  * <li> {@link SolrConstants#PROPERTY_SERVER_NAME}: The name assigned to
  * the SolrServer as parsed by {@link SolrServerProperties#getServerName()}. If
@@ -99,9 +105,9 @@ import org.xml.sax.SAXException;
  * @author Rupert Westenthaler
  *
  */
-public class ManagedSolrServer {
+public class SolrServerAdapter {
 
-    private final Logger log = LoggerFactory.getLogger(ManagedSolrServer.class);
+    private final Logger log = LoggerFactory.getLogger(SolrServerAdapter.class);
     
     private final Map<String,CoreRegistration> registrations;
     protected final CoreContainer server;
@@ -157,7 +163,7 @@ public class ManagedSolrServer {
      * valid value for the {@link SolrConstants#PROPERTY_SERVER_DIR} 
      * property.
      */
-    public ManagedSolrServer(BundleContext context,SolrServerProperties parsedServerProperties) throws ParserConfigurationException, IOException, SAXException{
+    public SolrServerAdapter(BundleContext context,SolrServerProperties parsedServerProperties) throws ParserConfigurationException, IOException, SAXException{
         if(parsedServerProperties == null){
             throw new IllegalArgumentException("The prsed Server Properties MUST NOT be NULL!");
         }
@@ -194,7 +200,7 @@ public class ManagedSolrServer {
         Set<String> coreNames = updateCoreNamesInServerProperties();
         //register the SolrServer
         this.serverRegistration = context.registerService(
-            CoreContainer.class.getName(), server, parsedServerProperties);
+            CoreContainer.class.getName(), server, serverProperties);
         //now register the cores
         for(String name : coreNames){
             registerCoreService(name,null);
@@ -219,7 +225,6 @@ public class ManagedSolrServer {
         //shutdown the CoreContainer itself
         server.shutdown();
     }
-
     /**
      * Removes the SolrCore for with the given name. This will also unregister
      * the according OSGI service. Note that SolrCores can be registerd with
@@ -234,10 +239,10 @@ public class ManagedSolrServer {
                 reg.unregister();
             }
             cleanupSolrCore(core);
-        }
-        //server.persist();
-        //update the OSGI service for the CoreContainer
-        updateServerRegistration();
+            //server.persist();
+            //update the OSGI service for the CoreContainer
+            updateServerRegistration();
+        } //else core already removed -> nothing to do
 
     }
     /**
@@ -252,6 +257,7 @@ public class ManagedSolrServer {
         //try to reload
         ClassLoader classLoader = updateContextClassLoader();
         try {
+            //TODO: what happens if the core with 'name' is no longer present?
             server.reload(name);
         } finally {
             Thread.currentThread().setContextClassLoader(classLoader);
@@ -264,7 +270,7 @@ public class ManagedSolrServer {
     }
     /**
      * Sets the {@link ClassLoader} of the {@link Thread#currentThread()} to the
-     * ClassLoader of {@link ManagedSolrServer} to ensure that all needed
+     * ClassLoader of {@link SolrServerAdapter} to ensure that all needed
      * Solr dependencies are loaded via the Bundle Classpath of the
      * <code>org.apache.commons.solr</code> bundle.<p>
      * Make sure that the ClassLoader is reset to the original value - as
@@ -278,7 +284,7 @@ public class ManagedSolrServer {
      *     }
      * </code></pre><p>
      * <b>TODO:</b><p>
-     * This currently sets the ClassLoader of {@link ManagedSolrServer}
+     * This currently sets the ClassLoader of {@link SolrServerAdapter}
      * to set the {@link Thread#setContextClassLoader(ClassLoader)}. It would 
      * be better to explicitly get the ClassLoader of the Bundle providing the
      * Solr Classes.
@@ -293,11 +299,17 @@ public class ManagedSolrServer {
          * (Rupert Westenthaler 20010209)
          */
         ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-        Thread.currentThread().setContextClassLoader(ManagedSolrServer.class.getClassLoader());
+        Thread.currentThread().setContextClassLoader(SolrServerAdapter.class.getClassLoader());
         return classLoader;
     }
-    protected void swap(String core1,String core2){
+    /**
+     * Swaps two cores
+     * @param core1 the first core to swap
+     * @param core2 the second core to swap
+     */
+    public void swap(String core1,String core2){
         //swap the cores
+        //TODO: what happens if one/both cores are no longer present?
         server.swap(core1, core2);
         //(re-)register the two cores
         registerCoreService(core1,null);
@@ -406,16 +418,39 @@ public class ManagedSolrServer {
     }
     
     /**
-     * Returns the ServiceReference for the {@link SolrServer} of the core
+     * Returns the ServiceReference for the {@link SolrCore} of the core
      * with the parsed name
      * @param name the name of the core
-     * @return the reference to the {@link SolrServer} or <code>null</code> if
+     * @return the reference to the {@link SolrCore} or <code>null</code> if
      * not managed.
      */
     public ServiceReference getCore(String name) {
         CoreRegistration reg = registrations.get(name);
         return reg != null ? reg.getServiceReference() : null;
     }
+    /**
+     * Returns the ServiceReference for the {@link SolrCore} of the parsed
+     * directory
+     * @param directory the directory
+     * @return the reference of <code>null</code> if no {@link SolrCore} for the
+     * parsed directory is registered for this {@link CoreContainer}.
+     */
+    public ServiceReference getCoreForDir(String directory){
+        //solr always uses ending '/'
+        if(directory.charAt(directory.length()-1) != File.separatorChar){
+            directory = directory+File.separatorChar;
+        }
+        synchronized (registrations) {
+            for(CoreRegistration reg : registrations.values()){
+                ServiceReference ref = reg.getServiceReference();
+                if(FilenameUtils.equalsNormalizedOnSystem(
+                    directory,(String)ref.getProperty(PROPERTY_CORE_DIR))){
+                    return ref;
+                }
+            }
+        }
+        return null;
+    }
 
     /**
      * Getter for a read-only list of cores that are currently managed by this
@@ -424,7 +459,8 @@ public class ManagedSolrServer {
      */
     @SuppressWarnings("unchecked")
     public Collection<String> getCores() {
-        return (Collection<String>)serverProperties.get(PROPERTY_SERVER_CORES);
+        return Collections.unmodifiableCollection(
+            (Collection<String>)serverProperties.get(PROPERTY_SERVER_CORES));
     }
 
     /**
@@ -441,6 +477,14 @@ public class ManagedSolrServer {
         Object value = serverRegistration.getReference().getProperty(PROPERTY_SERVER_NAME);
         return value == null ? null : value.toString();
     }
+    /**
+     * Getter for the {@link ServiceReference} for the {@link CoreContainer}
+     * managed by this instance
+     * @return the {@link ServiceReference}
+     */
+    public ServiceReference getServerReference(){
+        return serverRegistration.getReference();
+    }
     
     @Override
     public int hashCode() {
@@ -448,10 +492,10 @@ public class ManagedSolrServer {
     }
     @Override
     public boolean equals(Object obj) {
-        return obj instanceof ManagedSolrServer && 
-            ((ManagedSolrServer)obj).server.equals(server) &&
-            ((ManagedSolrServer)obj).context.equals(context) &&
-            ((ManagedSolrServer)obj).serverProperties.equals(serverProperties);
+        return obj instanceof SolrServerAdapter && 
+            ((SolrServerAdapter)obj).server.equals(server) &&
+            ((SolrServerAdapter)obj).context.equals(context) &&
+            ((SolrServerAdapter)obj).serverProperties.equals(serverProperties);
     }
     
     @Override
@@ -479,7 +523,7 @@ public class ManagedSolrServer {
     /**
      * Internally used to manage the OSGI service registration for
      * {@link SolrCore}s of the {@link CoreContainer} managed by this
-     * {@link ManagedSolrServer} instance
+     * {@link SolrServerAdapter} instance
      * @author Rupert Westenthaler
      *
      */
@@ -492,8 +536,8 @@ public class ManagedSolrServer {
          * @param name the name used to register the core
          * @param parsedCore the SolrCore to register
          * @throws IllegalStateException if the parsed name is <code>null</code>
-         * or empty; if the {@link ManagedSolrServer#server} does not know a
-         * SolrCore with the parsed name or if the {@link ManagedSolrServer#context}
+         * or empty; if the {@link SolrServerAdapter#server} does not know a
+         * SolrCore with the parsed name or if the {@link SolrServerAdapter#context}
          * is no longer valid
          */
         protected CoreRegistration(String name, SolrCore parsedCore) {
@@ -514,6 +558,11 @@ public class ManagedSolrServer {
             props.put(PROPERTY_CORE_SOLR_CONF, core.getConfigResource());
             props.put(PROPERTY_SERVER_NAME, serverProperties.get(PROPERTY_SERVER_NAME));
             props.put(PROPERTY_SERVER_DIR, serverProperties.get(PROPERTY_SERVER_DIR));
+            //looks like the SERVICE_PID property is not present within the metadata
+            //so we use SERVICE_ID instead. However keep on mind that SERVIVE_ID
+            //values change if a service is restarted.
+//            props.put(PROPERTY_CORE_SERVER_PID, serverRegistration.getReference().getProperty(SERVICE_PID));
+            props.put(PROPERTY_CORE_SERVER_ID, serverRegistration.getReference().getProperty(SERVICE_ID));
             Object ranking = serverProperties.get(PROPERTY_SERVER_RANKING);
             if(ranking != null)
                 props.put(PROPERTY_CORE_RANKING, ranking);
@@ -601,7 +650,7 @@ public class ManagedSolrServer {
     }
     /**
      * {@link Dictionary} implementation that provides getter and setter for
-     * typical properties configured for a {@link ManagedSolrServer}.<p>
+     * typical properties configured for a {@link SolrServerAdapter}.<p>
      * Stores its state in the {@link Dictionary} and implements {@link Cloneable}
      * @author Rupert Westenthaler
      */
@@ -691,6 +740,26 @@ public class ManagedSolrServer {
         public void setServerRanking(Integer ranking){
             properties.put(PROPERTY_SERVER_RANKING, ranking);
         }
+        
+        public boolean isPublishREST(){
+            Object value = properties.get(PROPERTY_SERVER_PUBLISH_REST);
+            if(value instanceof Boolean){
+                return ((Boolean)value).booleanValue();
+            } else if (value != null){
+                return Boolean.parseBoolean(value.toString());
+            } else {
+                return SolrConstants.DEFAULT_PUBLISH_REST;
+            }
+        }
+        
+        public void setPublishREST(Boolean state){
+            if(state == null){
+                properties.remove(PROPERTY_SERVER_PUBLISH_REST);
+            } else {
+                properties.put(PROPERTY_SERVER_PUBLISH_REST, state);
+            }
+        }
+        
         @Override
         public Enumeration<Object> elements() {
             return properties.elements();
@@ -728,7 +797,7 @@ public class ManagedSolrServer {
     /**
      * {@link Dictionary} implementation that provides getter and setter for
      * typical properties configured for a {@link SolrCore} registered to a 
-     * {@link ManagedSolrServer}.<p>
+     * {@link SolrServerAdapter}.<p>
      * Stores its state in the {@link Dictionary} and implements {@link Cloneable}
      * @author Rupert Westenthaler
      */
@@ -779,7 +848,8 @@ public class ManagedSolrServer {
             } else if(directory.isDirectory()){
                 coreProperties.put(PROPERTY_CORE_DIR, directory);
             } else {
-                throw new IllegalArgumentException("The parsed File MUST represent a Directory!");
+                throw new IllegalArgumentException("The parsed File '"+
+                    directory+"' MUST represent a Directory!");
             }
         }
         public String getCoreName(){

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

Copied: incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/impl/RESTfulSolrServerProvider.java (from r1195389, incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/impl/DefaultSolrServerProvider.java)
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/impl/RESTfulSolrServerProvider.java?p2=incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/impl/RESTfulSolrServerProvider.java&p1=incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/impl/DefaultSolrServerProvider.java&r1=1195389&r2=1205331&rev=1205331&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/impl/DefaultSolrServerProvider.java (original)
+++ incubator/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/impl/RESTfulSolrServerProvider.java Wed Nov 23 09:01:33 2011
@@ -37,7 +37,8 @@ import org.slf4j.LoggerFactory;
 
 /**
  * Implementation of the {@link SolrServerProvider} interface supporting all the types directly supported by
- * the SolrJ library. This includes all Clients using an remote SolrServer.
+ * the SolrJ library. This includes all Clients using the RESTful API of a 
+ * SolrServer.
  * <p>
  * This does not support an embedded SolrServer
  * 
@@ -46,9 +47,9 @@ import org.slf4j.LoggerFactory;
  */
 @Component(immediate = true)
 @Service
-public class DefaultSolrServerProvider implements SolrServerProvider {
+public class RESTfulSolrServerProvider implements SolrServerProvider {
 
-    private final Logger log = LoggerFactory.getLogger(DefaultSolrServerProvider.class);
+    private final Logger log = LoggerFactory.getLogger(RESTfulSolrServerProvider.class);
 
     @Override
     public SolrServer getSolrServer(SolrServerTypeEnum type, String uriOrPath, String... additional) throws NullPointerException,

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