use of org.opennms.netmgt.collection.api.StorageStrategy in project opennms by OpenNMS.
the class GenericTypeResource method instantiateStorageStrategy.
private StorageStrategy instantiateStorageStrategy(String className, String resourceTypeName) {
Class<?> cinst;
try {
cinst = Class.forName(className);
} catch (ClassNotFoundException e) {
throw new ObjectRetrievalFailureException(StorageStrategy.class, className, "Could not load class", e);
}
try {
StorageStrategy storageStrategy = (StorageStrategy) cinst.newInstance();
storageStrategy.setResourceTypeName(resourceTypeName);
return storageStrategy;
} catch (InstantiationException e) {
throw new ObjectRetrievalFailureException(StorageStrategy.class, className, "Could not instantiate", e);
} catch (IllegalAccessException e) {
throw new ObjectRetrievalFailureException(StorageStrategy.class, className, "Could not instantiate", e);
}
}
use of org.opennms.netmgt.collection.api.StorageStrategy in project opennms by OpenNMS.
the class WmiResourceType method instantiateStorageStrategy.
private void instantiateStorageStrategy(String className) {
Class<?> cinst;
try {
cinst = Class.forName(className);
} catch (ClassNotFoundException e) {
throw new ObjectRetrievalFailureException(StorageStrategy.class, className, "Could not load class", e);
}
try {
m_storageStrategy = (StorageStrategy) cinst.newInstance();
} catch (InstantiationException e) {
throw new ObjectRetrievalFailureException(StorageStrategy.class, className, "Could not instantiate", e);
} catch (IllegalAccessException e) {
throw new ObjectRetrievalFailureException(StorageStrategy.class, className, "Could not instantiate", e);
}
m_storageStrategy.setResourceTypeName(m_resourceType);
}
use of org.opennms.netmgt.collection.api.StorageStrategy in project opennms by OpenNMS.
the class GenericIndexResourceType method createTypes.
protected static Map<String, GenericIndexResourceType> createTypes(Map<String, ResourceType> configuredResourceTypes, ResourceStorageDao resourceStorageDao) {
Map<String, GenericIndexResourceType> resourceTypes = Maps.newLinkedHashMap();
List<ResourceType> resourceTypeList = new LinkedList<ResourceType>(configuredResourceTypes.values());
Collections.sort(resourceTypeList, new Comparator<ResourceType>() {
@Override
public int compare(ResourceType r0, ResourceType r1) {
// Sort by resource label, allowing the resource label to be null
final Comparator<? super String> comparator = (a, b) -> a.compareTo(b);
return Objects.compare(r0.getLabel(), r1.getLabel(), Comparator.nullsLast(comparator));
}
});
for (ResourceType resourceType : resourceTypeList) {
String className = resourceType.getStorageStrategy().getClazz();
Class<?> cinst;
try {
cinst = Class.forName(className);
} catch (ClassNotFoundException e) {
throw new ObjectRetrievalFailureException(StorageStrategy.class, className, "Could not load class '" + className + "' for resource type '" + resourceType.getName() + "'", e);
}
StorageStrategy storageStrategy;
try {
storageStrategy = (StorageStrategy) cinst.newInstance();
} catch (InstantiationException e) {
throw new ObjectRetrievalFailureException(StorageStrategy.class, className, "Could not instantiate class '" + className + "' for resource type '" + resourceType.getName() + "'", e);
} catch (IllegalAccessException e) {
throw new ObjectRetrievalFailureException(StorageStrategy.class, className, "Could not instantiate class '" + className + "' for resource type '" + resourceType.getName() + "'", e);
}
storageStrategy.setResourceTypeName(resourceType.getName());
GenericIndexResourceType genericIndexResourceType = new GenericIndexResourceType(resourceStorageDao, resourceType.getName(), resourceType.getLabel(), resourceType.getResourceLabel(), storageStrategy);
resourceTypes.put(genericIndexResourceType.getName(), genericIndexResourceType);
}
return resourceTypes;
}
use of org.opennms.netmgt.collection.api.StorageStrategy in project opennms by OpenNMS.
the class GenericIndexResourceType method instantiateStorageStrategy.
private void instantiateStorageStrategy(String className) {
Class<?> cinst;
try {
cinst = Class.forName(className);
} catch (ClassNotFoundException e) {
throw new ObjectRetrievalFailureException(StorageStrategy.class, className, "Could not load class", e);
}
try {
m_storageStrategy = (StorageStrategy) cinst.newInstance();
} catch (InstantiationException e) {
throw new ObjectRetrievalFailureException(StorageStrategy.class, className, "Could not instantiate", e);
} catch (IllegalAccessException e) {
throw new ObjectRetrievalFailureException(StorageStrategy.class, className, "Could not instantiate", e);
}
m_storageStrategy.setResourceTypeName(m_name);
if (getAgent() != null)
m_storageStrategy.setStorageStrategyService(getAgent());
}
Aggregations