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 2013/04/01 09:32:39 UTC

svn commit: r1463103 - in /stanbol/trunk/commons/solr: core/ core/src/main/java/org/apache/stanbol/commons/solr/ core/src/main/java/org/apache/stanbol/commons/solr/impl/ core/src/main/java/org/apache/stanbol/commons/solr/utils/ extras/icu/ extras/icu/s...

Author: rwesten
Date: Mon Apr  1 07:32:38 2013
New Revision: 1463103

URL: http://svn.apache.org/r1463103
Log:
STANBOL-1012: (1) Added OSGI enabled SolrResourceLoader that looksup Analyzer Factories as OSGI services (2) changed the SolrServerAdapter to use the OsgiSolrResourceLoader when creating SolrCores (3) added BundleActivator that registers all Analyzer Factories listed in META-INF/services files from the current module as OSGI services; STANBOL-1000: Changed the commons.solr.extras.icu module so that it does no longer export the org.apache.lucene.collation.* packages (as those are already exported by the commons.solr.core module)

Added:
    stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/impl/OsgiSolrResourceLoader.java
    stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/utils/AbstractAnalyzerFoctoryActivator.java
    stanbol/trunk/commons/solr/extras/icu/src/
    stanbol/trunk/commons/solr/extras/icu/src/main/
    stanbol/trunk/commons/solr/extras/icu/src/main/java/
    stanbol/trunk/commons/solr/extras/icu/src/main/java/org/
    stanbol/trunk/commons/solr/extras/icu/src/main/java/org/apache/
    stanbol/trunk/commons/solr/extras/icu/src/main/java/org/apache/stanbol/
    stanbol/trunk/commons/solr/extras/icu/src/main/java/org/apache/stanbol/commons/
    stanbol/trunk/commons/solr/extras/icu/src/main/java/org/apache/stanbol/commons/solr/
    stanbol/trunk/commons/solr/extras/icu/src/main/java/org/apache/stanbol/commons/solr/extras/
    stanbol/trunk/commons/solr/extras/icu/src/main/java/org/apache/stanbol/commons/solr/extras/icu/
    stanbol/trunk/commons/solr/extras/icu/src/main/java/org/apache/stanbol/commons/solr/extras/icu/impl/
    stanbol/trunk/commons/solr/extras/icu/src/main/java/org/apache/stanbol/commons/solr/extras/icu/impl/IcuAnalyzerFoctoryActivator.java
    stanbol/trunk/commons/solr/extras/kuromoji/src/
    stanbol/trunk/commons/solr/extras/kuromoji/src/main/
    stanbol/trunk/commons/solr/extras/kuromoji/src/main/java/
    stanbol/trunk/commons/solr/extras/kuromoji/src/main/java/org/
    stanbol/trunk/commons/solr/extras/kuromoji/src/main/java/org/apache/
    stanbol/trunk/commons/solr/extras/kuromoji/src/main/java/org/apache/stanbol/
    stanbol/trunk/commons/solr/extras/kuromoji/src/main/java/org/apache/stanbol/commons/
    stanbol/trunk/commons/solr/extras/kuromoji/src/main/java/org/apache/stanbol/commons/solr/
    stanbol/trunk/commons/solr/extras/kuromoji/src/main/java/org/apache/stanbol/commons/solr/extras/
    stanbol/trunk/commons/solr/extras/kuromoji/src/main/java/org/apache/stanbol/commons/solr/extras/kuromoji/
    stanbol/trunk/commons/solr/extras/kuromoji/src/main/java/org/apache/stanbol/commons/solr/extras/kuromoji/impl/
    stanbol/trunk/commons/solr/extras/kuromoji/src/main/java/org/apache/stanbol/commons/solr/extras/kuromoji/impl/KuromojiAnalyzerFoctoryActivator.java
    stanbol/trunk/commons/solr/extras/smartcn/src/
    stanbol/trunk/commons/solr/extras/smartcn/src/main/
    stanbol/trunk/commons/solr/extras/smartcn/src/main/java/
    stanbol/trunk/commons/solr/extras/smartcn/src/main/java/org/
    stanbol/trunk/commons/solr/extras/smartcn/src/main/java/org/apache/
    stanbol/trunk/commons/solr/extras/smartcn/src/main/java/org/apache/stanbol/
    stanbol/trunk/commons/solr/extras/smartcn/src/main/java/org/apache/stanbol/commons/
    stanbol/trunk/commons/solr/extras/smartcn/src/main/java/org/apache/stanbol/commons/solr/
    stanbol/trunk/commons/solr/extras/smartcn/src/main/java/org/apache/stanbol/commons/solr/extras/
    stanbol/trunk/commons/solr/extras/smartcn/src/main/java/org/apache/stanbol/commons/solr/extras/smartcn/
    stanbol/trunk/commons/solr/extras/smartcn/src/main/java/org/apache/stanbol/commons/solr/extras/smartcn/impl/
    stanbol/trunk/commons/solr/extras/smartcn/src/main/java/org/apache/stanbol/commons/solr/extras/smartcn/impl/SmartcnAnalyzerFoctoryActivator.java
    stanbol/trunk/commons/solr/extras/stempel/src/
    stanbol/trunk/commons/solr/extras/stempel/src/main/
    stanbol/trunk/commons/solr/extras/stempel/src/main/java/
    stanbol/trunk/commons/solr/extras/stempel/src/main/java/org/
    stanbol/trunk/commons/solr/extras/stempel/src/main/java/org/apache/
    stanbol/trunk/commons/solr/extras/stempel/src/main/java/org/apache/stanbol/
    stanbol/trunk/commons/solr/extras/stempel/src/main/java/org/apache/stanbol/commons/
    stanbol/trunk/commons/solr/extras/stempel/src/main/java/org/apache/stanbol/commons/solr/
    stanbol/trunk/commons/solr/extras/stempel/src/main/java/org/apache/stanbol/commons/solr/extras/
    stanbol/trunk/commons/solr/extras/stempel/src/main/java/org/apache/stanbol/commons/solr/extras/stempel/
    stanbol/trunk/commons/solr/extras/stempel/src/main/java/org/apache/stanbol/commons/solr/extras/stempel/impl/
    stanbol/trunk/commons/solr/extras/stempel/src/main/java/org/apache/stanbol/commons/solr/extras/stempel/impl/StempelAnalyzerFoctoryActivator.java
Modified:
    stanbol/trunk/commons/solr/core/pom.xml
    stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrConstants.java
    stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrServerAdapter.java
    stanbol/trunk/commons/solr/extras/icu/   (props changed)
    stanbol/trunk/commons/solr/extras/icu/pom.xml
    stanbol/trunk/commons/solr/extras/kuromoji/pom.xml
    stanbol/trunk/commons/solr/extras/smartcn/pom.xml
    stanbol/trunk/commons/solr/extras/stempel/pom.xml

Modified: stanbol/trunk/commons/solr/core/pom.xml
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/solr/core/pom.xml?rev=1463103&r1=1463102&r2=1463103&view=diff
==============================================================================
--- stanbol/trunk/commons/solr/core/pom.xml (original)
+++ stanbol/trunk/commons/solr/core/pom.xml Mon Apr  1 07:32:38 2013
@@ -97,6 +97,9 @@
               lucene-queryparser, lucene-sandbox, lucene-suggest, 
               zookeeper
             </Embed-Dependency>
+            <Private-Package>
+              org.apache.stanbol.commons.solr.impl;version=${project.version}
+            </Private-Package>
           </instructions>
         </configuration>
       </plugin>

Modified: stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrConstants.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrConstants.java?rev=1463103&r1=1463102&r2=1463103&view=diff
==============================================================================
--- stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrConstants.java (original)
+++ stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrConstants.java Mon Apr  1 07:32:38 2013
@@ -17,7 +17,10 @@
 package org.apache.stanbol.commons.solr;
 
 import java.io.File;
+import java.util.Locale;
 
+import org.apache.lucene.analysis.util.AbstractAnalysisFactory;
+import org.apache.lucene.util.Version;
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.core.SolrCore;
 import org.osgi.framework.Constants;
@@ -140,5 +143,16 @@ public final class SolrConstants {
      */
     public static final String SOLR_SCHEMA_NAME = "schema.xml";
 
+    /**
+     * Key used to store the name of the {@link AbstractAnalysisFactory}. This is
+     * the lower case version of the actual name excluding the detected
+     * suffix.<p>
+     * This property is added to {@link AbstractAnalysisFactory} instanced
+     * registered as OSGI services to workaround the SPI typically used by Solr 4
+     * to find anayzer factory instances.
+     */
+    public static final String PROPERTY_ANALYZER_FACTORY_NAME = "org.apache.lucene.analysis.factory.name";
+    
+    public static final String PROPERTY_LUCENE_MATCH_VERSION = Version.class.getName().toLowerCase(Locale.ROOT);
     
 }

