Skip to content
Snippets Groups Projects
Commit ec4b13bc authored by Nils Christian Ehmke's avatar Nils Christian Ehmke
Browse files

Some modifications for quality reasons.

parent b132a356
No related branches found
No related tags found
No related merge requests found
......@@ -875,16 +875,13 @@ public final class CurrentAnalysisEditorBean {
}
/**
* This method removes the given plugin from the project. If it is also the currently selected plugin, it will be deselected.
* Uses the given plugin to remove the corresponding connections (to other plugins or repositories) from the current project.
*
* @param plugin
* The plugin to be removed from the project.
* The plugin whose connections have to be removed.
*/
public void removePlugin(final MIPlugin plugin) {
private void removeCorrespondingConnections(final MIPlugin plugin) {
synchronized (this) {
this.project.getPlugins().remove(plugin);
// Remove the corresponding connections
final List<ConnectionFilterToFilter> ffDelList = new ArrayList<ConnectionFilterToFilter>();
for (final ConnectionFilterToFilter conn : this.filter2filterConnections) {
if ((conn.getSource() == plugin) || (conn.getDestination() == plugin)) {
......@@ -892,6 +889,7 @@ public final class CurrentAnalysisEditorBean {
}
}
this.filter2filterConnections.removeAll(ffDelList);
// Remove them from the project as well
for (final ConnectionFilterToFilter conn : ffDelList) {
if (conn.getDestination() == plugin) {
......@@ -906,17 +904,44 @@ public final class CurrentAnalysisEditorBean {
}
}
this.filter2repositoryConnections.removeAll(fRDelList);
this.pluginMap.remove(plugin);
}
}
/**
* Uses the given plugin to remove the corresponding ports from the current project.
*
* @param plugin
* The plugin whose ports have to be removed.
*/
private void removeCorrespondingPorts(final MIPlugin plugin) {
synchronized (this) {
// Remove the ports from the registry
for (final MIPort mPort : plugin.getOutputPorts()) {
this.portMap.remove(mPort);
}
// Remove the ports from the project
if (plugin instanceof MIFilter) {
for (final MIPort mPort : ((MIFilter) plugin).getInputPorts()) {
this.portMap.remove(mPort);
}
}
}
}
/**
* This method removes the given plugin from the project. If it is also the currently selected plugin, it will be deselected.
*
* @param plugin
* The plugin to be removed from the project.
*/
public void removePlugin(final MIPlugin plugin) {
synchronized (this) {
this.project.getPlugins().remove(plugin);
this.pluginMap.remove(plugin);
this.removeCorrespondingConnections(plugin);
this.removeCorrespondingPorts(plugin);
if (this.selectedPlugin == plugin) {
this.selectedPlugin = null; // NOPMD
}
......
......@@ -556,12 +556,8 @@ public final class FSManager { // NOCS (Class Data Abstraction Coupling, Class F
}
// Now assemble the URL class loader
return AccessController.doPrivileged(new PrivilegedAction<URLClassLoader>() {
@Override
public URLClassLoader run() {
return new URLClassLoader(libs.toArray(new URL[libs.size()]), AnalysisController.class.getClassLoader());
}
});
final PrivilegedClassLoaderAction action = new PrivilegedClassLoaderAction(libs);
return AccessController.doPrivileged(action);
}
}
......@@ -612,4 +608,37 @@ public final class FSManager { // NOCS (Class Data Abstraction Coupling, Class F
}
}
/**
* This helper class is responsible for creating a classloader as a privileged action. This is recommended due to the java security manager.
*
* @author Nils Christian Ehmke
* @version 1.0
*/
private static class PrivilegedClassLoaderAction implements PrivilegedAction<URLClassLoader> {
/**
* The list of libraries used to create the class loader.
*/
final List<URL> libs;
/**
* Creates a new instance of this class using the given parameters.
*
* @param libs
* The list of libraries used to create the class loader.
*/
public PrivilegedClassLoaderAction(final List<URL> libs) {
this.libs = libs;
}
/**
* Runs the action.
*
* @return The class loader.
*/
@Override
public URLClassLoader run() {
return new URLClassLoader(this.libs.toArray(new URL[this.libs.size()]), AnalysisController.class.getClassLoader());
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment