Skip to content
Snippets Groups Projects
Commit 341ffb2f authored by Carsten Stocklöw's avatar Carsten Stocklöw
Browse files

started with panel for bus members

parent 92c270e2
No related branches found
No related tags found
No related merge requests found
Showing
with 1014 additions and 17 deletions
...@@ -16,14 +16,14 @@ ...@@ -16,14 +16,14 @@
<url /> <url />
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.osgi</groupId> <groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId> <artifactId>org.osgi.core</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.osgi</groupId> <groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId> <artifactId>org.osgi.compendium</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.universAAL.middleware</groupId> <groupId>org.universAAL.middleware</groupId>
<artifactId>mw.data.representation.osgi</artifactId> <artifactId>mw.data.representation.osgi</artifactId>
...@@ -32,13 +32,23 @@ ...@@ -32,13 +32,23 @@
<groupId>org.universAAL.middleware</groupId> <groupId>org.universAAL.middleware</groupId>
<artifactId>mw.bus.service.osgi</artifactId> <artifactId>mw.bus.service.osgi</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.universAAL.middleware</groupId>
<artifactId>mw.bus.model.osgi</artifactId>
</dependency>
<dependency>
<groupId>org.universAAL.middleware</groupId> <groupId>org.universAAL.middleware</groupId>
<artifactId>mw.container.xfaces.osgi</artifactId> <artifactId>mw.container.xfaces.osgi</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>org.universAAL.middleware</groupId>
<artifactId>junit</artifactId> <artifactId>mw.bus.junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.universAAL.ontology</groupId>
<artifactId>ont.lighting</artifactId>
<version>3.2.1-SNAPSHOT</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
......
...@@ -30,6 +30,7 @@ public class Activator implements BundleActivator { ...@@ -30,6 +30,7 @@ public class Activator implements BundleActivator {
public static ModuleContext mc; public static ModuleContext mc;
public static BundleContext bc; public static BundleContext bc;
public static MessageContentSerializer contentSerializer = null; public static MessageContentSerializer contentSerializer = null;
public LogMonitor lm;
/** /**
* Start this bundle. This is not done in a separate thread so that we can * Start this bundle. This is not done in a separate thread so that we can
...@@ -40,10 +41,15 @@ public class Activator implements BundleActivator { ...@@ -40,10 +41,15 @@ public class Activator implements BundleActivator {
mc = uAALBundleContainer.THE_CONTAINER mc = uAALBundleContainer.THE_CONTAINER
.registerModule(new Object[] { context }); .registerModule(new Object[] { context });
LogMonitor lm = new LogMonitor(); start();
// context.registerService(new String[] { LogListener.class.getName() },
context.registerService(new String[] { LogListener.class.getName() }, // lm, null);
lm, null); }
public void start() {
lm = new LogMonitor();
mc.getContainer().shareObject(mc, lm,
new Object[] { LogListener.class.getName() });
} }
public void stop(BundleContext arg0) throws Exception { public void stop(BundleContext arg0) throws Exception {
......
...@@ -16,13 +16,14 @@ import org.universAAL.middleware.container.LogListener; ...@@ -16,13 +16,14 @@ import org.universAAL.middleware.container.LogListener;
*/ */
public class LogMonitor implements LogListener { public class LogMonitor implements LogListener {
LogListenerEx listeners[] = new LogListenerEx[3]; LogListenerEx listeners[] = new LogListenerEx[4];
MainGui gui = new MainGui(); MainGui gui = new MainGui();
LogMonitor() { LogMonitor() {
listeners[0] = new org.universAAL.tools.logmonitor.all_log.LogMonitor(); listeners[0] = new org.universAAL.tools.logmonitor.all_log.LogMonitor();
listeners[1] = new org.universAAL.tools.logmonitor.rdfvis.LogMonitor(); listeners[1] = new org.universAAL.tools.logmonitor.rdfvis.LogMonitor();
listeners[2] = new org.universAAL.tools.logmonitor.service_bus_matching.LogMonitor(); listeners[2] = new org.universAAL.tools.logmonitor.service_bus_matching.LogMonitor();
listeners[3] = new org.universAAL.tools.logmonitor.bus_member.LogMonitor();
for (int i = 0; i < listeners.length; i++) for (int i = 0; i < listeners.length; i++)
gui.addPanel(listeners[i].getTitle(), listeners[i].getPanel()); gui.addPanel(listeners[i].getTitle(), listeners[i].getPanel());
......
/*
Copyright 2007-2014 Fraunhofer IGD, http://www.igd.fraunhofer.de
Fraunhofer-Gesellschaft - Institut f�r Graphische Datenverarbeitung
*/
package org.universAAL.tools.logmonitor.bus_member;
import javax.swing.JPanel;
import org.universAAL.middleware.bus.model.AbstractBus;
import org.universAAL.middleware.container.LogListener;
import org.universAAL.tools.logmonitor.LogListenerEx;
import org.universAAL.tools.logmonitor.bus_member.gui.BusMemberGui;
public class LogMonitor implements LogListenerEx {
private BusMemberGui gui = new BusMemberGui();
/*-
* @see org.universAAL.middleware.container.LogListener#log(int,
* java.lang.String, java.lang.String, java.lang.String, java.lang.String,
* java.lang.Object[], java.lang.Throwable)
*/
public void log(int logLevel, String module, String pkg, String cls,
String method, Object[] msgPart, Throwable t) {
if (logLevel == LogListener.LOG_LEVEL_DEBUG) {
System.out.println(module);
// if (!"mw.bus.service.osgi".equals(module))
// return;
String pkg2 = AbstractBus.class.getPackage().getName();
String cls2 = AbstractBus.class.getName().substring(
pkg.length() + 1);
if (!cls2.equals(cls))
return;
if (!pkg2.equals(pkg))
return;
if (msgPart != null && msgPart.length == 2
&& msgPart[1] instanceof String) {
String id = (String) msgPart[1];
if ("register".equals(method))
handleRegister(id);
if ("unregister".equals(method))
handleUnregister(id);
}
}
}
private void handleRegister(String id) {
new MemberData(id).print();
}
private void handleUnregister(String id) {
}
public JPanel getPanel() {
return gui;
}
public String getTitle() {
return "Bus Member";
}
}
package org.universAAL.tools.logmonitor.bus_member;
import org.universAAL.middleware.bus.member.BusMemberType;
import org.universAAL.middleware.bus.model.AbstractBus;
public class MemberData {
public String id;
public String space;
public String peer;
public String module;
public String type;
public MemberData(String id) {
this.id = id;
String s = id;
int idx = id.lastIndexOf('#');
s = id.substring(0, idx);
if (s.startsWith(AbstractBus.uAAL_OPTIONAL_URI_PREFIX))
s = s.substring(AbstractBus.uAAL_OPTIONAL_URI_PREFIX.length());
int idx2 = s.lastIndexOf('/');
space = s.substring(0, idx2);
peer = s.substring(idx2 + 1);
s = id.substring(idx);
idx2 = s.indexOf('.');
module = s.substring(idx2 + 1);
s = s.substring(1, idx2);
System.out.println("--s: " + s);
for (BusMemberType t : BusMemberType.values()) {
if (s.endsWith(t.name()))
type = t.name();
}
}
public void print() {
System.out.println("---- MemberData");
System.out.println(" ID: " + id);
System.out.println(" space: " + space);
System.out.println(" peer: " + peer);
System.out.println(" module: " + module);
System.out.println(" type: " + type);
}
}
\ No newline at end of file
/*
Copyright 2007-2014 Fraunhofer IGD, http://www.igd.fraunhofer.de
Fraunhofer-Gesellschaft - Institut f�r Graphische Datenverarbeitung
*/
package org.universAAL.tools.logmonitor.bus_member.gui;
import java.awt.BorderLayout;
import java.util.Iterator;
import java.util.LinkedList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTable;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;
import org.universAAL.tools.logmonitor.service_bus_matching.LogMonitor;
import org.universAAL.tools.logmonitor.service_bus_matching.Matchmaking;
import org.universAAL.tools.logmonitor.service_bus_matching.URI;
import org.universAAL.tools.logmonitor.service_bus_matching.Matchmaking.SingleMatching;
/**
* The main frame.
*
* @author cstockloew
*
*/
public class BusMemberGui extends JPanel implements ListSelectionListener {
private static final long serialVersionUID = 1L;
/**
* The graphics panel where the content is drawn.
*/
BusMemberPane pane = new BusMemberPane();
/**
* The table containing a list of all messages.
*/
JTable table;
/**
* Create the main frame.
*/
public BusMemberGui() {
this.setLayout(new BorderLayout());
// Message overview
DefaultTableModel model = new DefaultTableModel();
model.addColumn("Time");
model.addColumn("Request");
model.addColumn("Matches");
model.addColumn("Result");
table = new JTable(model);
table.getSelectionModel().addListSelectionListener(this);
// overall view
JScrollPane scrollPaneLeft = new JScrollPane(table);
JScrollPane scrollPaneRight = new JScrollPane(pane);
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
scrollPaneLeft, scrollPaneRight);
splitPane.setDividerLocation(0.4);
add(splitPane, BorderLayout.CENTER);
}
/**
* Called whenever the value of the selection in the table showing the list
* of all messages changes.
*
* @param e
* The event that characterizes the change.
*/
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
int viewRow = table.getSelectedRow();
if (viewRow >= 0) {
Matchmaking m = LogMonitor.instance.getMatchmaking(viewRow);
// Matchmaking m = new Matchmaking();
// m.serviceURI = "serviceURI";
// m.numMatches = 0;
// m.date = new Date();
pane.show(m);
pane.setSelectionStart(0);
pane.setSelectionEnd(0);
}
}
}
/**
* Add a new entry.
*
* @param m
* The matchmaking.
*/
public void notify(Matchmaking m) {
// add entry to table
DefaultTableModel model = (DefaultTableModel) table.getModel();
String result = "<unknown>";
if (m.success != null) {
if (m.success.booleanValue()) {
if (m.numMatches == 1) {
// if we have only one match, print the URI of that match
result = "1 match";
LinkedList<SingleMatching> l = m.matchings;
for (Iterator<SingleMatching> it = l.iterator(); it
.hasNext();) {
SingleMatching s = (SingleMatching) it.next();
if (s.success.booleanValue()) {
result = URI.get(s.profileURI, true);
break;
}
}
} else
result = m.numMatches + " matches";
} else
result = "- no_match -";
}
model.addRow(new Object[] { m.getDateString(),
URI.get(m.serviceURI, true), "" + m.numMatches, result });
// if this is the first entry: show in panel
// if (model.getRowCount() == 1) {
// model.setsel
// panel.show(m);
// }
}
}
...@@ -39,6 +39,7 @@ import org.universAAL.tools.logmonitor.service_bus_matching.Matchmaking; ...@@ -39,6 +39,7 @@ import org.universAAL.tools.logmonitor.service_bus_matching.Matchmaking;
import org.universAAL.tools.logmonitor.service_bus_matching.URI; import org.universAAL.tools.logmonitor.service_bus_matching.URI;
import org.universAAL.tools.logmonitor.service_bus_matching.LogMonitor.ProfileInfo; import org.universAAL.tools.logmonitor.service_bus_matching.LogMonitor.ProfileInfo;
import org.universAAL.tools.logmonitor.service_bus_matching.Matchmaking.SingleMatching; import org.universAAL.tools.logmonitor.service_bus_matching.Matchmaking.SingleMatching;
import org.universAAL.tools.logmonitor.util.ClipboardHandling;
public class MatchmakingPane extends JTextPane { public class MatchmakingPane extends JTextPane {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Copyright 2007-2014 Fraunhofer IGD, http://www.igd.fraunhofer.de Copyright 2007-2014 Fraunhofer IGD, http://www.igd.fraunhofer.de
Fraunhofer-Gesellschaft - Institut f�r Graphische Datenverarbeitung Fraunhofer-Gesellschaft - Institut f�r Graphische Datenverarbeitung
*/ */
package org.universAAL.tools.logmonitor.service_bus_matching.gui; package org.universAAL.tools.logmonitor.util;
import java.awt.Toolkit; import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.Clipboard;
......
package org.universAAL.tools.logmonitor.test;
import org.universAAL.middleware.bus.junit.BusTestCase;
import org.universAAL.middleware.bus.permission.AccessControl;
import org.universAAL.middleware.container.utils.LogUtils;
import org.universAAL.middleware.owl.OntologyManagement;
import org.universAAL.middleware.service.DefaultServiceCaller;
import org.universAAL.ontology.lighting.LightingOntology;
import org.universAAL.ontology.location.LocationOntology;
import org.universAAL.ontology.phThing.PhThingOntology;
import org.universAAL.ontology.shape.ShapeOntology;
import org.universAAL.tools.logmonitor.Activator;
import org.universAAL.container.JUnit.JUnitContainer;
import org.universAAL.container.JUnit.JUnitModuleContext;
import org.universAAL.container.JUnit.JUnitModuleContext.LogLevel;
public class Test extends BusTestCase {
static boolean isSetUp = false;
static DefaultServiceCaller caller;
public void tearDown() {
// don't do anything here so we don't have to set up again
// while (true) {
// try {
// Thread.sleep(100);
// } catch (InterruptedException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
}
public void setUp() throws Exception {
if (isSetUp)
return;
super.setUp();
isSetUp = true;
OntologyManagement.getInstance().register(mc, new LocationOntology());
OntologyManagement.getInstance().register(mc, new ShapeOntology());
OntologyManagement.getInstance().register(mc, new PhThingOntology());
OntologyManagement.getInstance().register(mc, new LightingOntology());
mc.setAttribute(AccessControl.PROP_MODE, "none");
mc.setAttribute(AccessControl.PROP_MODE_UPDATE, "always");
Activator.mc = mc;
((JUnitModuleContext) mc).setLogLevel(LogLevel.DEBUG);
Activator a = new Activator();
a.start();
((JUnitContainer)mc.getContainer()).registerLogListeners(a.lm);
}
public void testAddScript() {
LogUtils.logDebug(mc, this.getClass(), "method", "msg");
caller = new DefaultServiceCaller(mc);
caller.close();
}
}
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