[New] Added StrolchComponent.getConfiguration()
- and thus removed any instance variables to it in subclasses
This commit is contained in:
parent
acd679636a
commit
29a88fe6ab
|
@ -1 +1 @@
|
||||||
Subproject commit 0c7315b713edb81442208c2b347c6432a3b6bc70
|
Subproject commit 21d640e081b3a32f7d668d39862014d4b629c1b9
|
|
@ -1 +1 @@
|
||||||
Subproject commit 2e58db83fd35fea958431d7a2e9edae14ff6a20b
|
Subproject commit 35bbb04d89cd6bd60ecf2ff1b49dba38a68f33a2
|
|
@ -33,6 +33,7 @@ public class StrolchComponent {
|
||||||
private final String componentName;
|
private final String componentName;
|
||||||
private ComponentState state;
|
private ComponentState state;
|
||||||
private ComponentVersion version;
|
private ComponentVersion version;
|
||||||
|
private ComponentConfiguration configuration;
|
||||||
|
|
||||||
public StrolchComponent(ComponentContainer container, String componentName) {
|
public StrolchComponent(ComponentContainer container, String componentName) {
|
||||||
this.container = container;
|
this.container = container;
|
||||||
|
@ -55,6 +56,10 @@ public class StrolchComponent {
|
||||||
return this.container;
|
return this.container;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ComponentConfiguration getConfiguration() {
|
||||||
|
return this.configuration;
|
||||||
|
}
|
||||||
|
|
||||||
protected void assertStarted() {
|
protected void assertStarted() {
|
||||||
if (getState() != ComponentState.STARTED) {
|
if (getState() != ComponentState.STARTED) {
|
||||||
String msg = "Component {0} is not yet started!"; //$NON-NLS-1$
|
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 {
|
public void initialize(ComponentConfiguration configuration) throws Exception {
|
||||||
|
this.configuration = configuration;
|
||||||
this.state = this.state.validateStateChange(ComponentState.INITIALIZED);
|
this.state = this.state.validateStateChange(ComponentState.INITIALIZED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,6 @@ import ch.eitchnet.privilege.model.Certificate;
|
||||||
public class PostgreSqlPersistenceHandler extends StrolchComponent implements PersistenceHandler {
|
public class PostgreSqlPersistenceHandler extends StrolchComponent implements PersistenceHandler {
|
||||||
|
|
||||||
public static final String SCRIPT_PREFIX = "strolch"; //$NON-NLS-1$
|
public static final String SCRIPT_PREFIX = "strolch"; //$NON-NLS-1$
|
||||||
private ComponentConfiguration componentConfiguration;
|
|
||||||
private Map<String, DataSource> dsMap;
|
private Map<String, DataSource> dsMap;
|
||||||
|
|
||||||
public PostgreSqlPersistenceHandler(ComponentContainer container, String componentName) {
|
public PostgreSqlPersistenceHandler(ComponentContainer container, String componentName) {
|
||||||
|
@ -65,8 +64,6 @@ public class PostgreSqlPersistenceHandler extends StrolchComponent implements Pe
|
||||||
@Override
|
@Override
|
||||||
public void initialize(ComponentConfiguration componentConfiguration) throws Exception {
|
public void initialize(ComponentConfiguration componentConfiguration) throws Exception {
|
||||||
|
|
||||||
this.componentConfiguration = componentConfiguration;
|
|
||||||
|
|
||||||
// server loader does not seem to work in all contexts, thus:
|
// server loader does not seem to work in all contexts, thus:
|
||||||
org.postgresql.Driver.getLogLevel();
|
org.postgresql.Driver.getLogLevel();
|
||||||
|
|
||||||
|
@ -88,12 +85,12 @@ public class PostgreSqlPersistenceHandler extends StrolchComponent implements Pe
|
||||||
@Override
|
@Override
|
||||||
public void start() throws Exception {
|
public void start() throws Exception {
|
||||||
|
|
||||||
boolean allowSchemaCreation = this.componentConfiguration.getBoolean(PROP_ALLOW_SCHEMA_CREATION, Boolean.FALSE);
|
ComponentConfiguration configuration = getConfiguration();
|
||||||
boolean allowSchemaMigration = this.componentConfiguration.getBoolean(PROP_ALLOW_SCHEMA_MIGRATION,
|
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.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(),
|
DbSchemaVersionCheck schemaVersionCheck = new DbSchemaVersionCheck(SCRIPT_PREFIX, this.getClass(),
|
||||||
allowSchemaCreation, allowSchemaMigration, allowSchemaDrop);
|
allowSchemaCreation, allowSchemaMigration, allowSchemaDrop);
|
||||||
|
|
|
@ -18,6 +18,7 @@ package li.strolch.rest;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
|
||||||
import li.strolch.agent.api.ComponentContainer;
|
import li.strolch.agent.api.ComponentContainer;
|
||||||
|
import li.strolch.agent.api.StrolchAgent;
|
||||||
import li.strolch.agent.api.StrolchComponent;
|
import li.strolch.agent.api.StrolchComponent;
|
||||||
import li.strolch.rest.filters.AccessControlResponseFilter;
|
import li.strolch.rest.filters.AccessControlResponseFilter;
|
||||||
import li.strolch.rest.filters.HttpCacheResponseFilter;
|
import li.strolch.rest.filters.HttpCacheResponseFilter;
|
||||||
|
@ -178,6 +179,10 @@ public class RestfulStrolchComponent extends StrolchComponent {
|
||||||
return super.getContainer();
|
return super.getContainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public StrolchAgent getAgent() {
|
||||||
|
return super.getContainer().getAgent();
|
||||||
|
}
|
||||||
|
|
||||||
public <T> T getComponent(Class<T> clazz) {
|
public <T> T getComponent(Class<T> clazz) {
|
||||||
return getContainer().getComponent(clazz);
|
return getContainer().getComponent(clazz);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue