All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.neo4j.kernel.EmbeddedReadOnlyGraphDatabase Maven / Gradle / Ivy

/**
 * Copyright (c) 2002-2013 "Neo Technology,"
 * Network Engine for Objects in Lund AB [http://neotechnology.com]
 *
 * This file is part of Neo4j.
 *
 * Neo4j is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see .
 */
package org.neo4j.kernel;

import java.util.HashMap;
import java.util.Map;

import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.event.KernelEventHandler;
import org.neo4j.graphdb.event.TransactionEventHandler;
import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.graphdb.index.IndexProvider;
import org.neo4j.helpers.Service;
import org.neo4j.helpers.Settings;
import org.neo4j.helpers.collection.Iterables;
import org.neo4j.kernel.extension.KernelExtensionFactory;
import org.neo4j.kernel.impl.cache.CacheProvider;
import org.neo4j.kernel.impl.transaction.xaframework.TransactionInterceptorProvider;

/**
 * A read-only version of {@link EmbeddedGraphDatabase}.
 * 

* Create an instance this way: * *

 * 
 * Map config = new HashMap();
 * config.put( "read_only", "true" );
 * graphDb = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(
 *         "var/graphdb" )
 *         .setConfig( config )
 *         .newGraphDatabase();
 * 
 * 
*/ public final class EmbeddedReadOnlyGraphDatabase extends InternalAbstractGraphDatabase { private static Map readOnlyParams = new HashMap(); static { readOnlyParams.put( GraphDatabaseSettings.read_only.name(), Settings.TRUE ); } /** * A non-standard way of creating an embedded read-only * {@link GraphDatabaseService} with a set of configuration parameters. Will * most likely be removed in future releases. *

* Creates an embedded {@link GraphDatabaseService} with a store located in * storeDir. If the directory shouldn't exist or isn't a neo4j * store an exception will be thrown. * * This is deprecated. Use {@link GraphDatabaseFactory} instead. * * @param storeDir the store directory for the Neo4j store files */ @Deprecated public EmbeddedReadOnlyGraphDatabase( String storeDir ) { this( storeDir, readOnlyParams ); } /** * A non-standard way of creating an embedded read-only * {@link GraphDatabaseService} with a set of configuration parameters. Will * most likely be removed in future releases. *

* Creates an embedded {@link GraphDatabaseService} with a store located in * storeDir. If the directory shouldn't exist or isn't a neo4j * store an exception will be thrown. * * This is deprecated. Use {@link GraphDatabaseFactory} instead. * * @param storeDir the store directory for the db files * @param params configuration parameters */ @Deprecated public EmbeddedReadOnlyGraphDatabase( String storeDir, Map params ) { this( storeDir, params, Service.load( IndexProvider.class ), Iterables., KernelExtensionFactory>cast( Service.load( KernelExtensionFactory.class ) ), Service.load( CacheProvider.class ), Service.load( TransactionInterceptorProvider.class ) ); } public EmbeddedReadOnlyGraphDatabase( String storeDir, Map params, Iterable indexProviders, Iterable> kernelExtensions, Iterable cacheProviders, Iterable transactionInterceptorProviders ) { super( storeDir, addReadOnly( params ), Iterables., Class>iterable( (Class) GraphDatabaseSettings.class ), indexProviders, kernelExtensions, cacheProviders, transactionInterceptorProviders ); run(); } private static Map addReadOnly( Map params ) { params.putAll( readOnlyParams ); return params; } public KernelEventHandler registerKernelEventHandler( KernelEventHandler handler ) { throw new UnsupportedOperationException(); } public TransactionEventHandler registerTransactionEventHandler( TransactionEventHandler handler ) { throw new UnsupportedOperationException(); } public KernelEventHandler unregisterKernelEventHandler( KernelEventHandler handler ) { throw new UnsupportedOperationException(); } public TransactionEventHandler unregisterTransactionEventHandler( TransactionEventHandler handler ) { throw new UnsupportedOperationException(); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy