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

Some minor code modifications for quality reasons; Added some comments; Minor bug fixing

parent 5b7d847c
No related branches found
No related tags found
No related merge requests found
<?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="FSReader" classname="kieker.analysis.plugin.reader.filesystem.FSReader">
<plugins xsi:type="Reader" 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"/>
......
......@@ -58,6 +58,7 @@ import kieker.analysis.repository.AbstractRepository;
import kieker.common.logging.Log;
import kieker.common.logging.LogFactory;
import kieker.webgui.beans.application.ProjectsBean;
import kieker.webgui.common.ClassAndMethodContainer;
import kieker.webgui.common.FSManager;
import kieker.webgui.common.Pair;
import kieker.webgui.common.PluginFinder;
......@@ -867,7 +868,7 @@ public final class CurrentAnalysisEditorBean {
public void addPlugin(final Class<AbstractPlugin> clazz) {
// Create a new instance for the model
final MIPlugin plugin;
if (AbstractReaderPlugin.class.isAssignableFrom(clazz)) {
if (this.classAndMethodContainer.getAbstractReaderPluginClass().isAssignableFrom(clazz)) {
plugin = this.factory.createReader();
} else {
plugin = this.factory.createFilter();
......
......@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
package kieker.webgui.beans.view;
package kieker.webgui.common;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
......@@ -37,34 +37,128 @@ import kieker.common.logging.Log;
import kieker.common.logging.LogFactory;
import kieker.webgui.common.exception.ProjectLoadException;
/**
* The {@link ClassAndMethodContainer} is a container which contains - as the name already suggests - various classes and methods. To be more precisely, it uses a
* given class loader to load the equivalence of specific classes within this application to ensure that comparisons, assignments and the use of specific methods
* will be done correctly. This is necessary as for every project within this application there will be a number of libraries which will be combined in one class
* loader. This will result in multiple version of one and the same class and therefore in problems, if one doesn't use the correct class version.
*
* @author Nils Christian Ehmke
* @version 1.0
*/
public final class ClassAndMethodContainer {
/**
* This is the logger, which will be used to log messages and exceptions for this class.
*/
private static final Log LOG = LogFactory.getLog(ClassAndMethodContainer.class);
/**
* The exception which is used if something went wrong during loading.
*/
private static final String MSG_LOAD_EXCEPTION = "An error occured while loading the classes and methods.";
/**
* This is the class equivalence of {@link AbstractRepository}.
*/
private final Class<?> abstractRepositoryClass;
/**
* This is the class equivalence of {@link AbstractPlugin}.
*/
private final Class<?> abstractPluginClass;
/**
* This is the class equivalence of {@link AbstractFilterPlugin}.
*/
private final Class<?> abstractFilterPluginClass;
/**
* This is the class equivalence of {@link AbstractRepository}.
*/
private final Class<?> abstractReaderPluginClass;
/**
* This is the class equivalence of {@link Plugin}.
*/
private final Class<? extends Annotation> pluginAnnotationClass;
/**
* This is the class equivalence of {@link Repository}.
*/
private final Class<? extends Annotation> repositoryAnnotationClass;
/**
* This is the class equivalence of {@link Property}.
*/
private final Class<? extends Annotation> propertyAnnotationClass;
/**
* This is the class equivalence of {@link OutputPort}.
*/
private final Class<? extends Annotation> outputPortAnnotationClass;
/**
* This is the class equivalence of {@link InputPort}.
*/
private final Class<? extends Annotation> inputPortAnnotationClass;
/**
* This is the class equivalence of {@link RepositoryPort}.
*/
private final Class<? extends Annotation> repositoryPortAnnotationClass;
/**
* This is the class equivalence of {@link Display}.
*/
private final Class<? extends Annotation> displayAnnotationClass;
/**
* This is the description()-method of the class equivalence of {@link Plugin}.
*/
private final Method pluginDescriptionMethod;
/**
* This is the description()-method of the class equivalence of {@link Repository}.
*/
private final Method repositoryDescriptionMethod;
/**
* This is the configuration()-method of the class equivalence of {@link Plugin}.
*/
private final Method pluginConfigurationMethod;
/**
* This is the description()-method of the class equivalence of {@link Repository}.
*/
private final Method repositoryConfigurationMethod;
/**
* This is the outputPorts()-method of the class equivalence of {@link Plugin}.
*/
private final Method pluginOutputPortsMethod;
/**
* This is the repositoryPorts()-method of the class equivalence of {@link Plugin}.
*/
private final Method pluginRepositoryPortsMethod;
/**
* This is the name()-method of the class equivalence of {@link Display}.
*/
private final Method displayNameMethod;
/**
* This is the name()-method of the class equivalence of {@link InputPort}.
*/
private final Method inputPortNameMethod;
/**
* This is the name()-method of the class equivalence of {@link OutputPort}.
*/
private final Method outputPortNameMethod;
/**
* This is the name()-method of the class equivalence of {@link RepositoryPort}.
*/
private final Method repositoryPortNameMethod;
/**
* This is the name()-method of the class equivalence of {@link Property}.
*/
private final Method propertyNameMethod;
/**
* This is the defaultValue()-method of the class equivalence of {@link Property}.
*/
private final Method propertyDefaultValueMethod;
/**
* Creates a new instance of this class, using the given class loader.
*
* @param classLoader
* The class loader which will be used to load all classes and determine their methods.
* @throws ProjectLoadException
* If one or more of the classes or methods for this container could not be found.
*/
@SuppressWarnings("unchecked")
public ClassAndMethodContainer(final ClassLoader classLoader) throws ProjectLoadException {
try {
this.abstractFilterPluginClass = classLoader.loadClass(AbstractFilterPlugin.class.getCanonicalName());
......@@ -93,106 +187,223 @@ public final class ClassAndMethodContainer {
this.propertyNameMethod = this.propertyAnnotationClass.getMethod("name", new Class<?>[0]);
this.propertyDefaultValueMethod = this.propertyAnnotationClass.getMethod("defaultValue", new Class<?>[0]);
} catch (final ClassNotFoundException ex) {
ClassAndMethodContainer.LOG.error("An error occured while loading the classes and methods.", ex);
throw new ProjectLoadException();
ClassAndMethodContainer.LOG.error(ClassAndMethodContainer.MSG_LOAD_EXCEPTION, ex);
throw new ProjectLoadException(ClassAndMethodContainer.MSG_LOAD_EXCEPTION, ex);
} catch (final NoSuchMethodException ex) {
ClassAndMethodContainer.LOG.error("An error occured while loading the classes and methods.", ex);
throw new ProjectLoadException();
ClassAndMethodContainer.LOG.error(ClassAndMethodContainer.MSG_LOAD_EXCEPTION, ex);
throw new ProjectLoadException(ClassAndMethodContainer.MSG_LOAD_EXCEPTION, ex);
} catch (final SecurityException ex) {
ClassAndMethodContainer.LOG.error("An error occured while loading the classes and methods.", ex);
throw new ProjectLoadException();
ClassAndMethodContainer.LOG.error(ClassAndMethodContainer.MSG_LOAD_EXCEPTION, ex);
throw new ProjectLoadException(ClassAndMethodContainer.MSG_LOAD_EXCEPTION, ex);
} catch (final ClassCastException ex) {
ClassAndMethodContainer.LOG.error(ClassAndMethodContainer.MSG_LOAD_EXCEPTION, ex);
throw new ProjectLoadException(ClassAndMethodContainer.MSG_LOAD_EXCEPTION, ex);
}
}
/**
* The getter-method for the field {@link ClassAndMethodContainer#abstractFilterPluginClass}.
*
* @return The current value for the field.
*/
public Class<?> getAbstractFilterPluginClass() {
return this.abstractFilterPluginClass;
}
/**
* The getter-method for the field {@link ClassAndMethodContainer#abstractReaderPluginClass}.
*
* @return The current value for the field.
*/
public Class<?> getAbstractReaderPluginClass() {
return this.abstractReaderPluginClass;
}
/**
* The getter-method for the field {@link ClassAndMethodContainer#pluginAnnotationClass}.
*
* @return The current value for the field.
*/
public Class<? extends Annotation> getPluginAnnotationClass() {
return this.pluginAnnotationClass;
}
/**
* The getter-method for the field {@link ClassAndMethodContainer#repositoryAnnotationClass}.
*
* @return The current value for the field.
*/
public Class<? extends Annotation> getRepositoryAnnotationClass() {
return this.repositoryAnnotationClass;
}
/**
* The getter-method for the field {@link ClassAndMethodContainer#propertyAnnotationClass}.
*
* @return The current value for the field.
*/
public Class<? extends Annotation> getPropertyAnnotationClass() {
return this.propertyAnnotationClass;
}
/**
* The getter-method for the field {@link ClassAndMethodContainer#outputPortAnnotationClass}.
*
* @return The current value for the field.
*/
public Class<? extends Annotation> getOutputPortAnnotationClass() {
return this.outputPortAnnotationClass;
}
/**
* The getter-method for the field {@link ClassAndMethodContainer#inputPortAnnotationClass}.
*
* @return The current value for the field.
*/
public Class<? extends Annotation> getInputPortAnnotationClass() {
return this.inputPortAnnotationClass;
}
/**
* The getter-method for the field {@link ClassAndMethodContainer#repositoryPortAnnotationClass}.
*
* @return The current value for the field.
*/
public Class<? extends Annotation> getRepositoryPortAnnotationClass() {
return this.repositoryPortAnnotationClass;
}
/**
* The getter-method for the field {@link ClassAndMethodContainer#displayAnnotationClass}.
*
* @return The current value for the field.
*/
public Class<? extends Annotation> getDisplayAnnotationClass() {
return this.displayAnnotationClass;
}
/**
* The getter-method for the field {@link ClassAndMethodContainer#pluginDescriptionMethod}.
*
* @return The current value for the field.
*/
public Method getPluginDescriptionMethod() {
return this.pluginDescriptionMethod;
}
/**
* The getter-method for the field {@link ClassAndMethodContainer#repositoryDescriptionMethod}.
*
* @return The current value for the field.
*/
public Method getRepositoryDescriptionMethod() {
return this.repositoryDescriptionMethod;
}
/**
* The getter-method for the field {@link ClassAndMethodContainer#pluginConfigurationMethod}.
*
* @return The current value for the field.
*/
public Method getPluginConfigurationMethod() {
return this.pluginConfigurationMethod;
}
/**
* The getter-method for the field {@link ClassAndMethodContainer#repositoryConfigurationMethod}.
*
* @return The current value for the field.
*/
public Method getRepositoryConfigurationMethod() {
return this.repositoryConfigurationMethod;
}
/**
* The getter-method for the field {@link ClassAndMethodContainer#pluginOutputPortsMethod}.
*
* @return The current value for the field.
*/
public Method getPluginOutputPortsMethod() {
return this.pluginOutputPortsMethod;
}
/**
* The getter-method for the field {@link ClassAndMethodContainer#pluginRepositoryPortsMethod}.
*
* @return The current value for the field.
*/
public Method getPluginRepositoryPortsMethod() {
return this.pluginRepositoryPortsMethod;
}
/**
* The getter-method for the field {@link ClassAndMethodContainer#displayNameMethod}.
*
* @return The current value for the field.
*/
public Method getDisplayNameMethod() {
return this.displayNameMethod;
}
/**
* The getter-method for the field {@link ClassAndMethodContainer#abstractRepositoryClass}.
*
* @return The current value for the field.
*/
public Class<?> getAbstractRepositoryClass() {
return this.abstractRepositoryClass;
}
/**
* The getter-method for the field {@link ClassAndMethodContainer#abstractPluginClass}.
*
* @return The current value for the field.
*/
public Class<?> getAbstractPluginClass() {
return this.abstractPluginClass;
}
/**
* The getter-method for the field {@link ClassAndMethodContainer#inputPortNameMethod}.
*
* @return The current value for the field.
*/
public Method getInputPortNameMethod() {
return this.inputPortNameMethod;
}
/**
* The getter-method for the field {@link ClassAndMethodContainer#outputPortNameMethod}.
*
* @return The current value for the field.
*/
public Method getOutputPortNameMethod() {
return this.outputPortNameMethod;
}
/**
* The getter-method for the field {@link ClassAndMethodContainer#repositoryPortNameMethod}.
*
* @return The current value for the field.
*/
public Method getRepositoryPortNameMethod() {
return this.repositoryPortNameMethod;
}
/**
* The getter-method for the field {@link ClassAndMethodContainer#propertyNameMethod}.
*
* @return The current value for the field.
*/
public Method getPropertyNameMethod() {
return this.propertyNameMethod;
}
/**
* The getter-method for the field {@link ClassAndMethodContainer#propertyDefaultValueMethod}.
*
* @return The current value for the field.
*/
public Method getPropertyDefaultValueMethod() {
return this.propertyDefaultValueMethod;
}
......
......@@ -84,6 +84,11 @@ public final class FSManager { // NOCS (Class Data Abstraction Coupling, Class F
* This is the name of the root-directory.
*/
private static final String ROOT_DIRECTORY = "data";
/**
* The library for kieker which is contained in the war-file as a ressource.
*/
private static final String KIEKER_LIB = "kieker-1.6-SNAPSHOT_emf.jar";
/**
* This is the buffer (in bytes) used to copy and upload files.
*/
......@@ -663,8 +668,7 @@ public final class FSManager { // NOCS (Class Data Abstraction Coupling, Class F
}
// Add the kieker lib!
final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
libs.add(contextClassLoader.getResource(Global.KIEKER_LIB));
libs.add(this.getKiekerURL());
// Now assemble the URL class loader
final PrivilegedClassLoaderAction action = new PrivilegedClassLoaderAction(libs);
......@@ -754,7 +758,7 @@ public final class FSManager { // NOCS (Class Data Abstraction Coupling, Class F
}
public URL getKiekerURL() {
return Thread.currentThread().getContextClassLoader().getResource(Global.KIEKER_LIB);
return Thread.currentThread().getContextClassLoader().getResource(FSManager.KIEKER_LIB);
}
}
......@@ -33,8 +33,6 @@ public final class Global {
*/
public static final String PAGE_PROJECT_OVERVIEW = "ProjectOverview.xhtml?faces-redirect=true";
public static final String KIEKER_LIB = "kieker-1.6-SNAPSHOT_emf.jar";
/**
* Default constructor.
*/
......
......@@ -26,7 +26,6 @@ import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarInputStream;
import kieker.webgui.beans.view.ClassAndMethodContainer;
import kieker.webgui.common.exception.ProjectLoadException;
/**
......
......@@ -41,4 +41,16 @@ public class ProjectLoadException extends Exception {
public ProjectLoadException(final String msg) {
super(msg);
}
/**
* Creates a new instance of this class using the given parameters.
*
* @param msg
* The message used for the exception.
* @param The
* cause for the method.
*/
public ProjectLoadException(final String msg, final Throwable cause) {
super(msg, cause);
}
}
This diff is collapsed.
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