You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by bd...@apache.org on 2011/04/06 15:25:47 UTC

svn commit: r1089445 - in /incubator/stanbol/trunk/commons: ./ stanboltools/datafileprovider/ stanboltools/datafileprovider/src/ stanboltools/datafileprovider/src/main/ stanboltools/datafileprovider/src/main/java/ stanboltools/datafileprovider/src/main...

Author: bdelacretaz
Date: Wed Apr  6 13:25:46 2011
New Revision: 1089445

URL: http://svn.apache.org/viewvc?rev=1089445&view=rev
Log:
STANBOL-146 - DataFileProvider service (WIP, no OSGi console plugin yet)

Added:
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/   (with props)
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/pom.xml   (with props)
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/DataFileProvider.java   (with props)
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/DataFileProviderEvent.java   (with props)
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/DataFileProviderLog.java   (with props)
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/MainDataFileProvider.java   (with props)
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/resources/
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/resources/OSGI-INF/
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/resources/OSGI-INF/metatype/
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/resources/OSGI-INF/metatype/metatype.properties   (with props)
Modified:
    incubator/stanbol/trunk/commons/pom.xml

Modified: incubator/stanbol/trunk/commons/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/pom.xml?rev=1089445&r1=1089444&r2=1089445&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/pom.xml (original)
+++ incubator/stanbol/trunk/commons/pom.xml Wed Apr  6 13:25:46 2011
@@ -32,6 +32,7 @@
     <module>testing/http</module>
     <module>testing/stanbol</module>
     <module>stanboltools/offline</module>
+    <module>stanboltools/datafileprovider</module>
     <module>installer/bundleprovider</module>
     <!-- not in a stable state right now 
     <module>installer/jarprovider</module>

Propchange: incubator/stanbol/trunk/commons/stanboltools/datafileprovider/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Apr  6 13:25:46 2011
@@ -0,0 +1,12 @@
+target
+bin
+*.iml
+*.ipr
+*.iws
+.settings
+.project
+.classpath
+.externalToolBuilders
+maven-eclipse.xml
+
+

Added: incubator/stanbol/trunk/commons/stanboltools/datafileprovider/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/stanboltools/datafileprovider/pom.xml?rev=1089445&view=auto
==============================================================================
--- incubator/stanbol/trunk/commons/stanboltools/datafileprovider/pom.xml (added)
+++ incubator/stanbol/trunk/commons/stanboltools/datafileprovider/pom.xml Wed Apr  6 13:25:46 2011
@@ -0,0 +1,79 @@
+<?xml version="1.0"?>
+<project>
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.stanbol</groupId>
+    <artifactId>stanbol-parent</artifactId>
+    <version>0.9-SNAPSHOT</version>
+    <relativePath>../../../parent</relativePath>
+  </parent>
+
+  <groupId>org.apache.stanbol</groupId>
+  <artifactId>org.apache.stanbol.commons.stanboltools.datafileprovider</artifactId>
+  <version>0.9-SNAPSHOT</version>
+  <packaging>bundle</packaging>
+
+  <name>Apache Stanbol Data File Provider</name>
+  <description>
+    Main DataFileProvider services
+    </description>
+  <scm>
+    <connection>
+      scm:svn:http://svn.apache.org/repos/asf/incubator/stanbol/trunk/commons/stanboltools/datafileprovider
+    </connection>
+    <developerConnection>
+      scm:svn:https://svn.apache.org/repos/asf/incubator/stanbol/trunk/commons/stanboltools/datafileprovider
+    </developerConnection>
+    <url>http://incubator.apache.org/stanbol/</url>
+  </scm>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-scr-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Export-Package>org.apache.stanbol.commons.stanboltools.datafileprovider</Export-Package>
+            <Private-Package>org.apache.stanbol.commons.stanboltools.datafileprovider.impl.*</Private-Package>
+          </instructions>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>2.3.1</version>
+        <configuration>
+          <source>1.6</source>
+          <target>1.6</target>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+      <version>1.5.2</version>
+    </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.compendium</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.felix</groupId>
+      <artifactId>org.apache.felix.scr.annotations</artifactId>
+    </dependency>
+  </dependencies>
+</project>

