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