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

Refactoring; Some comments added

parent 1680c6fe
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
package kieker.analysisRunner.common; package kieker.webgui.analysisRunner.common;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
......
package kieker.analysisRunner.connector; package kieker.webgui.analysisRunner.connector;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
...@@ -12,9 +12,9 @@ import kieker.analysis.AnalysisController.STATE; ...@@ -12,9 +12,9 @@ import kieker.analysis.AnalysisController.STATE;
import kieker.analysis.AnalysisControllerThread; import kieker.analysis.AnalysisControllerThread;
import kieker.analysis.exception.AnalysisConfigurationException; import kieker.analysis.exception.AnalysisConfigurationException;
import kieker.analysis.model.analysisMetaModel.MIProject; import kieker.analysis.model.analysisMetaModel.MIProject;
import kieker.analysisRunner.common.DisplayUpdateThread;
import kieker.common.logging.Log; import kieker.common.logging.Log;
import kieker.common.logging.LogFactory; import kieker.common.logging.LogFactory;
import kieker.webgui.analysisRunner.common.DisplayUpdateThread;
public class Connector extends UnicastRemoteObject implements IConnector { public class Connector extends UnicastRemoteObject implements IConnector {
...@@ -25,23 +25,38 @@ public class Connector extends UnicastRemoteObject implements IConnector { ...@@ -25,23 +25,38 @@ public class Connector extends UnicastRemoteObject implements IConnector {
private AnalysisControllerThread analysisThread = null; private AnalysisControllerThread analysisThread = null;
private DisplayUpdateThread displayUpdateThread = null; private DisplayUpdateThread displayUpdateThread = null;
/**
* Creates a new instance of this class.
*
* @throws RemoteException
* If something went wrong.
*/
public Connector() throws RemoteException { public Connector() throws RemoteException {
super(); super();
} }
/**
* {@inheritDoc}
*/
public void setKaxFile(final File file) throws RemoteException { public void setKaxFile(final File file) throws RemoteException {
synchronized (this) { synchronized (this) {
this.kaxFile = file; this.kaxFile = file;
} }
} }
/**
* {@inheritDoc}
*/
public void init() throws RemoteException { public void init() throws RemoteException {
synchronized (this) { synchronized (this) {
try { try {
this.stop();
final MIProject project = AnalysisController.loadFromFile(this.kaxFile); final MIProject project = AnalysisController.loadFromFile(this.kaxFile);
this.analysisController = AnalysisController.createAnalysisController(project, Thread.currentThread().getContextClassLoader()); this.analysisController = AnalysisController.createAnalysisController(project, Thread.currentThread().getContextClassLoader());
this.analysisThread = new AnalysisControllerThread(this.analysisController.getController()); this.analysisThread = new AnalysisControllerThread(this.analysisController.getController());
this.displayUpdateThread = new DisplayUpdateThread(this.analysisController.getPluginMap(), project); this.displayUpdateThread = new DisplayUpdateThread(this.analysisController.getPluginMap(), project);
Connector.LOG.info("Analysis initialized.");
} catch (final NullPointerException ex) { } catch (final NullPointerException ex) {
Connector.LOG.error("Invalid Project", ex); Connector.LOG.error("Invalid Project", ex);
System.exit(1); System.exit(1);
...@@ -55,13 +70,21 @@ public class Connector extends UnicastRemoteObject implements IConnector { ...@@ -55,13 +70,21 @@ public class Connector extends UnicastRemoteObject implements IConnector {
} }
} }
/**
* {@inheritDoc}
*/
public void start() throws RemoteException { public void start() throws RemoteException {
synchronized (this) { synchronized (this) {
this.analysisThread.start(); this.analysisThread.start();
this.displayUpdateThread.start(); this.displayUpdateThread.start();
Connector.LOG.info("Analysis started.");
} }
} }
/**
* {@inheritDoc}
*/
public void stop() throws RemoteException { public void stop() throws RemoteException {
synchronized (this) { synchronized (this) {
try { try {
...@@ -77,24 +100,35 @@ public class Connector extends UnicastRemoteObject implements IConnector { ...@@ -77,24 +100,35 @@ public class Connector extends UnicastRemoteObject implements IConnector {
this.analysisThread = null; this.analysisThread = null;
this.displayUpdateThread = null; this.displayUpdateThread = null;
Connector.LOG.info("Analysis stopped.");
} catch (final InterruptedException ex) { } catch (final InterruptedException ex) {
// Ignore exception // Ignore exception
} }
} }
} }
/**
* {@inheritDoc}
*/
public Serializable getDisplay(final String viewName, final String displayConnectorName) throws RemoteException { public Serializable getDisplay(final String viewName, final String displayConnectorName) throws RemoteException {
synchronized (this) { synchronized (this) {
return (Serializable) this.displayUpdateThread.getDisplay(viewName, displayConnectorName); return (Serializable) this.displayUpdateThread.getDisplay(viewName, displayConnectorName);
} }
} }
public STATE getState() { /**
* {@inheritDoc}
*/
public STATE getState() throws RemoteException {
synchronized (this) { synchronized (this) {
return this.analysisController.getController().getState(); return this.analysisController.getController().getState();
} }
} }
/**
* {@inheritDoc}
*/
public void terminateProgram() throws RemoteException { public void terminateProgram() throws RemoteException {
synchronized (this) { synchronized (this) {
this.stop(); this.stop();
......
package kieker.analysisRunner.connector; package kieker.webgui.analysisRunner.connector;
import java.io.File; import java.io.File;
import java.io.Serializable; import java.io.Serializable;
...@@ -7,18 +7,56 @@ import java.rmi.RemoteException; ...@@ -7,18 +7,56 @@ import java.rmi.RemoteException;
import kieker.analysis.AnalysisController; import kieker.analysis.AnalysisController;
/**
* This interface is a remote interface to communicate with this application via RMI.
*
* @author Nils Christian Ehmke
* @version 1.0
*/
public interface IConnector extends Remote { public interface IConnector extends Remote {
public void setKaxFile(final File file) throws RemoteException; public void setKaxFile(final File file) throws RemoteException;
/**
* This method initializes the configured analysis. It is assumed that the {@link #setKaxFile(File)}-method has already been called. If an analysis instance is
* running, it will be terminated.
*
* @throws RemoteException
* If something went wrong.
*/
public void init() throws RemoteException; public void init() throws RemoteException;
/**
* This method starts the already initializes analysis. It is assumed that the {@link #init()}-method has already been called.
*
* @throws RemoteException
* If something went wrong.
*/
public void start() throws RemoteException; public void start() throws RemoteException;
/**
* This method stops the currently running analysis. If no analysis is running, this method does nothing.
*
* @throws RemoteException
* If something went wrong.
*/
public void stop() throws RemoteException; public void stop() throws RemoteException;
/**
* This method stops the (potential) currently running analysis and terminates the program.
*
* @throws RemoteException
* If something went wrong.
*/
public void terminateProgram() throws RemoteException; public void terminateProgram() throws RemoteException;
/**
* This method delivers the current state of the analysis. It is assumed that the analysis has already been initialized.
*
* @return The state of the analysis.
* @throws RemoteException
* If something went wrong.
*/
public AnalysisController.STATE getState() throws RemoteException; public AnalysisController.STATE getState() throws RemoteException;
public Serializable getDisplay(final String viewName, final String displayConnectorName) throws RemoteException; public Serializable getDisplay(final String viewName, final String displayConnectorName) throws RemoteException;
......
package kieker.analysisRunner.main; package kieker.webgui.analysisRunner.main;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry; import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry; import java.rmi.registry.Registry;
import kieker.analysisRunner.connector.Connector;
import kieker.common.logging.Log; import kieker.common.logging.Log;
import kieker.common.logging.LogFactory; import kieker.common.logging.LogFactory;
import kieker.webgui.analysisRunner.connector.Connector;
public class Main { public class Main {
private static final Log LOG = LogFactory.getLog(Main.class); private static final Log LOG = LogFactory.getLog(Main.class);
/**
* This is the application's main method. It binds the instance of the class {@link Connector} to the given name.
*
* @param args
* The command line arguments. The first element will be used as a name to (re)bind the instance of {@link Connector}. This first parameter
* <b>must</b> be provided.
*/
public static void main(final String[] args) { public static void main(final String[] args) {
try { try {
final Registry registry = LocateRegistry.createRegistry(1099); final Registry registry = LocateRegistry.getRegistry();
registry.rebind(args[0], new Connector()); registry.rebind(args[0], new Connector());
Main.LOG.info("Connection established."); Main.LOG.info("Connection established.");
......
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