private ApplicationPassivationThread( Application application, PrintStream output, Logger logger ) { super( new ApplicationPassivation( application, output, logger ), application.name() + " Passivation Thread" ); }
protected Module metricsModule() { return application.findModule( "infra", "metrics" ); }
public void start() throws ActivationException { application.activate(); }
@Override public void activateService() throws IOException { File tmp; if( fileConfig == null ) { tmp = new File( "polygene", app.name() + "-" + app.version() ); } else { tmp = fileConfig.temporaryDirectory(); } workDir = new File( tmp, "uowfile-" + me.identity().get() ); if( !workDir.exists() && !workDir.mkdirs() ) { throw new IOException( "Unable to create temporary directory: " + workDir ); } }
@Override public void run() { try { application.passivate(); } catch( PassivationException ex ) { String message = application.name() + " " + ex.getMessage(); if( logger != null ) { logger.log( Level.SEVERE, message, ex ); } else if( output != null ) { output.println( message ); ex.printStackTrace( output ); } else { ex.printStackTrace(); } } }
protected final void assertUowTimer( MetricValuesProvider metrics ) throws PassivationException, ActivationException { Long initialUowCount = metrics.timerCount( UOW_TIMER_NAME ); runScenario1(); assertThat( UOW_TIMER_NAME + " count incremented by 3", metrics.timerCount( UOW_TIMER_NAME ), is( initialUowCount + 3L ) ); application.passivate(); application.activate(); assertThat( UOW_TIMER_NAME + " count reset on passivation", metrics.timerCount( UOW_TIMER_NAME ), equalTo( initialUowCount ) ); }
@Test public void canCreateAndQueryWithAllInMemory() throws Exception { Application application = createApplication( inMemoryRdf, inMemoryStore, domain ); try { application.activate(); Module domain = application.findModule( "Domain", "Domain" ); UnitOfWorkFactory unitOfWorkFactory = domain.unitOfWorkFactory(); createABunchOfStuffAndDoQueries( unitOfWorkFactory, domain ); } finally { application.passivate(); } }
public void stop() throws PassivationException { application.passivate(); }
public static void main( String[] args ) throws Exception { Energy4Java polygene = new Energy4Java( ); Server server = new Server( Protocol.HTTP, 8888 ); Application app = polygene.newApplication( new ForumAssembler(), new MetadataService() ); app.activate(); ContextRestlet restlet = app.findModule( "REST", "Restlet" ).newObject( ContextRestlet.class, new org.restlet.Context() ); ChallengeAuthenticator guard = new ChallengeAuthenticator(null, ChallengeScheme.HTTP_BASIC, "testRealm"); MapVerifier mapVerifier = new MapVerifier(); mapVerifier.getLocalSecrets().put("rickard", "secret".toCharArray()); guard.setVerifier(mapVerifier); guard.setNext(restlet); server.setNext( restlet ); server.start(); } }
@SuppressWarnings( "SameParameterValue" ) protected void addEntityInfoToInsertToEntityTablePS( EntityState state, PreparedStatement ps, int startingIndex ) throws SQLException { ps.setString( startingIndex, state.entityReference().identity().toString() ); ps.setTimestamp( startingIndex + 1, Timestamp.from( state.lastModified() ) ); ps.setString( startingIndex + 2, state.version() ); ps.setString( startingIndex + 3, this._app.version() ); }
for( ActivationEventListener activationListener : activationListeners ) application.registerActivationEventListener( activationListener ); application.activate(); if( passivationShutdownHook )
public ServiceFactoryBean( Application anApplication, String aServiceId ) throws IllegalArgumentException { notNull( anApplication, "Argument [anApplication] must not be [null]." ); notNull( aServiceId, "Argument [aServiceId] must not be [null]." ); ServiceLocator serviceLocator = new ServiceLocator( aServiceId ); anApplication.descriptor().accept( serviceLocator ); serviceReference = serviceLocator.locateService( anApplication ); if( serviceReference == null ) { throw new IllegalArgumentException( "Polygene service with id [" + aServiceId + "] is not found." ); } }
@Override public void beforeActivation( Application application ) { application.registerActivationEventListener( System.out::println ); } };
@Override protected String hostnames() { switch( application.mode() ) { case development: return "localhost:9042"; case staging: return "cassandra.staging:9042"; case production: return "cassandra1.prod:9042,cassandra2.prod:9042,cassandra3.prod:9042"; case test: default: return "cassandra.test:9042"; } } }
@Test public void canCreateAndQueryWithNativeRdfWithInMemoryStore() throws Exception { Application application = createApplication( nativeRdf, inMemoryStore, domain ); try { application.activate(); Module domain = application.findModule( "Domain", "Domain" ); UnitOfWorkFactory unitOfWorkFactory = domain.unitOfWorkFactory(); createABunchOfStuffAndDoQueries( unitOfWorkFactory, domain ); } finally { application.passivate(); } }
public void stop() throws PassivationException { application.passivate(); }
@Override public void run() { try { application.passivate(); } catch( PassivationException ex ) { String message = application.name() + " " + ex.getMessage(); if( logger != null ) { logger.log( Level.SEVERE, message, ex ); } else if( output != null ) { output.println( message ); ex.printStackTrace( output ); } else { ex.printStackTrace(); } } }
protected final void assertUowTimer( MetricValuesProvider metrics ) throws PassivationException, ActivationException { Long initialUowCount = metrics.timerCount( UOW_TIMER_NAME ); runScenario1(); assertThat( UOW_TIMER_NAME + " count incremented by 3", metrics.timerCount( UOW_TIMER_NAME ), is( initialUowCount + 3L ) ); application.passivate(); application.activate(); assertThat( UOW_TIMER_NAME + " count reset on passivation", metrics.timerCount( UOW_TIMER_NAME ), equalTo( initialUowCount ) ); }
@Test public void validateThatAssemblerCreatesApplication() throws AssemblyException, ActivationException { TestApplication assembler = new TestApplication( "Test Application", "1.0.1", Application.Mode.test ); assembler.initialize(); assembler.start(); assertThat( assembler.application().name(), equalTo("Test Application") ); assertThat( assembler.application().version(), equalTo("1.0.1") ); } }