protected ServiceFinder serviceFinder() { return moduleInstance.serviceFinder(); }
protected ServiceFinder serviceFinder() { return moduleInstance.serviceFinder(); }
public ScriptMixin( @Structure PolygeneSPI spi, @This Object thisComposite, @State StateHolder state, @Structure Layer layer, @Structure Module module, @Structure Application application ) { descriptor = spi.compositeDescriptorFor( thisComposite ); engine = createNewEngine(); Bindings mixinBindings = engine.getBindings( ScriptContext.ENGINE_SCOPE ); mixinBindings.put( "Polygene", spi ); mixinBindings.put( "application", application ); mixinBindings.put( "layer", layer ); mixinBindings.put( "module", module ); mixinBindings.put( "This", thisComposite ); mixinBindings.put( "state", state ); mixinBindings.put( "objectFactory", module.objectFactory() ); mixinBindings.put( "unitOfWorkFactory", module.unitOfWorkFactory() ); mixinBindings.put( "valueBuilderFactory", module.valueBuilderFactory() ); mixinBindings.put( "transientBuilderFactory", module.transientBuilderFactory() ); mixinBindings.put( "serviceFinder", module.serviceFinder() ); mixinBindings.put( "typeLookup", module.typeLookup() ); }
private Client findClient( Module module ) { Client client = module.serviceFinder().findService( ElasticSearchSupport.class ).get().client(); if( client == null ) { throw new IllegalStateException( "Embedded Elasticsearch Rule - Failed to find client" ); } return client; } }
if( value instanceof String && !propertyType.equals( String.class ) ) ServiceFinder serviceFinder = module.instance().serviceFinder(); Deserializer deserializer = serviceFinder.findService( Deserializer.class ).get(); if( deserializer != null )
@Override public void tearDown() throws Exception { Module storageModule = application.findModule( "Infrastructure Layer", "Storage Module" ); UnitOfWorkFactory uowf = storageModule.unitOfWorkFactory(); ServiceFinder serviceFinder = storageModule.serviceFinder(); UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Delete " + getClass().getSimpleName() + " test data" ) ); try { SQLConfiguration config = uow.get( SQLConfiguration.class, DEFAULT_ENTITYSTORE_IDENTITY ); Connection connection = serviceFinder.findService( DataSource.class ).get().getConnection(); connection.setAutoCommit( false ); String schemaName = config.schemaName().get(); try( Statement stmt = connection.createStatement() ) { stmt.execute( String.format( "DROP SCHEMA \"%s\" CASCADE", schemaName ) ); connection.commit(); } } finally { uow.discard(); super.tearDown(); } } }
@Override public void tearDown() throws Exception { Module storageModule = application.findModule( "Infrastructure Layer","Storage Module" ); UnitOfWorkFactory uowf = storageModule.unitOfWorkFactory(); UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Delete " + getClass().getSimpleName() + " test data" ) ); try { SQLEntityStoreConfiguration config = uow.get( SQLEntityStoreConfiguration.class, DEFAULT_ENTITYSTORE_IDENTITY ); Connection connection = storageModule.serviceFinder().findService( DataSource.class ).get().getConnection(); connection.setAutoCommit( false ); try( Statement stmt = connection.createStatement() ) { stmt.execute( String.format( "DELETE FROM %s.%s", config.schemaName().get(), config.entityTableName().get() ) ); connection.commit(); } } finally { uow.discard(); super.tearDown(); } } }
ServiceFinder serviceFinder = storageModule.serviceFinder(); UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Delete " + getClass().getSimpleName() + " test data" )
@Override public void tearDown() throws Exception { Module module = application.findModule( "Infrastructure Layer", "Storage Module" ); ServiceReference<CanRemoveAll> cleaner = module.serviceFinder().findService( CanRemoveAll.class ); if( cleaner.isActive() && cleaner.isAvailable() ) { cleaner.get().removeAll(); } else { throw new IllegalStateException( "Clean up operation of Cassandra database was not availeble." ); } super.tearDown(); } }
@Override public void setUp() throws Exception { super.setUp(); Module storageModule = application.findModule( "Infrastructure Layer", "Storage Module" ); MongoDBEntityStoreService es = storageModule.serviceFinder().findService( MongoDBEntityStoreService.class ).get(); mongo = es.mongoInstanceUsed(); dbName = es.dbInstanceUsed().getName(); }