<version>2.11.0</version>
</dependency>
<dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- <version>3.2.2</version>
+ <!-- only used in InstanceManger class -->
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-collections4</artifactId>
+ <version>4.4</version>
</dependency>
<dependency>
<groupId>net.sf.jopt-simple</groupId>
import java.io.IOException;
import java.util.List;
-import org.apache.commons.collections.map.ListOrderedMap;
+import org.apache.commons.collections4.map.ListOrderedMap;
import org.apache.log4j.Logger;
import org.eclipse.jetty.util.component.LifeCycle;
private static final Logger logger = Logger.getLogger(InstanceManager.class);
- private ListOrderedMap instances = new ListOrderedMap();
+ private ListOrderedMap<String,CdmInstance> instances = new ListOrderedMap<>();
private final StartupQueue queue = new StartupQueue();
*
* @return the instances
*/
- @SuppressWarnings("unchecked")
public List<CdmInstance> getInstances() {
return instances.valueList();
}
public CdmInstance getInstance(String instanceName) {
- return (CdmInstance) instances.get(instanceName);
+ return instances.get(instanceName);
}
/**
* Starts the instance
*
- * Rebinds the JndiDataSource and starts the given instance. The method
+ * Re-binds the JndiDataSource and starts the given instance. The method
* returns once the instance is fully started up.
*
* @param instance
*/
synchronized public void reLoadInstanceConfigurations() {
- ListOrderedMap currentInstances = instances;
- ListOrderedMap updatedInstances = new ListOrderedMap();
+ ListOrderedMap<String,CdmInstance> currentInstances = instances;
+ ListOrderedMap<String,CdmInstance> updatedInstances = new ListOrderedMap<>();
List<Configuration> configList = DataSourcePropertyParser.parseDataSourceConfigs(datasourcesFile);
logger.info("cdm server instance names loaded: " + configList.toString());
for (Configuration config : configList) {
String key = config.getInstanceName();
if (currentInstances.containsKey(key)) {
- CdmInstance existingInstance = (CdmInstance) currentInstances.get(key);
+ CdmInstance existingInstance = currentInstances.get(key);
if (!(existingInstance.getStatus().equals(Status.removed) && existingInstance.getWebAppContext() == null)) {
// re-added instance if not already removed (removed
// instances will not be re-added if they have been stopped
}
// find removed instances
- for (Object keyOfExisting : currentInstances.keyList()) {
+ for (String keyOfExisting : currentInstances.keyList()) {
if (!updatedInstances.containsKey(keyOfExisting)) {
- CdmInstance removedInstance = (CdmInstance) currentInstances.get(keyOfExisting);
+ CdmInstance removedInstance = currentInstances.get(keyOfExisting);
if (removedInstance.getStatus().equals(Status.removed)) {
// instance already is removed, forget it now
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
-
}
}