diff --git a/Kieker.WebGUI/bin/data/Bookstore-Example/Bookstore-Example.kax b/Kieker.WebGUI/bin/data/Bookstore-Example/Bookstore-Example.kax index 69649c9e6725117e53c1a8e11cf8f41b6350464d..23dbdb895defd1819afc273b49ff4117d386a6d7 100644 --- a/Kieker.WebGUI/bin/data/Bookstore-Example/Bookstore-Example.kax +++ b/Kieker.WebGUI/bin/data/Bookstore-Example/Bookstore-Example.kax @@ -1,47 +1,42 @@ <?xml version="1.0" encoding="UTF-8"?> <Project xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="platform:/resource/Kieker/model/AnalysisMetaModel.ecore"> - <plugins xsi:type="Filter" name="Response Time Filter" classname="kieker.examples.userguide.ch3and4bookstore.MyResponseTimeFilter"> + <plugins xsi:type="Filter" name="FSReader" classname="kieker.analysis.plugin.reader.filesystem.FSReader"> + <properties name="inputDirs" value="testdata"/> + <properties name="ignoreUnknownRecordTypes" value="false"/> + <outputPorts name="monitoringRecords" subscribers="//@plugins.1/@inputPorts.0 //@plugins.4/@inputPorts.0"/> + </plugins> + <plugins xsi:type="Filter" name="MyResponseTimeFilter" classname="kieker.examples.userguide.ch3and4bookstore.MyResponseTimeFilter"> <properties name="thresholdNanos" value="1900000"/> - <outputPorts name="validResponseTimes" subscribers="//@plugins.1/@inputPorts.0 //@plugins.5/@inputPorts.0"/> - <outputPorts name="invalidResponseTimes" subscribers="//@plugins.2/@inputPorts.0 //@plugins.6/@inputPorts.0"/> + <outputPorts name="validResponseTimes" subscribers="//@plugins.5/@inputPorts.0 //@plugins.2/@inputPorts.0"/> + <outputPorts name="invalidResponseTimes" subscribers="//@plugins.6/@inputPorts.0 //@plugins.3/@inputPorts.0"/> <inputPorts name="newResponseTime"/> </plugins> - <plugins xsi:type="Filter" name="Print valid" classname="kieker.examples.userguide.ch3and4bookstore.MyResponseTimeOutputPrinter"> + <plugins xsi:type="Filter" name="Valid Printer" classname="kieker.examples.userguide.ch3and4bookstore.MyResponseTimeOutputPrinter"> <properties name="validOutput" value="true"/> <inputPorts name="newEvent"/> </plugins> - <plugins xsi:type="Filter" name="Print invalid" classname="kieker.examples.userguide.ch3and4bookstore.MyResponseTimeOutputPrinter"> - <properties name="validOutput" value="false"/> - <inputPorts name="newEvent"/> - </plugins> - <plugins xsi:type="Reader" name="File System Reader" classname="kieker.analysis.plugin.reader.filesystem.FSReader"> - <properties name="ignoreUnknownRecordTypes" value="false"/> - <properties name="inputDirs" value="testdata"/> - <outputPorts name="monitoringRecords" subscribers="//@plugins.0/@inputPorts.0 //@plugins.4/@inputPorts.0"/> - </plugins> - <plugins xsi:type="Filter" name="Counter1" classname="kieker.analysis.plugin.filter.forward.CountingFilter"> + <plugins xsi:type="Filter" name="Invalid Counter" classname="kieker.analysis.plugin.filter.forward.CountingFilter"> <outputPorts name="relayedEvents"/> <outputPorts name="currentEventCount"/> <displays name="Counter Display"/> <inputPorts name="inputEvents"/> </plugins> - <plugins xsi:type="Filter" name="Counter2" classname="kieker.analysis.plugin.filter.forward.CountingFilter"> + <plugins xsi:type="Filter" name="Global Counter" classname="kieker.analysis.plugin.filter.forward.CountingFilter"> <outputPorts name="relayedEvents"/> <outputPorts name="currentEventCount"/> <displays name="Counter Display"/> <inputPorts name="inputEvents"/> </plugins> - <plugins xsi:type="Filter" name="Counter3" classname="kieker.analysis.plugin.filter.forward.CountingFilter"> + <plugins xsi:type="Filter" name="Valid Counter" classname="kieker.analysis.plugin.filter.forward.CountingFilter"> <outputPorts name="relayedEvents"/> <outputPorts name="currentEventCount"/> <displays name="Counter Display"/> <inputPorts name="inputEvents"/> </plugins> + <plugins xsi:type="Filter" name="Invalid Printer" classname="kieker.examples.userguide.ch3and4bookstore.MyResponseTimeOutputPrinter"> + <properties name="validOutput" value="false"/> + <inputPorts name="newEvent"/> + </plugins> <dependencies filePath="BookstoreApplication.jar"/> - <dependencies filePath="kieker-1.6-SNAPSHOT_emf.jar"/> - <views name="View" description="No description available."> - <displayConnectors name="FS Counter" display="//@plugins.4/@displays.0"/> - <displayConnectors name="Valid Counter" display="//@plugins.5/@displays.0"/> - <displayConnectors name="Invalid Counter" display="//@plugins.6/@displays.0"/> - </views> + <dependencies filePath="commons-cli-1.2.jar"/> </Project> diff --git a/Kieker.WebGUI/bin/data/Bookstore-Example/lib/BookstoreApplication.jar b/Kieker.WebGUI/bin/data/Bookstore-Example/lib/BookstoreApplication.jar index 620d8a18d9fd304960034fe0a9e7a61b75478a79..36f7e73732cb5dd887275451074486430e44c7da 100644 Binary files a/Kieker.WebGUI/bin/data/Bookstore-Example/lib/BookstoreApplication.jar and b/Kieker.WebGUI/bin/data/Bookstore-Example/lib/BookstoreApplication.jar differ diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/ClassAndMethodContainer.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/ClassAndMethodContainer.java new file mode 100644 index 0000000000000000000000000000000000000000..2fb36790de3f491efcc643d5a88d8cd7a6e18f29 --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/ClassAndMethodContainer.java @@ -0,0 +1,193 @@ +/*************************************************************************** + * 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.beans.view; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; + +import kieker.analysis.display.annotation.Display; +import kieker.analysis.plugin.AbstractPlugin; +import kieker.analysis.plugin.annotation.InputPort; +import kieker.analysis.plugin.annotation.OutputPort; +import kieker.analysis.plugin.annotation.Plugin; +import kieker.analysis.plugin.annotation.Property; +import kieker.analysis.plugin.annotation.RepositoryPort; +import kieker.analysis.plugin.filter.AbstractFilterPlugin; +import kieker.analysis.plugin.reader.AbstractReaderPlugin; +import kieker.analysis.repository.AbstractRepository; +import kieker.analysis.repository.annotation.Repository; +import kieker.common.logging.Log; +import kieker.common.logging.LogFactory; +import kieker.webgui.common.exception.ProjectLoadException; + +public final class ClassAndMethodContainer { + + private static final Log LOG = LogFactory.getLog(ClassAndMethodContainer.class); + + private final Class<?> abstractRepositoryClass; + private final Class<?> abstractPluginClass; + private final Class<?> abstractFilterPluginClass; + private final Class<?> abstractReaderPluginClass; + private final Class<? extends Annotation> pluginAnnotationClass; + private final Class<? extends Annotation> repositoryAnnotationClass; + private final Class<? extends Annotation> propertyAnnotationClass; + private final Class<? extends Annotation> outputPortAnnotationClass; + private final Class<? extends Annotation> inputPortAnnotationClass; + private final Class<? extends Annotation> repositoryPortAnnotationClass; + private final Class<? extends Annotation> displayAnnotationClass; + private final Method pluginDescriptionMethod; + private final Method repositoryDescriptionMethod; + private final Method pluginConfigurationMethod; + private final Method repositoryConfigurationMethod; + private final Method pluginOutputPortsMethod; + private final Method pluginRepositoryPortsMethod; + private final Method displayNameMethod; + private final Method inputPortNameMethod; + private final Method outputPortNameMethod; + private final Method repositoryPortNameMethod; + private final Method propertyNameMethod; + private final Method propertyDefaultValueMethod; + + public ClassAndMethodContainer(final ClassLoader classLoader) throws ProjectLoadException { + try { + this.abstractFilterPluginClass = classLoader.loadClass(AbstractFilterPlugin.class.getCanonicalName()); + this.abstractReaderPluginClass = classLoader.loadClass(AbstractReaderPlugin.class.getCanonicalName()); + this.abstractRepositoryClass = classLoader.loadClass(AbstractRepository.class.getCanonicalName()); + this.abstractPluginClass = classLoader.loadClass(AbstractPlugin.class.getCanonicalName()); + + this.pluginAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(Plugin.class.getCanonicalName()); + this.repositoryAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(Repository.class.getCanonicalName()); + this.propertyAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(Property.class.getCanonicalName()); + this.outputPortAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(OutputPort.class.getCanonicalName()); + this.inputPortAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(InputPort.class.getCanonicalName()); + this.repositoryPortAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(RepositoryPort.class.getCanonicalName()); + this.displayAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(Display.class.getCanonicalName()); + + this.pluginDescriptionMethod = this.pluginAnnotationClass.getMethod("description", new Class<?>[0]); + this.repositoryDescriptionMethod = this.repositoryAnnotationClass.getMethod("description", new Class<?>[0]); + this.pluginConfigurationMethod = this.pluginAnnotationClass.getMethod("configuration", new Class<?>[0]); + this.repositoryConfigurationMethod = this.repositoryAnnotationClass.getMethod("configuration", new Class<?>[0]); + this.pluginOutputPortsMethod = this.pluginAnnotationClass.getMethod("outputPorts", new Class<?>[0]); + this.pluginRepositoryPortsMethod = this.pluginAnnotationClass.getMethod("repositoryPorts", new Class<?>[0]); + this.displayNameMethod = this.displayAnnotationClass.getMethod("name", new Class<?>[0]); + this.inputPortNameMethod = this.inputPortAnnotationClass.getMethod("name", new Class<?>[0]); + this.outputPortNameMethod = this.outputPortAnnotationClass.getMethod("name", new Class<?>[0]); + this.repositoryPortNameMethod = this.repositoryPortAnnotationClass.getMethod("name", new Class<?>[0]); + this.propertyNameMethod = this.propertyAnnotationClass.getMethod("name", new Class<?>[0]); + this.propertyDefaultValueMethod = this.propertyAnnotationClass.getMethod("defaultValue", new Class<?>[0]); + } catch (final ReflectiveOperationException ex) { + ClassAndMethodContainer.LOG.error("An error occured while loading the classes and methods.", ex); + throw new ProjectLoadException(); + } + } + + public Class<?> getAbstractFilterPluginClass() { + return this.abstractFilterPluginClass; + } + + public Class<?> getAbstractReaderPluginClass() { + return this.abstractReaderPluginClass; + } + + public Class<? extends Annotation> getPluginAnnotationClass() { + return this.pluginAnnotationClass; + } + + public Class<? extends Annotation> getRepositoryAnnotationClass() { + return this.repositoryAnnotationClass; + } + + public Class<? extends Annotation> getPropertyAnnotationClass() { + return this.propertyAnnotationClass; + } + + public Class<? extends Annotation> getOutputPortAnnotationClass() { + return this.outputPortAnnotationClass; + } + + public Class<? extends Annotation> getInputPortAnnotationClass() { + return this.inputPortAnnotationClass; + } + + public Class<? extends Annotation> getRepositoryPortAnnotationClass() { + return this.repositoryPortAnnotationClass; + } + + public Class<? extends Annotation> getDisplayAnnotationClass() { + return this.displayAnnotationClass; + } + + public Method getPluginDescriptionMethod() { + return this.pluginDescriptionMethod; + } + + public Method getRepositoryDescriptionMethod() { + return this.repositoryDescriptionMethod; + } + + public Method getPluginConfigurationMethod() { + return this.pluginConfigurationMethod; + } + + public Method getRepositoryConfigurationMethod() { + return this.repositoryConfigurationMethod; + } + + public Method getPluginOutputPortsMethod() { + return this.pluginOutputPortsMethod; + } + + public Method getPluginRepositoryPortsMethod() { + return this.pluginRepositoryPortsMethod; + } + + public Method getDisplayNameMethod() { + return this.displayNameMethod; + } + + public Class<?> getAbstractRepositoryClass() { + return this.abstractRepositoryClass; + } + + public Class<?> getAbstractPluginClass() { + return this.abstractPluginClass; + } + + public Method getInputPortNameMethod() { + return this.inputPortNameMethod; + } + + public Method getOutputPortNameMethod() { + return this.outputPortNameMethod; + } + + public Method getRepositoryPortNameMethod() { + return this.repositoryPortNameMethod; + } + + public Method getPropertyNameMethod() { + return this.propertyNameMethod; + } + + public Method getPropertyDefaultValueMethod() { + return this.propertyDefaultValueMethod; + } + +} diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorBean.java index cf3b62efc71d86a91ca5b8d1c046fc045c8cbddf..2f9937162f7632e34594c31888188c05cc48b1f7 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorBean.java @@ -22,16 +22,13 @@ package kieker.webgui.beans.view; import java.io.IOException; import java.lang.annotation.Annotation; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.Collections; -import java.util.Iterator; import java.util.List; -import java.util.Map; import javax.faces.application.FacesMessage; import javax.faces.application.FacesMessage.Severity; @@ -40,7 +37,6 @@ import javax.faces.bean.ManagedProperty; import javax.faces.bean.ViewScoped; import javax.faces.context.FacesContext; -import kieker.analysis.display.annotation.Display; import kieker.analysis.model.analysisMetaModel.MIAnalysisMetaModelFactory; import kieker.analysis.model.analysisMetaModel.MIDependency; import kieker.analysis.model.analysisMetaModel.MIDisplay; @@ -55,16 +51,9 @@ import kieker.analysis.model.analysisMetaModel.MIRepository; import kieker.analysis.model.analysisMetaModel.MIRepositoryConnector; import kieker.analysis.model.analysisMetaModel.impl.MAnalysisMetaModelFactory; import kieker.analysis.plugin.AbstractPlugin; -import kieker.analysis.plugin.annotation.InputPort; -import kieker.analysis.plugin.annotation.OutputPort; -import kieker.analysis.plugin.annotation.Plugin; import kieker.analysis.plugin.annotation.Property; -import kieker.analysis.plugin.annotation.RepositoryPort; -import kieker.analysis.plugin.filter.AbstractFilterPlugin; import kieker.analysis.plugin.reader.AbstractReaderPlugin; import kieker.analysis.repository.AbstractRepository; -import kieker.analysis.repository.annotation.Repository; -import kieker.common.configuration.Configuration; import kieker.common.logging.Log; import kieker.common.logging.LogFactory; import kieker.webgui.beans.application.ProjectsBean; @@ -123,18 +112,15 @@ public final class CurrentAnalysisEditorBean { */ private long timeStamp; /** - * This list contains the available repositories for the current project. The list is from the type Class<?> to allow a modular algorithm for the tree - * assembling. + * This list contains the available repositories for the current project. */ private final List<Class<?>> availableRepositories = Collections.synchronizedList(new ArrayList<Class<?>>()); /** - * This list contains the available filters for the current project. The list is from the type Class<?> to allow a modular algorithm for the tree - * assembl + * This list contains the available filters for the current project. */ private final List<Class<?>> availableFilters = Collections.synchronizedList(new ArrayList<Class<?>>()); /** - * This list contains the available readers for the current project. The list is from the type Class<?> to allow a modular algorithm for the tree - * assembl + * This list contains the available readers for the current project. */ private final List<Class<?>> availableReaders = Collections.synchronizedList(new ArrayList<Class<?>>()); /** @@ -311,10 +297,10 @@ public final class CurrentAnalysisEditorBean { for (final Class<?> plugin : plugins) { if (!Modifier.isAbstract(plugin.getModifiers())) { // The following cast results in the unchecked-cast-warnings, but we know that the cast should be correct. - if (this.classAndMethodContainer.abstractFilterPluginClass.isAssignableFrom(plugin)) { + if (this.classAndMethodContainer.getAbstractFilterPluginClass().isAssignableFrom(plugin)) { this.availableFilters.add(plugin); } else { - if (this.classAndMethodContainer.abstractReaderPluginClass.isAssignableFrom(plugin)) { + if (this.classAndMethodContainer.getAbstractReaderPluginClass().isAssignableFrom(plugin)) { this.availableReaders.add(plugin); } } @@ -398,20 +384,20 @@ public final class CurrentAnalysisEditorBean { public String getDescription(final Class<?> clazz) { try { // Get the two potential annotations - final Annotation annotationPlugin = clazz.getAnnotation(this.classAndMethodContainer.pluginAnnotationClass); - final Annotation annotationRepository = clazz.getAnnotation(this.classAndMethodContainer.repositoryAnnotationClass); + final Annotation annotationPlugin = clazz.getAnnotation(this.classAndMethodContainer.getPluginAnnotationClass()); + final Annotation annotationRepository = clazz.getAnnotation(this.classAndMethodContainer.getRepositoryAnnotationClass()); // Now check which one of them is available - if ((annotationPlugin == null) || ((String) this.classAndMethodContainer.pluginDescriptionMethod.invoke(annotationPlugin, new Object[0])).isEmpty()) { + if ((annotationPlugin == null) || ((String) this.classAndMethodContainer.getPluginDescriptionMethod().invoke(annotationPlugin, new Object[0])).isEmpty()) { if ((annotationRepository == null) - || ((String) this.classAndMethodContainer.repositoryDescriptionMethod.invoke(annotationRepository, new Object[0])).isEmpty()) { + || ((String) this.classAndMethodContainer.getRepositoryDescriptionMethod().invoke(annotationRepository, new Object[0])).isEmpty()) { // None. Deliver a human readable substitute. return "No description available"; } else { - return (String) this.classAndMethodContainer.repositoryDescriptionMethod.invoke(annotationRepository, new Object[0]); + return (String) this.classAndMethodContainer.getRepositoryDescriptionMethod().invoke(annotationRepository, new Object[0]); } } else { - return (String) this.classAndMethodContainer.pluginDescriptionMethod.invoke(annotationPlugin, new Object[0]); + return (String) this.classAndMethodContainer.getPluginDescriptionMethod().invoke(annotationPlugin, new Object[0]); } } catch (final ReflectiveOperationException ex) { CurrentAnalysisEditorBean.LOG.warn("Could not invoke method", ex); @@ -424,8 +410,8 @@ public final class CurrentAnalysisEditorBean { try { // Get the two potential annotations - final Annotation annotationPlugin = clazz.getAnnotation(this.classAndMethodContainer.pluginAnnotationClass); - final Annotation annotationRepository = clazz.getAnnotation(this.classAndMethodContainer.repositoryAnnotationClass); + final Annotation annotationPlugin = clazz.getAnnotation(this.classAndMethodContainer.getPluginAnnotationClass()); + final Annotation annotationRepository = clazz.getAnnotation(this.classAndMethodContainer.getRepositoryAnnotationClass()); final Annotation[] properties; @@ -435,10 +421,10 @@ public final class CurrentAnalysisEditorBean { // None. properties = new Property[0]; } else { - properties = (Annotation[]) this.classAndMethodContainer.repositoryConfigurationMethod.invoke(annotationRepository, new Object[0]); + properties = (Annotation[]) this.classAndMethodContainer.getRepositoryConfigurationMethod().invoke(annotationRepository, new Object[0]); } } else { - properties = (Annotation[]) this.classAndMethodContainer.pluginConfigurationMethod.invoke(annotationPlugin, new Object[0]); + properties = (Annotation[]) this.classAndMethodContainer.getPluginConfigurationMethod().invoke(annotationPlugin, new Object[0]); } for (final Annotation property : properties) { @@ -463,7 +449,7 @@ public final class CurrentAnalysisEditorBean { for (final Method method : clazz.getMethods()) { // Get the potential annotation - final Annotation annotationPort = method.getAnnotation(this.classAndMethodContainer.inputPortAnnotationClass); + final Annotation annotationPort = method.getAnnotation(this.classAndMethodContainer.getInputPortAnnotationClass()); // Now check whether it is available if (annotationPort != null) { result.add(annotationPort); @@ -485,11 +471,11 @@ public final class CurrentAnalysisEditorBean { try { // Get the potential annotation - final Annotation annotationPlugin = clazz.getAnnotation(this.classAndMethodContainer.pluginAnnotationClass); + final Annotation annotationPlugin = clazz.getAnnotation(this.classAndMethodContainer.getPluginAnnotationClass()); // Now check whether it is available if (annotationPlugin != null) { - for (final Annotation oPort : (Annotation[]) this.classAndMethodContainer.pluginOutputPortsMethod.invoke(annotationPlugin, new Object[0])) { + for (final Annotation oPort : (Annotation[]) this.classAndMethodContainer.getPluginOutputPortsMethod().invoke(annotationPlugin, new Object[0])) { result.add(oPort); } } @@ -511,11 +497,11 @@ public final class CurrentAnalysisEditorBean { final List<Annotation> result = new ArrayList<Annotation>(); try { // Get the potential annotation - final Annotation annotationPlugin = clazz.getAnnotation(this.classAndMethodContainer.pluginAnnotationClass); + final Annotation annotationPlugin = clazz.getAnnotation(this.classAndMethodContainer.getPluginAnnotationClass()); // Now check whether it is available if (annotationPlugin != null) { - for (final Annotation rPort : (Annotation[]) this.classAndMethodContainer.pluginRepositoryPortsMethod.invoke(annotationPlugin, new Object[0])) { + for (final Annotation rPort : (Annotation[]) this.classAndMethodContainer.getPluginRepositoryPortsMethod().invoke(annotationPlugin, new Object[0])) { result.add(rPort); } } @@ -530,7 +516,7 @@ public final class CurrentAnalysisEditorBean { for (final Method method : clazz.getMethods()) { // Get the potential annotation - final Annotation display = method.getAnnotation(this.classAndMethodContainer.displayAnnotationClass); + final Annotation display = method.getAnnotation(this.classAndMethodContainer.getDisplayAnnotationClass()); // Now check whether it is available if (display != null) { result.add(display); @@ -653,7 +639,7 @@ public final class CurrentAnalysisEditorBean { final List<Annotation> displays = this.getDisplays(clazz); for (final Annotation display : displays) { final MIDisplay mDisplay = this.factory.createDisplay(); - mDisplay.setName((String) this.classAndMethodContainer.displayNameMethod.invoke(display, new Object[0])); + mDisplay.setName((String) this.classAndMethodContainer.getDisplayNameMethod().invoke(display, new Object[0])); plugin.getDisplays().add(mDisplay); } @@ -683,58 +669,42 @@ public final class CurrentAnalysisEditorBean { private boolean fillPorts(final Class<AbstractPlugin> clazz, final MIPlugin plugin) { synchronized (this) { try { - // Try to instantiate the given class, using the special constructor of Kieker. - final AbstractPlugin pluginInstance = clazz.getConstructor(Configuration.class).newInstance(new Configuration()); - - // Get the port and use them to initialize the model plugin. - final String[] inputPortNames = pluginInstance.getAllInputPortNames(); - final String[] outputPortNames = pluginInstance.getAllOutputPortNames(); - final String[] repositoryPortNames = pluginInstance.getAllRepositoryPortNames(); + // Get the ports + final List<Annotation> inputPorts = this.getInputPorts(clazz); + final List<Annotation> outputPorts = this.getOutputPorts(clazz); + final List<Annotation> repositoryPorts = this.getRepositoryPorts(clazz); // Add input ports if (plugin instanceof MIFilter) { - for (final String inputPortName : inputPortNames) { + for (final Annotation inputPort : inputPorts) { final MIInputPort mInputPort = this.factory.createInputPort(); - mInputPort.setName(inputPortName); - + mInputPort.setName((String) this.classAndMethodContainer.getInputPortNameMethod().invoke(inputPort, new Object[0])); mInputPort.setParent((MIFilter) plugin); } } // Add output ports. - for (final String outputPortName : outputPortNames) { + for (final Annotation outputPort : outputPorts) { final MIOutputPort mOutputPort = this.factory.createOutputPort(); - mOutputPort.setName(outputPortName); + mOutputPort.setName((String) this.classAndMethodContainer.getOutputPortNameMethod().invoke(outputPort, new Object[0])); mOutputPort.setParent(plugin); } // Add repository ports. - for (final String repositoryPortName : repositoryPortNames) { + for (final Annotation repositoryPort : repositoryPorts) { final MIRepositoryConnector mConnector = this.factory.createRepositoryConnector(); - mConnector.setName(repositoryPortName); + mConnector.setName((String) this.classAndMethodContainer.getRepositoryPortNameMethod().invoke(repositoryPort, new Object[0])); plugin.getRepositories().add(mConnector); } return true; - } catch (final InstantiationException ex) { - CurrentAnalysisEditorBean.LOG.error("An errcor occured while loading the ports of the plugin.", ex); - CurrentAnalysisEditorBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the ports of the plugin."); - return false; - } catch (final IllegalAccessException ex) { - CurrentAnalysisEditorBean.LOG.error("An errcor occured while loading the ports of the plugin.", ex); - CurrentAnalysisEditorBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the ports of the plugin."); - return false; - } catch (final InvocationTargetException ex) { - CurrentAnalysisEditorBean.LOG.error("An errcor occured while loading the ports of the plugin.", ex); - CurrentAnalysisEditorBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the ports of the plugin."); - return false; - } catch (final NoSuchMethodException ex) { - CurrentAnalysisEditorBean.LOG.error("An errcor occured while loading the ports of the plugin.", ex); + } catch (final ReflectiveOperationException ex) { + CurrentAnalysisEditorBean.LOG.error("An error occured while loading the ports of the plugin.", ex); CurrentAnalysisEditorBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the ports of the plugin."); return false; - } catch (final NoClassDefFoundError ex) { - CurrentAnalysisEditorBean.LOG.error("An errcor occured while loading the ports of the plugin.", ex); + } catch (final ClassCastException ex) { + CurrentAnalysisEditorBean.LOG.error("An error occured while loading the ports of the plugin.", ex); CurrentAnalysisEditorBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the ports of the plugin."); return false; } @@ -753,32 +723,25 @@ public final class CurrentAnalysisEditorBean { */ private boolean fillProperties(final Class<AbstractRepository> clazz, final MIRepository repository) { try { - // Try to instantiate the given class, using the special constructor of Kieker. - final AbstractRepository repositoryInstance = clazz.getConstructor(Configuration.class).newInstance(new Configuration()); - // Get the current configuration and use it to initialize the model repository, as THIS configuration instance will contain all keys. - final Configuration configuration = repositoryInstance.getCurrentConfiguration(); + // Get the default configuration and use it to initialize the model repository + final List<Annotation> properties = this.getProperties(clazz); + + for (final Annotation property : properties) { + final MIProperty mProperty = this.factory.createProperty(); - repository.getProperties().addAll(this.extractProperties(configuration)); + mProperty.setName((String) this.classAndMethodContainer.getPropertyNameMethod().invoke(property, new Object[0])); + mProperty.setValue((String) this.classAndMethodContainer.getPropertyDefaultValueMethod().invoke(property, new Object[0])); + + repository.getProperties().add(mProperty); + } return true; - } catch (final InstantiationException ex) { - CurrentAnalysisEditorBean.LOG.error("An errcor occured while loading the properties of the repository.", ex); - CurrentAnalysisEditorBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the repository."); - return false; - } catch (final IllegalAccessException ex) { - CurrentAnalysisEditorBean.LOG.error("An errcor occured while loading the properties of the repository.", ex); - CurrentAnalysisEditorBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the repository."); - return false; - } catch (final InvocationTargetException ex) { - CurrentAnalysisEditorBean.LOG.error("An errcor occured while loading the properties of the repository.", ex); - CurrentAnalysisEditorBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the repository."); - return false; - } catch (final NoSuchMethodException ex) { - CurrentAnalysisEditorBean.LOG.error("An errcor occured while loading the properties of the repository.", ex); + } catch (final ReflectiveOperationException ex) { + CurrentAnalysisEditorBean.LOG.error("An error occured while loading the properties of the repository.", ex); CurrentAnalysisEditorBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the repository."); return false; - } catch (final NoClassDefFoundError ex) { - CurrentAnalysisEditorBean.LOG.error("An errcor occured while loading the properties of the repository.", ex); + } catch (final ClassCastException ex) { + CurrentAnalysisEditorBean.LOG.error("An error occured while loading the properties of the repository.", ex); CurrentAnalysisEditorBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the repository."); return false; } @@ -796,63 +759,30 @@ public final class CurrentAnalysisEditorBean { */ private boolean fillProperties(final Class<AbstractPlugin> clazz, final MIPlugin plugin) { try { - // Try to instantiate the given class, using the special constructor of Kieker. - final AbstractPlugin pluginInstance = clazz.getConstructor(Configuration.class).newInstance(new Configuration()); - // Get the current configuration and use it to initialize the model plugin, as THIS configuration instance will contain all keys. - final Configuration configuration = pluginInstance.getCurrentConfiguration(); + // Get the default configuration and use it to initialize the model plugin + final List<Annotation> properties = this.getProperties(clazz); - plugin.getProperties().addAll(this.extractProperties(configuration)); + for (final Annotation property : properties) { + final MIProperty mProperty = this.factory.createProperty(); + + mProperty.setName((String) this.classAndMethodContainer.getPropertyNameMethod().invoke(property, new Object[0])); + mProperty.setValue((String) this.classAndMethodContainer.getPropertyDefaultValueMethod().invoke(property, new Object[0])); + + plugin.getProperties().add(mProperty); + } return true; - } catch (final InstantiationException ex) { - CurrentAnalysisEditorBean.LOG.error("An errcor occured while loading the properties of the plugin.", ex); - CurrentAnalysisEditorBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the plugin."); - return false; - } catch (final IllegalAccessException ex) { - CurrentAnalysisEditorBean.LOG.error("An errcor occured while loading the properties of the plugin.", ex); - CurrentAnalysisEditorBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the plugin."); - return false; - } catch (final InvocationTargetException ex) { - CurrentAnalysisEditorBean.LOG.error("An errcor occured while loading the properties of the plugin.", ex); - CurrentAnalysisEditorBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the plugin."); - return false; - } catch (final NoSuchMethodException ex) { - CurrentAnalysisEditorBean.LOG.error("An errcor occured while loading the properties of the plugin.", ex); + } catch (final ReflectiveOperationException ex) { + CurrentAnalysisEditorBean.LOG.error("An error occured while loading the properties of the plugin.", ex); CurrentAnalysisEditorBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the plugin."); return false; - } catch (final NoClassDefFoundError ex) { - CurrentAnalysisEditorBean.LOG.error("An errcor occured while loading the properties of the plugin.", ex); + } catch (final ClassCastException ex) { + CurrentAnalysisEditorBean.LOG.error("An error occured while loading the properties of the plugin.", ex); CurrentAnalysisEditorBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the plugin."); return false; } } - /** - * This method extracts the properties from the given configuration. In other words: For every key within the configuration, the method creates a model - * counterpart. - * - * @param configuration - * The configuration to be used for extraction. - * @return The list containing one {@link MIProperty} for every key within the configuration. - */ - private List<MIProperty> extractProperties(final Configuration configuration) { - final List<MIProperty> result = new ArrayList<MIProperty>(); - - // 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 = this.factory.createProperty(); - property.setName(entry.getKey().toString()); - property.setValue(entry.getValue().toString()); - - result.add(property); - } - - return result; - } - /** * This method adds a new repository to the current model, using the given instance of {@code Class} for it. * @@ -1097,56 +1027,19 @@ public final class CurrentAnalysisEditorBean { } } - public void edgeCreated(final EObject sourcePort, final EObject targetPort) { - ((MIOutputPort) sourcePort).getSubscribers().add((MIInputPort) targetPort); + public void edgeCreated(final MIOutputPort sourcePort, final MIInputPort targetPort) { + sourcePort.getSubscribers().add(targetPort); } - public void edgeRemoved(final EObject sourcePort, final EObject targetPort) { - ((MIOutputPort) sourcePort).getSubscribers().remove(targetPort); + public void edgeRemoved(final MIOutputPort sourcePort, final MIInputPort targetPort) { + sourcePort.getSubscribers().remove(targetPort); } - private static final class ClassAndMethodContainer { - - public final Class<?> abstractFilterPluginClass; - public final Class<?> abstractReaderPluginClass; - public final Class<? extends Annotation> pluginAnnotationClass; - public final Class<? extends Annotation> repositoryAnnotationClass; - public final Class<? extends Annotation> propertyAnnotationClass; - public final Class<? extends Annotation> outputPortAnnotationClass; - public final Class<? extends Annotation> inputPortAnnotationClass; - public final Class<? extends Annotation> repositoryPortAnnotationClass; - public final Class<? extends Annotation> displayAnnotationClass; - public final Method pluginDescriptionMethod; - public final Method repositoryDescriptionMethod; - public final Method pluginConfigurationMethod; - public final Method repositoryConfigurationMethod; - public final Method pluginOutputPortsMethod; - public final Method pluginRepositoryPortsMethod; - public final Method displayNameMethod; - - public ClassAndMethodContainer(final ClassLoader classLoader) throws ProjectLoadException { - try { - this.abstractFilterPluginClass = classLoader.loadClass(AbstractFilterPlugin.class.getCanonicalName()); - this.abstractReaderPluginClass = classLoader.loadClass(AbstractReaderPlugin.class.getCanonicalName()); - this.pluginAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(Plugin.class.getCanonicalName()); - this.repositoryAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(Repository.class.getCanonicalName()); - this.propertyAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(Property.class.getCanonicalName()); - this.outputPortAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(OutputPort.class.getCanonicalName()); - this.inputPortAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(InputPort.class.getCanonicalName()); - this.repositoryPortAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(RepositoryPort.class.getCanonicalName()); - this.displayAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(Display.class.getCanonicalName()); - - this.pluginDescriptionMethod = this.pluginAnnotationClass.getMethod("description", new Class<?>[0]); - this.repositoryDescriptionMethod = this.repositoryAnnotationClass.getMethod("description", new Class<?>[0]); - this.pluginConfigurationMethod = this.pluginAnnotationClass.getMethod("configuration", new Class<?>[0]); - this.repositoryConfigurationMethod = this.repositoryAnnotationClass.getMethod("configuration", new Class<?>[0]); - this.pluginOutputPortsMethod = this.pluginAnnotationClass.getMethod("outputPorts", new Class<?>[0]); - this.pluginRepositoryPortsMethod = this.pluginAnnotationClass.getMethod("repositoryPorts", new Class<?>[0]); - this.displayNameMethod = this.displayAnnotationClass.getMethod("name", new Class<?>[0]); - } catch (final ReflectiveOperationException ex) { - CurrentAnalysisEditorBean.LOG.error("An error occured while loading the classes and methods.", ex); - throw new ProjectLoadException(); - } - } + public void edgeCreated(final MIRepositoryConnector sourcePort, final MIRepository target) { + sourcePort.setRepository(target); + } + + public void edgeRemoved(final MIRepositoryConnector sourcePort, final MIRepository target) { + sourcePort.setRepository(null); } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorGraphBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorGraphBean.java index 9a6d9c94c79db6e3cbb5a384eff702bd31e47b7e..b75cfa927331b2fbad5cd685569bb1a1aa2c546f 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorGraphBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorGraphBean.java @@ -115,6 +115,8 @@ public class CurrentAnalysisEditorGraphBean { * This is the javascript code to rename a node within the graph. */ private static final String JS_CMD_RENAME_NODE = "graph.getNode(%s).name = '%s';"; + private static final Object REPOSITORY_INPUT_PORT = "R"; + /** * This map contains all components (plugins, repositories and ports) within the graph to identify them with a unique ID. */ @@ -137,7 +139,7 @@ public class CurrentAnalysisEditorGraphBean { RequestContext.getCurrentInstance().execute(CurrentAnalysisEditorGraphBean.JS_CMD_ADD_CLICK_LISTENER); RequestContext.getCurrentInstance().execute(CurrentAnalysisEditorGraphBean.JS_CMD_ADD_REMOVE_NODE_LISTENER); RequestContext.getCurrentInstance().execute(CurrentAnalysisEditorGraphBean.JS_CMD_ADD_CREATE_EDGE_LISTENER); - RequestContext.getCurrentInstance().execute(CurrentAnalysisEditorGraphBean.JS_CMD_ADD_REMOVE_EDGE_LISTENER); + // RequestContext.getCurrentInstance().execute(CurrentAnalysisEditorGraphBean.JS_CMD_ADD_REMOVE_EDGE_LISTENER); } /** @@ -154,8 +156,10 @@ public class CurrentAnalysisEditorGraphBean { * The filter which should be added to the graph. */ public void addFilter(final MIFilter filter) { - RequestContext.getCurrentInstance().execute(String.format(CurrentAnalysisEditorGraphBean.JS_CMD_ADD_FILTER, 0, 0, this.assembleGraphString(filter), - this.assembleGraphRepositoryPortString(filter), this.assembleGraphInputPortString(filter), this.assembleGraphOuputPortString(filter))); + RequestContext.getCurrentInstance().execute( + String.format(CurrentAnalysisEditorGraphBean.JS_CMD_ADD_FILTER, 0, 0, this.assembleGraphString(filter), + this.assembleGraphRepositoryPortString(filter.getRepositories()), this.assembleGraphInputPortString(filter), + this.assembleGraphOutputPortString(filter))); } /** @@ -166,7 +170,7 @@ public class CurrentAnalysisEditorGraphBean { */ public void addReader(final MIReader reader) { RequestContext.getCurrentInstance().execute(String.format(CurrentAnalysisEditorGraphBean.JS_CMD_ADD_READER, 0, 0, this.assembleGraphString(reader), - this.assembleGraphRepositoryPortString(reader), this.assembleGraphOuputPortString(reader))); + this.assembleGraphRepositoryPortString(reader.getRepositories()), this.assembleGraphOutputPortString(reader))); } /** @@ -176,7 +180,8 @@ public class CurrentAnalysisEditorGraphBean { * The repository which should be added to the graph. */ public void addRepository(final MIRepository repository) { - final String repoPort = String.format(CurrentAnalysisEditorGraphBean.JS_CMD_PORT, CurrentAnalysisEditorGraphBean.JS_CMD_PORT_TYPE_INPUT, "ip1", "N/A"); + final String repoPort = String.format(CurrentAnalysisEditorGraphBean.JS_CMD_PORT, CurrentAnalysisEditorGraphBean.JS_CMD_PORT_TYPE_INPUT, + CurrentAnalysisEditorGraphBean.REPOSITORY_INPUT_PORT, "N/A"); RequestContext.getCurrentInstance().execute(String.format(CurrentAnalysisEditorGraphBean.JS_CMD_ADD_REPOSITORY, 0, 0, this.assembleGraphString(repository), repoPort)); } @@ -231,19 +236,19 @@ public class CurrentAnalysisEditorGraphBean { * The plugin whose repository ports will be used. * @return A string containing the JS commands to create the repository ports. */ - private String assembleGraphRepositoryPortString(final MIPlugin plugin) { + private String assembleGraphRepositoryPortString(final EList<MIRepositoryConnector> ports) { final StringBuilder builder = new StringBuilder(); - final int len = plugin.getRepositories().size(); + final int len = ports.size(); for (int i = 0; i < len; i++) { - final MIRepositoryConnector port = plugin.getRepositories().get(i); + final MIRepositoryConnector port = ports.get(i); if (i != 0) { builder.append(','); } - builder.append(String.format(CurrentAnalysisEditorGraphBean.JS_CMD_PORT, port.getName(), port.getName(), port.getName())); + builder.append(String.format(CurrentAnalysisEditorGraphBean.JS_CMD_PORT, port.getName(), this.componentMap.get(port), port.getName())); } return builder.toString(); @@ -267,7 +272,7 @@ public class CurrentAnalysisEditorGraphBean { * The plugin whose output ports will be used. * @return A string containing the JS commands to create the output ports. */ - private String assembleGraphOuputPortString(final MIPlugin plugin) { + private String assembleGraphOutputPortString(final MIPlugin plugin) { return this.assembleGraphPortString(plugin.getOutputPorts()); } @@ -339,7 +344,6 @@ public class CurrentAnalysisEditorGraphBean { // Get the parameters final Map<String, String> paramMap = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap(); final String clickedNodeID = paramMap.get("ID"); - // Now search the correct node try { final EObject selectedNode = this.componentMap.get(Integer.parseInt(clickedNodeID)); @@ -362,10 +366,21 @@ public class CurrentAnalysisEditorGraphBean { // Now search the correct components try { final EObject sourcePort = this.componentMap.get(Integer.parseInt(sourcePortID)); - final EObject targetPort = this.componentMap.get(Integer.parseInt(targetPortID)); - - if ((sourcePort != null) && (targetPort != null) && (this.currentAnalysisEditorBean != null)) { - this.currentAnalysisEditorBean.edgeCreated(sourcePort, targetPort); + if (CurrentAnalysisEditorGraphBean.REPOSITORY_INPUT_PORT.equals(targetPortID)) { + // This is a special case: An edge between a filter and a repository + final String targetID = paramMap.get("targetPortID").split("\\.")[0]; + final EObject targetRepo = this.componentMap.get(Integer.parseInt(targetID)); + + if ((sourcePort instanceof MIRepositoryConnector) && (targetRepo instanceof MIRepository) && (this.currentAnalysisEditorBean != null)) { + this.currentAnalysisEditorBean.edgeCreated((MIRepositoryConnector) sourcePort, (MIRepository) targetRepo); + } + } else { + // This is the normal case: An edge between two filters + final EObject targetPort = this.componentMap.get(Integer.parseInt(targetPortID)); + + if ((sourcePort != null) && (targetPort != null) && (this.currentAnalysisEditorBean != null)) { + this.currentAnalysisEditorBean.edgeCreated((MIOutputPort) sourcePort, (MIInputPort) targetPort); + } } } catch (final NumberFormatException ex) { // Ignore an invalid ID, but log it. @@ -383,10 +398,20 @@ public class CurrentAnalysisEditorGraphBean { // Now search the correct components try { final EObject sourcePort = this.componentMap.get(Integer.parseInt(sourcePortID)); - final EObject targetPort = this.componentMap.get(Integer.parseInt(targetPortID)); - - if ((sourcePort != null) && (targetPort != null) && (this.currentAnalysisEditorBean != null)) { - this.currentAnalysisEditorBean.edgeRemoved(sourcePort, targetPort); + if (CurrentAnalysisEditorGraphBean.REPOSITORY_INPUT_PORT.equals(targetPortID)) { + // This is a special case: An edge between a filter and a repository + final String targetID = paramMap.get("targetPortID").split("\\.")[0]; + final EObject targetRepo = this.componentMap.get(Integer.parseInt(targetID)); + if ((sourcePort instanceof MIRepositoryConnector) && (targetRepo instanceof MIRepository) && (this.currentAnalysisEditorBean != null)) { + this.currentAnalysisEditorBean.edgeRemoved((MIRepositoryConnector) sourcePort, (MIRepository) targetRepo); + } + } else { + // This is the normal case: An edge between two filters + final EObject targetPort = this.componentMap.get(Integer.parseInt(targetPortID)); + + if ((sourcePort != null) && (targetPort != null) && (this.currentAnalysisEditorBean != null)) { + this.currentAnalysisEditorBean.edgeRemoved((MIOutputPort) sourcePort, (MIInputPort) targetPort); + } } } catch (final NumberFormatException ex) { // Ignore an invalid ID, but log it. diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginFinder.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginFinder.java index 8c0ff5e7d56ac24f70f87d0f40e0a25ca5b9907e..e2e2dbbe942fb35ba3a058c4a213c03e363b87d7 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginFinder.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginFinder.java @@ -20,17 +20,14 @@ package kieker.webgui.common; import java.io.IOException; -import java.lang.annotation.Annotation; import java.net.URL; import java.util.ArrayList; import java.util.List; import java.util.jar.JarEntry; import java.util.jar.JarInputStream; -import kieker.analysis.plugin.AbstractPlugin; -import kieker.analysis.plugin.annotation.Plugin; -import kieker.analysis.repository.AbstractRepository; -import kieker.analysis.repository.annotation.Repository; +import kieker.webgui.beans.view.ClassAndMethodContainer; +import kieker.webgui.common.exception.ProjectLoadException; /** * This tool class can be used to find all plugins and repositories within a given jar file - assuming that the given class loader knows these jars. @@ -40,11 +37,8 @@ import kieker.analysis.repository.annotation.Repository; */ public final class PluginFinder { + private final ClassAndMethodContainer classAndMethodContainer; private final ClassLoader classLoader; - private final Class<? extends Annotation> repositoryAnnotationClass; - private final Class<?> abstractRepositoryClass; - private final Class<? extends Annotation> pluginAnnotationClass; - private final Class<?> abstractPluginClass; /** * Creates a new instance of this class, using the given class loader. @@ -52,16 +46,11 @@ public final class PluginFinder { * @param classLoader * The {@link ClassLoader} which will be used to load the classes. * @throws ClassNotFoundException + * @throws ProjectLoadException */ - @SuppressWarnings("unchecked") - public PluginFinder(final ClassLoader classLoader) throws ClassNotFoundException { + public PluginFinder(final ClassLoader classLoader) throws ClassNotFoundException, ProjectLoadException { this.classLoader = classLoader; - - // Load the necessary classes and annotations for a correct comparison - this.repositoryAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(Repository.class.getCanonicalName()); - this.abstractRepositoryClass = classLoader.loadClass(AbstractRepository.class.getCanonicalName()); - this.pluginAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(Plugin.class.getCanonicalName()); - this.abstractPluginClass = classLoader.loadClass(AbstractPlugin.class.getCanonicalName()); + this.classAndMethodContainer = new ClassAndMethodContainer(classLoader); } /** @@ -81,7 +70,8 @@ public final class PluginFinder { result = new ArrayList<Class<?>>(); for (final Class<?> clazz : clazzes) { // This is the cast resulting in an unchecked cast warning. - if (clazz.isAnnotationPresent(this.repositoryAnnotationClass) && this.abstractRepositoryClass.isAssignableFrom(clazz)) { + if (clazz.isAnnotationPresent(this.classAndMethodContainer.getRepositoryAnnotationClass()) + && this.classAndMethodContainer.getAbstractRepositoryClass().isAssignableFrom(clazz)) { result.add(clazz); } } @@ -108,7 +98,8 @@ public final class PluginFinder { result = new ArrayList<Class<?>>(); for (final Class<?> clazz : clazzes) { // This is the cast resulting in an unchecked cast warning. - if (clazz.isAnnotationPresent(this.pluginAnnotationClass) && this.abstractPluginClass.isAssignableFrom(clazz)) { + if (clazz.isAnnotationPresent(this.classAndMethodContainer.getPluginAnnotationClass()) + && this.classAndMethodContainer.getAbstractPluginClass().isAssignableFrom(clazz)) { result.add(clazz); } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/ProjectLoadException.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/ProjectLoadException.java index fbcedbbf5722e5ca9057a4cff4556c316d8cae05..3937564d3a0b428c6abb81a68b1b72e82f8953e3 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/ProjectLoadException.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/ProjectLoadException.java @@ -1,3 +1,22 @@ +/*************************************************************************** + * 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.common.exception; public class ProjectLoadException extends Exception { diff --git a/Kieker.WebGUI/src/main/webapp/AnalysisEditor.xhtml b/Kieker.WebGUI/src/main/webapp/AnalysisEditor.xhtml index aa3891395ac77da6dbe1e89b12fb6fa1fe2a421b..bc81a429ff58670b1bfecf14fd7024a29f59ef8e 100644 --- a/Kieker.WebGUI/src/main/webapp/AnalysisEditor.xhtml +++ b/Kieker.WebGUI/src/main/webapp/AnalysisEditor.xhtml @@ -25,8 +25,6 @@ <script language="javascript" type="text/javascript" src="../js/jit.js"></script> <script language="javascript" type="text/javascript" src="../js/flowEditor.js"></script> - <script type="text/javascript" src="https://getfirebug.com/firebug-lite.js"></script> - <script> nodeClickListener = function(node, info, e) { nodeClickCommand([{name : 'ID', value : node.id}]);