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

Continued with the analysis control; Removed some bugs.

parent 51d388a1
No related branches found
No related tags found
No related merge requests found
......@@ -43,9 +43,9 @@ public class AnalysisControllerBean {
* The logger within this class.
*/
private static final Log LOG = LogFactory.getLog(AnalysisControllerBean.class);
/**
* The controller instance stored within this bean.
*/
/**
* The controller instance stored within this bean.
*/
private AnalysisController controller;
/**
......@@ -56,36 +56,41 @@ public class AnalysisControllerBean {
* No code necessary.
*/
}
/**
* Delivers the controller stored within this bean.
* @return The current controller in this bean.
*/
/**
* Delivers the controller stored within this bean.
*
* @return The current controller in this bean.
*/
public AnalysisController getController() {
return this.controller;
}
/**
* Sets the controller stored within this bean to a new value.
* @param controller The new controller.
*/
/**
* Sets the controller stored within this bean to a new value.
*
* @param controller
* The new controller.
*/
public void setController(final AnalysisController controller) {
this.controller = controller;
}
/**
* This method tries to instantiate a new controller using the given project. If the project is null, nothing happens.
* @param mProject The project used to create a new analysis controller.
*/
/**
* This method tries to instantiate a new controller using the given project. If the project is null, nothing happens.
*
* @param mProject
* The project used to create a new analysis controller.
*/
public void instantiate(final MIProject mProject) {
if (mProject != null) {
try {
/* Create a temporary file and store the model instance in it. */
/* Create a temporary file and store the model instance in it. */
final File tempFile = File.createTempFile("java", ".tmp");
AnalysisController.saveToFile(tempFile, mProject);
/* Try to create the controller. */
/* Try to create the controller. */
this.controller = new AnalysisController(tempFile, PluginClassLoader.getInstance());
/* Don't forget to remove the temporary file. */
/* Don't forget to remove the temporary file. */
tempFile.delete();
} catch (final IOException ex) {
AnalysisControllerBean.LOG.error("Could not create analysis controller.", ex);
......@@ -94,4 +99,22 @@ public class AnalysisControllerBean {
}
}
}
public void start() {
new Thread() {
@Override
public void run() {
AnalysisControllerBean.this.controller.run();
}
}.start();
}
public void stop() {
new Thread() {
@Override
public void run() {
AnalysisControllerBean.this.controller.terminate();
}
}.start();
}
}
......@@ -20,15 +20,20 @@
package kieker.webgui.common;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import kieker.analysis.AnalysisController;
import kieker.analysis.model.analysisMetaModel.MIDependency;
import kieker.common.logging.Log;
import kieker.common.logging.LogFactory;
/**
* 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
......@@ -39,6 +44,10 @@ import kieker.analysis.AnalysisController;
*/
public final class PluginClassLoader extends ClassLoader {
/**
* The logger within this class.
*/
private static final Log LOG = LogFactory.getLog(PluginClassLoader.class);
/**
* The singleton instance of this class.
*/
......@@ -49,10 +58,18 @@ public final class PluginClassLoader extends ClassLoader {
private final Map<String, URLClassLoader> classLoaders = new HashMap<String, URLClassLoader>();
/**
* The default constructor of this class.
* The default constructor of this class. During the creation all available libraries will be added to the class loader.
*/
private PluginClassLoader() {
/* No code necessary. */
/* Make sure that all libs are loaded. */
final List<MIDependency> libs = FileManager.getInstance().loadAllDependencies();
for (final MIDependency lib : libs) {
try {
addURL(new URL("file", "localhost", FileManager.getInstance().getFullPath(lib)));
} catch (MalformedURLException ex) {
LOG.warn("Could not load library.", ex);
}
}
}
/**
......@@ -103,13 +120,13 @@ public final class PluginClassLoader extends ClassLoader {
* @throws ClassNotFoundException
* If a class with the given name could not be found.
*/
@Override
@Override
public Class<?> loadClass(final String name) throws ClassNotFoundException {
try {
return ClassLoader.getSystemClassLoader().loadClass(name);
} catch (ClassNotFoundException ex) {
/* Ignore exception. */
}
try {
return ClassLoader.getSystemClassLoader().loadClass(name);
} catch (ClassNotFoundException ex) {
/* Ignore exception. */
}
synchronized (this) {
/* Run through all available class loaders and try to find the correct class. */
final Iterator<URLClassLoader> classLoaderIter = this.classLoaders.values().iterator();
......
......@@ -19,42 +19,59 @@
<p:layoutUnit header="Navigation" position="north" collapsible="true" resizable="true">
<!-- The control panel to get back. -->
<h:form>
<c:if test="#{empty selectedProjectBean.selectedProject}">
No project selected.
</c:if>
Click
<h:link outcome="/main">here</h:link>
to get back to the main menu.
</h:form>
</p:layoutUnit>
<p:layoutUnit position="center" >
<h:form id="centerForm">
<ui:repeat id="centerRepeat" value="#{selectedProjectBean.selectedProject.plugins}" var="plugin">
<p:panel header="#{plugin.name}" toggleSpeed="200" toggleable="true" id="plugin" style="width: 20%">
<p:commandLink ajax="true" value="Show Data"/>
</p:panel>
<p:draggable for="plugin">
</p:draggable>
</ui:repeat>
</h:form>
</p:layoutUnit>
<c:choose>
<c:when test="#{empty selectedProjectBean.selectedProject}">
<p:layoutUnit position="center" >
</p:layoutUnit>
</c:when>
<c:otherwise>
<p:layoutUnit position="center" >
<h:form id="centerForm">
<ui:repeat id="centerRepeat" value="#{selectedProjectBean.selectedProject.plugins}" var="plugin">
<p:panel header="#{plugin.name}" toggleSpeed="200" toggleable="true" id="plugin" style="width: 20%">
<p:commandLink ajax="true" value="Show Data"/>
</p:panel>
<p:draggable for="plugin">
</p:draggable>
</ui:repeat>
</h:form>
</p:layoutUnit>
<p:layoutUnit position="south" header="Analysis" resizable="true" collapsible="true">
<h:form id="analysisForm">
<p:commandButton value="Instantiate Analysis" action="#{analysisControllerBean.instantiate(selectedProjectBean.selectedProject)}" update=":analysisForm"/>
<p:commandButton value="Start Analysis" action="#{analysisControllerBean.controller.run()}" disabled="#{empty analysisControllerBean.controller}" update=":analysisForm"/>
<p:commandButton value="Stop Analysis" action="#{analysisControllerBean.controller.terminate()}" disabled="#{empty analysisControllerBean.controller}" update=":analysisForm"/>
<p:spacer height="0px" width="150px"/>
<c:choose>
<c:when test="#{empty analysisControllerBean.controller}">
<h:outputText value="Analysis State: N/A"/>
</c:when>
<c:otherwise>
<h:outputText value="Analysis State: #{analysisControllerBean.controller.state}"/>
</c:otherwise>
</c:choose>
</h:form>
</p:layoutUnit>
<p:layoutUnit position="south" header="Analysis" resizable="true" collapsible="true">
<h:form id="analysisForm">
<p:commandButton value="Instantiate Analysis" action="#{analysisControllerBean.instantiate(selectedProjectBean.selectedProject)}" update=":analysisForm:analysisStateText"/>
<p:commandButton value="Start Analysis" async="true" action="#{analysisControllerBean.controller.run()}" disabled="#{empty analysisControllerBean.controller}"/>
<p:commandButton value="Stop Analysis" async="true" action="#{analysisControllerBean.controller.terminate()}" disabled="#{empty analysisControllerBean.controller}"/>
<p:spacer height="0px" width="150px"/>
<c:choose>
<c:when test="#{empty analysisControllerBean.controller}">
<h:outputText id="analysisStateText" value="Analysis State: N/A"/><br/>
</c:when>
<c:otherwise>
<h:outputText id="analysisStateText" value="Analysis State: #{analysisControllerBean.controller.state}"/>
</c:otherwise>
</c:choose>
<p:poll interval="2" update=":analysisForm:analysisStateText"/>
</h:form>
</p:layoutUnit>
</c:otherwise>
</c:choose>
</p:layout>
</h:body>
</f:view>
......
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