Search in sources :

Example 1 with Injectable

use of org.neo4j.server.plugins.Injectable in project neo4j by neo4j.

the class ExtensionInitializer method initializePackages.

public Collection<Injectable<?>> initializePackages(Iterable<String> packageNames) {
    GraphDatabaseAPI graphDatabaseService = neoServer.getDatabase().getGraph();
    Config configuration = neoServer.getConfig();
    Collection<Injectable<?>> injectables = new HashSet<>();
    for (PluginLifecycle lifecycle : lifecycles) {
        if (hasPackage(lifecycle, packageNames)) {
            if (lifecycle instanceof SPIPluginLifecycle) {
                SPIPluginLifecycle lifeCycleSpi = (SPIPluginLifecycle) lifecycle;
                injectables.addAll(lifeCycleSpi.start(neoServer));
            } else {
                injectables.addAll(lifecycle.start(graphDatabaseService, new ConfigAdapter(configuration)));
            }
        }
    }
    return injectables;
}
Also used : Injectable(org.neo4j.server.plugins.Injectable) SPIPluginLifecycle(org.neo4j.server.plugins.SPIPluginLifecycle) PluginLifecycle(org.neo4j.server.plugins.PluginLifecycle) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) ConfigAdapter(org.neo4j.server.plugins.ConfigAdapter) Config(org.neo4j.kernel.configuration.Config) SPIPluginLifecycle(org.neo4j.server.plugins.SPIPluginLifecycle) HashSet(java.util.HashSet)

Example 2 with Injectable

use of org.neo4j.server.plugins.Injectable in project neo4j by neo4j.

the class ExtensionInitializerTest method testPluginInitialization.

@Test
public void testPluginInitialization() {
    Config config = Config.embeddedDefaults(stringMap(ServerSettings.transaction_idle_timeout.name(), "600"));
    NeoServer neoServer = Mockito.mock(NeoServer.class, Mockito.RETURNS_DEEP_STUBS);
    Mockito.when(neoServer.getConfig()).thenReturn(config);
    ExtensionInitializer extensionInitializer = new ExtensionInitializer(neoServer);
    Collection<Injectable<?>> injectableProperties = extensionInitializer.initializePackages(Arrays.asList("org.neo4j.server.modules"));
    assertTrue(injectableProperties.stream().anyMatch(i -> ServerSettings.transaction_idle_timeout.name().equals(i.getValue())));
}
Also used : NeoServer(org.neo4j.server.NeoServer) Configuration(org.apache.commons.configuration.Configuration) Arrays(java.util.Arrays) Config(org.neo4j.kernel.configuration.Config) Collection(java.util.Collection) ServerSettings(org.neo4j.server.configuration.ServerSettings) Iterators(org.neo4j.helpers.collection.Iterators) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Function(java.util.function.Function) NeoServer(org.neo4j.server.NeoServer) Mockito(org.mockito.Mockito) Injectable(org.neo4j.server.plugins.Injectable) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) PluginLifecycle(org.neo4j.server.plugins.PluginLifecycle) MapUtil.stringMap(org.neo4j.helpers.collection.MapUtil.stringMap) Injectable(org.neo4j.server.plugins.Injectable) Config(org.neo4j.kernel.configuration.Config) Test(org.junit.Test)

Aggregations

Config (org.neo4j.kernel.configuration.Config)2 Injectable (org.neo4j.server.plugins.Injectable)2 PluginLifecycle (org.neo4j.server.plugins.PluginLifecycle)2 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 Function (java.util.function.Function)1 Configuration (org.apache.commons.configuration.Configuration)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Test (org.junit.Test)1 Mockito (org.mockito.Mockito)1 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)1 Iterators (org.neo4j.helpers.collection.Iterators)1 MapUtil.stringMap (org.neo4j.helpers.collection.MapUtil.stringMap)1 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)1 NeoServer (org.neo4j.server.NeoServer)1 ServerSettings (org.neo4j.server.configuration.ServerSettings)1 ConfigAdapter (org.neo4j.server.plugins.ConfigAdapter)1 SPIPluginLifecycle (org.neo4j.server.plugins.SPIPluginLifecycle)1