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

The AnalysisController Log will now be intercepted.

parent 41f9a2fa
No related branches found
No related tags found
No related merge requests found
Showing
with 123 additions and 15 deletions
...@@ -292,7 +292,16 @@ public final class CurrentControllerBean { ...@@ -292,7 +292,16 @@ public final class CurrentControllerBean {
* *
* @return The current log entries. * @return The current log entries.
*/ */
public Collection<String> getLog() { public Object[] getAnalysisLog() {
try {
return this.projectManagerFacade.getLogEntries(this.projectName);
} catch (final AnalysisStateException ex) {
// Ignore
return new Object[0];
}
}
public Collection<String> getViewLog() {
return this.logEntries; return this.logEntries;
} }
......
...@@ -41,6 +41,7 @@ import kieker.analysis.repository.AbstractRepository; ...@@ -41,6 +41,7 @@ import kieker.analysis.repository.AbstractRepository;
import kieker.analysis.repository.annotation.Repository; import kieker.analysis.repository.annotation.Repository;
import kieker.common.logging.Log; import kieker.common.logging.Log;
import kieker.common.logging.LogFactory; import kieker.common.logging.LogFactory;
import kieker.common.logging.LogImplWebguiLogging;
import kieker.webgui.common.exception.ProjectLoadException; import kieker.webgui.common.exception.ProjectLoadException;
/** /**
...@@ -63,6 +64,7 @@ public final class ClassAndMethodContainer { ...@@ -63,6 +64,7 @@ public final class ClassAndMethodContainer {
*/ */
private static final String MSG_LOAD_EXCEPTION = "An error occured while loading the classes and methods."; private static final String MSG_LOAD_EXCEPTION = "An error occured while loading the classes and methods.";
private final Class<?> logImplWebguiLoggingClass;
/** /**
* This is the class equivalence of {@link AnalysisControllerWithMapping}. * This is the class equivalence of {@link AnalysisControllerWithMapping}.
*/ */
...@@ -224,6 +226,8 @@ public final class ClassAndMethodContainer { ...@@ -224,6 +226,8 @@ public final class ClassAndMethodContainer {
private final Method repositoryDependenciesMethod; private final Method repositoryDependenciesMethod;
private final Method pluginProgrammaticOnlyMethod; private final Method pluginProgrammaticOnlyMethod;
private final Method repositoryProgrammaticOnlyMethod; private final Method repositoryProgrammaticOnlyMethod;
private final Method logImplWebguiLoggingClassGetEntriesMethod;
/** /**
* This is the constructor for {@link AnalysisControllerThread}, which gets an instance of {@link AnalysisController}. * This is the constructor for {@link AnalysisControllerThread}, which gets an instance of {@link AnalysisController}.
*/ */
...@@ -240,6 +244,8 @@ public final class ClassAndMethodContainer { ...@@ -240,6 +244,8 @@ public final class ClassAndMethodContainer {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public ClassAndMethodContainer(final ClassLoader classLoader) throws ProjectLoadException { public ClassAndMethodContainer(final ClassLoader classLoader) throws ProjectLoadException {
try { try {
this.logImplWebguiLoggingClass = classLoader.loadClass(LogImplWebguiLogging.class.getName());
this.analysisControllerWithMappingClass = classLoader.loadClass(AnalysisControllerWithMapping.class.getName()); this.analysisControllerWithMappingClass = classLoader.loadClass(AnalysisControllerWithMapping.class.getName());
this.analysisControllerClass = classLoader.loadClass(AnalysisController.class.getName()); this.analysisControllerClass = classLoader.loadClass(AnalysisController.class.getName());
...@@ -284,6 +290,8 @@ public final class ClassAndMethodContainer { ...@@ -284,6 +290,8 @@ public final class ClassAndMethodContainer {
this.repositoryDependenciesMethod = this.repositoryAnnotationClass.getMethod("dependencies", new Class<?>[0]); this.repositoryDependenciesMethod = this.repositoryAnnotationClass.getMethod("dependencies", new Class<?>[0]);
this.pluginProgrammaticOnlyMethod = this.pluginAnnotationClass.getMethod("programmaticOnly", new Class<?>[0]); this.pluginProgrammaticOnlyMethod = this.pluginAnnotationClass.getMethod("programmaticOnly", new Class<?>[0]);
this.repositoryProgrammaticOnlyMethod = this.repositoryAnnotationClass.getMethod("programmaticOnly", new Class<?>[0]); this.repositoryProgrammaticOnlyMethod = this.repositoryAnnotationClass.getMethod("programmaticOnly", new Class<?>[0]);
this.logImplWebguiLoggingClassGetEntriesMethod = this.logImplWebguiLoggingClass.getMethod("getEntries", String.class);
// This is a special case as we need to load some additional classes to search for the correct method // This is a special case as we need to load some additional classes to search for the correct method
final Class<?> miProjectClass = classLoader.loadClass(MIProject.class.getName()); final Class<?> miProjectClass = classLoader.loadClass(MIProject.class.getName());
this.analysisControllerLoadFromFile = this.analysisControllerClass.getMethod("loadFromFile", File.class); this.analysisControllerLoadFromFile = this.analysisControllerClass.getMethod("loadFromFile", File.class);
...@@ -711,6 +719,14 @@ public final class ClassAndMethodContainer { ...@@ -711,6 +719,14 @@ public final class ClassAndMethodContainer {
return this.repositoryProgrammaticOnlyMethod; return this.repositoryProgrammaticOnlyMethod;
} }
public Class<?> getLogImplWebguiLoggingClass() {
return this.logImplWebguiLoggingClass;
}
public Method getLogImplWebguiLoggingClassGetEntriesMethod() {
return this.logImplWebguiLoggingClassGetEntriesMethod;
}
/** /**
* This method can be used to invoke a given method with given parameters, without having to mind about the exceptions. If an exception occurs, the given default * This method can be used to invoke a given method with given parameters, without having to mind about the exceptions. If an exception occurs, the given default
* value will be returned. * value will be returned.
......
/***************************************************************************
* Copyright 2012 Kieker Project (http://kieker-monitoring.net)
*
* 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;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
public class EnvironmentLoaderListener implements ServletContextListener {
@Override
public void contextDestroyed(final ServletContextEvent event) {
// No code necessary
}
@Override
public void contextInitialized(final ServletContextEvent event) {
// Set the system property to make sure that the webgui logger will be used
System.setProperty("kieker.common.logging.Log", "WEBGUI");
}
}
...@@ -336,4 +336,5 @@ public interface IProjectManagerFacade { ...@@ -336,4 +336,5 @@ public interface IProjectManagerFacade {
*/ */
public STATE getCurrentState(final String projectName) throws ProjectNotExistingException; public STATE getCurrentState(final String projectName) throws ProjectNotExistingException;
public Object[] getLogEntries(final String projectName) throws AnalysisStateException;
} }
...@@ -309,4 +309,13 @@ public final class ProjectManagerFacade implements IProjectManagerFacade { ...@@ -309,4 +309,13 @@ public final class ProjectManagerFacade implements IProjectManagerFacade {
return lock; return lock;
} }
@Override
public Object[] getLogEntries(final String projectName) throws AnalysisStateException {
final Object analysisLock = this.getLock(projectName, this.analysesLocks);
synchronized (analysisLock) {
return ACManager.getInstance().getLogEntries(projectName);
}
}
} }
...@@ -148,6 +148,14 @@ public final class ACManager { ...@@ -148,6 +148,14 @@ public final class ACManager {
analysis.stop(); analysis.stop();
} }
public Object[] getLogEntries(final String projectName) throws AnalysisStateException {
// The analysis for the given project must exist!
if (!this.analyses.containsKey(projectName)) {
throw new AnalysisStateException("The analysis has not been initialized yet.");
}
return this.analyses.get(projectName).getLogEntries();
}
/** /**
* This method delivers the display object of the (currently running) analysis for the given project and the given parameters. Technically it is an instance of * This method delivers the display object of the (currently running) analysis for the given project and the given parameters. Technically it is an instance of
* {@code AbstractDisplay}, but in fact the project specific class loader has been used. * {@code AbstractDisplay}, but in fact the project specific class loader has been used.
......
...@@ -24,6 +24,7 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -24,6 +24,7 @@ import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import kieker.analysis.AnalysisController;
import kieker.common.logging.Log; import kieker.common.logging.Log;
import kieker.common.logging.LogFactory; import kieker.common.logging.LogFactory;
import kieker.webgui.common.ClassAndMethodContainer; import kieker.webgui.common.ClassAndMethodContainer;
...@@ -154,6 +155,11 @@ public final class Analysis { ...@@ -154,6 +155,11 @@ public final class Analysis {
return this.updateDisplaysThread.getDisplay(viewName, displayName); return this.updateDisplaysThread.getDisplay(viewName, displayName);
} }
public Object[] getLogEntries() {
return (Object[]) ClassAndMethodContainer.invokeClassMethod(Analysis.this.classAndMethodContainer.getLogImplWebguiLoggingClassGetEntriesMethod(), null,
AnalysisController.class.getName());
}
/** /**
* This manager is responsible for the currently used and running instances of {@code AnalysisController}. It supplies methods to check the states of analysis, * This manager is responsible for the currently used and running instances of {@code AnalysisController}. It supplies methods to check the states of analysis,
* instantiate, start and to stop them. * instantiate, start and to stop them.
...@@ -161,7 +167,7 @@ public final class Analysis { ...@@ -161,7 +167,7 @@ public final class Analysis {
* @author Nils Christian Ehmke * @author Nils Christian Ehmke
* @version 1.0 * @version 1.0
*/ */
private static class UpdateDisplaysThread extends Thread { private class UpdateDisplaysThread extends Thread {
private static final long SLEEP_TIME_MS = 2 * 1000; private static final long SLEEP_TIME_MS = 2 * 1000;
// private final Object pluginMap; // private final Object pluginMap;
......
...@@ -13,4 +13,9 @@ analysisControllerStopAnalysis = Analyse Stoppen ...@@ -13,4 +13,9 @@ analysisControllerStopAnalysis = Analyse Stoppen
analysisControllerMsgNotInstantiated = Zeigt an, dass der AnalysisController noch nicht instanziiert wurde. analysisControllerMsgNotInstantiated = Zeigt an, dass der AnalysisController noch nicht instanziiert wurde.
analysisControllerMsgReady = Zeigt an, dass der AnalysisController zwar instanziiert, jedoch noch nicht gestartet wurde. analysisControllerMsgReady = Zeigt an, dass der AnalysisController zwar instanziiert, jedoch noch nicht gestartet wurde.
analysisControllerMsgRunning = Zeigt an, dass der AnalysisController gestartet wurde und zur Zeit läuft. analysisControllerMsgRunning = Zeigt an, dass der AnalysisController gestartet wurde und zur Zeit läuft.
analysisControllerMsgFailed = Zeigt an, dass der AnalysisController terminiert oder abgestürzt ist. analysisControllerMsgFailed = Zeigt an, dass der AnalysisController terminiert oder abgestürzt ist.
\ No newline at end of file
control = Steuerung
analysisControllerLog = AnalysisController Log
personalLog = Persönlicher Log
\ No newline at end of file
...@@ -13,4 +13,9 @@ analysisControllerStopAnalysis = Stop Analysis ...@@ -13,4 +13,9 @@ analysisControllerStopAnalysis = Stop Analysis
analysisControllerMsgNotInstantiated = Indicates that the AnalysisController has not been instantiated yet. analysisControllerMsgNotInstantiated = Indicates that the AnalysisController has not been instantiated yet.
analysisControllerMsgReady = Indicates that the AnalysisController has been instantiated, but not yet started. analysisControllerMsgReady = Indicates that the AnalysisController has been instantiated, but not yet started.
analysisControllerMsgRunning = Indicates that the AnalysisController has been started and is running. analysisControllerMsgRunning = Indicates that the AnalysisController has been started and is running.
analysisControllerMsgFailed = Indicates that the AnalysisController has been terminated or has failed. analysisControllerMsgFailed = Indicates that the AnalysisController has been terminated or has failed.
\ No newline at end of file
control = Control
analysisControllerLog = AnalysisController Log
personalLog = Personal Log
\ No newline at end of file
...@@ -68,20 +68,31 @@ ...@@ -68,20 +68,31 @@
<p:layoutUnit position="center" id="centerLayout"> <p:layoutUnit position="center" id="centerLayout">
<h:form id="logList"> <p:tabView id="tabView" style="height: 99%">
<ui:repeat value="#{currentControllerBean.log}" var="entry"> <p:tab title="#{localizedControllerPageMessages.personalLog}">
<h:outputText value="#{entry}"/><br/><br/> <h:form id="currentViewLog">
</ui:repeat> <ui:repeat value="#{currentControllerBean.viewLog}" var="entry" varStatus="stat">
</h:form> <h:outputText value="#{entry}"/><ui:fragment rendered="#{not stat.last}"><br/><br/></ui:fragment>
</ui:repeat>
</h:form>
</p:tab>
<p:tab title="#{localizedControllerPageMessages.analysisControllerLog}">
<h:form id="analysisControllerLog">
<ui:repeat value="#{currentControllerBean.analysisLog}" var="entry" varStatus="stat">
<h:outputText value="#{entry}"/><ui:fragment rendered="#{not stat.last}"><br/><br/></ui:fragment>
</ui:repeat>
</h:form>
</p:tab>
</p:tabView>
</p:layoutUnit> </p:layoutUnit>
<p:layoutUnit position="south" header="Control" resizable="true" collapsible="true"> <p:layoutUnit position="south" header="#{localizedControllerPageMessages.control}" resizable="true" collapsible="true">
<h:form id="controllerForm"> <h:form id="controllerForm">
<p:commandButton value="#{localizedControllerPageMessages.analysisControllerInstantiateAnalysisController}" action="#{currentControllerBean.instantiateAnalysis()}" update=":messages :logList" disabled="#{empty currentControllerBean.projectName}"/> <p:commandButton value="#{localizedControllerPageMessages.analysisControllerInstantiateAnalysisController}" action="#{currentControllerBean.instantiateAnalysis()}" update=":messages :tabView:currentViewLog" disabled="#{empty currentControllerBean.projectName}"/>
<p:commandButton value="#{localizedControllerPageMessages.analysisControllerCleaAnalysisController}" action="#{currentControllerBean.cleanAnalysis()}" update=":messages :logList" disabled="#{empty currentControllerBean.projectName}"/> <p:commandButton value="#{localizedControllerPageMessages.analysisControllerCleaAnalysisController}" action="#{currentControllerBean.cleanAnalysis()}" update=":messages :tabView:currentViewLog" disabled="#{empty currentControllerBean.projectName}"/>
<p:commandButton value="#{localizedControllerPageMessages.analysisControllerStartAnalysis}" action="#{currentControllerBean.startAnalysis()}" update=":messages :logList" disabled="#{empty currentControllerBean.projectName}"/> <p:commandButton value="#{localizedControllerPageMessages.analysisControllerStartAnalysis}" action="#{currentControllerBean.startAnalysis()}" update=":messages :tabView:currentViewLog" disabled="#{empty currentControllerBean.projectName}"/>
<p:commandButton value="#{localizedControllerPageMessages.analysisControllerStopAnalysis}" action="#{currentControllerBean.stopAnalysis()}" update=":messages :logList" disabled="#{empty currentControllerBean.projectName}"/> <p:commandButton value="#{localizedControllerPageMessages.analysisControllerStopAnalysis}" action="#{currentControllerBean.stopAnalysis()}" update=":messages :tabView:currentViewLog" disabled="#{empty currentControllerBean.projectName}"/>
<p:poll interval="1" update=":ledsForm"/> <p:poll interval="1" update=":ledsForm :tabView:analysisControllerLog"/>
</h:form> </h:form>
<hr/> <hr/>
<h:form id="ledsForm"> <h:form id="ledsForm">
......
...@@ -92,4 +92,7 @@ ...@@ -92,4 +92,7 @@
<dispatcher>ERROR</dispatcher> <dispatcher>ERROR</dispatcher>
</filter-mapping> </filter-mapping>
<listener>
<listener-class>kieker.webgui.common.EnvironmentLoaderListener</listener-class>
</listener>
</web-app> </web-app>
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