[New] Implemented separate DataStoreMode for each StrolchRealm
This commit is contained in:
parent
c1a84fc480
commit
14de9b29df
|
@ -17,7 +17,6 @@ package li.strolch.agent.api;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import li.strolch.agent.impl.DataStoreMode;
|
|
||||||
import li.strolch.agent.impl.StrolchRealm;
|
import li.strolch.agent.impl.StrolchRealm;
|
||||||
import li.strolch.exception.StrolchException;
|
import li.strolch.exception.StrolchException;
|
||||||
import li.strolch.runtime.StrolchConstants;
|
import li.strolch.runtime.StrolchConstants;
|
||||||
|
@ -31,8 +30,6 @@ public interface ComponentContainer {
|
||||||
|
|
||||||
public abstract ComponentState getState();
|
public abstract ComponentState getState();
|
||||||
|
|
||||||
public abstract DataStoreMode getDataStoreMode();
|
|
||||||
|
|
||||||
public abstract boolean hasComponent(Class<?> clazz);
|
public abstract boolean hasComponent(Class<?> clazz);
|
||||||
|
|
||||||
public abstract <T> T getComponent(Class<T> clazz);
|
public abstract <T> T getComponent(Class<T> clazz);
|
||||||
|
|
|
@ -24,7 +24,7 @@ import li.strolch.runtime.StrolchConstants;
|
||||||
/**
|
/**
|
||||||
* @author Robert von Burg <eitch@eitchnet.ch>
|
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||||
*/
|
*/
|
||||||
public interface ElementMapHandler {
|
public interface RealmHandler {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the names of the configured {@link StrolchRealm StrolchRealms}
|
* Returns the names of the configured {@link StrolchRealm StrolchRealms}
|
|
@ -19,14 +19,10 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import li.strolch.agent.impl.ComponentContainerImpl;
|
import li.strolch.agent.impl.ComponentContainerImpl;
|
||||||
import li.strolch.agent.impl.DataStoreMode;
|
|
||||||
import li.strolch.agent.impl.ElementMapHandlerConfigurator;
|
|
||||||
import li.strolch.runtime.configuration.ComponentConfiguration;
|
|
||||||
import li.strolch.runtime.configuration.ConfigurationParser;
|
import li.strolch.runtime.configuration.ConfigurationParser;
|
||||||
import li.strolch.runtime.configuration.RuntimeConfiguration;
|
import li.strolch.runtime.configuration.RuntimeConfiguration;
|
||||||
import li.strolch.runtime.configuration.StrolchConfiguration;
|
import li.strolch.runtime.configuration.StrolchConfiguration;
|
||||||
|
@ -40,9 +36,6 @@ import org.slf4j.LoggerFactory;
|
||||||
public class StrolchAgent {
|
public class StrolchAgent {
|
||||||
|
|
||||||
private static final String AGENT_VERSION_PROPERTIES = "/agentVersion.properties"; //$NON-NLS-1$
|
private static final String AGENT_VERSION_PROPERTIES = "/agentVersion.properties"; //$NON-NLS-1$
|
||||||
public static final String PROP_DATA_STORE_MODE = "dataStoreMode"; //$NON-NLS-1$
|
|
||||||
public static final String PROP_DATA_STORE_FILE = "dataStoreFile"; //$NON-NLS-1$
|
|
||||||
public static final String PROP_REALMS = "realms"; //$NON-NLS-1$
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(StrolchAgent.class);
|
private static final Logger logger = LoggerFactory.getLogger(StrolchAgent.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,19 +88,11 @@ public class StrolchAgent {
|
||||||
logger.info(MessageFormat.format(msg, path.getAbsolutePath()));
|
logger.info(MessageFormat.format(msg, path.getAbsolutePath()));
|
||||||
|
|
||||||
this.strolchConfiguration = ConfigurationParser.parseConfiguration(path);
|
this.strolchConfiguration = ConfigurationParser.parseConfiguration(path);
|
||||||
RuntimeConfiguration runtimeConfiguration = this.strolchConfiguration.getRuntimeConfiguration();
|
|
||||||
DataStoreMode dataStoreMode = DataStoreMode.parseDataStoreMode(runtimeConfiguration.getString(
|
|
||||||
PROP_DATA_STORE_MODE, null));
|
|
||||||
|
|
||||||
ElementMapHandlerConfigurator mapHandlerConfigurator = dataStoreMode.getElementMapConfigurationConfigurator();
|
ComponentContainerImpl container = new ComponentContainerImpl(this);
|
||||||
List<ComponentConfiguration> configurations = mapHandlerConfigurator.buildConfigurations(this);
|
|
||||||
for (ComponentConfiguration configuration : configurations) {
|
|
||||||
this.strolchConfiguration.addConfiguration(configuration.getName(), configuration);
|
|
||||||
}
|
|
||||||
|
|
||||||
ComponentContainerImpl container = new ComponentContainerImpl(this, dataStoreMode);
|
|
||||||
this.container = container;
|
this.container = container;
|
||||||
|
|
||||||
|
RuntimeConfiguration runtimeConfiguration = this.strolchConfiguration.getRuntimeConfiguration();
|
||||||
logger.info(MessageFormat.format("Setup Agent {0}", runtimeConfiguration.getApplicationName())); //$NON-NLS-1$
|
logger.info(MessageFormat.format("Setup Agent {0}", runtimeConfiguration.getApplicationName())); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,60 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package li.strolch.agent.impl;
|
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import li.strolch.agent.api.ComponentContainer;
|
|
||||||
import li.strolch.agent.api.ElementMapHandler;
|
|
||||||
import li.strolch.agent.api.StrolchComponent;
|
|
||||||
import li.strolch.exception.StrolchException;
|
|
||||||
import ch.eitchnet.utils.dbc.DBC;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Robert von Burg <eitch@eitchnet.ch>
|
|
||||||
*/
|
|
||||||
public abstract class AbstractElementMapHandler extends StrolchComponent implements ElementMapHandler {
|
|
||||||
|
|
||||||
protected Map<String, StrolchRealm> realms;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param container
|
|
||||||
* @param componentName
|
|
||||||
*/
|
|
||||||
public AbstractElementMapHandler(ComponentContainer container, String componentName) {
|
|
||||||
super(container, componentName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<String> getRealmNames() {
|
|
||||||
return new HashSet<>(this.realms.keySet());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public StrolchRealm getRealm(String realm) throws StrolchException {
|
|
||||||
DBC.PRE.assertNotEmpty("Realm name must be set!", realm);
|
|
||||||
StrolchRealm strolchRealm = this.realms.get(realm);
|
|
||||||
if (strolchRealm == null) {
|
|
||||||
String msg = "No realm is configured with the name {0}"; //$NON-NLS-1$
|
|
||||||
msg = MessageFormat.format(msg, realm);
|
|
||||||
throw new StrolchException(msg);
|
|
||||||
}
|
|
||||||
return strolchRealm;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -184,7 +184,7 @@ public abstract class CachedElementMap<T extends StrolchElement> implements Elem
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Special method used when starting the container to cache the values. Not to be used anywhere else but from the
|
* Special method used when starting the container to cache the values. Not to be used anywhere else but from the
|
||||||
* {@link CachedElementMapHandler} and of course through the {@link #add(StrolchTransaction, StrolchElement)}-call
|
* {@link CachedRealm} and of course through the {@link #add(StrolchTransaction, StrolchElement)}-call
|
||||||
* to not duplicate code
|
* to not duplicate code
|
||||||
*
|
*
|
||||||
* @param element
|
* @param element
|
||||||
|
|
|
@ -1,113 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package li.strolch.agent.impl;
|
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import li.strolch.agent.api.ComponentContainer;
|
|
||||||
import li.strolch.agent.api.StrolchAgent;
|
|
||||||
import li.strolch.model.Order;
|
|
||||||
import li.strolch.model.Resource;
|
|
||||||
import li.strolch.persistence.api.OrderDao;
|
|
||||||
import li.strolch.persistence.api.PersistenceHandler;
|
|
||||||
import li.strolch.persistence.api.ResourceDao;
|
|
||||||
import li.strolch.persistence.api.StrolchTransaction;
|
|
||||||
import li.strolch.runtime.StrolchConstants;
|
|
||||||
import li.strolch.runtime.configuration.ComponentConfiguration;
|
|
||||||
import li.strolch.runtime.configuration.RuntimeConfiguration;
|
|
||||||
import ch.eitchnet.utils.helper.StringHelper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Robert von Burg <eitch@eitchnet.ch>
|
|
||||||
*/
|
|
||||||
public class CachedElementMapHandler extends AbstractElementMapHandler {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param container
|
|
||||||
* @param componentName
|
|
||||||
*/
|
|
||||||
public CachedElementMapHandler(ComponentContainer container, String componentName) {
|
|
||||||
super(container, componentName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initialize(ComponentConfiguration configuration) {
|
|
||||||
|
|
||||||
RuntimeConfiguration runtimeConfiguration = configuration.getRuntimeConfiguration();
|
|
||||||
String[] realms = runtimeConfiguration.getStringArray(StrolchAgent.PROP_REALMS, StrolchConstants.DEFAULT_REALM);
|
|
||||||
|
|
||||||
this.realms = new HashMap<>();
|
|
||||||
for (String realm : realms) {
|
|
||||||
PersistenceHandler persistenceHandler = getContainer().getComponent(PersistenceHandler.class);
|
|
||||||
CachedResourceMap resourceMap = new CachedResourceMap();
|
|
||||||
CachedOrderMap orderMap = new CachedOrderMap();
|
|
||||||
StrolchRealm strolchRealm = new StrolchRealm(realm, persistenceHandler, resourceMap, orderMap);
|
|
||||||
this.realms.put(realm, strolchRealm);
|
|
||||||
}
|
|
||||||
|
|
||||||
super.initialize(configuration);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void start() {
|
|
||||||
|
|
||||||
for (String realm : this.realms.keySet()) {
|
|
||||||
|
|
||||||
long start = System.nanoTime();
|
|
||||||
int nrOfOrders = 0;
|
|
||||||
int nrOfResources = 0;
|
|
||||||
|
|
||||||
StrolchRealm strolchRealm = this.realms.get(realm);
|
|
||||||
CachedOrderMap orderMap = (CachedOrderMap) strolchRealm.getOrderMap();
|
|
||||||
CachedResourceMap resourceMap = (CachedResourceMap) strolchRealm.getResourceMap();
|
|
||||||
|
|
||||||
try (StrolchTransaction tx = strolchRealm.openTx()) {
|
|
||||||
ResourceDao resourceDao = tx.getPersistenceHandler().getResourceDao(tx);
|
|
||||||
Set<String> resourceTypes = resourceDao.queryTypes();
|
|
||||||
for (String type : resourceTypes) {
|
|
||||||
List<Resource> resources = resourceDao.queryAll(type);
|
|
||||||
for (Resource resource : resources) {
|
|
||||||
resourceMap.insert(resource, null);
|
|
||||||
nrOfResources++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try (StrolchTransaction tx = strolchRealm.openTx()) {
|
|
||||||
OrderDao orderDao = tx.getPersistenceHandler().getOrderDao(tx);
|
|
||||||
Set<String> orderTypes = orderDao.queryTypes();
|
|
||||||
for (String type : orderTypes) {
|
|
||||||
List<Order> orders = orderDao.queryAll(type);
|
|
||||||
for (Order order : orders) {
|
|
||||||
orderMap.insert(order, null);
|
|
||||||
nrOfOrders++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
long duration = System.nanoTime() - start;
|
|
||||||
String durationS = StringHelper.formatNanoDuration(duration);
|
|
||||||
logger.info(MessageFormat.format("Loading Model from Database for realm {0} took {1}.", realm, durationS)); //$NON-NLS-1$
|
|
||||||
logger.info(MessageFormat.format("Loaded {0} Orders", nrOfOrders)); //$NON-NLS-1$
|
|
||||||
logger.info(MessageFormat.format("Loaded {0} Resources", nrOfResources)); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
super.start();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,53 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package li.strolch.agent.impl;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import li.strolch.agent.api.ElementMapHandler;
|
|
||||||
import li.strolch.agent.api.StrolchAgent;
|
|
||||||
import li.strolch.persistence.api.PersistenceHandler;
|
|
||||||
import li.strolch.runtime.configuration.ComponentConfiguration;
|
|
||||||
import li.strolch.runtime.configuration.RuntimeConfiguration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Robert von Burg <eitch@eitchnet.ch>
|
|
||||||
*/
|
|
||||||
public class CachedElementMapHandlerConfigurator implements ElementMapHandlerConfigurator {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ComponentConfiguration> buildConfigurations(StrolchAgent agent) {
|
|
||||||
|
|
||||||
String name = ElementMapHandler.class.getSimpleName();
|
|
||||||
String api = ElementMapHandler.class.getName();
|
|
||||||
String impl = CachedElementMapHandler.class.getName();
|
|
||||||
|
|
||||||
Map<String, String> configurationValues = new HashMap<>();
|
|
||||||
Set<String> dependencies = new HashSet<>();
|
|
||||||
dependencies.add(PersistenceHandler.class.getSimpleName());
|
|
||||||
|
|
||||||
RuntimeConfiguration runtimeConfiguration = agent.getStrolchConfiguration().getRuntimeConfiguration();
|
|
||||||
ComponentConfiguration configuration = new ComponentConfiguration(runtimeConfiguration, name,
|
|
||||||
configurationValues, api, impl, dependencies);
|
|
||||||
|
|
||||||
return Arrays.asList(configuration);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,122 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package li.strolch.agent.impl;
|
||||||
|
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import li.strolch.agent.api.ComponentContainer;
|
||||||
|
import li.strolch.agent.api.OrderMap;
|
||||||
|
import li.strolch.agent.api.ResourceMap;
|
||||||
|
import li.strolch.model.Order;
|
||||||
|
import li.strolch.model.Resource;
|
||||||
|
import li.strolch.persistence.api.OrderDao;
|
||||||
|
import li.strolch.persistence.api.PersistenceHandler;
|
||||||
|
import li.strolch.persistence.api.ResourceDao;
|
||||||
|
import li.strolch.persistence.api.StrolchTransaction;
|
||||||
|
import li.strolch.runtime.configuration.ComponentConfiguration;
|
||||||
|
import ch.eitchnet.utils.helper.StringHelper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||||
|
*/
|
||||||
|
public class CachedRealm extends StrolchRealm {
|
||||||
|
|
||||||
|
private PersistenceHandler persistenceHandler;
|
||||||
|
private CachedResourceMap resourceMap;
|
||||||
|
private CachedOrderMap orderMap;
|
||||||
|
|
||||||
|
public CachedRealm(String realm) {
|
||||||
|
super(realm);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataStoreMode getMode() {
|
||||||
|
return DataStoreMode.CACHED;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StrolchTransaction openTx() {
|
||||||
|
return this.persistenceHandler.openTx(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResourceMap getResourceMap() {
|
||||||
|
return this.resourceMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OrderMap getOrderMap() {
|
||||||
|
return this.orderMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(ComponentContainer container, ComponentConfiguration configuration) {
|
||||||
|
|
||||||
|
this.persistenceHandler = container.getComponent(PersistenceHandler.class);
|
||||||
|
this.resourceMap = new CachedResourceMap();
|
||||||
|
this.orderMap = new CachedOrderMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start() {
|
||||||
|
|
||||||
|
long start = System.nanoTime();
|
||||||
|
int nrOfOrders = 0;
|
||||||
|
int nrOfResources = 0;
|
||||||
|
|
||||||
|
try (StrolchTransaction tx = openTx()) {
|
||||||
|
ResourceDao resourceDao = tx.getPersistenceHandler().getResourceDao(tx);
|
||||||
|
Set<String> resourceTypes = resourceDao.queryTypes();
|
||||||
|
for (String type : resourceTypes) {
|
||||||
|
List<Resource> resources = resourceDao.queryAll(type);
|
||||||
|
for (Resource resource : resources) {
|
||||||
|
resourceMap.insert(resource, null);
|
||||||
|
nrOfResources++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try (StrolchTransaction tx = openTx()) {
|
||||||
|
OrderDao orderDao = tx.getPersistenceHandler().getOrderDao(tx);
|
||||||
|
Set<String> orderTypes = orderDao.queryTypes();
|
||||||
|
for (String type : orderTypes) {
|
||||||
|
List<Order> orders = orderDao.queryAll(type);
|
||||||
|
for (Order order : orders) {
|
||||||
|
orderMap.insert(order, null);
|
||||||
|
nrOfOrders++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
long duration = System.nanoTime() - start;
|
||||||
|
String durationS = StringHelper.formatNanoDuration(duration);
|
||||||
|
logger.info(MessageFormat.format("Loading Model from Database for realm {0} took {1}.", getRealm(), durationS)); //$NON-NLS-1$
|
||||||
|
logger.info(MessageFormat.format("Loaded {0} Orders", nrOfOrders)); //$NON-NLS-1$
|
||||||
|
logger.info(MessageFormat.format("Loaded {0} Resources", nrOfResources)); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop() {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroy() {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
|
@ -24,7 +24,7 @@ import java.util.Set;
|
||||||
|
|
||||||
import li.strolch.agent.api.ComponentContainer;
|
import li.strolch.agent.api.ComponentContainer;
|
||||||
import li.strolch.agent.api.ComponentState;
|
import li.strolch.agent.api.ComponentState;
|
||||||
import li.strolch.agent.api.ElementMapHandler;
|
import li.strolch.agent.api.RealmHandler;
|
||||||
import li.strolch.agent.api.StrolchAgent;
|
import li.strolch.agent.api.StrolchAgent;
|
||||||
import li.strolch.agent.api.StrolchComponent;
|
import li.strolch.agent.api.StrolchComponent;
|
||||||
import li.strolch.exception.StrolchException;
|
import li.strolch.exception.StrolchException;
|
||||||
|
@ -40,17 +40,14 @@ public class ComponentContainerImpl implements ComponentContainer {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ComponentContainerImpl.class);
|
private static final Logger logger = LoggerFactory.getLogger(ComponentContainerImpl.class);
|
||||||
|
|
||||||
private StrolchAgent agent;
|
private StrolchAgent agent;
|
||||||
private DataStoreMode dataStoreMode;
|
|
||||||
|
|
||||||
private Map<Class<?>, StrolchComponent> componentMap;
|
private Map<Class<?>, StrolchComponent> componentMap;
|
||||||
private Map<String, ComponentController> controllerMap;
|
private Map<String, ComponentController> controllerMap;
|
||||||
private ComponentDependencyAnalyzer dependencyAnalyzer;
|
private ComponentDependencyAnalyzer dependencyAnalyzer;
|
||||||
private StrolchConfiguration strolchConfiguration;
|
private StrolchConfiguration strolchConfiguration;
|
||||||
private ComponentState state;
|
private ComponentState state;
|
||||||
|
|
||||||
public ComponentContainerImpl(StrolchAgent agent, DataStoreMode dataStoreMode) {
|
public ComponentContainerImpl(StrolchAgent agent) {
|
||||||
this.agent = agent;
|
this.agent = agent;
|
||||||
this.dataStoreMode = dataStoreMode;
|
|
||||||
this.state = ComponentState.UNDEFINED;
|
this.state = ComponentState.UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,11 +61,6 @@ public class ComponentContainerImpl implements ComponentContainer {
|
||||||
return this.state;
|
return this.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public DataStoreMode getDataStoreMode() {
|
|
||||||
return this.dataStoreMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Class<?>> getComponentTypes() {
|
public Set<Class<?>> getComponentTypes() {
|
||||||
return this.componentMap.keySet();
|
return this.componentMap.keySet();
|
||||||
|
@ -93,12 +85,12 @@ public class ComponentContainerImpl implements ComponentContainer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getRealmNames() {
|
public Set<String> getRealmNames() {
|
||||||
return getComponent(ElementMapHandler.class).getRealmNames();
|
return getComponent(RealmHandler.class).getRealmNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StrolchRealm getRealm(String realm) throws StrolchException {
|
public StrolchRealm getRealm(String realm) throws StrolchException {
|
||||||
return getComponent(ElementMapHandler.class).getRealm(realm);
|
return getComponent(RealmHandler.class).getRealm(realm);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeComponent(Map<Class<?>, StrolchComponent> componentMap,
|
private void initializeComponent(Map<Class<?>, StrolchComponent> componentMap,
|
||||||
|
|
|
@ -24,30 +24,30 @@ import java.text.MessageFormat;
|
||||||
public enum DataStoreMode {
|
public enum DataStoreMode {
|
||||||
EMPTY {
|
EMPTY {
|
||||||
@Override
|
@Override
|
||||||
public ElementMapHandlerConfigurator getElementMapConfigurationConfigurator() {
|
public StrolchRealm createRealm(String realm) {
|
||||||
return new EmptyElementMapHandlerConfigurator();
|
return new EmptyRealm(realm);
|
||||||
}
|
}
|
||||||
}, //
|
}, //
|
||||||
TRANSIENT {
|
TRANSIENT {
|
||||||
@Override
|
@Override
|
||||||
public ElementMapHandlerConfigurator getElementMapConfigurationConfigurator() {
|
public StrolchRealm createRealm(String realm) {
|
||||||
return new TransientElementMapHandlerConfigurator();
|
return new TransientRealm(realm);
|
||||||
}
|
}
|
||||||
}, //
|
}, //
|
||||||
CACHED {
|
CACHED {
|
||||||
@Override
|
@Override
|
||||||
public ElementMapHandlerConfigurator getElementMapConfigurationConfigurator() {
|
public StrolchRealm createRealm(String realm) {
|
||||||
return new CachedElementMapHandlerConfigurator();
|
return new CachedRealm(realm);
|
||||||
}
|
}
|
||||||
}, //
|
}, //
|
||||||
TRANSACTIONAL {
|
TRANSACTIONAL {
|
||||||
@Override
|
@Override
|
||||||
public ElementMapHandlerConfigurator getElementMapConfigurationConfigurator() {
|
public StrolchRealm createRealm(String realm) {
|
||||||
return new TransactionalElementMapHandlerConfigurator();
|
return new TransactionalRealm(realm);
|
||||||
}
|
}
|
||||||
}; //
|
}; //
|
||||||
|
|
||||||
public abstract ElementMapHandlerConfigurator getElementMapConfigurationConfigurator();
|
public abstract StrolchRealm createRealm(String realm);
|
||||||
|
|
||||||
public static DataStoreMode parseDataStoreMode(String modeS) {
|
public static DataStoreMode parseDataStoreMode(String modeS) {
|
||||||
for (DataStoreMode dataStoreMode : values()) {
|
for (DataStoreMode dataStoreMode : values()) {
|
||||||
|
|
|
@ -0,0 +1,110 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package li.strolch.agent.impl;
|
||||||
|
|
||||||
|
import static ch.eitchnet.utils.helper.StringHelper.DOT;
|
||||||
|
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import li.strolch.agent.api.ComponentContainer;
|
||||||
|
import li.strolch.agent.api.RealmHandler;
|
||||||
|
import li.strolch.agent.api.StrolchComponent;
|
||||||
|
import li.strolch.exception.StrolchException;
|
||||||
|
import li.strolch.runtime.StrolchConstants;
|
||||||
|
import li.strolch.runtime.configuration.ComponentConfiguration;
|
||||||
|
import ch.eitchnet.utils.dbc.DBC;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||||
|
*/
|
||||||
|
public class DefaultRealmHandler extends StrolchComponent implements RealmHandler {
|
||||||
|
|
||||||
|
public static final String PREFIX_DATA_STORE_MODE = "dataStoreMode"; //$NON-NLS-1$
|
||||||
|
public static final String PROP_REALMS = "realms"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
protected Map<String, StrolchRealm> realms;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param container
|
||||||
|
* @param componentName
|
||||||
|
*/
|
||||||
|
public DefaultRealmHandler(ComponentContainer container, String componentName) {
|
||||||
|
super(container, componentName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getRealmNames() {
|
||||||
|
return new HashSet<>(this.realms.keySet());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StrolchRealm getRealm(String realm) throws StrolchException {
|
||||||
|
DBC.PRE.assertNotEmpty("Realm name must be set!", realm);
|
||||||
|
StrolchRealm strolchRealm = this.realms.get(realm);
|
||||||
|
if (strolchRealm == null) {
|
||||||
|
String msg = "No realm is configured with the name {0}"; //$NON-NLS-1$
|
||||||
|
msg = MessageFormat.format(msg, realm);
|
||||||
|
throw new StrolchException(msg);
|
||||||
|
}
|
||||||
|
return strolchRealm;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(ComponentConfiguration configuration) {
|
||||||
|
|
||||||
|
this.realms = new HashMap<>();
|
||||||
|
String[] realms = configuration.getStringArray(PROP_REALMS, StrolchConstants.DEFAULT_REALM);
|
||||||
|
for (String realmName : realms) {
|
||||||
|
String dataStoreModeKey = PREFIX_DATA_STORE_MODE;
|
||||||
|
if (!realmName.equals(StrolchConstants.DEFAULT_REALM))
|
||||||
|
dataStoreModeKey += DOT + realmName;
|
||||||
|
|
||||||
|
String realmMode = configuration.getString(dataStoreModeKey, null);
|
||||||
|
DataStoreMode dataStoreMode = DataStoreMode.parseDataStoreMode(realmMode);
|
||||||
|
StrolchRealm realm = dataStoreMode.createRealm(realmName);
|
||||||
|
this.realms.put(realmName, realm);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String realmName : this.realms.keySet()) {
|
||||||
|
StrolchRealm realm = this.realms.get(realmName);
|
||||||
|
realm.initialize(getContainer(), configuration);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.initialize(configuration);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start() {
|
||||||
|
for (String realmName : this.realms.keySet()) {
|
||||||
|
StrolchRealm realm = this.realms.get(realmName);
|
||||||
|
realm.start();
|
||||||
|
}
|
||||||
|
super.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop() {
|
||||||
|
for (String realmName : this.realms.keySet()) {
|
||||||
|
StrolchRealm realm = this.realms.get(realmName);
|
||||||
|
realm.stop();
|
||||||
|
}
|
||||||
|
super.stop();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,29 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package li.strolch.agent.impl;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import li.strolch.agent.api.StrolchAgent;
|
|
||||||
import li.strolch.runtime.configuration.ComponentConfiguration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Robert von Burg <eitch@eitchnet.ch>
|
|
||||||
*/
|
|
||||||
public interface ElementMapHandlerConfigurator {
|
|
||||||
|
|
||||||
public List<ComponentConfiguration> buildConfigurations(StrolchAgent agent);
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package li.strolch.agent.impl;
|
|
||||||
|
|
||||||
import li.strolch.agent.api.ComponentContainer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Robert von Burg <eitch@eitchnet.ch>
|
|
||||||
*/
|
|
||||||
public class EmptyElementMapHandler extends InMemoryElementMapHandler {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param container
|
|
||||||
* @param componentName
|
|
||||||
*/
|
|
||||||
public EmptyElementMapHandler(ComponentContainer container, String componentName) {
|
|
||||||
super(container, componentName);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package li.strolch.agent.impl;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import li.strolch.agent.api.ElementMapHandler;
|
|
||||||
import li.strolch.agent.api.StrolchAgent;
|
|
||||||
import li.strolch.runtime.configuration.ComponentConfiguration;
|
|
||||||
import li.strolch.runtime.configuration.RuntimeConfiguration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Robert von Burg <eitch@eitchnet.ch>
|
|
||||||
*/
|
|
||||||
public class EmptyElementMapHandlerConfigurator extends TransientElementMapHandlerConfigurator {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected ComponentConfiguration getElementMapHandlerConfiguration(StrolchAgent agent) {
|
|
||||||
String name = ElementMapHandler.class.getSimpleName();
|
|
||||||
String api = ElementMapHandler.class.getName();
|
|
||||||
String impl = EmptyElementMapHandler.class.getName();
|
|
||||||
|
|
||||||
Map<String, String> configurationValues = new HashMap<>();
|
|
||||||
Set<String> dependencies = Collections.emptySet();
|
|
||||||
|
|
||||||
RuntimeConfiguration runtimeConfiguration = agent.getStrolchConfiguration().getRuntimeConfiguration();
|
|
||||||
ComponentConfiguration configuration = new ComponentConfiguration(runtimeConfiguration, name,
|
|
||||||
configurationValues, api, impl, dependencies);
|
|
||||||
|
|
||||||
return configuration;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package li.strolch.agent.impl;
|
||||||
|
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
|
||||||
|
import li.strolch.agent.api.ComponentContainer;
|
||||||
|
import li.strolch.agent.api.OrderMap;
|
||||||
|
import li.strolch.agent.api.ResourceMap;
|
||||||
|
import li.strolch.persistence.api.PersistenceHandler;
|
||||||
|
import li.strolch.persistence.api.StrolchTransaction;
|
||||||
|
import li.strolch.persistence.inmemory.InMemoryPersistence;
|
||||||
|
import li.strolch.runtime.configuration.ComponentConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||||
|
*/
|
||||||
|
public class EmptyRealm extends StrolchRealm {
|
||||||
|
|
||||||
|
private ResourceMap resourceMap;
|
||||||
|
private OrderMap orderMap;
|
||||||
|
private PersistenceHandler persistenceHandler;
|
||||||
|
|
||||||
|
public EmptyRealm(String realm) {
|
||||||
|
super(realm);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataStoreMode getMode() {
|
||||||
|
return DataStoreMode.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StrolchTransaction openTx() {
|
||||||
|
return this.persistenceHandler.openTx(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResourceMap getResourceMap() {
|
||||||
|
return this.resourceMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OrderMap getOrderMap() {
|
||||||
|
return this.orderMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(ComponentContainer container, ComponentConfiguration configuration) {
|
||||||
|
this.persistenceHandler = new InMemoryPersistence();
|
||||||
|
this.resourceMap = new TransactionalResourceMap();
|
||||||
|
this.orderMap = new TransactionalOrderMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start() {
|
||||||
|
logger.info(MessageFormat.format("Initialized EMPTY Realm {0}", getRealm())); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop() {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroy() {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,57 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package li.strolch.agent.impl;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import li.strolch.agent.api.ComponentContainer;
|
|
||||||
import li.strolch.agent.api.StrolchAgent;
|
|
||||||
import li.strolch.persistence.api.PersistenceHandler;
|
|
||||||
import li.strolch.runtime.StrolchConstants;
|
|
||||||
import li.strolch.runtime.configuration.ComponentConfiguration;
|
|
||||||
import li.strolch.runtime.configuration.RuntimeConfiguration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Robert von Burg <eitch@eitchnet.ch>
|
|
||||||
*/
|
|
||||||
public class InMemoryElementMapHandler extends AbstractElementMapHandler {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param container
|
|
||||||
* @param componentName
|
|
||||||
*/
|
|
||||||
public InMemoryElementMapHandler(ComponentContainer container, String componentName) {
|
|
||||||
super(container, componentName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initialize(ComponentConfiguration configuration) {
|
|
||||||
|
|
||||||
RuntimeConfiguration runtimeConfiguration = configuration.getRuntimeConfiguration();
|
|
||||||
String[] realms = runtimeConfiguration.getStringArray(StrolchAgent.PROP_REALMS, StrolchConstants.DEFAULT_REALM);
|
|
||||||
|
|
||||||
this.realms = new HashMap<>();
|
|
||||||
for (String realm : realms) {
|
|
||||||
PersistenceHandler persistenceHandler = getContainer().getComponent(PersistenceHandler.class);
|
|
||||||
TransactionalResourceMap resourceMap = new TransactionalResourceMap();
|
|
||||||
TransactionalOrderMap orderMap = new TransactionalOrderMap();
|
|
||||||
StrolchRealm strolchRealm = new StrolchRealm(realm, persistenceHandler, resourceMap, orderMap);
|
|
||||||
this.realms.put(realm, strolchRealm);
|
|
||||||
}
|
|
||||||
|
|
||||||
super.initialize(configuration);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -15,50 +15,44 @@
|
||||||
*/
|
*/
|
||||||
package li.strolch.agent.impl;
|
package li.strolch.agent.impl;
|
||||||
|
|
||||||
|
import li.strolch.agent.api.ComponentContainer;
|
||||||
import li.strolch.agent.api.OrderMap;
|
import li.strolch.agent.api.OrderMap;
|
||||||
import li.strolch.agent.api.ResourceMap;
|
import li.strolch.agent.api.ResourceMap;
|
||||||
import li.strolch.persistence.api.PersistenceHandler;
|
|
||||||
import li.strolch.persistence.api.StrolchTransaction;
|
import li.strolch.persistence.api.StrolchTransaction;
|
||||||
|
import li.strolch.runtime.configuration.ComponentConfiguration;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Robert von Burg <eitch@eitchnet.ch>
|
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||||
*/
|
*/
|
||||||
public class StrolchRealm {
|
public abstract class StrolchRealm {
|
||||||
|
|
||||||
|
protected static final Logger logger = LoggerFactory.getLogger(StrolchRealm.class);
|
||||||
private String realm;
|
private String realm;
|
||||||
private ResourceMap resourceMap;
|
|
||||||
private OrderMap orderMap;
|
|
||||||
private PersistenceHandler persistenceHandler;
|
|
||||||
|
|
||||||
public StrolchRealm(String realm, PersistenceHandler persistenceHandler, ResourceMap resourceMap, OrderMap orderMap) {
|
public StrolchRealm(String realm) {
|
||||||
this.realm = realm;
|
this.realm = realm;
|
||||||
this.persistenceHandler = persistenceHandler;
|
|
||||||
this.resourceMap = resourceMap;
|
|
||||||
this.orderMap = orderMap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the realm
|
|
||||||
*/
|
|
||||||
public String getRealm() {
|
public String getRealm() {
|
||||||
return this.realm;
|
return this.realm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StrolchTransaction openTx() {
|
public abstract DataStoreMode getMode();
|
||||||
return this.persistenceHandler.openTx(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
public abstract void initialize(ComponentContainer container, ComponentConfiguration configuration);
|
||||||
* @return the resourceMap
|
|
||||||
*/
|
|
||||||
public ResourceMap getResourceMap() {
|
|
||||||
return this.resourceMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
public abstract void start();
|
||||||
* @return the orderMap
|
|
||||||
*/
|
public abstract void stop();
|
||||||
public OrderMap getOrderMap() {
|
|
||||||
return this.orderMap;
|
public abstract void destroy();
|
||||||
}
|
|
||||||
|
public abstract StrolchTransaction openTx();
|
||||||
|
|
||||||
|
public abstract ResourceMap getResourceMap();
|
||||||
|
|
||||||
|
public abstract OrderMap getOrderMap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,70 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package li.strolch.agent.impl;
|
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
|
||||||
|
|
||||||
import li.strolch.agent.api.ComponentContainer;
|
|
||||||
import li.strolch.agent.api.OrderMap;
|
|
||||||
import li.strolch.agent.api.ResourceMap;
|
|
||||||
import li.strolch.persistence.api.StrolchTransaction;
|
|
||||||
import ch.eitchnet.utils.helper.StringHelper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Robert von Burg <eitch@eitchnet.ch>
|
|
||||||
*/
|
|
||||||
public class TransactionalElementMapHandler extends InMemoryElementMapHandler {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param container
|
|
||||||
* @param componentName
|
|
||||||
*/
|
|
||||||
public TransactionalElementMapHandler(ComponentContainer container, String componentName) {
|
|
||||||
super(container, componentName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void start() {
|
|
||||||
|
|
||||||
for (String realm : this.realms.keySet()) {
|
|
||||||
|
|
||||||
long start = System.nanoTime();
|
|
||||||
int nrOfOrders = 0;
|
|
||||||
int nrOfResources = 0;
|
|
||||||
|
|
||||||
StrolchRealm strolchRealm = this.realms.get(realm);
|
|
||||||
OrderMap orderMap = strolchRealm.getOrderMap();
|
|
||||||
ResourceMap resourceMap = strolchRealm.getResourceMap();
|
|
||||||
|
|
||||||
try (StrolchTransaction tx = strolchRealm.openTx()) {
|
|
||||||
nrOfOrders = orderMap.getAllKeys(tx).size();
|
|
||||||
}
|
|
||||||
|
|
||||||
try (StrolchTransaction tx = strolchRealm.openTx()) {
|
|
||||||
nrOfResources = resourceMap.getAllKeys(tx).size();
|
|
||||||
}
|
|
||||||
|
|
||||||
long duration = System.nanoTime() - start;
|
|
||||||
String durationS = StringHelper.formatNanoDuration(duration);
|
|
||||||
logger.info(MessageFormat
|
|
||||||
.format("Initialized Transactional Maps for realm {0} took {1}.", realm, durationS)); //$NON-NLS-1$
|
|
||||||
logger.info(MessageFormat.format("There are {0} Orders", nrOfOrders)); //$NON-NLS-1$
|
|
||||||
logger.info(MessageFormat.format("There are {0} Resources", nrOfResources)); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
super.start();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,53 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package li.strolch.agent.impl;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import li.strolch.agent.api.ElementMapHandler;
|
|
||||||
import li.strolch.agent.api.StrolchAgent;
|
|
||||||
import li.strolch.persistence.api.PersistenceHandler;
|
|
||||||
import li.strolch.runtime.configuration.ComponentConfiguration;
|
|
||||||
import li.strolch.runtime.configuration.RuntimeConfiguration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Robert von Burg <eitch@eitchnet.ch>
|
|
||||||
*/
|
|
||||||
public class TransactionalElementMapHandlerConfigurator implements ElementMapHandlerConfigurator {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ComponentConfiguration> buildConfigurations(StrolchAgent agent) {
|
|
||||||
|
|
||||||
String name = ElementMapHandler.class.getSimpleName();
|
|
||||||
String api = ElementMapHandler.class.getName();
|
|
||||||
String impl = TransactionalElementMapHandler.class.getName();
|
|
||||||
|
|
||||||
Map<String, String> configurationValues = new HashMap<>();
|
|
||||||
Set<String> dependencies = new HashSet<>();
|
|
||||||
dependencies.add(PersistenceHandler.class.getSimpleName());
|
|
||||||
|
|
||||||
RuntimeConfiguration runtimeConfiguration = agent.getStrolchConfiguration().getRuntimeConfiguration();
|
|
||||||
ComponentConfiguration configuration = new ComponentConfiguration(runtimeConfiguration, name,
|
|
||||||
configurationValues, api, impl, dependencies);
|
|
||||||
|
|
||||||
return Arrays.asList(configuration);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,100 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package li.strolch.agent.impl;
|
||||||
|
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
|
||||||
|
import li.strolch.agent.api.ComponentContainer;
|
||||||
|
import li.strolch.agent.api.OrderMap;
|
||||||
|
import li.strolch.agent.api.ResourceMap;
|
||||||
|
import li.strolch.persistence.api.PersistenceHandler;
|
||||||
|
import li.strolch.persistence.api.StrolchTransaction;
|
||||||
|
import li.strolch.runtime.configuration.ComponentConfiguration;
|
||||||
|
import ch.eitchnet.utils.helper.StringHelper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||||
|
*/
|
||||||
|
public class TransactionalRealm extends StrolchRealm {
|
||||||
|
|
||||||
|
private ResourceMap resourceMap;
|
||||||
|
private OrderMap orderMap;
|
||||||
|
private PersistenceHandler persistenceHandler;
|
||||||
|
|
||||||
|
public TransactionalRealm(String realm) {
|
||||||
|
super(realm);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataStoreMode getMode() {
|
||||||
|
return DataStoreMode.TRANSACTIONAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StrolchTransaction openTx() {
|
||||||
|
return this.persistenceHandler.openTx(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResourceMap getResourceMap() {
|
||||||
|
return this.resourceMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OrderMap getOrderMap() {
|
||||||
|
return this.orderMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(ComponentContainer container, ComponentConfiguration configuration) {
|
||||||
|
this.resourceMap = new TransactionalResourceMap();
|
||||||
|
this.orderMap = new TransactionalOrderMap();
|
||||||
|
this.persistenceHandler = container.getComponent(PersistenceHandler.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start() {
|
||||||
|
|
||||||
|
long start = System.nanoTime();
|
||||||
|
int nrOfOrders = 0;
|
||||||
|
int nrOfResources = 0;
|
||||||
|
|
||||||
|
try (StrolchTransaction tx = openTx()) {
|
||||||
|
nrOfOrders = orderMap.getAllKeys(tx).size();
|
||||||
|
}
|
||||||
|
|
||||||
|
try (StrolchTransaction tx = openTx()) {
|
||||||
|
nrOfResources = resourceMap.getAllKeys(tx).size();
|
||||||
|
}
|
||||||
|
|
||||||
|
long duration = System.nanoTime() - start;
|
||||||
|
String durationS = StringHelper.formatNanoDuration(duration);
|
||||||
|
logger.info(MessageFormat.format(
|
||||||
|
"Initialized Transactional Maps for realm {0} took {1}.", getRealm(), durationS)); //$NON-NLS-1$
|
||||||
|
logger.info(MessageFormat.format("There are {0} Orders", nrOfOrders)); //$NON-NLS-1$
|
||||||
|
logger.info(MessageFormat.format("There are {0} Resources", nrOfResources)); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop() {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroy() {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,100 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package li.strolch.agent.impl;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.text.MessageFormat;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import li.strolch.agent.api.ComponentContainer;
|
|
||||||
import li.strolch.agent.api.StrolchAgent;
|
|
||||||
import li.strolch.model.xml.XmlModelSaxReader.XmlModelStatistics;
|
|
||||||
import li.strolch.model.xml.XmlModelSaxFileReader;
|
|
||||||
import li.strolch.persistence.api.StrolchTransaction;
|
|
||||||
import li.strolch.runtime.StrolchConstants;
|
|
||||||
import li.strolch.runtime.configuration.ComponentConfiguration;
|
|
||||||
import li.strolch.runtime.configuration.RuntimeConfiguration;
|
|
||||||
import li.strolch.runtime.configuration.StrolchConfigurationException;
|
|
||||||
import ch.eitchnet.utils.helper.StringHelper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Robert von Burg <eitch@eitchnet.ch>
|
|
||||||
*/
|
|
||||||
public class TransientElementMapHandler extends InMemoryElementMapHandler {
|
|
||||||
|
|
||||||
private Map<String, File> realmModelFiles;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param container
|
|
||||||
* @param componentName
|
|
||||||
*/
|
|
||||||
public TransientElementMapHandler(ComponentContainer container, String componentName) {
|
|
||||||
super(container, componentName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initialize(ComponentConfiguration configuration) {
|
|
||||||
super.initialize(configuration);
|
|
||||||
|
|
||||||
this.realmModelFiles = new HashMap<>();
|
|
||||||
RuntimeConfiguration runtimeConfiguration = configuration.getRuntimeConfiguration();
|
|
||||||
for (String realm : this.realms.keySet()) {
|
|
||||||
String key = getDataStoreFilePropKey(realm);
|
|
||||||
|
|
||||||
if (!runtimeConfiguration.hasProperty(key)) {
|
|
||||||
String msg = "There is no data store file for realm {0}. Set a property with key {1}"; //$NON-NLS-1$
|
|
||||||
msg = MessageFormat.format(msg, realm, key);
|
|
||||||
throw new StrolchConfigurationException(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
File modelFile = runtimeConfiguration.getDataFile(key, null, runtimeConfiguration, true);
|
|
||||||
this.realmModelFiles.put(realm, modelFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getDataStoreFilePropKey(String realm) {
|
|
||||||
if (realm.equals(StrolchConstants.DEFAULT_REALM))
|
|
||||||
return StrolchAgent.PROP_DATA_STORE_FILE;
|
|
||||||
return StrolchAgent.PROP_DATA_STORE_FILE + "." + realm; //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void start() {
|
|
||||||
|
|
||||||
for (String realm : this.realms.keySet()) {
|
|
||||||
|
|
||||||
StrolchRealm strolchRealm = this.realms.get(realm);
|
|
||||||
|
|
||||||
File modelFile = this.realmModelFiles.get(realm);
|
|
||||||
XmlModelStatistics statistics;
|
|
||||||
try (StrolchTransaction tx = strolchRealm.openTx()) {
|
|
||||||
InMemoryElementListener elementListener = new InMemoryElementListener(tx);
|
|
||||||
XmlModelSaxFileReader handler = new XmlModelSaxFileReader(elementListener, modelFile);
|
|
||||||
handler.parseFile();
|
|
||||||
statistics = handler.getStatistics();
|
|
||||||
}
|
|
||||||
|
|
||||||
String durationS = StringHelper.formatNanoDuration(statistics.durationNanos);
|
|
||||||
logger.info(MessageFormat.format(
|
|
||||||
"Loading XML Model file {0} for realm {1} took {2}.", modelFile.getName(), realm, durationS)); //$NON-NLS-1$
|
|
||||||
logger.info(MessageFormat.format("Loaded {0} Orders", statistics.nrOfOrders)); //$NON-NLS-1$
|
|
||||||
logger.info(MessageFormat.format("Loaded {0} Resources", statistics.nrOfResources)); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
super.start();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,76 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package li.strolch.agent.impl;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import li.strolch.agent.api.ElementMapHandler;
|
|
||||||
import li.strolch.agent.api.StrolchAgent;
|
|
||||||
import li.strolch.persistence.api.PersistenceHandler;
|
|
||||||
import li.strolch.persistence.inmemory.InMemoryPersistenceHandler;
|
|
||||||
import li.strolch.runtime.configuration.ComponentConfiguration;
|
|
||||||
import li.strolch.runtime.configuration.RuntimeConfiguration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Robert von Burg <eitch@eitchnet.ch>
|
|
||||||
*/
|
|
||||||
public class TransientElementMapHandlerConfigurator implements ElementMapHandlerConfigurator {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ComponentConfiguration> buildConfigurations(StrolchAgent agent) {
|
|
||||||
|
|
||||||
List<ComponentConfiguration> configurations = new ArrayList<>();
|
|
||||||
configurations.add(getElementMapHandlerConfiguration(agent));
|
|
||||||
configurations.add(getPersistenceHandlerConfiguration(agent));
|
|
||||||
|
|
||||||
return configurations;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ComponentConfiguration getPersistenceHandlerConfiguration(StrolchAgent agent) {
|
|
||||||
String name = PersistenceHandler.class.getSimpleName();
|
|
||||||
String api = PersistenceHandler.class.getName();
|
|
||||||
String impl = InMemoryPersistenceHandler.class.getName();
|
|
||||||
|
|
||||||
Map<String, String> configurationValues = new HashMap<>();
|
|
||||||
Set<String> dependencies = Collections.emptySet();
|
|
||||||
|
|
||||||
RuntimeConfiguration runtimeConfiguration = agent.getStrolchConfiguration().getRuntimeConfiguration();
|
|
||||||
ComponentConfiguration configuration = new ComponentConfiguration(runtimeConfiguration, name,
|
|
||||||
configurationValues, api, impl, dependencies);
|
|
||||||
return configuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ComponentConfiguration getElementMapHandlerConfiguration(StrolchAgent agent) {
|
|
||||||
String name = ElementMapHandler.class.getSimpleName();
|
|
||||||
String api = ElementMapHandler.class.getName();
|
|
||||||
String impl = TransientElementMapHandler.class.getName();
|
|
||||||
|
|
||||||
Map<String, String> configurationValues = new HashMap<>();
|
|
||||||
Set<String> dependencies = new HashSet<>();
|
|
||||||
dependencies.add(PersistenceHandler.class.getSimpleName());
|
|
||||||
|
|
||||||
RuntimeConfiguration runtimeConfiguration = agent.getStrolchConfiguration().getRuntimeConfiguration();
|
|
||||||
ComponentConfiguration configuration = new ComponentConfiguration(runtimeConfiguration, name,
|
|
||||||
configurationValues, api, impl, dependencies);
|
|
||||||
return configuration;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,120 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package li.strolch.agent.impl;
|
||||||
|
|
||||||
|
import static ch.eitchnet.utils.helper.StringHelper.DOT;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
|
||||||
|
import li.strolch.agent.api.ComponentContainer;
|
||||||
|
import li.strolch.agent.api.OrderMap;
|
||||||
|
import li.strolch.agent.api.ResourceMap;
|
||||||
|
import li.strolch.model.xml.XmlModelSaxFileReader;
|
||||||
|
import li.strolch.model.xml.XmlModelSaxReader.XmlModelStatistics;
|
||||||
|
import li.strolch.persistence.api.PersistenceHandler;
|
||||||
|
import li.strolch.persistence.api.StrolchTransaction;
|
||||||
|
import li.strolch.persistence.inmemory.InMemoryPersistence;
|
||||||
|
import li.strolch.runtime.StrolchConstants;
|
||||||
|
import li.strolch.runtime.configuration.ComponentConfiguration;
|
||||||
|
import li.strolch.runtime.configuration.StrolchConfigurationException;
|
||||||
|
import ch.eitchnet.utils.helper.StringHelper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||||
|
*/
|
||||||
|
public class TransientRealm extends StrolchRealm {
|
||||||
|
|
||||||
|
public static final String PREFIX_DATA_STORE_FILE = "dataStoreFile"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private ResourceMap resourceMap;
|
||||||
|
private OrderMap orderMap;
|
||||||
|
private PersistenceHandler persistenceHandler;
|
||||||
|
|
||||||
|
private File modelFile;
|
||||||
|
|
||||||
|
public TransientRealm(String realm) {
|
||||||
|
super(realm);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataStoreMode getMode() {
|
||||||
|
return DataStoreMode.TRANSIENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StrolchTransaction openTx() {
|
||||||
|
return this.persistenceHandler.openTx(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResourceMap getResourceMap() {
|
||||||
|
return this.resourceMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OrderMap getOrderMap() {
|
||||||
|
return this.orderMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(ComponentContainer container, ComponentConfiguration configuration) {
|
||||||
|
|
||||||
|
String key = PREFIX_DATA_STORE_FILE;
|
||||||
|
if (!getRealm().equals(StrolchConstants.DEFAULT_REALM))
|
||||||
|
key += DOT + getRealm();
|
||||||
|
|
||||||
|
if (!configuration.hasProperty(key)) {
|
||||||
|
String msg = "There is no data store file for realm {0}. Set a property with key {1}"; //$NON-NLS-1$
|
||||||
|
msg = MessageFormat.format(msg, getRealm(), key);
|
||||||
|
throw new StrolchConfigurationException(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.modelFile = configuration.getDataFile(key, null, configuration.getRuntimeConfiguration(), true);
|
||||||
|
|
||||||
|
this.persistenceHandler = new InMemoryPersistence();
|
||||||
|
this.resourceMap = new TransactionalResourceMap();
|
||||||
|
this.orderMap = new TransactionalOrderMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start() {
|
||||||
|
|
||||||
|
XmlModelStatistics statistics;
|
||||||
|
try (StrolchTransaction tx = openTx()) {
|
||||||
|
InMemoryElementListener elementListener = new InMemoryElementListener(tx);
|
||||||
|
XmlModelSaxFileReader handler = new XmlModelSaxFileReader(elementListener, modelFile);
|
||||||
|
handler.parseFile();
|
||||||
|
statistics = handler.getStatistics();
|
||||||
|
}
|
||||||
|
|
||||||
|
String durationS = StringHelper.formatNanoDuration(statistics.durationNanos);
|
||||||
|
logger.info(MessageFormat.format(
|
||||||
|
"Loading XML Model file {0} for realm {1} took {2}.", modelFile.getName(), getRealm(), durationS)); //$NON-NLS-1$
|
||||||
|
logger.info(MessageFormat.format("Loaded {0} Orders", statistics.nrOfOrders)); //$NON-NLS-1$
|
||||||
|
logger.info(MessageFormat.format("Loaded {0} Resources", statistics.nrOfResources)); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop() {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroy() {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
package li.strolch.persistence.inmemory;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import li.strolch.agent.impl.StrolchRealm;
|
||||||
|
import li.strolch.persistence.api.OrderDao;
|
||||||
|
import li.strolch.persistence.api.PersistenceHandler;
|
||||||
|
import li.strolch.persistence.api.ResourceDao;
|
||||||
|
import li.strolch.persistence.api.StrolchTransaction;
|
||||||
|
|
||||||
|
public class InMemoryPersistence implements PersistenceHandler {
|
||||||
|
|
||||||
|
private Map<String, DaoCache> daoCache;
|
||||||
|
|
||||||
|
public InMemoryPersistence() {
|
||||||
|
this.daoCache = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StrolchTransaction openTx(StrolchRealm realm) {
|
||||||
|
return new InMemoryTransaction(realm, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OrderDao getOrderDao(StrolchTransaction tx) {
|
||||||
|
DaoCache daoCache = getDaoCache(tx);
|
||||||
|
return daoCache.getOrderDao();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResourceDao getResourceDao(StrolchTransaction tx) {
|
||||||
|
DaoCache daoCache = getDaoCache(tx);
|
||||||
|
return daoCache.getResourceDao();
|
||||||
|
}
|
||||||
|
|
||||||
|
private synchronized DaoCache getDaoCache(StrolchTransaction tx) {
|
||||||
|
DaoCache daoCache = this.daoCache.get(tx.getRealmName());
|
||||||
|
if (daoCache == null) {
|
||||||
|
daoCache = new DaoCache(new InMemoryOrderDao(), new InMemoryResourceDao());
|
||||||
|
this.daoCache.put(tx.getRealmName(), daoCache);
|
||||||
|
}
|
||||||
|
return daoCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DaoCache {
|
||||||
|
private OrderDao orderDao;
|
||||||
|
private ResourceDao resourceDao;
|
||||||
|
|
||||||
|
public DaoCache(OrderDao orderDao, ResourceDao resourceDao) {
|
||||||
|
this.orderDao = orderDao;
|
||||||
|
this.resourceDao = resourceDao;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrderDao getOrderDao() {
|
||||||
|
return this.orderDao;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResourceDao getResourceDao() {
|
||||||
|
return this.resourceDao;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,8 +1,20 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package li.strolch.persistence.inmemory;
|
package li.strolch.persistence.inmemory;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import li.strolch.agent.api.ComponentContainer;
|
import li.strolch.agent.api.ComponentContainer;
|
||||||
import li.strolch.agent.api.StrolchComponent;
|
import li.strolch.agent.api.StrolchComponent;
|
||||||
import li.strolch.agent.impl.StrolchRealm;
|
import li.strolch.agent.impl.StrolchRealm;
|
||||||
|
@ -12,61 +24,40 @@ import li.strolch.persistence.api.ResourceDao;
|
||||||
import li.strolch.persistence.api.StrolchTransaction;
|
import li.strolch.persistence.api.StrolchTransaction;
|
||||||
import li.strolch.runtime.configuration.ComponentConfiguration;
|
import li.strolch.runtime.configuration.ComponentConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class InMemoryPersistenceHandler extends StrolchComponent implements PersistenceHandler {
|
public class InMemoryPersistenceHandler extends StrolchComponent implements PersistenceHandler {
|
||||||
|
|
||||||
private Map<String, DaoCache> daoCache;
|
private InMemoryPersistence persistenceHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param container
|
||||||
|
* @param componentName
|
||||||
|
*/
|
||||||
public InMemoryPersistenceHandler(ComponentContainer container, String componentName) {
|
public InMemoryPersistenceHandler(ComponentContainer container, String componentName) {
|
||||||
super(container, componentName);
|
super(container, componentName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StrolchTransaction openTx(StrolchRealm realm) {
|
public void initialize(ComponentConfiguration configuration) {
|
||||||
return new InMemoryTransaction(realm, this);
|
this.persistenceHandler = new InMemoryPersistence();
|
||||||
|
super.initialize(configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(ComponentConfiguration configuration) {
|
public StrolchTransaction openTx(StrolchRealm realm) {
|
||||||
super.initialize(configuration);
|
return this.persistenceHandler.openTx(realm);
|
||||||
this.daoCache = new HashMap<>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OrderDao getOrderDao(StrolchTransaction tx) {
|
public OrderDao getOrderDao(StrolchTransaction tx) {
|
||||||
DaoCache daoCache = getDaoCache(tx);
|
return this.persistenceHandler.getOrderDao(tx);
|
||||||
return daoCache.getOrderDao();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourceDao getResourceDao(StrolchTransaction tx) {
|
public ResourceDao getResourceDao(StrolchTransaction tx) {
|
||||||
DaoCache daoCache = getDaoCache(tx);
|
return this.persistenceHandler.getResourceDao(tx);
|
||||||
return daoCache.getResourceDao();
|
|
||||||
}
|
|
||||||
|
|
||||||
private synchronized DaoCache getDaoCache(StrolchTransaction tx) {
|
|
||||||
DaoCache daoCache = this.daoCache.get(tx.getRealmName());
|
|
||||||
if (daoCache == null) {
|
|
||||||
daoCache = new DaoCache(new InMemoryOrderDao(), new InMemoryResourceDao());
|
|
||||||
this.daoCache.put(tx.getRealmName(), daoCache);
|
|
||||||
}
|
|
||||||
return daoCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DaoCache {
|
|
||||||
private OrderDao orderDao;
|
|
||||||
private ResourceDao resourceDao;
|
|
||||||
|
|
||||||
public DaoCache(OrderDao orderDao, ResourceDao resourceDao) {
|
|
||||||
this.orderDao = orderDao;
|
|
||||||
this.resourceDao = resourceDao;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderDao getOrderDao() {
|
|
||||||
return this.orderDao;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResourceDao getResourceDao() {
|
|
||||||
return this.resourceDao;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ import ch.eitchnet.utils.helper.StringHelper;
|
||||||
|
|
||||||
public class InMemoryTransaction extends AbstractTransaction {
|
public class InMemoryTransaction extends AbstractTransaction {
|
||||||
|
|
||||||
private InMemoryPersistenceHandler persistenceHandler;
|
private InMemoryPersistence persistenceHandler;
|
||||||
|
|
||||||
private TransactionCloseStrategy closeStrategy;
|
private TransactionCloseStrategy closeStrategy;
|
||||||
private ObserverHandler observerHandler;
|
private ObserverHandler observerHandler;
|
||||||
|
@ -28,7 +28,7 @@ public class InMemoryTransaction extends AbstractTransaction {
|
||||||
private TransactionResult txResult;
|
private TransactionResult txResult;
|
||||||
private boolean open;
|
private boolean open;
|
||||||
|
|
||||||
public InMemoryTransaction(StrolchRealm realm, InMemoryPersistenceHandler persistenceHandler) {
|
public InMemoryTransaction(StrolchRealm realm, InMemoryPersistence persistenceHandler) {
|
||||||
super(realm);
|
super(realm);
|
||||||
this.persistenceHandler = persistenceHandler;
|
this.persistenceHandler = persistenceHandler;
|
||||||
this.startTime = System.nanoTime();
|
this.startTime = System.nanoTime();
|
||||||
|
|
|
@ -18,7 +18,7 @@ package li.strolch.service.api;
|
||||||
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.ElementMapHandler;
|
import li.strolch.agent.api.RealmHandler;
|
||||||
import li.strolch.agent.impl.StrolchRealm;
|
import li.strolch.agent.impl.StrolchRealm;
|
||||||
import li.strolch.exception.StrolchException;
|
import li.strolch.exception.StrolchException;
|
||||||
import li.strolch.persistence.api.StrolchTransaction;
|
import li.strolch.persistence.api.StrolchTransaction;
|
||||||
|
@ -79,11 +79,11 @@ public abstract class AbstractService<T extends ServiceArgument, U extends Servi
|
||||||
}
|
}
|
||||||
|
|
||||||
protected StrolchRealm getRealm(String realm) {
|
protected StrolchRealm getRealm(String realm) {
|
||||||
return getComponent(ElementMapHandler.class).getRealm(realm);
|
return getComponent(RealmHandler.class).getRealm(realm);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected StrolchTransaction openTx(String realm) {
|
protected StrolchTransaction openTx(String realm) {
|
||||||
return getComponent(ElementMapHandler.class).getRealm(realm).openTx();
|
return getComponent(RealmHandler.class).getRealm(realm).openTx();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -15,8 +15,21 @@
|
||||||
*/
|
*/
|
||||||
package li.strolch.agent;
|
package li.strolch.agent;
|
||||||
|
|
||||||
|
import static li.strolch.agent.ComponentContainerTest.PATH_REALM_CONTAINER;
|
||||||
|
import static li.strolch.agent.ComponentContainerTest.PATH_REALM_RUNTIME;
|
||||||
|
import static li.strolch.agent.ComponentContainerTest.destroyContainer;
|
||||||
|
import static li.strolch.agent.ComponentContainerTest.logger;
|
||||||
|
import static li.strolch.agent.ComponentContainerTest.startContainer;
|
||||||
|
import static li.strolch.agent.ComponentContainerTest.testContainer;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import li.strolch.agent.api.ComponentContainer;
|
||||||
import li.strolch.agent.api.StrolchAgent;
|
import li.strolch.agent.api.StrolchAgent;
|
||||||
import static li.strolch.agent.ComponentContainerTest.*;
|
import li.strolch.agent.impl.DataStoreMode;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -32,7 +45,20 @@ public class RealmTest {
|
||||||
StrolchAgent agent = startContainer(PATH_REALM_RUNTIME, PATH_REALM_CONTAINER);
|
StrolchAgent agent = startContainer(PATH_REALM_RUNTIME, PATH_REALM_CONTAINER);
|
||||||
testContainer(agent);
|
testContainer(agent);
|
||||||
|
|
||||||
|
ComponentContainer container = agent.getContainer();
|
||||||
|
Set<String> realmNames = container.getRealmNames();
|
||||||
|
assertEquals(6, realmNames.size());
|
||||||
|
|
||||||
|
Set<String> expectedRealmNames = new HashSet<>(Arrays.asList("defaultRealm", "myRealm", "otherRealm",
|
||||||
|
"cachedRealm", "transactionalRealm", "emptyRealm"));
|
||||||
|
assertEquals(expectedRealmNames, realmNames);
|
||||||
|
|
||||||
|
assertEquals(DataStoreMode.TRANSIENT, container.getRealm("defaultRealm").getMode());
|
||||||
|
assertEquals(DataStoreMode.TRANSIENT, container.getRealm("myRealm").getMode());
|
||||||
|
assertEquals(DataStoreMode.TRANSIENT, container.getRealm("otherRealm").getMode());
|
||||||
|
assertEquals(DataStoreMode.CACHED, container.getRealm("cachedRealm").getMode());
|
||||||
|
assertEquals(DataStoreMode.TRANSACTIONAL, container.getRealm("transactionalRealm").getMode());
|
||||||
|
assertEquals(DataStoreMode.EMPTY, container.getRealm("emptyRealm").getMode());
|
||||||
|
|
||||||
destroyContainer(agent);
|
destroyContainer(agent);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -29,10 +29,6 @@ import li.strolch.agent.api.StrolchComponent;
|
||||||
import li.strolch.agent.impl.ComponentContainerImpl;
|
import li.strolch.agent.impl.ComponentContainerImpl;
|
||||||
import li.strolch.agent.impl.ComponentController;
|
import li.strolch.agent.impl.ComponentController;
|
||||||
import li.strolch.agent.impl.ComponentDependencyAnalyzer;
|
import li.strolch.agent.impl.ComponentDependencyAnalyzer;
|
||||||
import li.strolch.agent.impl.DataStoreMode;
|
|
||||||
import li.strolch.runtime.configuration.ConfigurationParser;
|
|
||||||
import li.strolch.runtime.configuration.StrolchConfiguration;
|
|
||||||
import li.strolch.runtime.configuration.StrolchConfigurationException;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
|
@ -111,7 +107,7 @@ public class ControllerDependencyTest {
|
||||||
@Before
|
@Before
|
||||||
public void setupModel() {
|
public void setupModel() {
|
||||||
|
|
||||||
this.container = new ComponentContainerImpl(null, DataStoreMode.EMPTY);
|
this.container = new ComponentContainerImpl(null);
|
||||||
|
|
||||||
this.con2 = new ComponentController(new StrolchComponent(this.container, "2"));
|
this.con2 = new ComponentController(new StrolchComponent(this.container, "2"));
|
||||||
this.con5 = new ComponentController(new StrolchComponent(this.container, "5"));
|
this.con5 = new ComponentController(new StrolchComponent(this.container, "5"));
|
||||||
|
@ -342,7 +338,6 @@ public class ControllerDependencyTest {
|
||||||
this.con9.addUpstreamDependency(this.con3);
|
this.con9.addUpstreamDependency(this.con3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldNotBreakModel1() {
|
public void shouldNotBreakModel1() {
|
||||||
assertModel();
|
assertModel();
|
||||||
|
@ -540,7 +535,7 @@ public class ControllerDependencyTest {
|
||||||
@Test
|
@Test
|
||||||
public void shouldAddDepedencies() {
|
public void shouldAddDepedencies() {
|
||||||
|
|
||||||
ComponentContainerImpl container = new ComponentContainerImpl(null, DataStoreMode.EMPTY);
|
ComponentContainerImpl container = new ComponentContainerImpl(null);
|
||||||
StrolchComponent component = new StrolchComponent(container, "1"); //$NON-NLS-1$
|
StrolchComponent component = new StrolchComponent(container, "1"); //$NON-NLS-1$
|
||||||
ComponentController controller = new ComponentController(component);
|
ComponentController controller = new ComponentController(component);
|
||||||
|
|
||||||
|
|
|
@ -3,16 +3,24 @@
|
||||||
<Runtime>
|
<Runtime>
|
||||||
<applicationName>StrolchRuntimeTest</applicationName>
|
<applicationName>StrolchRuntimeTest</applicationName>
|
||||||
<Properties>
|
<Properties>
|
||||||
<dataStoreMode>CACHED</dataStoreMode>
|
|
||||||
<dataStoreFile>StrolchModel.xml</dataStoreFile>
|
|
||||||
<verbose>true</verbose>
|
<verbose>true</verbose>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Runtime>
|
</Runtime>
|
||||||
|
<Component>
|
||||||
|
<name>RealmHandler</name>
|
||||||
|
<api>li.strolch.agent.api.RealmHandler</api>
|
||||||
|
<impl>li.strolch.agent.impl.DefaultRealmHandler</impl>
|
||||||
|
<depends>PersistenceHandler</depends>
|
||||||
|
<Properties>
|
||||||
|
<dataStoreMode>CACHED</dataStoreMode>
|
||||||
|
<dataStoreFile>StrolchModel.xml</dataStoreFile>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
<Component>
|
<Component>
|
||||||
<name>ServiceHandler</name>
|
<name>ServiceHandler</name>
|
||||||
<api>li.strolch.runtime.configuration.model.ServiceHandlerTest</api>
|
<api>li.strolch.runtime.configuration.model.ServiceHandlerTest</api>
|
||||||
<impl>li.strolch.runtime.configuration.model.ServiceHandlerTestImpl</impl>
|
<impl>li.strolch.runtime.configuration.model.ServiceHandlerTestImpl</impl>
|
||||||
<depends>PersistenceHandler</depends>
|
<depends>RealmHandler</depends>
|
||||||
<Properties>
|
<Properties>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Component>
|
</Component>
|
||||||
|
|
|
@ -3,15 +3,22 @@
|
||||||
<Runtime>
|
<Runtime>
|
||||||
<applicationName>StrolchRuntimeTest</applicationName>
|
<applicationName>StrolchRuntimeTest</applicationName>
|
||||||
<Properties>
|
<Properties>
|
||||||
<dataStoreMode>EMPTY</dataStoreMode>
|
|
||||||
<verbose>true</verbose>
|
<verbose>true</verbose>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Runtime>
|
</Runtime>
|
||||||
|
<Component>
|
||||||
|
<name>RealmHandler</name>
|
||||||
|
<api>li.strolch.agent.api.RealmHandler</api>
|
||||||
|
<impl>li.strolch.agent.impl.DefaultRealmHandler</impl>
|
||||||
|
<Properties>
|
||||||
|
<dataStoreMode>EMPTY</dataStoreMode>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
<Component>
|
<Component>
|
||||||
<name>ServiceHandler</name>
|
<name>ServiceHandler</name>
|
||||||
<api>li.strolch.service.api.ServiceHandler</api>
|
<api>li.strolch.service.api.ServiceHandler</api>
|
||||||
<impl>li.strolch.service.SimpleServiceHandler</impl>
|
<impl>li.strolch.service.SimpleServiceHandler</impl>
|
||||||
<depends>Agent</depends>
|
<depends>RealmHandler</depends>
|
||||||
<Properties>
|
<Properties>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Component>
|
</Component>
|
||||||
|
|
|
@ -3,14 +3,22 @@
|
||||||
<Runtime>
|
<Runtime>
|
||||||
<applicationName>StrolchRuntimeTest</applicationName>
|
<applicationName>StrolchRuntimeTest</applicationName>
|
||||||
<Properties>
|
<Properties>
|
||||||
<dataStoreMode>EMPTY</dataStoreMode>
|
|
||||||
<verbose>true</verbose>
|
<verbose>true</verbose>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Runtime>
|
</Runtime>
|
||||||
|
<Component>
|
||||||
|
<name>RealmHandler</name>
|
||||||
|
<api>li.strolch.agent.api.RealmHandler</api>
|
||||||
|
<impl>li.strolch.agent.impl.DefaultRealmHandler</impl>
|
||||||
|
<Properties>
|
||||||
|
<dataStoreMode>EMPTY</dataStoreMode>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
<Component>
|
<Component>
|
||||||
<name>ServiceHandler</name>
|
<name>ServiceHandler</name>
|
||||||
<api>li.strolch.runtime.configuration.model.ServiceHandlerTest</api>
|
<api>li.strolch.runtime.configuration.model.ServiceHandlerTest</api>
|
||||||
<impl>li.strolch.runtime.configuration.model.ServiceHandlerTestImpl</impl>
|
<impl>li.strolch.runtime.configuration.model.ServiceHandlerTestImpl</impl>
|
||||||
|
<depends>RealmHandler</depends>
|
||||||
<Properties>
|
<Properties>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Component>
|
</Component>
|
||||||
|
|
|
@ -4,18 +4,31 @@
|
||||||
<applicationName>StrolchRuntimeTest</applicationName>
|
<applicationName>StrolchRuntimeTest</applicationName>
|
||||||
<Properties>
|
<Properties>
|
||||||
<dataStoreMode>TRANSIENT</dataStoreMode>
|
<dataStoreMode>TRANSIENT</dataStoreMode>
|
||||||
<realms>defaultRealm, myRealm, otherRealm</realms>
|
|
||||||
<dataStoreFile>DefaultRealm.xml</dataStoreFile>
|
|
||||||
<dataStoreFile.myRealm>MyRealm.xml</dataStoreFile.myRealm>
|
|
||||||
<dataStoreFile.otherRealm>OtherRealm.xml</dataStoreFile.otherRealm>
|
|
||||||
<verbose>true</verbose>
|
<verbose>true</verbose>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Runtime>
|
</Runtime>
|
||||||
|
<Component>
|
||||||
|
<name>RealmHandler</name>
|
||||||
|
<api>li.strolch.agent.api.RealmHandler</api>
|
||||||
|
<impl>li.strolch.agent.impl.DefaultRealmHandler</impl>
|
||||||
|
<Properties>
|
||||||
|
<realms>defaultRealm, myRealm, otherRealm, cachedRealm, transactionalRealm, emptyRealm</realms>
|
||||||
|
<dataStoreMode>TRANSIENT</dataStoreMode>
|
||||||
|
<dataStoreFile>DefaultRealm.xml</dataStoreFile>
|
||||||
|
<dataStoreMode.myRealm>TRANSIENT</dataStoreMode.myRealm>
|
||||||
|
<dataStoreFile.myRealm>MyRealm.xml</dataStoreFile.myRealm>
|
||||||
|
<dataStoreMode.otherRealm>TRANSIENT</dataStoreMode.otherRealm>
|
||||||
|
<dataStoreFile.otherRealm>OtherRealm.xml</dataStoreFile.otherRealm>
|
||||||
|
<dataStoreMode.transactionalRealm>TRANSACTIONAL</dataStoreMode.transactionalRealm>
|
||||||
|
<dataStoreMode.cachedRealm>CACHED</dataStoreMode.cachedRealm>
|
||||||
|
<dataStoreMode.emptyRealm>EMPTY</dataStoreMode.emptyRealm>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
<Component>
|
<Component>
|
||||||
<name>ServiceHandler</name>
|
<name>ServiceHandler</name>
|
||||||
<api>li.strolch.runtime.configuration.model.ServiceHandlerTest</api>
|
<api>li.strolch.runtime.configuration.model.ServiceHandlerTest</api>
|
||||||
<impl>li.strolch.runtime.configuration.model.ServiceHandlerTestImpl</impl>
|
<impl>li.strolch.runtime.configuration.model.ServiceHandlerTestImpl</impl>
|
||||||
<depends>PersistenceHandler</depends>
|
<depends>RealmHandler</depends>
|
||||||
<Properties>
|
<Properties>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Component>
|
</Component>
|
||||||
|
@ -35,4 +48,9 @@
|
||||||
<verbose>true</verbose>
|
<verbose>true</verbose>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Component>
|
</Component>
|
||||||
|
<Component>
|
||||||
|
<name>PersistenceHandler</name>
|
||||||
|
<api>li.strolch.persistence.api.PersistenceHandler</api>
|
||||||
|
<impl>li.strolch.persistence.inmemory.InMemoryPersistenceHandler</impl>
|
||||||
|
</Component>
|
||||||
</StrolchConfiguration>
|
</StrolchConfiguration>
|
|
@ -3,16 +3,24 @@
|
||||||
<Runtime>
|
<Runtime>
|
||||||
<applicationName>StrolchRuntimeTest</applicationName>
|
<applicationName>StrolchRuntimeTest</applicationName>
|
||||||
<Properties>
|
<Properties>
|
||||||
<dataStoreMode>TRANSACTIONAL</dataStoreMode>
|
|
||||||
<dataStoreFile>StrolchModel.xml</dataStoreFile>
|
|
||||||
<verbose>true</verbose>
|
<verbose>true</verbose>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Runtime>
|
</Runtime>
|
||||||
|
<Component>
|
||||||
|
<name>RealmHandler</name>
|
||||||
|
<api>li.strolch.agent.api.RealmHandler</api>
|
||||||
|
<impl>li.strolch.agent.impl.DefaultRealmHandler</impl>
|
||||||
|
<depends>PersistenceHandler</depends>
|
||||||
|
<Properties>
|
||||||
|
<dataStoreMode>TRANSACTIONAL</dataStoreMode>
|
||||||
|
<dataStoreFile>StrolchModel.xml</dataStoreFile>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
<Component>
|
<Component>
|
||||||
<name>ServiceHandler</name>
|
<name>ServiceHandler</name>
|
||||||
<api>li.strolch.runtime.configuration.model.ServiceHandlerTest</api>
|
<api>li.strolch.runtime.configuration.model.ServiceHandlerTest</api>
|
||||||
<impl>li.strolch.runtime.configuration.model.ServiceHandlerTestImpl</impl>
|
<impl>li.strolch.runtime.configuration.model.ServiceHandlerTestImpl</impl>
|
||||||
<depends>PersistenceHandler</depends>
|
<depends>RealmHandler</depends>
|
||||||
<Properties>
|
<Properties>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Component>
|
</Component>
|
||||||
|
|
|
@ -3,16 +3,24 @@
|
||||||
<Runtime>
|
<Runtime>
|
||||||
<applicationName>StrolchRuntimeTest</applicationName>
|
<applicationName>StrolchRuntimeTest</applicationName>
|
||||||
<Properties>
|
<Properties>
|
||||||
<dataStoreMode>TRANSIENT</dataStoreMode>
|
|
||||||
<dataStoreFile>StrolchModel.xml</dataStoreFile>
|
|
||||||
<verbose>true</verbose>
|
<verbose>true</verbose>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Runtime>
|
</Runtime>
|
||||||
|
<Component>
|
||||||
|
<name>RealmHandler</name>
|
||||||
|
<api>li.strolch.agent.api.RealmHandler</api>
|
||||||
|
<impl>li.strolch.agent.impl.DefaultRealmHandler</impl>
|
||||||
|
<!-- depends>PersistenceHandler</depends-->
|
||||||
|
<Properties>
|
||||||
|
<dataStoreMode>TRANSIENT</dataStoreMode>
|
||||||
|
<dataStoreFile>StrolchModel.xml</dataStoreFile>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
<Component>
|
<Component>
|
||||||
<name>ServiceHandler</name>
|
<name>ServiceHandler</name>
|
||||||
<api>li.strolch.runtime.configuration.model.ServiceHandlerTest</api>
|
<api>li.strolch.runtime.configuration.model.ServiceHandlerTest</api>
|
||||||
<impl>li.strolch.runtime.configuration.model.ServiceHandlerTestImpl</impl>
|
<impl>li.strolch.runtime.configuration.model.ServiceHandlerTestImpl</impl>
|
||||||
<depends>PersistenceHandler</depends>
|
<depends>RealmHandler</depends>
|
||||||
<Properties>
|
<Properties>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Component>
|
</Component>
|
||||||
|
@ -36,7 +44,7 @@
|
||||||
<name>EnumHandler</name>
|
<name>EnumHandler</name>
|
||||||
<api>li.strolch.runtime.query.enums.EnumHandler</api>
|
<api>li.strolch.runtime.query.enums.EnumHandler</api>
|
||||||
<impl>li.strolch.runtime.query.enums.DefaultEnumHandler</impl>
|
<impl>li.strolch.runtime.query.enums.DefaultEnumHandler</impl>
|
||||||
<depends>ElementMapHandler</depends>
|
<depends>RealmHandler</depends>
|
||||||
<Properties>
|
<Properties>
|
||||||
<realm>defaultRealm</realm>
|
<realm>defaultRealm</realm>
|
||||||
<salutations>Resource/Enumeration/salutations</salutations>
|
<salutations>Resource/Enumeration/salutations</salutations>
|
||||||
|
|
Loading…
Reference in New Issue