Search in sources :

Example 16 with ComponentContext

use of org.osgi.service.component.ComponentContext in project stanbol by apache.

the class WeightedChain method addingService.

@Override
public Object addingService(ServiceReference reference) {
    invalidateExecutionPlan();
    ComponentContext context = this.context;
    if (context != null) {
        return context.getBundleContext().getService(reference);
    } else {
        log.warn("Unable to get EnhancementEngine for Reference {} because" + "this {} seams already be deactivated -> return null", reference.getProperty(EnhancementEngine.PROPERTY_NAME), toString());
        return null;
    }
}
Also used : ComponentContext(org.osgi.service.component.ComponentContext)

Example 17 with ComponentContext

use of org.osgi.service.component.ComponentContext in project stanbol by apache.

the class WeightedChain method removedService.

@Override
public void removedService(ServiceReference reference, Object service) {
    invalidateExecutionPlan();
    ComponentContext context = this.context;
    if (context != null) {
        context.getBundleContext().ungetService(reference);
    }
}
Also used : ComponentContext(org.osgi.service.component.ComponentContext)

Example 18 with ComponentContext

use of org.osgi.service.component.ComponentContext in project stanbol by apache.

the class TokenizerAndTokenFIlterTest method init.

@BeforeClass
public static void init() throws ConfigurationException {
    Dictionary<String, Object> config = new Hashtable<String, Object>();
    config.put(LuceneLabelTokenizer.PROPERTY_TOKENIZER_FACTORY, TOKENIZER_FACTORY_CLASS);
    config.put(LuceneLabelTokenizer.PROPERTY_TOKEN_FILTER_FACTORY, TOKEN_FILTER_FACTORY_CLASSES);
    config.put(LabelTokenizer.SUPPORTED_LANUAGES, "zh");
    ComponentContext cc = new MockComponentContext(config);
    luceneLabelTokenizer = new LuceneLabelTokenizer();
    luceneLabelTokenizer.activate(cc);
}
Also used : LuceneLabelTokenizer(org.apache.stanbol.enhancer.engines.entitylinking.labeltokenizer.lucene.LuceneLabelTokenizer) ComponentContext(org.osgi.service.component.ComponentContext) Hashtable(java.util.Hashtable) BeforeClass(org.junit.BeforeClass)

Example 19 with ComponentContext

use of org.osgi.service.component.ComponentContext in project stanbol by apache.

the class LuceneLabelTokenizerTest method init.

@BeforeClass
public static void init() throws ConfigurationException {
    Dictionary<String, Object> config = new Hashtable<String, Object>();
    config.put(LuceneLabelTokenizer.PROPERTY_TOKENIZER_FACTORY, TOKENIZER_FACTORY_CLASS);
    config.put(LabelTokenizer.SUPPORTED_LANUAGES, "en");
    ComponentContext cc = new MockComponentContext(config);
    luceneLabelTokenizer = new LuceneLabelTokenizer();
    luceneLabelTokenizer.activate(cc);
}
Also used : LuceneLabelTokenizer(org.apache.stanbol.enhancer.engines.entitylinking.labeltokenizer.lucene.LuceneLabelTokenizer) ComponentContext(org.osgi.service.component.ComponentContext) Hashtable(java.util.Hashtable) BeforeClass(org.junit.BeforeClass)

Example 20 with ComponentContext

use of org.osgi.service.component.ComponentContext in project stanbol by apache.

the class OpenNlpLabelTokenizerTest method init.

@BeforeClass
public static final void init() throws ConfigurationException {
    Dictionary<String, Object> config = new Hashtable<String, Object>();
    config.put(LabelTokenizer.SUPPORTED_LANUAGES, "*");
    ComponentContext cc = new MockComponentContext(config);
    tokenizer = new OpenNlpLabelTokenizer();
    tokenizer.openNlp = new OpenNLP(new ClasspathDataFileProvider(null));
    tokenizer.activate(cc);
}
Also used : ComponentContext(org.osgi.service.component.ComponentContext) OpenNLP(org.apache.stanbol.commons.opennlp.OpenNLP) Hashtable(java.util.Hashtable) BeforeClass(org.junit.BeforeClass)

Aggregations

ComponentContext (org.osgi.service.component.ComponentContext)35 Test (org.junit.Test)16 Dictionary (java.util.Dictionary)14 BundleContext (org.osgi.framework.BundleContext)11 Hashtable (java.util.Hashtable)5 Expectations (org.jmock.Expectations)4 HashMap (java.util.HashMap)3 ContentItem (org.apache.stanbol.enhancer.servicesapi.ContentItem)3 StringSource (org.apache.stanbol.enhancer.servicesapi.impl.StringSource)3 BeforeClass (org.junit.BeforeClass)3 ServiceReference (org.osgi.framework.ServiceReference)3 IRI (org.apache.clerezza.commons.rdf.IRI)2 RDFTerm (org.apache.clerezza.commons.rdf.RDFTerm)2 LuceneLabelTokenizer (org.apache.stanbol.enhancer.engines.entitylinking.labeltokenizer.lucene.LuceneLabelTokenizer)2 Mockery (org.jmock.Mockery)2 JUnit4Mockery (org.jmock.integration.junit4.JUnit4Mockery)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 InputStream (java.io.InputStream)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1