org.bimserver.plugins.PluginBundleImpl Maven / Gradle / Ivy
package org.bimserver.plugins;
import java.io.Closeable;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.bimserver.interfaces.objects.SPluginBundle;
import org.bimserver.interfaces.objects.SPluginBundleVersion;
public class PluginBundleImpl implements PluginBundle, Iterable {
private final Map pluginsContexts = new HashMap<>();
private final Set cloaseables = new HashSet<>();
private SPluginBundleVersion pluginBundleVersion;
private PluginBundleVersionIdentifier pluginBundleVersionIdentifier;
private SPluginBundle sPluginBundle;
public PluginBundleImpl(PluginBundleVersionIdentifier pluginBundleVersionIdentifier, SPluginBundle sPluginBundle, SPluginBundleVersion pluginBundleVersion) {
this.pluginBundleVersionIdentifier = pluginBundleVersionIdentifier;
this.sPluginBundle = sPluginBundle;
this.pluginBundleVersion = pluginBundleVersion;
}
public void add(PluginContext pluginContext) {
pluginsContexts.put(pluginContext.getPlugin().getClass().getName(), pluginContext);
}
@Override
public Iterator iterator() {
return pluginsContexts.values().iterator();
}
public void close() throws IOException {
for (Closeable closeable : cloaseables) {
closeable.close();
}
}
public void addCloseable(Closeable closeable) {
cloaseables.add(closeable);
}
public PluginBundleVersionIdentifier getPluginBundleVersionIdentifier() {
return pluginBundleVersionIdentifier;
}
@Override
public String getVersion() {
return pluginBundleVersion.getVersion();
}
public SPluginBundleVersion getPluginBundleVersion() {
return pluginBundleVersion;
}
@Override
public SPluginBundle getPluginBundle() {
SPluginBundle result = new SPluginBundle();
result.setName(sPluginBundle.getName());
result.setOrganization(sPluginBundle.getOrganization());
return result;
}
@Override
public PluginContext getPluginContext(String name) {
return pluginsContexts.get(name);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy