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

Modified details and added a lot of comments.

parent 0ce71ca1
No related branches found
No related tags found
No related merge requests found
Showing
with 661 additions and 492 deletions
...@@ -73,7 +73,7 @@ public class DependenciesBean { ...@@ -73,7 +73,7 @@ public class DependenciesBean {
/** /**
* Tries to upload a given file as a new dependency. If the dependency does already exist, it will be overwritten. If the dependencies has been uploaded * Tries to upload a given file as a new dependency. If the dependency does already exist, it will be overwritten. If the dependencies has been uploaded
* sucesfully, the plugin class loader will get the lib as well. * successfully, the plugin class loader will get the lib as well.
* *
* @param file * @param file
* The file to be uploaded. * The file to be uploaded.
......
...@@ -22,8 +22,8 @@ package kieker.webgui.beans.request; ...@@ -22,8 +22,8 @@ package kieker.webgui.beans.request;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean; import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped; import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
...@@ -34,7 +34,7 @@ import kieker.webgui.beans.application.DependenciesBean; ...@@ -34,7 +34,7 @@ import kieker.webgui.beans.application.DependenciesBean;
import kieker.webgui.beans.session.SelectedProjectBean; import kieker.webgui.beans.session.SelectedProjectBean;
/** /**
* This bean contains the currently choosen dependencies. This has to be request scoped, because the bean fetches the currently selected project when created. * This bean contains the currently chosen dependencies. This has to be request scoped, because the bean fetches the currently selected project when created.
* *
* @author Nils Christian Ehmke * @author Nils Christian Ehmke
* @version 1.0 * @version 1.0
...@@ -48,7 +48,7 @@ public class SelectedDependenciesBean { ...@@ -48,7 +48,7 @@ public class SelectedDependenciesBean {
*/ */
private List<MIDependency> dependencies; private List<MIDependency> dependencies;
/** /**
* This field contains the corresponding project, which will be mofified by this bean. * This field contains the corresponding project, which will be modified by this bean.
*/ */
private final MIProject project; private final MIProject project;
...@@ -74,10 +74,10 @@ public class SelectedDependenciesBean { ...@@ -74,10 +74,10 @@ public class SelectedDependenciesBean {
* use our "own" dependencies which we have to compare with the dependencies in the project. * use our "own" dependencies which we have to compare with the dependencies in the project.
*/ */
if (depBean != null) { if (depBean != null) {
List<MIDependency> availableDependencies = depBean.getDependencies(); final List<MIDependency> availableDependencies = depBean.getDependencies();
for (MIDependency dependency : this.project.getDependencies()) { for (final MIDependency dependency : this.project.getDependencies()) {
for (MIDependency actDependency : availableDependencies) { for (final MIDependency actDependency : availableDependencies) {
if (actDependency.getFilePath().equals(dependency.getFilePath())) { if (actDependency.getFilePath().equals(dependency.getFilePath())) {
this.dependencies.add(actDependency); this.dependencies.add(actDependency);
continue; continue;
......
...@@ -27,10 +27,8 @@ import javax.faces.bean.SessionScoped; ...@@ -27,10 +27,8 @@ import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
/** /**
* This bean can be used for a single session of a user and stores the * This bean can be used for a single session of a user and stores the currently used theme (look and feel) for this user. Currently the default value being used is
* currently used theme (look and feel) for this user. Currently the * the "glass-x"-theme, if none other value can be find within the parameters of the faces context.
* default value being used is the "glass-x"-theme, if none is find within
* the parameters of the faces context.
* *
* @author Nils Christian Ehmke * @author Nils Christian Ehmke
* *
...@@ -56,7 +54,7 @@ public class CurrentThemeBean { ...@@ -56,7 +54,7 @@ public class CurrentThemeBean {
public CurrentThemeBean() { public CurrentThemeBean() {
/* Get the parameters within the current context. */ /* Get the parameters within the current context. */
final Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap(); final Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
/* Try to find the default theme. */ /* Try to find the default theme within the parameters. */
if (params.containsKey("theme")) { if (params.containsKey("theme")) {
this.theme = params.get("theme"); this.theme = params.get("theme");
} else { } else {
......
...@@ -29,6 +29,9 @@ import kieker.webgui.beans.application.DependenciesBean; ...@@ -29,6 +29,9 @@ import kieker.webgui.beans.application.DependenciesBean;
import org.primefaces.model.UploadedFile; import org.primefaces.model.UploadedFile;
/** /**
* This bean is a session bean and can be used to store and upload a new dependency. It accesses the application instance of <code>DependenciesBean</code> directly.
*
* @see DependenciesBean
* *
* @author Nils Christian Ehmke * @author Nils Christian Ehmke
* @version 1.0 * @version 1.0
......
...@@ -20,10 +20,326 @@ ...@@ -20,10 +20,326 @@
package kieker.webgui.beans.session; package kieker.webgui.beans.session;
import java.lang.reflect.Modifier;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import kieker.analysis.model.analysisMetaModel.MIAnalysisPlugin;
import kieker.analysis.model.analysisMetaModel.MIDependency;
import kieker.analysis.model.analysisMetaModel.MIInputPort;
import kieker.analysis.model.analysisMetaModel.MIOutputPort;
import kieker.analysis.model.analysisMetaModel.MIPlugin;
import kieker.analysis.model.analysisMetaModel.MIProject;
import kieker.analysis.model.analysisMetaModel.MIProperty;
import kieker.analysis.model.analysisMetaModel.MIReader;
import kieker.analysis.model.analysisMetaModel.impl.MAnalysisMetaModelFactory;
import kieker.analysis.plugin.AbstractAnalysisPlugin;
import kieker.analysis.plugin.AbstractPlugin;
import kieker.analysis.plugin.AbstractReaderPlugin;
import kieker.analysis.repository.AbstractRepository;
import kieker.common.configuration.Configuration;
import kieker.webgui.common.Connection;
import kieker.webgui.common.FileManager;
import kieker.webgui.common.PluginClassLoader;
import kieker.webgui.common.PluginFinder;
import org.eclipse.emf.common.util.EList;
/** /**
* This session bean stores the currently selected main project of the user and provides different methods to access and manipulate the properties of this project.
* *
* @author Nils Christian Ehmke * @author Nils Christian Ehmke
* @version 1.0
*/ */
@ManagedBean
@SessionScoped
public class SelectedMainProjectBean { public class SelectedMainProjectBean {
/**
* This constant is used as the host for the dependencies.
*/
private static final String URL_LOCALHOST = "localhost";
/**
* This constant is used as a protocol for the dependencies.
*/
private static final String URL_PROTOCOL_FILE = "file";
/**
* The main project of the current user.
*/
private MIProject mainProject;
/**
* This list contains the connections (between the filters) within the current main project.
*/
private List<Connection> connections;
/**
* Creates a new instance of this class.
*/
public SelectedMainProjectBean() {
this.connections = new ArrayList<Connection>();
}
/**
* Delivers the main project of the current user. It can be null.
*
* @return The user's main project.
*/
public final MIProject getMainProject() {
return this.mainProject;
}
/**
* Sets the main project of the current user.
*
* @param mainProject
* The new main project of the current user.
*/
public final void setMainProject(final MIProject mainProject) {
this.mainProject = mainProject;
this.connections = this.getConnectionsFromMainProject();
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "", "New main project: " + mainProject.getName()));
}
/**
* Delivers the "font weight" (whether the font is bold or normal) for a given project. This can be especially be used to mark a selected main project.
*
* @param project
* The project to be checked.
* @return "bold" if the given project is the current main project, "normal" otherwise.
*/
public final String getFontWeight(final MIProject project) {
// TODO: This should be done via c:if or something
if (project == this.mainProject) {
return "bold";
} else {
return "normal";
}
}
/**
* This method delivers the available reader-plugins for the current main project. The delivered plugins are never abstract.
*
* @return A list with all readers.
*/
public final List<Class<AbstractReaderPlugin>> getAvailableReaders() {
final List<Class<AbstractReaderPlugin>> list = new ArrayList<Class<AbstractReaderPlugin>>();
if (this.mainProject != null) {
for (final MIDependency lib : this.mainProject.getDependencies()) {
try {
PluginClassLoader.getInstance().addURL(
new URL(SelectedMainProjectBean.URL_PROTOCOL_FILE, SelectedMainProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib)));
} catch (final MalformedURLException ex) {
// TODO Log exception
}
try {
final List<Class<AbstractPlugin>> plugins = PluginFinder.getAllPluginsWithinJar(new URL(SelectedMainProjectBean.URL_PROTOCOL_FILE,
SelectedMainProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib)));
for (final Class<?> plugin : plugins) {
if (!Modifier.isAbstract(plugin.getModifiers()) && AbstractReaderPlugin.class.isAssignableFrom(plugin)) {
list.add((Class<AbstractReaderPlugin>) plugin);
}
}
} catch (final MalformedURLException ex) {
ex.printStackTrace();
// TODO Log exception
}
}
}
return list;
}
/**
* This method delivers the available filter-plugins for the current main project. The delivered plugins are never abstract.
*
* @return A list with all filter.
*/
public final List<Class<AbstractAnalysisPlugin>> getAvailableFilters() {
final List<Class<AbstractAnalysisPlugin>> list = new ArrayList<Class<AbstractAnalysisPlugin>>();
if (this.mainProject != null) {
for (final MIDependency lib : this.mainProject.getDependencies()) {
try {
PluginClassLoader.getInstance().addURL(
new URL(SelectedMainProjectBean.URL_PROTOCOL_FILE, SelectedMainProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib)));
} catch (final MalformedURLException ex) {
// TODO Log exception
}
try {
final List<Class<AbstractPlugin>> plugins = PluginFinder.getAllPluginsWithinJar(new URL(SelectedMainProjectBean.URL_PROTOCOL_FILE,
SelectedMainProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib)));
for (final Class<?> plugin : plugins) {
if (!Modifier.isAbstract(plugin.getModifiers()) && AbstractAnalysisPlugin.class.isAssignableFrom(plugin)) {
list.add((Class<AbstractAnalysisPlugin>) plugin);
}
}
} catch (final MalformedURLException ex) {
ex.printStackTrace();
// TODO Log exception
}
}
}
return list;
}
/**
* This method delivers the available repositories for the current main project. The delivered repositories are never abstract.
*
* @return A list with all repositories.
*/
public final List<Class<AbstractRepository>> getAvailableRepositories() {
final List<Class<AbstractRepository>> list = new ArrayList<Class<AbstractRepository>>();
if (this.mainProject != null) {
for (final MIDependency lib : this.mainProject.getDependencies()) {
try {
PluginClassLoader.getInstance().addURL(
new URL(SelectedMainProjectBean.URL_PROTOCOL_FILE, SelectedMainProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib)));
} catch (final MalformedURLException ex) {
// TODO Log exception
}
try {
final List<Class<AbstractRepository>> repositories = PluginFinder.getAllRepositoriesWithinJar(new URL(SelectedMainProjectBean.URL_PROTOCOL_FILE,
SelectedMainProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib)));
for (final Class<AbstractRepository> repository : repositories) {
if (!Modifier.isAbstract(repository.getModifiers())) {
list.add(repository);
}
}
} catch (final MalformedURLException ex) {
ex.printStackTrace();
// TODO Log exception
}
}
}
return list;
}
/**
* This method uses the actual plugin to create the model configuration instances and add them to the model plugin instance.
*
* @param plugin
* The plugin whose configuration will be used.
* @param mPlugin
* The model plugin which will be modified.
*/
private static void addConfiguration(final AbstractPlugin plugin, final MIPlugin mPlugin) {
/* Get the current configuration and use it to initialize the model plugin. */
final Configuration configuration = plugin.getCurrentConfiguration();
final MAnalysisMetaModelFactory factory = new MAnalysisMetaModelFactory();
/* Run through all entries. */
final Iterator<Map.Entry<Object, Object>> iterator = configuration.entrySet().iterator();
while (iterator.hasNext()) {
final Map.Entry<Object, Object> entry = iterator.next();
/* Create a property object for the current entry. */
final MIProperty property = factory.createProperty();
property.setName(entry.getKey().toString());
property.setValue(entry.getValue().toString());
mPlugin.getProperties().add(property);
}
}
/**
* This method can be used to add a model plugin instance to the current main project using the given class.
*
* @param pluginClass
* The class which will be instantiated.
*/
public final void addPlugin(final Class<AbstractPlugin> pluginClass) {
// TODO It seems like it is necessary to completly load all properties, including the available ports in order to work
final MAnalysisMetaModelFactory factory = new MAnalysisMetaModelFactory();
try {
final AbstractPlugin plugin = pluginClass.getConstructor(Configuration.class).newInstance(new Configuration());
if (AbstractReaderPlugin.class.isAssignableFrom(pluginClass)) {
final MIReader reader = factory.createReader();
reader.setClassname(pluginClass.getCanonicalName());
reader.setName(pluginClass.getSimpleName());
SelectedMainProjectBean.addConfiguration(plugin, reader);
this.mainProject.getPlugins().add(reader);
} else {
final MIAnalysisPlugin filter = factory.createAnalysisPlugin();
filter.setClassname(pluginClass.getCanonicalName());
filter.setName(pluginClass.getSimpleName());
SelectedMainProjectBean.addConfiguration(plugin, filter);
this.mainProject.getPlugins().add(filter);
}
} catch (final Exception ex) {
// TODO Log exception
}
}
/**
* This method removes a given model plugin instance from the current main project.
*
* @param plugin
* The project to be removed.
*/
public final void removePlugin(final MIPlugin plugin) {
this.mainProject.getPlugins().remove(plugin);
}
/**
* This method extracts the connections between the filters from the current main project.
*
* @return A list with all connections available.
*/
private List<Connection> getConnectionsFromMainProject() {
final List<Connection> result = new ArrayList<Connection>();
if (this.mainProject != null) {
final EList<MIPlugin> mPlugins = this.mainProject.getPlugins();
for (final MIPlugin mPlugin : mPlugins) {
final EList<MIOutputPort> mOutputPorts = mPlugin.getOutputPorts();
for (final MIOutputPort mOutputPort : mOutputPorts) {
final EList<MIInputPort> mInputPorts = mOutputPort.getSubscribers();
for (final MIInputPort mInputPort : mInputPorts) {
result.add(new Connection(mPlugin, mInputPort.getParent(), mInputPort, mOutputPort));
}
}
}
}
return result;
}
/**
* Delivers the connections (between the filters) within the current main project.
*
* @return A list containing all available connections.
*/
public List<Connection> getConnections() {
return this.connections;
}
/**
* This method adds an empty connection to the current main project.
*/
public void addConnection() {
this.connections.add(new Connection(null, null, null, null));
}
/**
* This method "submits" the current connections to the main project (In other words: The connections will be stored within the main project).
*/
public void submitConnections() {
// TODO: Implement
}
} }
...@@ -43,7 +43,9 @@ public final class SelectedPluginBean { ...@@ -43,7 +43,9 @@ public final class SelectedPluginBean {
/** /**
* Creates a new instance of this class. * Creates a new instance of this class.
*/ */
public SelectedPluginBean() {} public SelectedPluginBean() {
/* No code necessary. */
}
/** /**
* Delivers the stored plugin. * Delivers the stored plugin.
......
...@@ -19,39 +19,11 @@ ...@@ -19,39 +19,11 @@
***************************************************************************/ ***************************************************************************/
package kieker.webgui.beans.session; package kieker.webgui.beans.session;
import java.lang.reflect.Modifier;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean; import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped; import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import kieker.analysis.model.analysisMetaModel.MIAnalysisPlugin;
import kieker.analysis.model.analysisMetaModel.MIDependency;
import kieker.analysis.model.analysisMetaModel.MIInputPort;
import kieker.analysis.model.analysisMetaModel.MIOutputPort;
import kieker.analysis.model.analysisMetaModel.MIPlugin;
import kieker.analysis.model.analysisMetaModel.MIProject; import kieker.analysis.model.analysisMetaModel.MIProject;
import kieker.analysis.model.analysisMetaModel.MIProperty;
import kieker.analysis.model.analysisMetaModel.MIReader;
import kieker.analysis.model.analysisMetaModel.impl.MAnalysisMetaModelFactory;
import kieker.analysis.plugin.AbstractAnalysisPlugin;
import kieker.analysis.plugin.AbstractPlugin;
import kieker.analysis.plugin.AbstractReaderPlugin;
import kieker.analysis.repository.AbstractRepository;
import kieker.common.configuration.Configuration;
import kieker.webgui.common.Connection;
import kieker.webgui.common.FileManager;
import kieker.webgui.common.PluginClassLoader;
import kieker.webgui.common.PluginFinder;
import org.eclipse.emf.common.util.EList;
import org.primefaces.event.NodeSelectEvent; import org.primefaces.event.NodeSelectEvent;
import org.primefaces.model.TreeNode; import org.primefaces.model.TreeNode;
...@@ -65,15 +37,6 @@ import org.primefaces.model.TreeNode; ...@@ -65,15 +37,6 @@ import org.primefaces.model.TreeNode;
@SessionScoped @SessionScoped
public class SelectedProjectBean { public class SelectedProjectBean {
/**
* This constant is used as the host for the dependencies.
*/
private static final String URL_LOCALHOST = "localhost";
/**
* This constant is used as a protocol for the dependencies.
*/
private static final String URL_PROTOCOL_FILE = "file";
/** /**
* The currently selected node of the current user. * The currently selected node of the current user.
*/ */
...@@ -82,12 +45,6 @@ public class SelectedProjectBean { ...@@ -82,12 +45,6 @@ public class SelectedProjectBean {
* The selected project of the current user. * The selected project of the current user.
*/ */
private MIProject selectedProject; private MIProject selectedProject;
/**
* The main project of the current user.
*/
private MIProject mainProject;
private List<Connection> connections;
/** /**
* Creates a new instance of this class. * Creates a new instance of this class.
...@@ -96,28 +53,6 @@ public class SelectedProjectBean { ...@@ -96,28 +53,6 @@ public class SelectedProjectBean {
/* /*
* No code necessary. * No code necessary.
*/ */
this.connections = new ArrayList<Connection>();
}
/**
* Delivers the main project of the current user. It can be null.
*
* @return The user's main project.
*/
public final MIProject getMainProject() {
return this.mainProject;
}
/**
* Sets the main project of the current user.
*
* @param mainProject
* The new main project of the current user.
*/
public final void setMainProject(final MIProject mainProject) {
this.mainProject = mainProject;
this.connections = this.getConnectionsFromMainProject();
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "", "New main project: " + mainProject.getName()));
} }
/** /**
...@@ -173,201 +108,4 @@ public class SelectedProjectBean { ...@@ -173,201 +108,4 @@ public class SelectedProjectBean {
} }
} }
/**
* Delivers the "font weight" (whether the font is bold or normal) for a given project. This can be especially be used to mark a selected main project.
*
* @param project
* The project to be checked.
* @return "bold" if the given project is the current main project, "normal" otherwise.
*/
public final String getFontWeight(final MIProject project) {
if (project == this.mainProject) {
return "bold";
} else {
return "normal";
}
}
/**
* This method delivers the available reader-plugins for the current main project. The delivered plugins are never abstract.
*
* @return A list with all readers.
*/
public final List<Class<AbstractReaderPlugin>> getAvailableReaders() {
final List<Class<AbstractReaderPlugin>> list = new ArrayList<Class<AbstractReaderPlugin>>();
if (this.mainProject != null) {
for (final MIDependency lib : this.mainProject.getDependencies()) {
try {
PluginClassLoader.getInstance().addURL(
new URL(SelectedProjectBean.URL_PROTOCOL_FILE, SelectedProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib)));
} catch (final MalformedURLException ex) {
// TODO Log exception
}
try {
final List<Class<AbstractPlugin>> plugins = PluginFinder.getAllPluginsWithinJar(new URL(SelectedProjectBean.URL_PROTOCOL_FILE,
SelectedProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib)));
for (final Class<?> plugin : plugins) {
if (!Modifier.isAbstract(plugin.getModifiers()) && AbstractReaderPlugin.class.isAssignableFrom(plugin)) {
list.add((Class<AbstractReaderPlugin>) plugin);
}
}
} catch (final MalformedURLException ex) {
ex.printStackTrace();
// TODO Log exception
}
}
}
return list;
}
/**
* This method delivers the available filter-plugins for the current main project. The delivered plugins are never abstract.
*
* @return A list with all filter.
*/
public final List<Class<AbstractAnalysisPlugin>> getAvailableFilters() {
final List<Class<AbstractAnalysisPlugin>> list = new ArrayList<Class<AbstractAnalysisPlugin>>();
if (this.mainProject != null) {
for (final MIDependency lib : this.mainProject.getDependencies()) {
try {
PluginClassLoader.getInstance().addURL(
new URL(SelectedProjectBean.URL_PROTOCOL_FILE, SelectedProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib)));
} catch (final MalformedURLException ex) {
// TODO Log exception
}
try {
final List<Class<AbstractPlugin>> plugins = PluginFinder.getAllPluginsWithinJar(new URL(SelectedProjectBean.URL_PROTOCOL_FILE,
SelectedProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib)));
for (final Class<?> plugin : plugins) {
if (!Modifier.isAbstract(plugin.getModifiers()) && AbstractAnalysisPlugin.class.isAssignableFrom(plugin)) {
list.add((Class<AbstractAnalysisPlugin>) plugin);
}
}
} catch (final MalformedURLException ex) {
ex.printStackTrace();
// TODO Log exception
}
}
}
return list;
}
/**
* This method delivers the available repositories for the current main project. The delivered repositories are never abstract.
*
* @return A list with all repositories.
*/
public final List<Class<AbstractRepository>> getAvailableRepositories() {
final List<Class<AbstractRepository>> list = new ArrayList<Class<AbstractRepository>>();
if (this.mainProject != null) {
for (final MIDependency lib : this.mainProject.getDependencies()) {
try {
PluginClassLoader.getInstance().addURL(
new URL(SelectedProjectBean.URL_PROTOCOL_FILE, SelectedProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib)));
} catch (final MalformedURLException ex) {
// TODO Log exception
}
try {
final List<Class<AbstractRepository>> repositories = PluginFinder.getAllRepositoriesWithinJar(new URL(SelectedProjectBean.URL_PROTOCOL_FILE,
SelectedProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib)));
for (final Class<AbstractRepository> repository : repositories) {
if (!Modifier.isAbstract(repository.getModifiers())) {
list.add(repository);
}
}
} catch (final MalformedURLException ex) {
ex.printStackTrace();
// TODO Log exception
}
}
}
return list;
}
private static void addConfiguration(final AbstractPlugin plugin, final MIPlugin mPlugin) {
/* Get the current configuration and use it to initialize the model plugin. */
final Configuration configuration = plugin.getCurrentConfiguration();
final MAnalysisMetaModelFactory factory = new MAnalysisMetaModelFactory();
/* Run through all entries. */
final Iterator<Map.Entry<Object, Object>> iterator = configuration.entrySet().iterator();
while (iterator.hasNext()) {
final Map.Entry<Object, Object> entry = iterator.next();
/* Create a property object for the current entry. */
final MIProperty property = factory.createProperty();
property.setName(entry.getKey().toString());
property.setValue(entry.getValue().toString());
mPlugin.getProperties().add(property);
}
}
public final void addPlugin(final Class<AbstractPlugin> pluginClass) {
// TODO It seems like it is necessary to completly load all properties, including the available ports in order to work
final MAnalysisMetaModelFactory factory = new MAnalysisMetaModelFactory();
try {
final AbstractPlugin plugin = pluginClass.getConstructor(Configuration.class).newInstance(new Configuration());
if (AbstractReaderPlugin.class.isAssignableFrom(pluginClass)) {
final MIReader reader = factory.createReader();
reader.setClassname(pluginClass.getCanonicalName());
reader.setName(pluginClass.getSimpleName());
SelectedProjectBean.addConfiguration(plugin, reader);
this.mainProject.getPlugins().add(reader);
} else {
final MIAnalysisPlugin filter = factory.createAnalysisPlugin();
filter.setClassname(pluginClass.getCanonicalName());
filter.setName(pluginClass.getSimpleName());
SelectedProjectBean.addConfiguration(plugin, filter);
this.mainProject.getPlugins().add(filter);
}
} catch (final Exception ex) {
// TODO Log exception
}
}
public final void removePlugin(final MIPlugin plugin) {
this.mainProject.getPlugins().remove(plugin);
}
private List<Connection> getConnectionsFromMainProject() {
final List<Connection> result = new ArrayList<Connection>();
if (this.mainProject != null) {
final EList<MIPlugin> mPlugins = this.mainProject.getPlugins();
for (final MIPlugin mPlugin : mPlugins) {
final EList<MIOutputPort> mOutputPorts = mPlugin.getOutputPorts();
for (final MIOutputPort mOutputPort : mOutputPorts) {
final EList<MIInputPort> mInputPorts = mOutputPort.getSubscribers();
for (final MIInputPort mInputPort : mInputPorts) {
result.add(new Connection(mPlugin, mInputPort.getParent(), mInputPort, mOutputPort));
}
}
}
}
return result;
}
public List<Connection> getConnections() {
return this.connections;
}
public void addConnection() {
this.connections.add(new Connection(null, null, null, null));
}
public void submitConnections() {
// TODO
}
} }
...@@ -20,67 +20,141 @@ ...@@ -20,67 +20,141 @@
package kieker.webgui.common; package kieker.webgui.common;
import kieker.analysis.AnalysisController;
import kieker.analysis.model.analysisMetaModel.MIInputPort; import kieker.analysis.model.analysisMetaModel.MIInputPort;
import kieker.analysis.model.analysisMetaModel.MIOutputPort; import kieker.analysis.model.analysisMetaModel.MIOutputPort;
import kieker.analysis.model.analysisMetaModel.MIPlugin; import kieker.analysis.model.analysisMetaModel.MIPlugin;
import kieker.analysis.plugin.AbstractPlugin;
/** /**
* This class is a helper class containing a connection between two filters.
* *
* @author Nils Christian Ehmke * @author Nils Christian Ehmke
* @version 1.0
*/ */
public class Connection { public class Connection {
/**
* The source filter.
*/
private MIPlugin source; private MIPlugin source;
/**
* The destination filter.
*/
private MIPlugin destination; private MIPlugin destination;
/**
* The input port which will be used from the destination.
*/
private MIInputPort inputPort; private MIInputPort inputPort;
/**
* The output port which will be used from the source.
*/
private MIOutputPort outputPort; private MIOutputPort outputPort;
public Connection(MIPlugin source, MIPlugin destination, MIInputPort inputPort, MIOutputPort outputPort) { /**
* Creates a new instance of this class using the given parameters.
*
* @param source
* The source filter.
* @param destination
* The destination filter.
* @param inputPort
* The input port which will be used from the destination.
* @param outputPort
* The output port which will be used from the source.
*/
public Connection(final MIPlugin source, final MIPlugin destination, final MIInputPort inputPort, final MIOutputPort outputPort) {
this.source = source; this.source = source;
this.destination = destination; this.destination = destination;
this.inputPort = inputPort; this.inputPort = inputPort;
this.outputPort = outputPort; this.outputPort = outputPort;
} }
/**
* Delivers the current destination.
*
* @return The destination filter.
*/
public MIPlugin getDestination() { public MIPlugin getDestination() {
return destination; return this.destination;
} }
public void setDestination(MIPlugin destination) { /**
* Sets the new destination.
*
* @param destination
* The new destination filter.
*/
public void setDestination(final MIPlugin destination) {
this.destination = destination; this.destination = destination;
} }
/**
* Delivers the current input port.
*
* @return The input port which will be used from the destination.
*/
public MIInputPort getInputPort() { public MIInputPort getInputPort() {
return inputPort; return this.inputPort;
} }
public void setInputPort(MIInputPort inputPort) { /**
* Sets the input port to a new value.
*
* @param inputPort
* The new input port which will be used from the destination.
*/
public void setInputPort(final MIInputPort inputPort) {
this.inputPort = inputPort; this.inputPort = inputPort;
} }
/**
* Delivers the current output port.
*
* @return The output port which will be used from the source.
*/
public MIOutputPort getOutputPort() { public MIOutputPort getOutputPort() {
return outputPort; return this.outputPort;
} }
public void setOutputPort(MIOutputPort outputPort) { /**
* Sets the new output port.
*
* @param outputPort
* The new output port which will be used from the source.
*/
public void setOutputPort(final MIOutputPort outputPort) {
this.outputPort = outputPort; this.outputPort = outputPort;
} }
/**
* Delivers the source filter.
*
* @return The source filter.
*/
public MIPlugin getSource() { public MIPlugin getSource() {
return source; return this.source;
} }
public void setSource(MIPlugin source) { /**
* Sets the source filter to a new value.
*
* @param source
* The new source filter.
*/
public void setSource(final MIPlugin source) {
this.source = source; this.source = source;
} }
/**
* Checks whether the current configuration is valid. The configuration is valid if and only if: All four components are not null, the ports exist and are
* compatible.
*
* @return
*/
public boolean isValid() { public boolean isValid() {
if (source == null || destination == null || inputPort == null || outputPort == null) { if (this.source == null || this.destination == null || this.inputPort == null || this.outputPort == null) {
return false; return false;
} }
// TODO: This is not necessarily valid currently // TODO: This is currently not necessarily valid
return true; return true;
} }
} }
...@@ -26,12 +26,11 @@ import java.io.FileOutputStream; ...@@ -26,12 +26,11 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.faces.application.FacesMessage; import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import kieker.analysis.AnalysisController; import kieker.analysis.AnalysisController;
import kieker.analysis.model.analysisMetaModel.*;
import kieker.analysis.model.analysisMetaModel.*;
import kieker.analysis.model.analysisMetaModel.MIDependency; import kieker.analysis.model.analysisMetaModel.MIDependency;
import kieker.analysis.model.analysisMetaModel.MIProject; import kieker.analysis.model.analysisMetaModel.MIProject;
import kieker.analysis.model.analysisMetaModel.impl.MAnalysisMetaModelFactory; import kieker.analysis.model.analysisMetaModel.impl.MAnalysisMetaModelFactory;
...@@ -41,13 +40,9 @@ import kieker.common.logging.LogFactory; ...@@ -41,13 +40,9 @@ import kieker.common.logging.LogFactory;
import org.primefaces.model.UploadedFile; import org.primefaces.model.UploadedFile;
/** /**
* This is a singleton class for the access to the file system. It makes sure * This is a singleton class for the access to the file system. It makes sure that the necessary directories for the execution of the application exist. <b>Do
* that the necessary directories for the execution of the application exist. * not</b> remove directories created from this manager during runtime! Directories are created during first access to the class.<br>
* <b>Do not</b> remove directories created from this manager during runtime! * Currently nearly all methods are synchronized. A fine grained synchronization should be implemented in the future.
* Directories are created during first access to the class.<br>
* Currently
* nearly all methods are synchronized. A fine grained synchronization should be
* implemented in the future.
* *
* @author Nils Christian Ehmke * @author Nils Christian Ehmke
* @version 1.0 * @version 1.0
...@@ -102,182 +97,183 @@ public final class FileManager { ...@@ -102,182 +97,183 @@ public final class FileManager {
/** /**
* Checks whether all directories are available and creates them if necessary. * Checks whether all directories are available and creates them if necessary.
*/ */
private synchronized void checkAndCreateDirectories() { private void checkAndCreateDirectories() {
/* synchronized (this) {
* Make sure that the directories exist and create them if necessary. /*
*/ * Make sure that the directories exist and create them if necessary.
final File dirProj = new File(FileManager.PROJECT_DIR); */
final File dirLib = new File(FileManager.LIB_DIR); final File dirProj = new File(FileManager.PROJECT_DIR);
boolean couldCreated = true; final File dirLib = new File(FileManager.LIB_DIR);
boolean couldCreated = true;
if (!dirProj.exists()) { if (!dirProj.exists()) {
couldCreated &= dirProj.mkdirs(); couldCreated &= dirProj.mkdirs();
} }
if (!dirLib.exists()) { if (!dirLib.exists()) {
couldCreated &= dirLib.mkdirs(); couldCreated &= dirLib.mkdirs();
} }
if (!couldCreated) { if (!couldCreated) {
FileManager.LOG.error("Could not create the necessary directories for the application"); FileManager.LOG.error("Could not create the necessary directories for the application");
}
} }
} }
/** /**
* This method saves a given project using the name of the project as the * This method saves a given project using the name of the project as the project-directory. The project-directory must already exist.
* project-directory. The project-directory must already exist.
* *
* @param project * @param project
* The project to be stored. * The project to be stored.
* @return true iff the project-directory does already exist and the storage * @return true iff the project-directory does already exist and the storage was successful.
* was successful.
*/ */
public final synchronized boolean saveProject(final MIProject project) { public final boolean saveProject(final MIProject project) {
final String projectName = project.getName(); synchronized (this) {
final String projectName = project.getName();
final File dirProject = new File(FileManager.PROJECT_DIR + File.separator + projectName); final File dirProject = new File(FileManager.PROJECT_DIR + File.separator + projectName);
/*
* Make sure that the directory for the project exists.
*/
if (dirProject.exists()) {
/* /*
* Try to save the project. * Make sure that the directory for the project exists.
*/ */
final File fileProject = new File(dirProject, projectName + FileManager.EXTENSION); if (dirProject.exists()) {
try { /*
// TODO Copy before saving as the controller destroys at least the dependencies. * Try to save the project.
final AnalysisController controller = new AnalysisController(project); */
if (controller.saveToFile(fileProject)) { final File fileProject = new File(dirProject, projectName + FileManager.EXTENSION);
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "", "Project saved: " + project.getName())); try {
return true; // TODO Copy before saving as the controller destroys at least the dependencies.
final AnalysisController controller = new AnalysisController(project);
if (controller.saveToFile(fileProject)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "", "Project saved: " + project.getName()));
return true;
}
} catch (final NullPointerException ex) {
FileManager.LOG.error("Could not save project '" + projectName + "'.", ex);
} }
} catch (final NullPointerException ex) {
FileManager.LOG.error("Could not save project '" + projectName + "'.", ex);
} }
return false;
} }
return false;
} }
/** /**
* This method saves a given project using the name of the project as the * This method saves a given project using the name of the project as the project-directory. The project-directory must not already exist.
* project-directory. THe project-directory must not already exist.
* *
* @param project * @param project
* The project to be stored. * The project to be stored.
* @return true iff the project-directory does not already exist and the * @return true iff the project-directory does not already exist and the storage was successful.
* storage was successful.
*/ */
public final synchronized boolean saveNewProject(final MIProject project) { public final boolean saveNewProject(final MIProject project) {
final String projectName = project.getName(); synchronized (this) {
final File dirProject = new File(FileManager.PROJECT_DIR + File.separator + projectName); final String projectName = project.getName();
final File dirProject = new File(FileManager.PROJECT_DIR + File.separator + projectName);
/*
* Make sure that the project does not already exist and create the
* project directory.
*/
if (dirProject.exists() || !dirProject.mkdir()) {
return false;
} else {
/* /*
* The directory should exist now. Store the project. * Make sure that the project does not already exist and create the
* project directory.
*/ */
return this.saveProject(project); if (dirProject.exists() || !dirProject.mkdir()) {
return false;
} else {
/*
* The directory should exist now. Store the project.
*/
return this.saveProject(project);
}
} }
} }
/** /**
* This method can be used to load all currently saved projects. * This method can be used to load all currently saved projects.
* *
* @return A list containing the loaded projects. If something went wrong, * @return A list containing the loaded projects. If something went wrong, an empty list will be returned, never null.
* an empty list will be returned, never null.
*/ */
public final synchronized List<MIProject> loadAllProjects() { public final List<MIProject> loadAllProjects() {
final List<MIProject> resultList = new ArrayList<MIProject>(); final List<MIProject> resultList = new ArrayList<MIProject>();
synchronized (this) {
/* /*
* Try to get all directories within the project directory. * Try to get all directories within the project directory.
*/ */
final File[] directories = new File(FileManager.PROJECT_DIR).listFiles(); final File[] directories = new File(FileManager.PROJECT_DIR).listFiles();
if (directories != null) { if (directories != null) {
for (final File directory : directories) { for (final File directory : directories) {
if (directory.isDirectory()) { if (directory.isDirectory()) {
/*
* If there is a project file within the directory, we know
* the name of it.
*/
final File projectFile = new File(directory, directory.getName() + FileManager.EXTENSION);
if (projectFile.exists()) {
/* /*
* Try to load the project. * If there is a project file within the directory, we know
* the name of it.
*/ */
final MIProject project = AnalysisController.loadFromFile(projectFile); final File projectFile = new File(directory, directory.getName() + FileManager.EXTENSION);
if (project != null) { if (projectFile.exists()) {
resultList.add(project); /*
* Try to load the project.
*/
final MIProject project = AnalysisController.loadFromFile(projectFile);
if (project != null) {
resultList.add(project);
}
} }
} }
} }
} }
} }
return resultList; return resultList;
} }
/** /**
* This method uploads a given file as a new dependency. The file is stored * This method uploads a given file as a new dependency. The file is stored within the lib-directory of this application. If a file with the same name does
* within the lib-directory of this application. If a file with the same * already exist, it will be replaces.
* name does already exist, it will be replaces.
* *
* @param file * @param file
* The file to be uploaded. * The file to be uploaded.
* @return The new dependency iff the uploading was sucesfull, null * @return The new dependency iff the uploading was successful, null otherwise.
* otherwise.
*/ */
public final synchronized MIDependency uploadDependency(final UploadedFile file) { public final MIDependency uploadDependency(final UploadedFile file) {
final File depFile = new File(FileManager.LIB_DIR, file.getFileName()); synchronized (this) {
final File depFile = new File(FileManager.LIB_DIR, file.getFileName());
BufferedInputStream in = null;
BufferedOutputStream out = null;
try {
/*
* Get the streams.
*/
in = new BufferedInputStream(file.getInputstream());
out = new BufferedOutputStream(new FileOutputStream(depFile));
final byte[] buf = new byte[FileManager.BUF_SIZE];
int count;
/* BufferedInputStream in = null;
* Transfer the file. BufferedOutputStream out = null;
*/
while ((count = in.read(buf)) != -1) {
out.write(buf, 0, count);
}
} catch (final IOException ex) {
FileManager.LOG.error("Could not transfer file '" + file.getFileName() + "'");
return null;
} finally {
/*
* Try to make sure that the streams will be closed.
*/
try { try {
if (in != null) { /*
in.close(); * Get the streams.
*/
in = new BufferedInputStream(file.getInputstream());
out = new BufferedOutputStream(new FileOutputStream(depFile));
final byte[] buf = new byte[FileManager.BUF_SIZE];
int count;
/*
* Transfer the file.
*/
while ((count = in.read(buf)) != -1) {
out.write(buf, 0, count);
} }
} catch (final IOException ex) { } catch (final IOException ex) {
FileManager.LOG.warn("Error while uploading dependency '" + file.getFileName() + "'."); FileManager.LOG.error("Could not transfer file '" + file.getFileName() + "'");
} return null;
try { } finally {
if (out != null) { /*
out.close(); * Try to make sure that the streams will be closed.
*/
try {
if (in != null) {
in.close();
}
} catch (final IOException ex) {
FileManager.LOG.warn("Error while uploading dependency '" + file.getFileName() + "'.");
}
try {
if (out != null) {
out.close();
}
} catch (final IOException ex) {
FileManager.LOG.warn("Error while uploading dependency '" + file.getFileName() + "'.");
} }
} catch (final IOException ex) {
FileManager.LOG.warn("Error while uploading dependency '" + file.getFileName() + "'.");
} }
final MIDependency dependency = this.factory.createDependency();
dependency.setFilePath(depFile.getName());
return dependency;
} }
final MIDependency dependency = this.factory.createDependency();
dependency.setFilePath(depFile.getName());
return dependency;
} }
/** /**
...@@ -294,22 +290,23 @@ public final class FileManager { ...@@ -294,22 +290,23 @@ public final class FileManager {
* *
* @return A list containing all available dependencies. If there are no files, an empty list will be returned. * @return A list containing all available dependencies. If there are no files, an empty list will be returned.
*/ */
public final synchronized List<MIDependency> loadAllDependencies() { public final List<MIDependency> loadAllDependencies() {
final List<MIDependency> resultList = new ArrayList<MIDependency>(); final List<MIDependency> resultList = new ArrayList<MIDependency>();
/* synchronized (this) {
* Try to get all files within the library directory. /*
*/ * Try to get all files within the library directory.
final File[] files = new File(FileManager.LIB_DIR).listFiles(); */
if (files != null) { final File[] files = new File(FileManager.LIB_DIR).listFiles();
for (final File file : files) { if (files != null) {
if (file.isFile() && file.getName().endsWith(FileManager.JAR_EXTENSION)) { for (final File file : files) {
final MIDependency dependency = this.factory.createDependency(); if (file.isFile() && file.getName().endsWith(FileManager.JAR_EXTENSION)) {
dependency.setFilePath(file.getName()); final MIDependency dependency = this.factory.createDependency();
resultList.add(dependency); dependency.setFilePath(file.getName());
resultList.add(dependency);
}
} }
} }
} }
return resultList; return resultList;
} }
...@@ -318,39 +315,42 @@ public final class FileManager { ...@@ -318,39 +315,42 @@ public final class FileManager {
* *
* @param dependency * @param dependency
* The dependency to be removed. * The dependency to be removed.
* @return true iff the dependency exists and the removal was succesful. * @return true iff the dependency exists and the removal was successful.
*/ */
public final synchronized boolean deleteDependency(final MIDependency dependency) { public final boolean deleteDependency(final MIDependency dependency) {
final File file = new File(FileManager.LIB_DIR, dependency.getFilePath()); synchronized (this) {
if (file.isFile()) { final File file = new File(FileManager.LIB_DIR, dependency.getFilePath());
return file.delete(); if (file.isFile()) {
return file.delete();
}
return false;
} }
return false;
} }
/** /**
* This method tries to delete a project, by removing the directory of * This method tries to delete a project, by removing the directory of the project and its contents. If something went wrong, the integrity of the folder
* the project and its contents. If something went wrong, the integrity * structure is not guaranteed.
* of the folder structure is not guaruanteed.
* *
* @param project * @param project
* The project to be removed. * The project to be removed.
* @return true iff the project has been removed sucessfully. * @return true iff the project has been removed successfully.
*/ */
public final synchronized boolean deleteProject(final MIProject project) { public final boolean deleteProject(final MIProject project) {
final String projectName = project.getName(); final String projectName = project.getName();
final File dirProject = new File(FileManager.PROJECT_DIR + File.separator + projectName); final File dirProject = new File(FileManager.PROJECT_DIR + File.separator + projectName);
if (dirProject.isDirectory()) { synchronized (this) {
final File[] files = dirProject.listFiles(); if (dirProject.isDirectory()) {
for (final File file : files) { final File[] files = dirProject.listFiles();
if (!file.delete()) { for (final File file : files) {
return false; if (!file.delete()) {
return false;
}
} }
return dirProject.delete();
} }
return dirProject.delete(); return false;
} }
return false;
} }
/** /**
...@@ -364,12 +364,22 @@ public final class FileManager { ...@@ -364,12 +364,22 @@ public final class FileManager {
final String projectName = project.getName(); final String projectName = project.getName();
final File projectFile = new File(FileManager.PROJECT_DIR + File.separator + projectName + File.separator + projectName + FileManager.EXTENSION); final File projectFile = new File(FileManager.PROJECT_DIR + File.separator + projectName + File.separator + projectName + FileManager.EXTENSION);
if (projectFile.isFile()) { synchronized (this) {
return AnalysisController.loadFromFile(projectFile); if (projectFile.isFile()) {
return AnalysisController.loadFromFile(projectFile);
}
} }
return null; return null;
} }
/**
* This method can be used to deliver the correct and full path to a given library. This is necessary as only the name of the dependencies is stored within the
* model dependency. It is not guaranteed that the given path points to an existing file though.
*
* @param dependency
* The dependency which will be used to assemble the path.
* @return An absolute path to the given dependency.
*/
public String getFullPath(final MIDependency dependency) { public String getFullPath(final MIDependency dependency) {
return new File(FileManager.LIB_DIR, dependency.getFilePath()).getAbsolutePath(); return new File(FileManager.LIB_DIR, dependency.getFilePath()).getAbsolutePath();
} }
......
...@@ -31,10 +31,8 @@ import java.util.Map; ...@@ -31,10 +31,8 @@ import java.util.Map;
import kieker.analysis.AnalysisController; import kieker.analysis.AnalysisController;
/** /**
* This singleton class is responsible for the dynamic loading of classes. * This singleton class is responsible for the dynamic loading of classes. Unlike a normal <code>URLClassLoader</code> it is possible to dynamically add and remove
* Unlike a normal <code>URLClassLoader</code> it is possible to dynamically add * urls from the class loader. This instance should always be used if plugin objects have to be created.
* and remove urls from the class loader. This instance should always be used if
* plugin objects have to be created.
* *
* @author Nils Christian Ehmke * @author Nils Christian Ehmke
* @version 1.0 * @version 1.0
...@@ -54,7 +52,7 @@ public final class PluginClassLoader { ...@@ -54,7 +52,7 @@ public final class PluginClassLoader {
* The default constructor of this class. * The default constructor of this class.
*/ */
private PluginClassLoader() { private PluginClassLoader() {
// Nothing to do /* No code necessary. */
} }
/** /**
...@@ -97,8 +95,7 @@ public final class PluginClassLoader { ...@@ -97,8 +95,7 @@ public final class PluginClassLoader {
} }
/** /**
* This method tries to load the class with the given name using the * This method tries to load the class with the given name using the currently loaded dependencies.
* currently loaded dependencies.
* *
* @param name * @param name
* The name of the class to be loaded. * The name of the class to be loaded.
......
...@@ -33,6 +33,8 @@ import kieker.analysis.plugin.annotation.Plugin; ...@@ -33,6 +33,8 @@ import kieker.analysis.plugin.annotation.Plugin;
import kieker.analysis.repository.AbstractRepository; import kieker.analysis.repository.AbstractRepository;
/** /**
* This tool class can be used to find all plugins and repositories within a given jar file - assuming that the <code>PluginClassLoader</code> knows these jars.
*
* @author Nils Christian Ehmke * @author Nils Christian Ehmke
* @version 1.0 * @version 1.0
*/ */
...@@ -41,9 +43,19 @@ public final class PluginFinder { ...@@ -41,9 +43,19 @@ public final class PluginFinder {
/** /**
* Creates a new instance of this class. * Creates a new instance of this class.
*/ */
private PluginFinder() {} private PluginFinder() {
/* No code necessary. */
}
/**
* This method delivers all classes which are available in the given jar and are compatible with <code>AbstractRepository</code>).
*
* @param url
* The url for the jar.
* @return A list containing all available repository-classes or null, if an exception occurred.
*/
public static List<Class<AbstractRepository>> getAllRepositoriesWithinJar(final URL url) { public static List<Class<AbstractRepository>> getAllRepositoriesWithinJar(final URL url) {
// TODO: Merge this with the other method
try { try {
/* /*
* Open the jar file and run through all entries within this file. * Open the jar file and run through all entries within this file.
...@@ -61,10 +73,7 @@ public final class PluginFinder { ...@@ -61,10 +73,7 @@ public final class PluginFinder {
* Try to find a class with the same name. * Try to find a class with the same name.
*/ */
final Class<?> c = PluginClassLoader.getInstance().loadClass(name); final Class<?> c = PluginClassLoader.getInstance().loadClass(name);
/*
* If it is a class and has the annotation - put it into our
* list.
*/
if (AbstractRepository.class.isAssignableFrom(c)) { if (AbstractRepository.class.isAssignableFrom(c)) {
result.add((Class<AbstractRepository>) c); result.add((Class<AbstractRepository>) c);
} }
...@@ -81,13 +90,12 @@ public final class PluginFinder { ...@@ -81,13 +90,12 @@ public final class PluginFinder {
} }
/** /**
* This method delivers all classes which are available in the given jar and * This method delivers all classes which are available in the given jar and have the Plugin-Annotation from the Kieker framework (And are correctly compatible
* has the Plugin-Annotation from the Kieker framework. * with <code>AbstractPlugin</code>).
* *
* @param url * @param url
* The url for the jar. * The url for the jar.
* @return A list containing all available plugin-classes or null, if an * @return A list containing all available plugin-classes or null, if an exception occurred.
* exception occured.
*/ */
public static List<Class<AbstractPlugin>> getAllPluginsWithinJar(final URL url) { public static List<Class<AbstractPlugin>> getAllPluginsWithinJar(final URL url) {
try { try {
......
...@@ -28,6 +28,7 @@ import javax.faces.convert.Converter; ...@@ -28,6 +28,7 @@ import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter; import javax.faces.convert.FacesConverter;
/** /**
* This converter can be used to convert a class to a string and vice versa.
* *
* @author Nils Christian Ehmke * @author Nils Christian Ehmke
* @version 1.0 * @version 1.0
......
...@@ -34,10 +34,8 @@ import kieker.webgui.common.FileManager; ...@@ -34,10 +34,8 @@ import kieker.webgui.common.FileManager;
import kieker.webgui.common.PluginFinder; import kieker.webgui.common.PluginFinder;
/** /**
* This converter can be used to convert an instance of <i>MIDependency</i> to * This converter can be used to convert an instance of <i>MIDependency</i> to the number of plugins within the dependency, but of course <b>not</b> vice versa. The
* the number of plugins within the dependency, but of course <b>not</b> vice * number is cached to avoid that the converter holds the file permanently.
* versa. The number is cached to avoid that the converter holds the file
* permanently.
* *
* @author Nils Christian Ehmke * @author Nils Christian Ehmke
* @version 1.0 * @version 1.0
......
/***************************************************************************
* Copyright 2012 by
* + Christian-Albrechts-University of Kiel
* + Department of Computer Science
* + Software Engineering Group
* and others.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
package kieker.webgui.converter; package kieker.webgui.converter;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import javax.faces.component.UIComponent; import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import javax.faces.convert.Converter; import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter; import javax.faces.convert.FacesConverter;
import kieker.analysis.model.analysisMetaModel.MIPlugin; import kieker.analysis.model.analysisMetaModel.MIPlugin;
/** /**
* This converter can be used to convert a given plugin model instance to a string and vice versa (It uses the object'S toString-method).
* *
* @author Nils Christian Ehmke * @author Nils Christian Ehmke
* @version 1.0
*/ */
@FacesConverter(value = MIPluginToStringConverter.NAME) @FacesConverter(value = MIPluginToStringConverter.NAME)
public class MIPluginToStringConverter implements Converter { public class MIPluginToStringConverter implements Converter {
...@@ -18,25 +41,27 @@ public class MIPluginToStringConverter implements Converter { ...@@ -18,25 +41,27 @@ public class MIPluginToStringConverter implements Converter {
* This is the name of this converter. * This is the name of this converter.
*/ */
public static final String NAME = "kieker.webgui.converter.MIPluginToStringConverter"; public static final String NAME = "kieker.webgui.converter.MIPluginToStringConverter";
/**
* This field stores the mapping.
*/
private static ConcurrentHashMap<String, MIPlugin> map = new ConcurrentHashMap<String, MIPlugin>(); private static ConcurrentHashMap<String, MIPlugin> map = new ConcurrentHashMap<String, MIPlugin>();
/** /**
* Creates a new instance of this class. * Creates a new instance of this class.
*/ */
public MIPluginToStringConverter() { public MIPluginToStringConverter() {
/* No code necessary. */
} }
@Override @Override
public Object getAsObject(final FacesContext fc, final UIComponent uic, final String string) { public Object getAsObject(final FacesContext fc, final UIComponent uic, final String string) {
return map.get(string); return MIPluginToStringConverter.map.get(string);
} }
@Override @Override
public String getAsString(final FacesContext fc, final UIComponent uic, final Object o) { public String getAsString(final FacesContext fc, final UIComponent uic, final Object o) {
String result = o.toString(); final String result = o.toString();
map.put(result, (MIPlugin) o); MIPluginToStringConverter.map.put(result, (MIPlugin) o);
return result; return result;
} }
} }
...@@ -27,8 +27,7 @@ import javax.faces.convert.FacesConverter; ...@@ -27,8 +27,7 @@ import javax.faces.convert.FacesConverter;
import kieker.analysis.model.analysisMetaModel.MIProject; import kieker.analysis.model.analysisMetaModel.MIProject;
/** /**
* This converter can be used to convert an instance of <i>MIProject</i> to a * This converter can be used to convert an instance of <i>MIProject</i> to a human readable string, but <b>not</b> vice versa.
* human readable string, but <b>not</b> vice versa.
* *
* @author Nils Christian Ehmke * @author Nils Christian Ehmke
* @version 1.0 * @version 1.0
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
<!-- This is the submenu for the current project, for example if someone doesn't want to use the context menu within the browser. --> <!-- This is the submenu for the current project, for example if someone doesn't want to use the context menu within the browser. -->
<p:submenu label="Current Project"> <p:submenu label="Current Project">
<p:menuitem value="Save Project" ajax="true" action="#{projectsBean.saveProject(selectedProjectBean.getSelectedProject())}" update=":projectsForm" /> <p:menuitem value="Save Project" ajax="true" action="#{projectsBean.saveProject(selectedProjectBean.getSelectedProject())}" update=":projectsForm" />
<p:menuitem value="Set as Main Project" ajax="true" action="#{selectedProjectBean.setMainProject(selectedProjectBean.getSelectedProject())}" update=":projectsForm" /> <p:menuitem value="Set as Main Project" ajax="true" action="#{selectedMainProjectBean.setMainProject(selectedProjectBean.getSelectedProject())}" update=":projectsForm" />
<p:separator /> <p:separator />
<p:menuitem value="Delete Project" ajax="true" onclick="deleteProjectDialog.show()" /> <p:menuitem value="Delete Project" ajax="true" onclick="deleteProjectDialog.show()" />
<p:menuitem value="Reset Project" ajax="true" onclick="resetProjectDialog.show()" /> <p:menuitem value="Reset Project" ajax="true" onclick="resetProjectDialog.show()" />
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
<p:ajax event="select" listener="#{selectedProjectBean.onNodeSelect}"/> <p:ajax event="select" listener="#{selectedProjectBean.onNodeSelect}"/>
<p:treeNode type="project"> <p:treeNode type="project">
<h:outputText style="font-weight: #{selectedProjectBean.getFontWeight(node)}" value="#{node}"> <h:outputText style="font-weight: #{selectedMainProjectBean.getFontWeight(node)}" value="#{node}">
<f:converter <f:converter
converterId="kieker.webgui.converter.MIProjectToStringConverter" /> converterId="kieker.webgui.converter.MIProjectToStringConverter" />
</h:outputText> </h:outputText>
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
<p:contextMenu for="projectsTree" nodeType="project"> <p:contextMenu for="projectsTree" nodeType="project">
<p:menuitem value="Save Project" ajax="true" action="#{projectsBean.saveProject(selectedProjectBean.getSelectedProject())}" update=":projectsForm" /> <p:menuitem value="Save Project" ajax="true" action="#{projectsBean.saveProject(selectedProjectBean.getSelectedProject())}" update=":projectsForm" />
<p:menuitem value="Set as Main Project" ajax="true" action="#{selectedProjectBean.setMainProject(selectedProjectBean.getSelectedProject())}" update=":projectsForm :toolpalette :centerForm" /> <p:menuitem value="Set as Main Project" ajax="true" action="#{selectedMainProjectBean.setMainProject(selectedProjectBean.getSelectedProject())}" update=":projectsForm :toolpalette :centerForm" />
<p:separator /> <p:separator />
<p:menuitem value="Delete Project" ajax="true" onclick="deleteProjectDialog.show()" /> <p:menuitem value="Delete Project" ajax="true" onclick="deleteProjectDialog.show()" />
...@@ -104,12 +104,12 @@ ...@@ -104,12 +104,12 @@
<!-- The following layout unit is within the center and used for the graph. --> <!-- The following layout unit is within the center and used for the graph. -->
<p:layoutUnit position="center" id="centerLayout"> <p:layoutUnit position="center" id="centerLayout">
<h:form id="centerForm"> <h:form id="centerForm">
<ui:repeat id="centerRepeat" value="#{selectedProjectBean.mainProject.plugins}" var="plugin"> <ui:repeat id="centerRepeat" value="#{selectedMainProjectBean.mainProject.plugins}" var="plugin">
<p:panel header="#{plugin.name}" closable="true" closeSpeed="200" toggleSpeed="200" toggleable="true" id="plugin" style="width: 30%"> <p:panel header="#{plugin.name}" closable="true" closeSpeed="200" toggleSpeed="200" toggleable="true" id="plugin" style="width: 30%">
<p:commandLink ajax="true" value="Configure" action="#{selectedPluginBean.setPlugin(plugin)}" update=":propertiesForm"/> <p:commandLink ajax="true" value="Configure" action="#{selectedPluginBean.setPlugin(plugin)}" update=":propertiesForm"/>
<br/> <br/>
<p:commandLink ajax="true" value="Connect" update=":connectionDialogForm" onclick="connectionDialog.show();"/> <p:commandLink ajax="true" value="Connect" update=":connectionDialogForm" onclick="connectionDialog.show();"/>
<p:ajax event="close" listener="#{selectedProjectBean.removePlugin(plugin)}" update=":centerForm"/> <p:ajax event="close" listener="#{selectedMainProjectBean.removePlugin(plugin)}" update=":centerForm"/>
</p:panel> </p:panel>
<p:draggable for="plugin"> <p:draggable for="plugin">
</p:draggable> </p:draggable>
...@@ -156,17 +156,17 @@ ...@@ -156,17 +156,17 @@
<h:form id="toolpalette"> <h:form id="toolpalette">
<p:accordionPanel multiple="true" activeIndex=""> <p:accordionPanel multiple="true" activeIndex="">
<p:tab title="Reader"> <p:tab title="Reader">
<ui:repeat value="#{selectedProjectBean.availableReaders}" var="reader"> <ui:repeat value="#{selectedMainProjectBean.availableReaders}" var="reader">
<p:commandLink value="#{reader.simpleName}" action="#{selectedProjectBean.addPlugin(reader)}" update=":projectsForm :centerForm" /><br/> <p:commandLink value="#{reader.simpleName}" action="#{selectedMainProjectBean.addPlugin(reader)}" update=":projectsForm :centerForm" /><br/>
</ui:repeat> </ui:repeat>
</p:tab> </p:tab>
<p:tab title="Filter"> <p:tab title="Filter">
<ui:repeat value="#{selectedProjectBean.availableFilters}" var="filter"> <ui:repeat value="#{selectedMainProjectBean.availableFilters}" var="filter">
<p:commandLink value="#{filter.simpleName}" action="#{selectedProjectBean.addPlugin(filter)}" update=":projectsForm :centerForm"/><br/> <p:commandLink value="#{filter.simpleName}" action="#{selectedMainProjectBean.addPlugin(filter)}" update=":projectsForm :centerForm"/><br/>
</ui:repeat> </ui:repeat>
</p:tab> </p:tab>
<p:tab title="Repositories"> <p:tab title="Repositories">
<ui:repeat value="#{selectedProjectBean.availableRepositories}" var="repository"> <ui:repeat value="#{selectedMainProjectBean.availableRepositories}" var="repository">
<p:commandLink value="#{repository.simpleName}" update=":projectsForm :centerForm"/><br/> <p:commandLink value="#{repository.simpleName}" update=":projectsForm :centerForm"/><br/>
</ui:repeat> </ui:repeat>
</p:tab> </p:tab>
......
...@@ -11,10 +11,10 @@ ...@@ -11,10 +11,10 @@
<p:dialog id="connectionDialog" header="Manage Connections" resizable="false" <p:dialog id="connectionDialog" header="Manage Connections" resizable="false"
modal="true" widgetVar="connectionDialog"> modal="true" widgetVar="connectionDialog">
<h:form id="connectionDialogForm"> <h:form id="connectionDialogForm">
<c:if test="#{not empty selectedProjectBean.mainProject}"> <c:if test="#{not empty selectedMainProjectBean.mainProject}">
<p:commandButton value="Add Connection" ajax="true" action="#{selectedProjectBean.addConnection()}" update=":connectionDialogForm"/> <p:commandButton value="Add Connection" ajax="true" action="#{selectedMainProjectBean.addConnection()}" update=":connectionDialogForm"/>
<br/><br/> <br/><br/>
<p:dataTable value="#{selectedProjectBean.connections}" var="connection"> <p:dataTable value="#{selectedMainProjectBean.connections}" var="connection">
<p:column headerText="Source" style="width:125px"> <p:column headerText="Source" style="width:125px">
<p:cellEditor> <p:cellEditor>
<f:facet name="output"> <f:facet name="output">
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
</f:facet> </f:facet>
<f:facet name="input"> <f:facet name="input">
<h:selectOneMenu converter="kieker.webgui.converter.MIPluginToStringConverter" value="#{connection.source}"> <h:selectOneMenu converter="kieker.webgui.converter.MIPluginToStringConverter" value="#{connection.source}">
<f:selectItems value="#{selectedProjectBean.mainProject.plugins}" <f:selectItems value="#{selectedMainProjectBean.mainProject.plugins}"
var="plugin" var="plugin"
itemLabel="#{plugin.name}" itemLabel="#{plugin.name}"
itemValue="#{plugin}"/> itemValue="#{plugin}"/>
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
</f:facet> </f:facet>
<f:facet name="input"> <f:facet name="input">
<h:selectOneMenu converter="kieker.webgui.converter.MIPluginToStringConverter" value="#{connection.destination}"> <h:selectOneMenu converter="kieker.webgui.converter.MIPluginToStringConverter" value="#{connection.destination}">
<f:selectItems value="#{selectedProjectBean.mainProject.plugins}" <f:selectItems value="#{selectedMainProjectBean.mainProject.plugins}"
var="plugin" var="plugin"
itemLabel="#{plugin.name}" itemLabel="#{plugin.name}"
itemValue="#{plugin}"/> itemValue="#{plugin}"/>
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
</p:dataTable> </p:dataTable>
<br/> <br/>
<center> <center>
<p:commandButton value="Ok" action="#{selectedProjectBean.submitConnections()}" oncomplete="connectionDialog.hide();" /> <p:commandButton value="Ok" action="#{selectedMainProjectBean.submitConnections()}" oncomplete="connectionDialog.hide();" />
</center> </center>
</c:if> </c:if>
</h:form> </h:form>
......
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