Propchange: incubator/stanbol/trunk/commons/stanboltools/datafileprovider/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/DataFileProvider.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/DataFileProvider.java?rev=1089445&view=auto
==============================================================================
--- incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/DataFileProvider.java (added)
+++ incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/DataFileProvider.java Wed Apr  6 13:25:46 2011
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.stanbol.commons.stanboltools.datafileprovider;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Used to provide read-only data files (indexes, models etc.) from various
+ * locations (bundle resources, filesystem folders etc.) allowing users to
+ * overrides default data files with their own.
+ * 
+ * See STANBOL-146 for requirements.
+ */
+public interface DataFileProvider {
+    /** Get the InputStream of the specified
+     *  data file, according to this provider's
+     *  priority rules.
+     *  
+     *  @param bundleSymbolicName can be used to differentiate 
+     *      between files which have the same name
+     *  @param filename name of the file to open
+     *  @param downloadExplanation explains how to get the "full"
+     *      version of the data file, in case we don't find it or in
+     *      case we supply a default small variant.
+     * @return InputStream to read the file, must be closed by 
+     *      caller when done
+     * @throws IOException problem finding or reading the file
+     */
+    InputStream getInputStream(
+            String bundleSymbolicName, 
+            String filename,
+            String downloadExplanation) throws IOException;
+}

Propchange: incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/DataFileProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/DataFileProvider.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/DataFileProviderEvent.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/DataFileProviderEvent.java?rev=1089445&view=auto
==============================================================================
--- incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/DataFileProviderEvent.java (added)
+++ incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/DataFileProviderEvent.java Wed Apr  6 13:25:46 2011
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.stanbol.commons.stanboltools.datafileprovider;
+
+import java.util.Date;
+
+
+/** Used to record a log of {@link DataFileProvider} operations */
+public class DataFileProviderEvent {
+    private final Date timestamp;
+    private final String bundleSymbolicName;
+    private final String filename;
+    private final String downloadExplanation;
+    private final String loadingClass;
+    private final String actualFileLocation;
+    
+    public DataFileProviderEvent(String bundleSymbolicName, String filename, String downloadExplanation, 
+            String loadingClass, String actualFileLocation) {
+        this.timestamp = new Date();
+        this.bundleSymbolicName = bundleSymbolicName;
+        this.filename = filename;
+        this.downloadExplanation = downloadExplanation;
+        this.loadingClass = loadingClass;
+        this.actualFileLocation = actualFileLocation;
+    }
+    
+    @Override
+    public String toString() {
+        
+        final StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getName());
+
+        sb.append(", bundleSymbolicName=");
+        sb.append(bundleSymbolicName);
+        
+        sb.append(", filename=");
+        sb.append(filename);
+
+        sb.append(", loadingClass=");
+        sb.append(loadingClass);
+        
+        sb.append(", actualFileLocation=");
+        sb.append(actualFileLocation);
+        
+        return sb.toString();
+    }
+
+    /** @return the timestamp of this event */ 
+    public Date getTimestamp() {
+        return timestamp;
+    }
+
+    /** @return the bundle symbolic name that was passed to the DataFileProvider */ 
+    public String getBundleSymbolicName() {
+        return bundleSymbolicName;
+    }
+
+    /** @return the filename that was passed to the DataFileProvider */ 
+    public String getFilename() {
+        return filename;
+    }
+
+    /** @return the download explanation that was passed to the DataFileProvider */ 
+    public String getDownloadExplanation() {
+        return downloadExplanation;
+    }
+
+    /** @return the name of the class which provided the file */ 
+    public String getLoadingClass() {
+        return loadingClass;
+    }
+    
+    /** @return the actual location of the file that was loaded, empty if file was not found */ 
+    public String getActualFileLocation() {
+        return actualFileLocation;
+    }
+}

