本文整理汇总了Java中org.opennms.netmgt.provision.persist.foreignsource.ForeignSource.getDetectors方法的典型用法代码示例。如果您正苦于以下问题:Java ForeignSource.getDetectors方法的具体用法?Java ForeignSource.getDetectors怎么用?Java ForeignSource.getDetectors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opennms.netmgt.provision.persist.foreignsource.ForeignSource
的用法示例。
在下文中一共展示了ForeignSource.getDetectors方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDetectorsForForeignSource
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
/** {@inheritDoc} */
public List<ServiceDetector> getDetectorsForForeignSource(final String foreignSourceName) {
final ForeignSource foreignSource = m_foreignSourceRepository.getForeignSource(foreignSourceName);
assertNotNull(foreignSource, "Expected a foreignSource with name %s", foreignSourceName);
final List<PluginConfig> detectorConfigs = foreignSource.getDetectors();
if (detectorConfigs == null) {
return new ArrayList<ServiceDetector>(m_pluginRegistry.getAllPlugins(ServiceDetector.class));
}
final List<ServiceDetector> detectors = new ArrayList<ServiceDetector>(detectorConfigs.size());
for(final PluginConfig detectorConfig : detectorConfigs) {
final ServiceDetector detector = m_pluginRegistry.getPluginInstance(ServiceDetector.class, detectorConfig);
if (detector == null) {
errorf(this, "Configured plugin does not exist: %s", detectorConfig);
} else {
detector.setServiceName(detectorConfig.getName());
detector.init();
detectors.add(detector);
}
}
return detectors;
}
示例2: testDefaultForeignSource
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
@Test
public void testDefaultForeignSource() throws Exception {
createRequisition();
List<String> detectorList = Arrays.asList(new String[]{ "DNS", "FTP", "HTTP", "HTTPS", "ICMP", "IMAP", "LDAP", "NRPE", "POP3", "SMTP", "SNMP", "SSH" });
String uuid = UUID.randomUUID().toString();
ForeignSource defaultForeignSource = m_foreignSourceRepository.getForeignSource(uuid);
assertEquals("name must match requested foreign source repository name", uuid, defaultForeignSource.getName());
assertEquals("scan-interval must be 1 day", 86400000, defaultForeignSource.getScanInterval().getMillis());
assertEquals("foreign source must have no default policies", 0, defaultForeignSource.getPolicies().size());
List<String> fsNames = new ArrayList<String>();
for (PluginConfig config : defaultForeignSource.getDetectors()) {
fsNames.add(config.getName());
}
assertEquals("detector list must match expected defaults", detectorList, fsNames);
assertTrue("foreign source must be tagged as default", defaultForeignSource.isDefault());
}
示例3: deleteDetector
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
/**
* <p>deleteDetector</p>
*
* @param foreignSource a {@link java.lang.String} object.
* @param detector a {@link java.lang.String} object.
* @return a {@link javax.ws.rs.core.Response} object.
*/
@DELETE
@Path("{foreignSource}/detectors/{detector}")
@Transactional
public Response deleteDetector(@PathParam("foreignSource") String foreignSource, @PathParam("detector") String detector) {
writeLock();
try {
ForeignSource fs = getActiveForeignSource(foreignSource);
List<PluginConfig> detectors = fs.getDetectors();
PluginConfig removed = removeEntry(detectors, detector);
if (removed != null) {
fs.updateDateStamp();
fs.setDetectors(detectors);
m_pendingForeignSourceRepository.save(fs);
return Response.ok().build();
}
return Response.notModified().build();
} finally {
writeUnlock();
}
}
示例4: processForeignSources
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
private Map<String, ServiceCompound> processForeignSources(ForeignSource foreignSource, Map<String, ServiceCompound> serviceCompounds) {
for (PluginConfig detector : foreignSource.getDetectors()) {
if (!serviceCompounds.containsKey(detector.getName())){
serviceCompounds.put(detector.getName(), new ServiceCompound(detector.getName()));
}
serviceCompounds.get(detector.getName()).setDetector(detector);
}
return serviceCompounds;
}
示例5: deleteDetector
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
/** {@inheritDoc} */
public ForeignSource deleteDetector(String foreignSource, String name) {
ForeignSource fs = getForeignSource(foreignSource);
List<PluginConfig> detectors = fs.getDetectors();
for (Iterator<PluginConfig> i = detectors.iterator(); i.hasNext(); ) {
PluginConfig pc = i.next();
if (pc.getName().equals(name)) {
i.remove();
break;
}
}
m_pendingForeignSourceRepository.save(fs);
return fs;
}