Modified: stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrServerAdapter.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrServerAdapter.java?rev=1463103&r1=1463102&r2=1463103&view=diff
==============================================================================
--- stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrServerAdapter.java (original)
+++ stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/SolrServerAdapter.java Mon Apr  1 07:32:38 2013
@@ -54,7 +54,11 @@ import org.apache.commons.io.FilenameUti
 import org.apache.solr.core.CloseHook;
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.core.CoreDescriptor;
+import org.apache.solr.core.SolrConfig;
 import org.apache.solr.core.SolrCore;
+import org.apache.solr.core.SolrResourceLoader;
+import org.apache.solr.schema.IndexSchema;
+import org.apache.stanbol.commons.solr.impl.OsgiSolrResourceLoader;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
@@ -371,15 +375,23 @@ public class SolrServerAdapter {
         ClassLoader classLoader = updateContextClassLoader();
         SolrCore core;
         try {
-//            SolrResourceLoader loader = new OsgiResourceLoader(coreDir.getAbsolutePath(), 
-//                SolrServerAdapter.class.getClassLoader());
-//            SolrConfig config = new OsgiEnabledSolrConfig(loader, "solrconfig.xml", null);
-//            IndexSchema schema = new IndexSchema(config,"schema.xml",null);
+            //This API usage is based on CoreContainer#createFromLocal(..) 
+            //version 4.1
+            //Using this rather low level API is necessary to allow the usage
+            //of an own SolrResourceLoader
             CoreDescriptor coreDescriptor = new CoreDescriptor(server, 
                 coreName, coreDir.getAbsolutePath());
-//            core = new SolrCore(coreName, coreDir.getAbsolutePath(), config, schema,coreDescriptor);
-//            server.register(coreName, core, false);
-            core = server.create(coreDescriptor);
+            SolrResourceLoader loader = new OsgiSolrResourceLoader(context, coreDir.getAbsolutePath(), 
+                SolrServerAdapter.class.getClassLoader());
+            SolrConfig config = new SolrConfig(loader, coreDescriptor.getConfigName(), null);
+            IndexSchema schema = new IndexSchema(config,coreDescriptor.getSchemaName(),null);
+            core = new SolrCore(coreDescriptor.getName(), null, config, schema,coreDescriptor);
+            if (core.getUpdateHandler().getUpdateLog() != null) {
+                // always kick off recovery if we are in standalone mode.
+                core.getUpdateHandler().getUpdateLog().recoverFromLog();
+            }
+            server.register(coreName, core, false);
+            //core = server.create(coreDescriptor);
             //add the CloseHook
             core.addCloseHook(closeHook);
             // parse ture as third argument to avoid closing the current core for now

Added: stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/impl/OsgiSolrResourceLoader.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/impl/OsgiSolrResourceLoader.java?rev=1463103&view=auto
==============================================================================
--- stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/impl/OsgiSolrResourceLoader.java (added)
+++ stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/impl/OsgiSolrResourceLoader.java Mon Apr  1 07:32:38 2013
@@ -0,0 +1,106 @@
+package org.apache.stanbol.commons.solr.impl;
+
+import static org.apache.stanbol.commons.solr.SolrConstants.PROPERTY_ANALYZER_FACTORY_NAME;
+
+import java.util.Locale;
+import java.util.Properties;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.lucene.analysis.util.CharFilterFactory;
+import org.apache.lucene.analysis.util.TokenFilterFactory;
+import org.apache.lucene.analysis.util.TokenizerFactory;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.core.SolrResourceLoader;
+import org.apache.stanbol.commons.solr.SolrServerAdapter;
+import org.apache.stanbol.commons.solr.utils.AbstractAnalyzerFoctoryActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * Overrides the {@link SolrResourceLoader#findClass(String, Class, String...)}
+ * method to look for {@link TokenFilterFactory}, {@link CharFilterFactory} and
+ * {@link TokenizerFactory} registered as OSGI services.<p>
+ * This is because Solr 4 uses SPI ("META-INF/services" files) to lookup
+ * those factories and this does not work across bundles in OSGI.<p>
+ * This {@link SolrResourceLoader} variant is intended to be used together
+ * with Bundle-Activators based on the {@link AbstractAnalyzerFoctoryActivator}.
+ * <p> The {@link SolrServerAdapter} does use this class as {@link SolrResourceLoader}
+ * when creating {@link SolrCore}s.
+ * 
+ * @author Rupert Westenthaler
+ *
+ */
+public class OsgiSolrResourceLoader extends SolrResourceLoader {
+
+    /*
+     * static members form the parent implementation that are not visible to subclasses in a different package
+     */
+    static final String project = "solr";
+    static final String base = "org.apache" + "." + project;
+    private static final Pattern legacyAnalysisPattern = Pattern.compile("((\\Q" + base
+            + ".analysis.\\E)|(\\Q" + project
+            + ".\\E))([\\p{L}_$][\\p{L}\\p{N}_$]+?)(TokenFilter|Filter|Tokenizer|CharFilter)Factory");
+
+    protected final BundleContext bc;
+
+    public OsgiSolrResourceLoader(BundleContext bc, String instanceDir) {
+        super(instanceDir, OsgiSolrResourceLoader.class.getClassLoader());
+        this.bc = bc;
+    }
+
+    public OsgiSolrResourceLoader(BundleContext bc, String instanceDir, ClassLoader parent) {
+        super(instanceDir, parent);
+        this.bc = bc;
+    }
+
+    public OsgiSolrResourceLoader(BundleContext bc, String instanceDir, ClassLoader parent,
+            Properties coreProperties) {
+        super(instanceDir, parent, coreProperties);
+        this.bc = bc;
+    }
+
+    @Override
+    public <T> Class<? extends T> findClass(String cname, Class<T> expectedType, String... subpackages) {
+        Class<? extends T> clazz = null;
+        RuntimeException parentEx = null;
+        try {
+            clazz = super.findClass(cname, expectedType, subpackages);
+        } catch (RuntimeException e) {
+            parentEx = e;
+        }
+        if (clazz != null) {
+            return clazz;
+        }
+        final Matcher m = legacyAnalysisPattern.matcher(cname);
+        if (m.matches()) {
+            final String name = m.group(4);
+            log.trace("Trying to load class from analysis SPI using name='{}'", name);
+            ServiceReference[] referenced;
+            try {
+                referenced =
+                        bc.getServiceReferences(expectedType.getName(),
+                            String.format("(%s=%s)", PROPERTY_ANALYZER_FACTORY_NAME, name.toLowerCase(Locale.ROOT)));
+            } catch (InvalidSyntaxException e) {
+                throw new IllegalStateException("Unable to create Filter for Service with name '" + name
+                        + "'!", e);
+            }
+            if (referenced != null && referenced.length > 0) {
+                Object service = bc.getService(referenced[0]);
+                if (service != null) {
+                    clazz = (Class<? extends T>) service.getClass();
+                    bc.ungetService(referenced[0]); //we return the class and do not use the service
+                    return clazz;
+                }
+            }
+        }
+        if(parentEx != null) {
+            throw parentEx;
+        } else {
+            throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "Error loading class '" + cname + "'");
+        }
+    }
+
+}

Added: stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/utils/AbstractAnalyzerFoctoryActivator.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/utils/AbstractAnalyzerFoctoryActivator.java?rev=1463103&view=auto
==============================================================================
--- stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/utils/AbstractAnalyzerFoctoryActivator.java (added)
+++ stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/utils/AbstractAnalyzerFoctoryActivator.java Mon Apr  1 07:32:38 2013
@@ -0,0 +1,149 @@
+package org.apache.stanbol.commons.solr.utils;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.ServiceConfigurationError;
+
+import org.apache.lucene.analysis.util.AbstractAnalysisFactory;
+import org.apache.lucene.analysis.util.CharFilterFactory;
+import org.apache.lucene.analysis.util.TokenFilterFactory;
+import org.apache.lucene.analysis.util.TokenizerFactory;
+import org.apache.lucene.util.SPIClassIterator;
+import org.apache.lucene.util.Version;
+import org.apache.stanbol.commons.solr.SolrConstants;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * {@link BundleActivator} that initialises all {@link CharFilterFactory},
+ * {@link TokenizerFactory} and {@link TokenFilterFactory} implementations
+ * present in the current module as OSGI services. <p>
+ * Users need to extend this class, but do not need to provide any additional
+ * functionality.
+ * @author Rupert Westenthaler
+ *
+ */
+public abstract class AbstractAnalyzerFoctoryActivator implements BundleActivator {
+
+    private static Logger log = LoggerFactory.getLogger(AbstractAnalyzerFoctoryActivator.class);
+
+    public static final Map<Class<? extends AbstractAnalysisFactory>, String[]> SUFFIXES;
+    
+    static { //Defaults are based on the source code of Solr 4.1
+        Map<Class<? extends AbstractAnalysisFactory>, String[]> suffixes = 
+                new HashMap<Class<? extends AbstractAnalysisFactory>,String[]>();
+        suffixes.put(TokenFilterFactory.class, new String[] { 
+            TokenFilterFactory.class.getSimpleName(), "FilterFactory" });
+        SUFFIXES = Collections.unmodifiableMap(suffixes);
+    }
+
+    private ClassLoader classLoader;
+    private List<ServiceRegistration> charFilterFactoryRegistrations;
+    private List<ServiceRegistration> tokenizerFactoryRegistrations;
+    private List<ServiceRegistration> tokenFilterFactoryRegistrations;
+    
+    
+    protected AbstractAnalyzerFoctoryActivator(){
+        this.classLoader = getClass().getClassLoader();
+    }
+    
+    @Override
+    public void start(BundleContext context) throws Exception {
+        charFilterFactoryRegistrations = registerAnalyzerFactories(context, 
+            classLoader, CharFilterFactory.class);
+        tokenizerFactoryRegistrations = registerAnalyzerFactories(context, 
+            classLoader, TokenizerFactory.class);
+        tokenFilterFactoryRegistrations = registerAnalyzerFactories(context, 
+            classLoader, TokenFilterFactory.class);
+
+    }
+
+    @Override
+    public void stop(BundleContext context) throws Exception {
+        for(ServiceRegistration sr : charFilterFactoryRegistrations){
+            sr.unregister();
+        }
+        for(ServiceRegistration sr : tokenizerFactoryRegistrations){
+            sr.unregister();
+        }
+        for(ServiceRegistration sr : tokenFilterFactoryRegistrations){
+            sr.unregister();
+        }
+
+    }
+    
+    /**
+     * Helper class that registers Lucene 4 {@link AbstractAnalysisFactory} instances
+     * with the OSGI service registry.
+     * <p>
+     * It uses the {@link SPIClassIterator} to load instances from the provided
+     * {@link ClassLoader}. Note that only factories noted in <code>META-INF/serivces</code>
+     * files embedded within the current module will be found and registered.
+     * This means that this code needs typically be used in the Bundle Activator for 
+     * all modules providing Solr analyzer factories.     
+     * @param bc The BundleContext used to register the services
+     * @param classloader the classloader of the current modlue
+     * @param type the type of the Factories to register
+     * @return the ServiceRegistrations for the found factories
+     */
+    protected <S extends AbstractAnalysisFactory> List<ServiceRegistration> registerAnalyzerFactories(BundleContext bc, ClassLoader classloader, Class<S> type){
+        //this code is based on org.apache.lucene.analysis.util.AnalysisSPILoader
+        //but registers the loaded classes as services to the OSGI environment
+        SPIClassIterator<S> loader = SPIClassIterator.get(type, classloader);
+        String[] suffixes = SUFFIXES.get(type);
+        if(suffixes == null){
+            suffixes = new String[]{type.getSimpleName()};
+        }
+        List<ServiceRegistration> registrations = new ArrayList<ServiceRegistration>();
+        log.debug("Register {} for Bundle {}", type.getSimpleName(), bc.getBundle().getSymbolicName());
+        while (loader.hasNext()) {
+            final Class<? extends S> service = loader.next();
+            final String clazzName = service.getSimpleName();
+            String name = null;
+            for (String suffix : suffixes) {
+              if (clazzName.endsWith(suffix)) {
+                name = clazzName.substring(0, clazzName.length() - suffix.length()).toLowerCase(Locale.ROOT);
+                break;
+              }
+            }
+            if (name == null) {
+              throw new ServiceConfigurationError("The class name " + service.getName() +
+                " has wrong suffix, allowed are: " + Arrays.toString(suffixes));
+            }
+            AbstractAnalysisFactory factory;
+            try {
+                factory = service.newInstance();
+            } catch (Exception e) {
+                throw new IllegalArgumentException("SPI class of type "+ type.getName()
+                    + " with name '"+name+"' cannot be instantiated. This is likely "
+                    + "due to a misconfiguration of the java class '" 
+                    + service.getName() + "': ", e);
+            }
+            Dictionary<String,Object> prop = new Hashtable<String,Object>();
+            prop.put(SolrConstants.PROPERTY_ANALYZER_FACTORY_NAME,name);
+            Version version = factory.getLuceneMatchVersion();
+            if(version != null){
+                prop.put(SolrConstants.PROPERTY_LUCENE_MATCH_VERSION, version.name());
+            }
+            //use 0 - bundle id as service ranking. This ensures that if two
+            //factories do use the same name the one provided by the bundle with the
+            //lower id is used by default
+            int serviceRanking = 0 - (int)bc.getBundle().getBundleId();
+            prop.put(Constants.SERVICE_RANKING, serviceRanking);
+            log.debug(" ... {} (name={})",service.getName(),name);
+            registrations.add(bc.registerService(type.getName(), factory, prop));
+        }
+        return registrations;
+    }
+}

Propchange: stanbol/trunk/commons/solr/extras/icu/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Apr  1 07:32:38 2013
@@ -0,0 +1,7 @@
+target
+
+.project
+
+.settings
+
+.classpath

Modified: stanbol/trunk/commons/solr/extras/icu/pom.xml
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/solr/extras/icu/pom.xml?rev=1463103&r1=1463102&r2=1463103&view=diff
==============================================================================
--- stanbol/trunk/commons/solr/extras/icu/pom.xml (original)
+++ stanbol/trunk/commons/solr/extras/icu/pom.xml Mon Apr  1 07:32:38 2013
@@ -49,6 +49,12 @@
         <extensions>true</extensions>
         <configuration>
           <instructions>
+            <Bundle-Activator>
+              org.apache.stanbol.commons.solr.extras.icu.impl.IcuAnalyzerFoctoryActivator
+            </Bundle-Activator>
+            <Private-Package>
+                org.apache.stanbol.commons.solr.extras.icu.impl;version=${project.version}
+            </Private-Package>
             <Embed-Dependency>lucene-analyzers-icu, icu4j</Embed-Dependency>
             <Import-Package>
               *
@@ -56,9 +62,13 @@
             <!-- used instead of Export-Package to preserve the jars -->
             <_exportcontents>
               com.ibm.icu.*;version=4.8.1.1,
-              org.apache.lucene.analysis.icu.*;version=${solr-version},
-              org.apache.lucene.collation.*;version=${solr-version}
+              org.apache.lucene.analysis.icu.*;version=${solr-version}
             </_exportcontents>
+            <!-- 
+              NOTE: can not export 
+                  org.apache.lucene.collation.*;version=${solr-version} 
+              because those packages are already exported by commons.solr.core 
+               -->
           </instructions>
         </configuration>
       </plugin>
@@ -75,6 +85,11 @@
 
   <dependencies>
     <dependency>
+      <groupId>org.apache.stanbol</groupId>
+      <artifactId>org.apache.stanbol.commons.solr.core</artifactId>
+      <version>0.12.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
       <groupId>org.apache.lucene</groupId>
       <artifactId>lucene-analyzers-icu</artifactId>
     </dependency>

Added: stanbol/trunk/commons/solr/extras/icu/src/main/java/org/apache/stanbol/commons/solr/extras/icu/impl/IcuAnalyzerFoctoryActivator.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/solr/extras/icu/src/main/java/org/apache/stanbol/commons/solr/extras/icu/impl/IcuAnalyzerFoctoryActivator.java?rev=1463103&view=auto
==============================================================================
--- stanbol/trunk/commons/solr/extras/icu/src/main/java/org/apache/stanbol/commons/solr/extras/icu/impl/IcuAnalyzerFoctoryActivator.java (added)
+++ stanbol/trunk/commons/solr/extras/icu/src/main/java/org/apache/stanbol/commons/solr/extras/icu/impl/IcuAnalyzerFoctoryActivator.java Mon Apr  1 07:32:38 2013
@@ -0,0 +1,10 @@
+package org.apache.stanbol.commons.solr.extras.icu.impl;
+
+import org.apache.stanbol.commons.solr.utils.AbstractAnalyzerFoctoryActivator;
+
+public final class IcuAnalyzerFoctoryActivator extends AbstractAnalyzerFoctoryActivator {
+    
+    public IcuAnalyzerFoctoryActivator() {
+        super();
+    }
+}

Modified: stanbol/trunk/commons/solr/extras/kuromoji/pom.xml
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/solr/extras/kuromoji/pom.xml?rev=1463103&r1=1463102&r2=1463103&view=diff
==============================================================================
--- stanbol/trunk/commons/solr/extras/kuromoji/pom.xml (original)
+++ stanbol/trunk/commons/solr/extras/kuromoji/pom.xml Mon Apr  1 07:32:38 2013
@@ -49,6 +49,12 @@
         <extensions>true</extensions>
         <configuration>
           <instructions>
+            <Bundle-Activator>
+              org.apache.stanbol.commons.solr.extras.kuromoji.impl.KuromojiAnalyzerFoctoryActivator
+            </Bundle-Activator>
+            <Private-Package>
+                org.apache.stanbol.commons.solr.extras.kuromoji.impl;version=${project.version}
+            </Private-Package>
             <Embed-Dependency>lucene-analyzers-kuromoji</Embed-Dependency>
             <Import-Package>
               org.apache.lucene.analysis.ja,
@@ -80,6 +86,11 @@
 
   <dependencies>
     <dependency>
+      <groupId>org.apache.stanbol</groupId>
+      <artifactId>org.apache.stanbol.commons.solr.core</artifactId>
+      <version>0.12.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
       <groupId>org.apache.lucene</groupId>
       <artifactId>lucene-analyzers-kuromoji</artifactId>
     </dependency>

Added: stanbol/trunk/commons/solr/extras/kuromoji/src/main/java/org/apache/stanbol/commons/solr/extras/kuromoji/impl/KuromojiAnalyzerFoctoryActivator.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/solr/extras/kuromoji/src/main/java/org/apache/stanbol/commons/solr/extras/kuromoji/impl/KuromojiAnalyzerFoctoryActivator.java?rev=1463103&view=auto
==============================================================================
--- stanbol/trunk/commons/solr/extras/kuromoji/src/main/java/org/apache/stanbol/commons/solr/extras/kuromoji/impl/KuromojiAnalyzerFoctoryActivator.java (added)
+++ stanbol/trunk/commons/solr/extras/kuromoji/src/main/java/org/apache/stanbol/commons/solr/extras/kuromoji/impl/KuromojiAnalyzerFoctoryActivator.java Mon Apr  1 07:32:38 2013
@@ -0,0 +1,10 @@
+package org.apache.stanbol.commons.solr.extras.kuromoji.impl;
+
+import org.apache.stanbol.commons.solr.utils.AbstractAnalyzerFoctoryActivator;
+
+public final class KuromojiAnalyzerFoctoryActivator extends AbstractAnalyzerFoctoryActivator {
+    
+    public KuromojiAnalyzerFoctoryActivator() {
+        super();
+    }
+}

Modified: stanbol/trunk/commons/solr/extras/smartcn/pom.xml
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/solr/extras/smartcn/pom.xml?rev=1463103&r1=1463102&r2=1463103&view=diff
==============================================================================
--- stanbol/trunk/commons/solr/extras/smartcn/pom.xml (original)
+++ stanbol/trunk/commons/solr/extras/smartcn/pom.xml Mon Apr  1 07:32:38 2013
@@ -50,6 +50,12 @@
         <extensions>true</extensions>
         <configuration>
           <instructions>
+            <Bundle-Activator>
+              org.apache.stanbol.commons.solr.extras.smartcn.impl.SmartcnAnalyzerFoctoryActivator
+            </Bundle-Activator>
+            <Private-Package>
+              org.apache.stanbol.commons.solr.extras.smartcn.impl;version=${project.version}
+            </Private-Package>
             <Embed-Dependency>lucene-analyzers-smartcn</Embed-Dependency>
             <Import-Package>
               org.apache.lucene.analysis.cn.smart,
@@ -77,6 +83,11 @@
 
   <dependencies>
     <dependency>
+      <groupId>org.apache.stanbol</groupId>
+      <artifactId>org.apache.stanbol.commons.solr.core</artifactId>
+      <version>0.12.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
       <groupId>org.apache.lucene</groupId>
       <artifactId>lucene-analyzers-smartcn</artifactId>
       <!--<version>3.6.1</version>-->

Added: stanbol/trunk/commons/solr/extras/smartcn/src/main/java/org/apache/stanbol/commons/solr/extras/smartcn/impl/SmartcnAnalyzerFoctoryActivator.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/solr/extras/smartcn/src/main/java/org/apache/stanbol/commons/solr/extras/smartcn/impl/SmartcnAnalyzerFoctoryActivator.java?rev=1463103&view=auto
==============================================================================
--- stanbol/trunk/commons/solr/extras/smartcn/src/main/java/org/apache/stanbol/commons/solr/extras/smartcn/impl/SmartcnAnalyzerFoctoryActivator.java (added)
+++ stanbol/trunk/commons/solr/extras/smartcn/src/main/java/org/apache/stanbol/commons/solr/extras/smartcn/impl/SmartcnAnalyzerFoctoryActivator.java Mon Apr  1 07:32:38 2013
@@ -0,0 +1,10 @@
+package org.apache.stanbol.commons.solr.extras.smartcn.impl;
+
+import org.apache.stanbol.commons.solr.utils.AbstractAnalyzerFoctoryActivator;
+
+public final class SmartcnAnalyzerFoctoryActivator extends AbstractAnalyzerFoctoryActivator {
+    
+    public SmartcnAnalyzerFoctoryActivator() {
+        super();
+    }
+}

Modified: stanbol/trunk/commons/solr/extras/stempel/pom.xml
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/solr/extras/stempel/pom.xml?rev=1463103&r1=1463102&r2=1463103&view=diff
==============================================================================
--- stanbol/trunk/commons/solr/extras/stempel/pom.xml (original)
+++ stanbol/trunk/commons/solr/extras/stempel/pom.xml Mon Apr  1 07:32:38 2013
@@ -50,6 +50,12 @@
         <extensions>true</extensions>
         <configuration>
           <instructions>
+            <Bundle-Activator>
+              org.apache.stanbol.commons.solr.extras.stempel.impl.StempelAnalyzerFoctoryActivator
+            </Bundle-Activator>
+            <Private-Package>
+                org.apache.stanbol.commons.solr.extras.stempel.impl;version=${project.version}
+            </Private-Package>
             <Embed-Dependency>lucene-analyzers-stempel</Embed-Dependency>
             <Import-Package>
               org.apache.lucene.analysis.pl,
@@ -79,6 +85,11 @@
 
   <dependencies>
     <dependency>
+      <groupId>org.apache.stanbol</groupId>
+      <artifactId>org.apache.stanbol.commons.solr.core</artifactId>
+      <version>0.12.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
       <groupId>org.apache.lucene</groupId>
       <artifactId>lucene-analyzers-stempel</artifactId>
     </dependency>

Added: stanbol/trunk/commons/solr/extras/stempel/src/main/java/org/apache/stanbol/commons/solr/extras/stempel/impl/StempelAnalyzerFoctoryActivator.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/solr/extras/stempel/src/main/java/org/apache/stanbol/commons/solr/extras/stempel/impl/StempelAnalyzerFoctoryActivator.java?rev=1463103&view=auto
==============================================================================
--- stanbol/trunk/commons/solr/extras/stempel/src/main/java/org/apache/stanbol/commons/solr/extras/stempel/impl/StempelAnalyzerFoctoryActivator.java (added)
+++ stanbol/trunk/commons/solr/extras/stempel/src/main/java/org/apache/stanbol/commons/solr/extras/stempel/impl/StempelAnalyzerFoctoryActivator.java Mon Apr  1 07:32:38 2013
@@ -0,0 +1,10 @@
+package org.apache.stanbol.commons.solr.extras.stempel.impl;
+
+import org.apache.stanbol.commons.solr.utils.AbstractAnalyzerFoctoryActivator;
+
+public final class StempelAnalyzerFoctoryActivator extends AbstractAnalyzerFoctoryActivator {
+    
+    public StempelAnalyzerFoctoryActivator() {
+        super();
+    }
+}