Propchange: incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/DataFileProviderEvent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/DataFileProviderEvent.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/DataFileProviderLog.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/DataFileProviderLog.java?rev=1089445&view=auto
==============================================================================
--- incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/DataFileProviderLog.java (added)
+++ incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/DataFileProviderLog.java Wed Apr  6 13:25:46 2011
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.stanbol.commons.stanboltools.datafileprovider;
+
+/** Holds the {@link DataFileProviderEvent}s generated
+ *  by the main {@link DataFileProvider}
+ */
+public interface DataFileProviderLog extends Iterable<DataFileProviderEvent> {
+    /** @return the maximum number of events that this service holds.
+     *      If the current size() is greater or equal than this, events
+     *      might have been discarded. 
+     */
+    int maxEventsCount();
+    
+    /** @return the actual number of events stored */
+    int size();
+}

Propchange: incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/DataFileProviderLog.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/DataFileProviderLog.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: 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=1089445&view=auto
==============================================================================
--- incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/MainDataFileProvider.java (added)
+++ incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/MainDataFileProvider.java Wed Apr  6 13:25:46 2011
@@ -0,0 +1,196 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.stanbol.commons.stanboltools.datafileprovider.impl;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Dictionary;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+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.Property;
+import org.apache.felix.scr.annotations.Service;
+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.Constants;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.component.ComponentContext;
+import org.osgi.util.tracker.ServiceTracker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** The main DatafileProvider, delegates to other DataFileProvider if 
+ *  the requested file is not found in its datafiles folder.
+ *  
+ *  Must have the lowest service ranking of all DatafileProvider, so
+ *  that this is the default one which delegates to others. 
+ */
+@Component(immediate=true, metatype=true)
+@Service
+@Property(name=Constants.SERVICE_RANKING, intValue=0)
+public class MainDataFileProvider implements DataFileProvider, DataFileProviderLog {
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
+    
+    @Property(value="./datafiles")
+    public static final String DATA_FILES_FOLDER_PROP = "data.files.folder";
+    private File dataFilesFolder;
+    
+    @Property(intValue=100)
+    public static final String MAX_EVENTS_PROP = "max.events";
+    private int maxEvents;
+    
+    /** List of past events, up to maxEvents in size */
+    private final List<DataFileProviderEvent> events = new LinkedList<DataFileProviderEvent>();
+    
+    /** Track providers to which we can delegate */
+    private ServiceTracker providersTracker;
+    
+    @Activate
+    protected void activate(ComponentContext ctx) throws ConfigurationException {
+        dataFilesFolder = new File(requireProperty(ctx.getProperties(), DATA_FILES_FOLDER_PROP, String.class));
+        maxEvents = requireProperty(ctx.getProperties(), MAX_EVENTS_PROP, Integer.class).intValue();
+        
+        providersTracker = new ServiceTracker(ctx.getBundleContext(), DataFileProvider.class.getName(), null);
+        providersTracker.open();
+        
+        log.info("Activated, max.events {}, data files folder {}", maxEvents, dataFilesFolder.getAbsolutePath());
+    }
+    
+    @Deactivate
+    protected void deactivate(ComponentContext ctx) {
+        if(providersTracker != null) {
+            providersTracker.close();
+            providersTracker = null;
+        }
+    }
+    
+    @SuppressWarnings("unchecked")
+    private <ResultType> ResultType requireProperty(Dictionary<?, ?> props, String name, Class<ResultType> clazz) 
+    throws ConfigurationException {
+        final Object o = props.get(name);
+        if(o == null) {
+            throw new ConfigurationException(name, "Missing required configuration property: " + name);
+        }
+        if( !( clazz.isAssignableFrom(o.getClass()))) {
+            throw new ConfigurationException(name, "Property is not a " + clazz.getName());
+        }
+        return (ResultType)o;
+    }
+
+    /** @inheritDoc */
+    @Override
+    public Iterator<DataFileProviderEvent> iterator() {
+        // Iterate on a copy of our list to avoid concurrency issues
+        final List<DataFileProviderEvent> copy = new LinkedList<DataFileProviderEvent>();
+        synchronized (events) {
+            copy.addAll(events);
+        }
+        return copy.iterator();
+    }
+
+    /** @inheritDoc */
+    @Override
+    public int maxEventsCount() {
+        return maxEvents;
+    }
+
+    /** @inheritDoc */
+    @Override
+    public int size() {
+        return events.size();
+    }
+
+    /** @inheritDoc */
+    @SuppressWarnings("unchecked")
+    @Override
+    public InputStream getInputStream(String bundleSymbolicName,
+            String filename, String downloadExplanation) throws IOException {
+        InputStream result = null;
+        String fileUrl = null;
+        String loadingClass = null;
+        
+        // First look for the file in our data folder,
+        // with and without bundle symbolic name prefix
+        final String [] candidateNames = {
+                bundleSymbolicName + "-" + filename,
+                filename
+        };
+        for(String name : candidateNames) {
+            final File f = new File(dataFilesFolder, name);
+            log.debug("Looking for file {}", f.getAbsolutePath());
+            if(f.exists() && f.canRead()) {
+                log.debug("File found in data files folder: {}", filename);
+                result = new FileInputStream(f);
+                fileUrl = "file://" + f.getAbsolutePath();
+                loadingClass = this.getClass().getName();
+                break;
+            }
+        }
+        
+        // Then, if not found, query other DataFileProviders,
+        // ordered by service ranking
+        if(result == null) {
+            // Sort providers by service ranking
+            final List<ServiceReference> refs = Arrays.asList(providersTracker.getServiceReferences());
+            Collections.sort(refs);
+            for(ServiceReference ref: refs) {
+                final Object o = providersTracker.getService(ref);
+                if(o == this) {
+                    continue;
+                }
+                final DataFileProvider dfp = (DataFileProvider)o;
+                result = dfp.getInputStream(bundleSymbolicName, filename, downloadExplanation);
+                if(result == null) {
+                    log.debug("{} does not provide file {}", dfp, filename);
+                } else {
+                    fileUrl = dfp.getClass().getName() + "://" + filename;
+                    loadingClass = dfp.getClass().getName();
+                }
+            }
+        }
+        
+        // Add event
+        final DataFileProviderEvent event = new DataFileProviderEvent(
+                bundleSymbolicName, filename, 
+                downloadExplanation, loadingClass, fileUrl);
+        
+        synchronized (events) {
+            if(events.size() >= maxEvents) {
+                events.remove(0);
+            }
+            events.add(event);
+        }
+
+        if(result == null) {
+            throw new IOException("File not found: " + filename);
+        }
+        
+        log.info("Successfully loaded file {}", event);
+        return result;
+    }
+}
\ No newline at end of file

Propchange: incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/MainDataFileProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/MainDataFileProvider.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/resources/OSGI-INF/metatype/metatype.properties
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/resources/OSGI-INF/metatype/metatype.properties?rev=1089445&view=auto
==============================================================================
--- incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/resources/OSGI-INF/metatype/metatype.properties (added)
+++ incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/resources/OSGI-INF/metatype/metatype.properties Wed Apr  6 13:25:46 2011
@@ -0,0 +1,10 @@
+org.apache.stanbol.commons.stanboltools.datafileprovider.impl.MainDataFileProvider.name = MainDataFileProvider
+org.apache.stanbol.commons.stanboltools.datafileprovider.impl.MainDataFileProvider.description = Provider of \
+	read-only data files for Stanbol components. Delegates to other DataFileProviders unless the requested \
+	file is found in its data files directory   
+
+data.files.folder.name = Data files folder 
+data.files.folder.description = Path (absolute or relative) where data files can be found
+
+max.events.name = Max. events
+max.events.description = Maximum number of DataFileProviderEvents to keep
\ No newline at end of file

Propchange: incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/resources/OSGI-INF/metatype/metatype.properties
------------------------------------------------------------------------------
    svn:eol-style = native