本文整理了Java中org.neo4j.kernel.impl.util.Dependencies.satisfyDependency()
方法的一些代码示例,展示了Dependencies.satisfyDependency()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dependencies.satisfyDependency()
方法的具体详情如下:
包路径:org.neo4j.kernel.impl.util.Dependencies
类名称:Dependencies
方法名:satisfyDependency
暂无
代码示例来源:origin: neo4j/neo4j
public void satisfyDependencies( Object... dependencies )
{
for ( Object dependency : dependencies )
{
satisfyDependency( dependency );
}
}
代码示例来源:origin: neo4j/neo4j
/**
* Puts state of a certain type.
*
* @param state state instance to set.
* @see #getState(Class)
* @throws IllegalStateException if state of this type has already been defined.
*/
public <T> void putState( T state )
{
accessibleState.put( state.getClass(), state );
dependencies.satisfyDependency( state );
}
代码示例来源:origin: neo4j/neo4j
public static QueryExecutionEngine initialize( Dependencies deps, GraphDatabaseAPI graphAPI,
Iterable<QueryEngineProvider> providers )
{
List<QueryEngineProvider> engineProviders = asList( providers );
engineProviders.sort( Comparator.comparingInt( QueryEngineProvider::enginePriority ) );
QueryEngineProvider provider = Iterables.firstOrNull( engineProviders );
if ( provider == null )
{
return noEngine();
}
QueryExecutionEngine engine = provider.createEngine( deps, graphAPI );
return deps.satisfyDependency( engine );
}
代码示例来源:origin: neo4j/neo4j
private static <T> T dependency( Dependencies dependencies, Class<T> type, Function<DependencyResolver,T> defaultSupplier )
{
try
{
return dependencies.resolveDependency( type );
}
catch ( IllegalArgumentException | UnsatisfiedDependencyException e )
{
return dependencies.satisfyDependency( defaultSupplier.apply( dependencies ) );
}
}
代码示例来源:origin: neo4j/neo4j
private void buildTransactionMonitor( KernelTransactions kernelTransactions, Clock clock, Config config )
{
KernelTransactionMonitor kernelTransactionTimeoutMonitor = new KernelTransactionMonitor( kernelTransactions, clock, logService );
dataSourceDependencies.satisfyDependency( kernelTransactionTimeoutMonitor );
KernelTransactionMonitorScheduler transactionMonitorScheduler =
new KernelTransactionMonitorScheduler( kernelTransactionTimeoutMonitor, scheduler,
config.get( GraphDatabaseSettings.transaction_monitor_check_interval ).toMillis() );
life.add( transactionMonitorScheduler );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void givenSatisfiedTypeInParentAndDependenciesWhenResolveWithTypeInDependenciesThenInstanceReturned()
{
// Given
Dependencies parent = new Dependencies( );
Dependencies dependencies = new Dependencies( parent );
Collection foo = new ArrayList( );
dependencies.satisfyDependency( foo );
parent.satisfyDependency( new ArrayList());
// When
Collection instance = dependencies.resolveDependency( Collection.class );
// Then
assertThat(instance, equalTo(foo));
}
代码示例来源:origin: neo4j/neo4j
@Test
void shouldNotSupportMultipleProvidersWithSameDescriptor()
{
// given
IndexProviderDescriptor descriptor = new IndexProviderDescriptor( "provider", "1.2" );
IndexProvider provider1 = mock( IndexProvider.class );
when( provider1.getProviderDescriptor() ).thenReturn( descriptor );
IndexProvider provider2 = mock( IndexProvider.class );
when( provider2.getProviderDescriptor() ).thenReturn( descriptor );
Dependencies dependencies = new Dependencies();
dependencies.satisfyDependency( provider1 );
dependencies.satisfyDependency( provider2 );
// when
assertThrows( IllegalArgumentException.class, () -> createDefaultProviderMap( dependencies, descriptor ).init() );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void givenSatisfiedTypeWhenResolveWithSuperTypeThenInstanceReturned()
{
// Given
Dependencies dependencies = new Dependencies( );
AbstractList foo = new ArrayList( );
dependencies.satisfyDependency( foo );
// When
AbstractList instance = dependencies.resolveDependency( AbstractList.class );
// Then
assertThat(instance, equalTo(foo));
}
代码示例来源:origin: neo4j/neo4j
@Test
public void givenSatisfiedTypeWhenResolveWithInterfaceThenInstanceReturned()
{
// Given
Dependencies dependencies = new Dependencies( );
List foo = new ArrayList( );
dependencies.satisfyDependency( foo );
// When
List instance = dependencies.resolveDependency( List.class );
// Then
assertThat(instance, equalTo(foo));
}
代码示例来源:origin: neo4j/neo4j
@Test
public void givenSatisfiedTypeWhenResolveWithSubInterfaceThenInstanceReturned()
{
// Given
Dependencies dependencies = new Dependencies( );
Collection foo = new ArrayList( );
dependencies.satisfyDependency( foo );
// When
Collection instance = dependencies.resolveDependency( Collection.class );
// Then
assertThat(instance, equalTo(foo));
}
代码示例来源:origin: neo4j/neo4j
@Override
public void init()
{
for ( KernelExtensionFactory<?> kernelExtensionFactory : kernelExtensionFactories )
{
try
{
Object kernelExtensionDependencies = getKernelExtensionDependencies( kernelExtensionFactory );
Lifecycle dependency = newInstance( kernelContext, kernelExtensionFactory, kernelExtensionDependencies );
Objects.requireNonNull( dependency, kernelExtensionFactory.toString() + " returned a null KernelExtension" );
life.add( dependencies.satisfyDependency( dependency ) );
}
catch ( UnsatisfiedDependencyException exception )
{
kernelExtensionFailureStrategy.handle( kernelExtensionFactory, exception );
}
catch ( Throwable throwable )
{
kernelExtensionFailureStrategy.handle( kernelExtensionFactory, throwable );
}
}
life.init();
}
代码示例来源:origin: neo4j/neo4j
@Test
public void givenSatisfiedTypeWhenResolveWithTypeThenInstanceReturned()
{
// Given
Dependencies dependencies = new Dependencies( );
String foo = "foo";
dependencies.satisfyDependency( foo );
// When
String instance = dependencies.resolveDependency( String.class );
// Then
assertThat(instance, equalTo(foo));
}
代码示例来源:origin: neo4j/neo4j
@Test
public void givenSatisfiedTypeInParentWhenResolveWithTypeInEmptyDependenciesThenInstanceReturned()
{
// Given
Dependencies parent = new Dependencies( );
Dependencies dependencies = new Dependencies( parent );
Collection foo = new ArrayList( );
dependencies.satisfyDependency( foo );
// When
Collection instance = dependencies.resolveDependency( Collection.class );
// Then
assertThat(instance, equalTo(foo));
}
代码示例来源:origin: neo4j/neo4j
@Test
public void flushOfThePageCacheOnShutdownDoesNotHappenIfTheDbIsUnhealthy() throws Throwable
{
DatabaseHealth health = mock( DatabaseHealth.class );
when( health.isHealthy() ).thenReturn( false );
PageCache pageCache = spy( pageCacheRule.getPageCache( fs.get() ) );
Dependencies dependencies = new Dependencies();
dependencies.satisfyDependency( health );
NeoStoreDataSource ds = dsRule.getDataSource( dir.databaseLayout(), fs.get(), pageCache, dependencies );
ds.start();
verify( pageCache, never() ).flushAndForce();
ds.stop();
ds.shutdown();
verify( pageCache, never() ).flushAndForce( IOLimiter.UNLIMITED );
}
代码示例来源:origin: neo4j/neo4j
private LifeSupport initializeExtensions( Dependencies dependencies )
{
LifeSupport extensionsLife = new LifeSupport();
extensionsLife.add( new DatabaseKernelExtensions( new SimpleKernelContext( databaseLayout.databaseDirectory(), databaseInfo, dependencies ),
kernelExtensionFactories, dependencies, fail() ) );
indexProviderMap = extensionsLife.add( new DefaultIndexProviderMap( dependencies, config ) );
dependencies.satisfyDependency( indexProviderMap );
extensionsLife.init();
return extensionsLife;
}
代码示例来源:origin: neo4j/neo4j
@Test
void shouldThrowOnLookupOnUnknownProvider()
{
// given
IndexProvider provider = mock( IndexProvider.class );
IndexProviderDescriptor descriptor = new IndexProviderDescriptor( "provider", "1.2" );
when( provider.getProviderDescriptor() ).thenReturn( descriptor );
Dependencies dependencies = new Dependencies();
dependencies.satisfyDependency( provider );
// when
DefaultIndexProviderMap defaultIndexProviderMap = createDefaultProviderMap( dependencies, descriptor );
defaultIndexProviderMap.init();
assertThrows( IndexProviderNotFoundException.class, () -> defaultIndexProviderMap.lookup( new IndexProviderDescriptor( "provider2", "1.2" ) ) );
}
代码示例来源:origin: neo4j/neo4j
@Override
protected QueryExecutionEngine createEngine( Dependencies deps, GraphDatabaseAPI graphAPI )
{
GraphDatabaseCypherService queryService = new GraphDatabaseCypherService( graphAPI );
deps.satisfyDependency( queryService );
DependencyResolver resolver = graphAPI.getDependencyResolver();
LogService logService = resolver.resolveDependency( LogService.class );
Monitors monitors = resolver.resolveDependency( Monitors.class );
Config config = resolver.resolveDependency( Config.class );
CypherConfiguration cypherConfig = CypherConfiguration.fromConfig( config );
CypherPlannerConfiguration plannerConfig = cypherConfig.toCypherPlannerConfiguration( config );
CypherRuntimeConfiguration runtimeConfig = cypherConfig.toCypherRuntimeConfiguration();
LogProvider logProvider = logService.getInternalLogProvider();
CommunityCompilerFactory compilerFactory =
new CommunityCompilerFactory( queryService, monitors, logProvider, plannerConfig, runtimeConfig );
deps.satisfyDependencies( compilerFactory );
return createEngine( queryService, config, logProvider, compilerFactory );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void buildDefaultContextWithDependencies() throws IOException
{
SimpleLogVersionRepository logVersionRepository = new SimpleLogVersionRepository( 2 );
SimpleTransactionIdStore transactionIdStore = new SimpleTransactionIdStore();
Dependencies dependencies = new Dependencies();
dependencies.satisfyDependency( logVersionRepository );
dependencies.satisfyDependency( transactionIdStore );
TransactionLogFilesContext context =
builder( testDirectory.databaseLayout(), fileSystem ).withDependencies( dependencies ).buildContext();
assertEquals( fileSystem, context.getFileSystem() );
assertNotNull( context.getLogEntryReader() );
assertSame( LogFileCreationMonitor.NO_MONITOR, context.getLogFileCreationMonitor() );
assertEquals( ByteUnit.mebiBytes( 250 ), context.getRotationThreshold().get() );
assertEquals( 1, context.getLastCommittedTransactionId() );
assertEquals( 2, context.getLogVersionRepository().getCurrentLogVersion() );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void databaseHealthShouldBeHealedOnStart() throws Throwable
{
NeoStoreDataSource theDataSource = null;
try
{
DatabaseHealth databaseHealth = new DatabaseHealth( mock( DatabasePanicEventGenerator.class ),
NullLogProvider.getInstance().getLog( DatabaseHealth.class ) );
Dependencies dependencies = new Dependencies();
dependencies.satisfyDependency( databaseHealth );
theDataSource = dsRule.getDataSource( dir.databaseLayout(), fs.get(), pageCacheRule.getPageCache( fs.get() ),
dependencies );
databaseHealth.panic( new Throwable() );
theDataSource.start();
databaseHealth.assertHealthy( Throwable.class );
}
finally
{
if ( theDataSource != null )
{
theDataSource.stop();
theDataSource.shutdown();
}
}
}
代码示例来源:origin: neo4j/neo4j
private void initializeStores( DatabaseLayout databaseLayout, Map<String,String> additionalConfig ) throws IOException
{
Dependencies dependencies = new Dependencies();
dependencies.satisfyDependency( Config.defaults( additionalConfig ) );
ds = dsRule.getDataSource( databaseLayout, fs.get(), pageCache, dependencies );
ds.start();
NeoStores neoStores = ds.getDependencyResolver()
.resolveDependency( RecordStorageEngine.class ).testAccessNeoStores();
pStore = neoStores.getPropertyStore();
rtStore = neoStores.getRelationshipTypeTokenStore();
relStore = neoStores.getRelationshipStore();
nodeStore = neoStores.getNodeStore();
storageReader = ds.getDependencyResolver().resolveDependency( StorageEngine.class ).newReader();
}
内容来源于网络,如有侵权,请联系作者删除!