use of org.opennms.netmgt.provision.ServiceDetector in project opennms by OpenNMS.
the class DefaultForeignSourceService method getDetectorTypes.
/**
* <p>getDetectorTypes</p>
*
* @return a {@link java.util.Map} object.
*/
@Override
public Map<String, String> getDetectorTypes() {
if (m_detectors == null) {
Map<String, String> detectors = new TreeMap<String, String>();
for (ServiceDetector d : m_serviceRegistry.findProviders(ServiceDetector.class)) {
String serviceName = d.getServiceName();
if (serviceName == null) {
serviceName = d.getClass().getSimpleName();
}
String className = d.getClass().getName();
// NMS-8119: The class name may be changed when using proxy objects
if (d instanceof TargetClassAware) {
className = ((TargetClassAware) d).getTargetClass().getName();
}
detectors.put(serviceName, className);
}
m_detectors = new LinkedHashMap<String, String>();
for (Entry<String, String> e : detectors.entrySet()) {
m_detectors.put(e.getValue(), e.getKey());
}
}
return m_detectors;
}
use of org.opennms.netmgt.provision.ServiceDetector in project opennms by OpenNMS.
the class ServiceDetectorRegistryImpl method createDetector.
private static ServiceDetector createDetector(ServiceDetectorFactory<? extends ServiceDetector> factory, Map<String, String> properties) {
if (factory == null) {
return null;
}
final ServiceDetector detector = factory.createDetector();
BeanWrapper wrapper = PropertyAccessorFactory.forBeanPropertyAccess(detector);
wrapper.setPropertyValues(properties);
return detector;
}
use of org.opennms.netmgt.provision.ServiceDetector in project opennms by OpenNMS.
the class ServiceDetectorRegistryImpl method afterPropertiesSet.
@Override
public void afterPropertiesSet() throws Exception {
// Register all of the @Autowired ServiceDetectorFactory implementations
if (m_detectorFactories != null) {
for (ServiceDetectorFactory<?> factory : m_detectorFactories) {
// Determine the implementation type
Map<String, String> props = new HashMap<>();
ServiceDetector detector = factory.createDetector();
// Register the factory
onBind(factory, props);
// Add the detector to the service registry
addAllExtensions(Collections.singleton(detector), ServiceDetector.class);
}
}
}
use of org.opennms.netmgt.provision.ServiceDetector in project opennms by OpenNMS.
the class DetectorClientRpcModule method execute.
@Override
public CompletableFuture<DetectorResponseDTO> execute(DetectorRequestDTO request) {
String className = request.getClassName();
Map<String, String> attributes = request.getAttributeMap();
ServiceDetector detector = serviceDetectorRegistry.getDetectorByClassName(className, attributes);
if (detector == null) {
throw new IllegalArgumentException("No detector found with class name '" + className + "'.");
}
return detectService(detector, request);
}
use of org.opennms.netmgt.provision.ServiceDetector in project opennms by OpenNMS.
the class DetectorRequestBuilderImpl method withServiceName.
@Override
public DetectorRequestBuilder withServiceName(String serviceName) {
final ServiceDetector detector = client.getRegistry().getDetectorByServiceName(serviceName);
if (detector == null) {
throw new IllegalArgumentException("No detector found with service name '" + serviceName + "'.");
}
this.className = detector.getClass().getCanonicalName();
return this;
}
Aggregations