use of java.util.Dictionary in project opennms by OpenNMS.
the class KarafExtender method init.
public void init() throws InterruptedException {
Objects.requireNonNull(m_configurationAdmin, "configurationAdmin");
Objects.requireNonNull(m_mavenResolver, "mavenResolver");
Objects.requireNonNull(m_featuresService, "featuresService");
List<Repository> repositories;
try {
repositories = getRepositories();
} catch (IOException e) {
LOG.error("Failed to retrieve the list of repositories. Aborting.", e);
return;
}
// Prepend the featuresBoot from the repository definitions
List<Feature> featuresBoot = repositories.stream().flatMap(r -> r.getFeaturesBoot().stream()).collect(Collectors.toList());
try {
featuresBoot.addAll(getFeaturesBoot());
} catch (IOException e) {
LOG.error("Failed to retrieve the list of features to boot. Aborting.", e);
return;
}
// Filter the list of features
filterFeatures(featuresBoot);
// Build a comma separated list of our Maven repositories
StringBuilder mavenReposSb = new StringBuilder();
for (Repository repository : repositories) {
if (mavenReposSb.length() != 0) {
mavenReposSb.append(",");
}
mavenReposSb.append(repository.toMavenUri());
}
LOG.info("Updating Maven repositories to include: {}", mavenReposSb);
try {
final Configuration config = m_configurationAdmin.getConfiguration(PAX_MVN_PID);
if (config == null) {
throw new IOException("The OSGi configuration (admin) registry was found for pid " + PAX_MVN_PID + ", but a configuration could not be located/generated. This shouldn't happen.");
}
final Dictionary<String, Object> props = config.getProperties();
props.put(PAX_MVN_REPOSITORIES, mavenReposSb.toString());
config.update(props);
} catch (IOException e) {
LOG.error("Failed to update the list of Maven repositories to '{}'. Aborting.", mavenReposSb, e);
return;
}
// The configuration update is async, we need to wait for the feature URLs to be resolvable before we use them
LOG.info("Waiting up-to 30 seconds for the Maven repositories to be updated...");
// Attempting to resolve a missing features writes an exception to the log
// We sleep fix a fixed amount of time before our first try in order to help minimize the logged
// exceptions, even if we catch them
Thread.sleep(2000);
for (int i = 28; i > 0 && !canResolveAllFeatureUris(repositories); i--) {
Thread.sleep(1000);
}
for (Repository repository : repositories) {
for (URI featureUri : repository.getFeatureUris()) {
try {
LOG.info("Adding feature repository: {}", featureUri);
m_featuresService.addRepository(featureUri);
m_featuresService.refreshRepository(featureUri);
} catch (Exception e) {
LOG.error("Failed to add feature repository '{}'. Skipping.", featureUri, e);
}
}
}
final Set<String> featuresToInstall = featuresBoot.stream().map(f -> f.getVersion() != null ? f.getName() + "/" + f.getVersion() : f.getName()).collect(Collectors.toCollection(LinkedHashSet::new));
try {
LOG.info("Installing features: {}", featuresToInstall);
m_featuresService.installFeatures(featuresToInstall, EnumSet.noneOf(Option.class));
} catch (Exception e) {
LOG.error("Failed to install one or more features.", e);
}
}
use of java.util.Dictionary in project opennms by OpenNMS.
the class EchoRpcThreadIT method addServicesOnStartup.
@SuppressWarnings("rawtypes")
@Override
protected void addServicesOnStartup(Map<String, KeyValueHolder<Object, Dictionary>> services) {
services.put(MinionIdentity.class.getName(), new KeyValueHolder<Object, Dictionary>(new MockMinionIdentity(REMOTE_LOCATION_NAME), new Properties()));
Properties props = new Properties();
props.setProperty("alias", "opennms.broker");
services.put(Component.class.getName(), new KeyValueHolder<Object, Dictionary>(queuingservice, props));
services.put(RpcModule.class.getName(), new KeyValueHolder<Object, Dictionary>(lockingRpcModule, new Properties()));
}
use of java.util.Dictionary in project opennms by OpenNMS.
the class LocationAwareSnmpClientIT method addServicesOnStartup.
@SuppressWarnings("rawtypes")
@Override
protected void addServicesOnStartup(Map<String, KeyValueHolder<Object, Dictionary>> services) {
services.put(MinionIdentity.class.getName(), new KeyValueHolder<Object, Dictionary>(new MinionIdentity() {
@Override
public String getId() {
return "0";
}
@Override
public String getLocation() {
return REMOTE_LOCATION_NAME;
}
}, new Properties()));
Properties props = new Properties();
props.setProperty("alias", "opennms.broker");
services.put(Component.class.getName(), new KeyValueHolder<Object, Dictionary>(queuingservice, props));
}
use of java.util.Dictionary in project intellij-community by JetBrains.
the class JavadocGenerationPanel method handleSlider.
private void handleSlider() {
int value = myScopeSlider.getValue();
Dictionary labelTable = myScopeSlider.getLabelTable();
for (Enumeration enumeration = labelTable.keys(); enumeration.hasMoreElements(); ) {
Integer key = (Integer) enumeration.nextElement();
JLabel label = (JLabel) labelTable.get(key);
label.setForeground(key.intValue() <= value ? Color.black : Gray._100);
}
}
use of java.util.Dictionary in project intellij-community by JetBrains.
the class SliderSelectorAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
final JPanel result = new JPanel(new BorderLayout());
final JLabel label = new JLabel(myConfiguration.getSelectText());
label.setBorder(BorderFactory.createEmptyBorder(4, 4, 0, 0));
JPanel wrapper = new JPanel(new BorderLayout());
wrapper.add(label, BorderLayout.NORTH);
final Dictionary dictionary = myConfiguration.getDictionary();
final Enumeration elements = dictionary.elements();
final JSlider slider = new JSlider(SwingConstants.HORIZONTAL, myConfiguration.getMin(), myConfiguration.getMax(), myConfiguration.getSelected()) {
Integer myWidth = null;
@Override
public Dimension getPreferredSize() {
final Dimension size = super.getPreferredSize();
if (myWidth == null) {
myWidth = 10;
final FontMetrics fm = getFontMetrics(getFont());
while (elements.hasMoreElements()) {
String text = ((JLabel) elements.nextElement()).getText();
myWidth += fm.stringWidth(text + "W");
}
}
return new Dimension(myWidth, size.height);
}
};
slider.setMinorTickSpacing(1);
slider.setPaintTicks(true);
slider.setPaintTrack(true);
slider.setSnapToTicks(true);
UIUtil.setSliderIsFilled(slider, true);
slider.setPaintLabels(true);
slider.setLabelTable(dictionary);
if (!myConfiguration.isShowOk()) {
result.add(wrapper, BorderLayout.WEST);
result.add(slider, BorderLayout.CENTER);
} else {
result.add(wrapper, BorderLayout.WEST);
result.add(slider, BorderLayout.CENTER);
}
final Runnable saveSelection = () -> {
int value = slider.getModel().getValue();
myConfiguration.getResultConsumer().consume(value);
};
final Ref<JBPopup> popupRef = new Ref<>(null);
final JBPopup popup = JBPopupFactory.getInstance().createComponentPopupBuilder(result, slider).setMovable(true).setCancelOnWindowDeactivation(true).setCancelKeyEnabled(myConfiguration.isShowOk()).setKeyboardActions(Collections.singletonList(Pair.<ActionListener, KeyStroke>create(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
saveSelection.run();
popupRef.get().closeOk(null);
}
}, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)))).createPopup();
popupRef.set(popup);
if (myConfiguration.isShowOk()) {
final JButton done = new JButton("Done");
final JBPanel doneWrapper = new JBPanel(new BorderLayout());
doneWrapper.add(done, BorderLayout.NORTH);
result.add(doneWrapper, BorderLayout.EAST);
done.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
saveSelection.run();
popup.closeOk(null);
}
});
} else {
popup.setFinalRunnable(saveSelection);
}
InputEvent inputEvent = e.getInputEvent();
show(e, result, popup, inputEvent);
}
Aggregations