Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Factor out SPI class from ProcedureGDSFacadeSPI
- Loading branch information
Showing
2 changed files
with
182 additions
and
125 deletions.
There are no files selected for viewing
175 changes: 175 additions & 0 deletions
175
community/kernel/src/main/java/org/neo4j/kernel/impl/proc/ProcedureGDBFacadeSPI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
/* | ||
* Copyright (c) 2002-2016 "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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.kernel.impl.proc; | ||
|
||
import java.net.URL; | ||
import java.util.Map; | ||
import java.util.function.Supplier; | ||
|
||
import org.neo4j.function.ThrowingFunction; | ||
import org.neo4j.graphdb.DependencyResolver; | ||
import org.neo4j.graphdb.Result; | ||
import org.neo4j.graphdb.event.KernelEventHandler; | ||
import org.neo4j.graphdb.event.TransactionEventHandler; | ||
import org.neo4j.graphdb.security.URLAccessValidationError; | ||
import org.neo4j.kernel.api.KernelTransaction; | ||
import org.neo4j.kernel.api.Statement; | ||
import org.neo4j.kernel.api.legacyindex.AutoIndexing; | ||
import org.neo4j.kernel.impl.coreapi.CoreAPIAvailabilityGuard; | ||
import org.neo4j.kernel.impl.factory.GraphDatabaseFacade; | ||
import org.neo4j.kernel.impl.query.QueryExecutionEngine; | ||
import org.neo4j.kernel.impl.query.QueryExecutionKernelException; | ||
import org.neo4j.kernel.impl.query.QuerySession; | ||
import org.neo4j.kernel.impl.store.StoreId; | ||
|
||
class ProcedureGDBFacadeSPI implements GraphDatabaseFacade.SPI | ||
{ | ||
private final KernelTransaction transaction; | ||
private final Supplier<QueryExecutionEngine> queryExecutor; | ||
|
||
private final DependencyResolver resolver; | ||
private final AutoIndexing autoIndexing; | ||
private final Supplier<StoreId> storeId; | ||
private final CoreAPIAvailabilityGuard availability; | ||
private final ThrowingFunction<URL, URL, URLAccessValidationError> urlValidator; | ||
|
||
public ProcedureGDBFacadeSPI( KernelTransaction transaction, Supplier<QueryExecutionEngine> queryExecutor, DependencyResolver resolver, AutoIndexing autoIndexing, | ||
Supplier<StoreId> storeId, CoreAPIAvailabilityGuard availability, ThrowingFunction<URL, URL, URLAccessValidationError> urlValidator ) | ||
{ | ||
this.transaction = transaction; | ||
this.queryExecutor = queryExecutor; | ||
this.resolver = resolver; | ||
this.autoIndexing = autoIndexing; | ||
this.storeId = storeId; | ||
this.availability = availability; | ||
this.urlValidator = urlValidator; | ||
} | ||
|
||
@Override | ||
public boolean databaseIsAvailable( long timeout ) | ||
{ | ||
return availability.isAvailable( timeout ); | ||
} | ||
|
||
@Override | ||
public DependencyResolver resolver() | ||
{ | ||
return resolver; | ||
} | ||
|
||
@Override | ||
public StoreId storeId() | ||
{ | ||
return storeId.get(); | ||
} | ||
|
||
@Override | ||
public String storeDir() | ||
{ | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public String name() | ||
{ | ||
return "ProcedureGraphDatabaseService"; | ||
} | ||
|
||
@Override | ||
public KernelTransaction currentTransaction() | ||
{ | ||
availability.assertDatabaseAvailable(); | ||
return transaction; | ||
} | ||
|
||
@Override | ||
public boolean isInOpenTransaction() | ||
{ | ||
return transaction.isOpen(); | ||
} | ||
|
||
@Override | ||
public Statement currentStatement() | ||
{ | ||
return transaction.acquireStatement(); | ||
} | ||
|
||
@Override | ||
public Result executeQuery( String query, Map<String, Object> parameters, QuerySession querySession ) | ||
{ | ||
try | ||
{ | ||
availability.assertDatabaseAvailable(); | ||
return queryExecutor.get().executeQuery( query, parameters, querySession ); | ||
} | ||
catch ( QueryExecutionKernelException e ) | ||
{ | ||
throw e.asUserException(); | ||
} | ||
} | ||
|
||
@Override | ||
public AutoIndexing autoIndexing() | ||
{ | ||
return autoIndexing; | ||
} | ||
|
||
@Override | ||
public void registerKernelEventHandler( KernelEventHandler handler ) | ||
{ | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public void unregisterKernelEventHandler( KernelEventHandler handler ) | ||
{ | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public <T> void registerTransactionEventHandler( TransactionEventHandler<T> handler ) | ||
{ | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public <T> void unregisterTransactionEventHandler( TransactionEventHandler<T> handler ) | ||
{ | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public URL validateURLAccess( URL url ) throws URLAccessValidationError | ||
{ | ||
return urlValidator.apply( url ); | ||
} | ||
|
||
@Override | ||
public void shutdown() | ||
{ | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public KernelTransaction beginTransaction() | ||
{ | ||
throw new UnsupportedOperationException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters