[New] Added StrolchComponent.getConfiguration()

- and thus removed any instance variables to it in subclasses
This commit is contained in:
Robert von Burg 2015-07-10 10:48:17 +02:00
parent acd679636a
commit 29a88fe6ab
5 changed files with 19 additions and 11 deletions

@ -1 +1 @@
Subproject commit 0c7315b713edb81442208c2b347c6432a3b6bc70
Subproject commit 21d640e081b3a32f7d668d39862014d4b629c1b9

@ -1 +1 @@
Subproject commit 2e58db83fd35fea958431d7a2e9edae14ff6a20b
Subproject commit 35bbb04d89cd6bd60ecf2ff1b49dba38a68f33a2

View File

@ -33,6 +33,7 @@ public class StrolchComponent {
private final String componentName;
private ComponentState state;
private ComponentVersion version;
private ComponentConfiguration configuration;
public StrolchComponent(ComponentContainer container, String componentName) {
this.container = container;
@ -55,6 +56,10 @@ public class StrolchComponent {
return this.container;
}
protected ComponentConfiguration getConfiguration() {
return this.configuration;
}
protected void assertStarted() {
if (getState() != ComponentState.STARTED) {
String msg = "Component {0} is not yet started!"; //$NON-NLS-1$
@ -74,6 +79,7 @@ public class StrolchComponent {
}
public void initialize(ComponentConfiguration configuration) throws Exception {
this.configuration = configuration;
this.state = this.state.validateStateChange(ComponentState.INITIALIZED);
}

View File

@ -55,7 +55,6 @@ import ch.eitchnet.privilege.model.Certificate;
public class PostgreSqlPersistenceHandler extends StrolchComponent implements PersistenceHandler {
public static final String SCRIPT_PREFIX = "strolch"; //$NON-NLS-1$
private ComponentConfiguration componentConfiguration;
private Map<String, DataSource> dsMap;
public PostgreSqlPersistenceHandler(ComponentContainer container, String componentName) {
@ -65,8 +64,6 @@ public class PostgreSqlPersistenceHandler extends StrolchComponent implements Pe
@Override
public void initialize(ComponentConfiguration componentConfiguration) throws Exception {
this.componentConfiguration = componentConfiguration;
// server loader does not seem to work in all contexts, thus:
org.postgresql.Driver.getLogLevel();
@ -88,12 +85,12 @@ public class PostgreSqlPersistenceHandler extends StrolchComponent implements Pe
@Override
public void start() throws Exception {
boolean allowSchemaCreation = this.componentConfiguration.getBoolean(PROP_ALLOW_SCHEMA_CREATION, Boolean.FALSE);
boolean allowSchemaMigration = this.componentConfiguration.getBoolean(PROP_ALLOW_SCHEMA_MIGRATION,
ComponentConfiguration configuration = getConfiguration();
boolean allowSchemaCreation = configuration.getBoolean(PROP_ALLOW_SCHEMA_CREATION, Boolean.FALSE);
boolean allowSchemaMigration = configuration.getBoolean(PROP_ALLOW_SCHEMA_MIGRATION, Boolean.FALSE);
boolean allowSchemaDrop = configuration.getBoolean(PROP_ALLOW_SCHEMA_DROP, Boolean.FALSE);
boolean allowDataInitOnSchemaCreate = configuration.getBoolean(PROP_ALLOW_DATA_INIT_ON_SCHEMA_CREATE,
Boolean.FALSE);
boolean allowSchemaDrop = this.componentConfiguration.getBoolean(PROP_ALLOW_SCHEMA_DROP, Boolean.FALSE);
boolean allowDataInitOnSchemaCreate = this.componentConfiguration.getBoolean(
PROP_ALLOW_DATA_INIT_ON_SCHEMA_CREATE, Boolean.FALSE);
DbSchemaVersionCheck schemaVersionCheck = new DbSchemaVersionCheck(SCRIPT_PREFIX, this.getClass(),
allowSchemaCreation, allowSchemaMigration, allowSchemaDrop);
@ -160,7 +157,7 @@ public class PostgreSqlPersistenceHandler extends StrolchComponent implements Pe
public ActivityDao getActivityDao(StrolchTransaction tx) {
return ((PostgreSqlStrolchTransaction) tx).getActivityDao();
}
@Override
public AuditDao getAuditDao(StrolchTransaction tx) {
return ((PostgreSqlStrolchTransaction) tx).getAuditDao();

View File

@ -18,6 +18,7 @@ package li.strolch.rest;
import java.text.MessageFormat;
import li.strolch.agent.api.ComponentContainer;
import li.strolch.agent.api.StrolchAgent;
import li.strolch.agent.api.StrolchComponent;
import li.strolch.rest.filters.AccessControlResponseFilter;
import li.strolch.rest.filters.HttpCacheResponseFilter;
@ -178,6 +179,10 @@ public class RestfulStrolchComponent extends StrolchComponent {
return super.getContainer();
}
public StrolchAgent getAgent() {
return super.getContainer().getAgent();
}
public <T> T getComponent(Class<T> clazz) {
return getContainer().getComponent(clazz);
}