You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2012/12/13 01:01:07 UTC
[40/52] [partial] ISIS-188: renaming packages in line with
groupId:artifactId
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/HttpServerMonitor.java
----------------------------------------------------------------------
diff --git a/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/HttpServerMonitor.java b/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/HttpServerMonitor.java
deleted file mode 100644
index b5c78c4..0000000
--- a/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/HttpServerMonitor.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.isis.runtimes.dflt.monitoring.servermonitor;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.net.URLDecoder;
-import java.util.StringTokenizer;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.core.commons.config.ConfigurationConstants;
-import org.apache.isis.runtimes.dflt.runtime.system.IsisSystem;
-import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
-
-public class HttpServerMonitor extends AbstractServerMonitor {
- private static final Logger LOG = Logger.getLogger(HttpServerMonitor.class);
- private static final int DEFAULT_PORT = 8081;
- private static final String PORT = ConfigurationConstants.ROOT + "monitor.http.port";
- private final MonitorListenerImpl monitor = new MonitorListenerImpl();
-
- @Override
- protected int getPort() {
- return IsisContext.getConfiguration().getInteger(PORT, DEFAULT_PORT);
- }
-
- @Override
- protected boolean handleRequest(final PrintWriter writer, final String request) throws IOException {
- if (request == null || request.length() == 0) {
- LOG.info("Connection dropped");
- return false;
- }
- final StringTokenizer st = new StringTokenizer(request);
- if (st.countTokens() != 3) {
- httpErrorResponse(writer, 444, "Unparsable input " + request);
- return false;
- }
-
- final String type = st.nextToken();
- if (!type.equals("GET")) {
- httpErrorResponse(writer, 400, "Invalid method " + type);
- return false;
- }
-
- String query = st.nextToken();
- query = URLDecoder.decode(query, "UTF-8");
-
- if (query.equals("/")) {
- query = "/monitor";
- }
-
- if (query.startsWith("/monitor")) {
- query = query.substring("/monitor".length());
-
- if (query.startsWith("?")) {
- query = query.substring(1);
- }
-
- monitor.writeHtmlPage(query, writer);
- } else {
- httpErrorResponse(writer, 404, "Failed to find " + query);
-
- writer.println("[Request: HTTP/1.0 200");
- writer.println("Content-Type: text/html");
- writer.println("]");
- }
- return false;
- }
-
- private void httpErrorResponse(final PrintWriter writer, final int errorNo, final String response) {
- writer.println("HTTP/1.0 " + errorNo + " " + response);
- writer.println("Content-Type: text/html");
- writer.println("");
-
- writer.println("<HTML><HEAD><TITLE>Error " + errorNo + " - " + response + "</TITLE></HEAD>");
- writer.println("<BODY><h1>" + errorNo + " - " + response + "</h1>");
- writer.println("</BODY></HTML>");
-
- writer.flush();
- }
-
- @Override
- public void setTarget(final IsisSystem system) {
- // monitor.setTarget(system);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/Monitor.java
----------------------------------------------------------------------
diff --git a/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/Monitor.java b/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/Monitor.java
deleted file mode 100644
index 4b6e398..0000000
--- a/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/Monitor.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.isis.runtimes.dflt.monitoring.servermonitor;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.core.commons.debug.DebuggableWithTitle;
-
-public class Monitor {
- private static final Logger LOG = Logger.getLogger(Monitor.class);
- private static List<MonitorListener> listeners = new ArrayList<MonitorListener>();
-
- public static void addListener(final MonitorListener listener) {
- listeners.add(listener);
- }
-
- public static void removeListener(final MonitorListener listener) {
- listeners.remove(listener);
- }
-
- public static void addEvent(final String category, final String message) {
- addEvent(category, message, null);
- }
-
- public static void addEvent(final String category, final String message, final DebuggableWithTitle[] debug) {
- final MonitorEvent event = new MonitorEvent(category, message, debug);
- LOG.info(event);
- dispatchEvent(event);
- }
-
- private static void dispatchEvent(final MonitorEvent event) {
- for (final MonitorListener listener : listeners) {
- listener.postEvent(event);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/MonitorEvent.java
----------------------------------------------------------------------
diff --git a/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/MonitorEvent.java b/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/MonitorEvent.java
deleted file mode 100644
index 5b88ae0..0000000
--- a/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/MonitorEvent.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.isis.runtimes.dflt.monitoring.servermonitor;
-
-import org.apache.isis.core.commons.debug.DebugString;
-import org.apache.isis.core.commons.debug.DebuggableWithTitle;
-
-public class MonitorEvent {
- private static int nextSerialId = 1;
- private final int serialId = nextSerialId++;
- private final String message;
- private final String category;
- private final DebugString debug;
-
- public MonitorEvent(final String category, final String message, final DebuggableWithTitle[] debugDetails) {
- this.message = message;
- this.category = category;
- debug = new DebugString();
- try {
- if (debugDetails != null) {
- for (final DebuggableWithTitle info : debugDetails) {
- debug.appendTitle(info.debugTitle());
- debug.indent();
- info.debugData(debug);
- debug.unindent();
- }
- }
- } catch (final RuntimeException e) {
- debug.appendException(e);
- }
- }
-
- public String getCategory() {
- return category;
- }
-
- public String getMessage() {
- return message;
- }
-
- public int getSerialId() {
- return serialId;
- }
-
- public String getDebug() {
- return debug.toString();
- }
-
- @Override
- public String toString() {
- return category + ": " + message;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/MonitorListener.java
----------------------------------------------------------------------
diff --git a/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/MonitorListener.java b/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/MonitorListener.java
deleted file mode 100644
index 25d5d9e..0000000
--- a/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/MonitorListener.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.isis.runtimes.dflt.monitoring.servermonitor;
-
-public interface MonitorListener {
- void postEvent(MonitorEvent event);
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/MonitorListenerImpl.java
----------------------------------------------------------------------
diff --git a/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/MonitorListenerImpl.java b/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/MonitorListenerImpl.java
deleted file mode 100644
index c4622f0..0000000
--- a/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/MonitorListenerImpl.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.isis.runtimes.dflt.monitoring.servermonitor;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.isis.core.commons.debug.DebugString;
-import org.apache.isis.core.commons.debug.DebuggableWithTitle;
-import org.apache.isis.core.commons.ensure.Assert;
-import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
-
-public class MonitorListenerImpl implements MonitorListener {
- private final List<MonitorEvent> requests = new ArrayList<MonitorEvent>();
-
- public MonitorListenerImpl() {
- org.apache.isis.runtimes.dflt.monitoring.servermonitor.Monitor.addListener(this);
- }
-
- @Override
- public void postEvent(final MonitorEvent event) {
- // TODO use a stack of limited size so we have FIFO list
- if (requests.size() > 50) {
- requests.remove(0);
- }
- requests.add(event);
- }
-
- public void writeHtmlPage(final String section, final PrintWriter writer) throws IOException {
- Assert.assertNotNull(section);
- Assert.assertNotNull(writer);
- final String sectionName = section.equals("") ? "Overview" : section;
-
- writer.println("<HTML><HEAD><TITLE>NOF System Monitor - " + sectionName + "</TITLE></HEAD>");
- writer.println("<BODY>");
-
- writer.println("<h1>" + sectionName + "</h1>");
-
- final StringBuffer navigation = new StringBuffer("<p>");
- // final String[] options = target.debugSectionNames();
- final DebuggableWithTitle[] infos = IsisContext.debugSystem();
- for (int i = 0; i < infos.length; i++) {
- final String name = infos[i].debugTitle();
- appendNavigationLink(navigation, name, i > 0);
- }
- appendNavigationLink(navigation, "Requests", true);
- navigation.append("</p>");
-
- writer.println(navigation);
- writer.println("<pre>");
- if (sectionName.equals("Requests")) {
- int i = 1;
- for (final MonitorEvent event : requests) {
- writer.print("<a href=\"monitor?request=" + event.getSerialId() + "\">");
- writer.print(i++ + ". " + event);
- writer.println("</a>");
- }
- } else if (sectionName.startsWith("request=")) {
- final int requestId = Integer.valueOf(sectionName.substring("request=".length())).intValue();
- for (final MonitorEvent request : requests) {
- if (request.getSerialId() == requestId) {
- writer.println(request.getDebug());
- break;
- }
- }
- } else {
- for (final DebuggableWithTitle info : infos) {
- if (info.debugTitle().equals(sectionName)) {
- // TODO use an HTML debug string
- final DebugString debug = new DebugString();
- info.debugData(debug);
- writer.println(debug.toString());
- break;
- }
- }
- }
- writer.println("</pre>");
-
- writer.println(navigation);
- writer.println("</BODY></HTML>");
- }
-
- private void appendNavigationLink(final StringBuffer navigation, final String name, final boolean appendDivider) throws UnsupportedEncodingException {
- if (appendDivider) {
- navigation.append(" | ");
- }
- navigation.append("<a href=\"monitor?");
- navigation.append(URLEncoder.encode(name, "UTF-8"));
- navigation.append("\">");
- navigation.append(name);
- navigation.append("</a>");
- }
-
- public void writeTextPage(final String section, final PrintWriter writer) throws IOException {
- Assert.assertNotNull(section);
- Assert.assertNotNull(writer);
- final String sectionName = section.equals("") ? "Overview" : section;
-
- writer.println(sectionName);
-
- final DebuggableWithTitle[] infos = IsisContext.debugSystem();
- if (sectionName.equals("Events")) {
- int i = 1;
- for (final MonitorEvent event : requests) {
- writer.println(i++ + ". " + event);
- }
- // TODO add clause for request
- } else {
- for (final DebuggableWithTitle info : infos) {
- if (info.debugTitle().equals(sectionName)) {
- final DebugString debug = new DebugString();
- info.debugData(debug);
- writer.println(debug.toString());
- }
- }
- }
-
- writer.print("[Options: ");
- // final String[] options = target.debugSectionNames();
- for (final DebuggableWithTitle info : infos) {
- writer.print(info.debugTitle() + " ");
- }
- // writer.println();
- }
- /*
- * public void setTarget(final DebugSelection debugInfo2) { target =
- * debugInfo2; }
- */
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/SocketServerMonitor.java
----------------------------------------------------------------------
diff --git a/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/SocketServerMonitor.java b/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/SocketServerMonitor.java
deleted file mode 100644
index cdac945..0000000
--- a/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/SocketServerMonitor.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.isis.runtimes.dflt.monitoring.servermonitor;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.net.URLDecoder;
-
-import org.apache.isis.core.commons.config.ConfigurationConstants;
-import org.apache.isis.runtimes.dflt.runtime.system.IsisSystem;
-import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
-
-public class SocketServerMonitor extends AbstractServerMonitor {
- private static final int DEFAULT_PORT = 8009;
- private static final String PORT = ConfigurationConstants.ROOT + "monitor.telnet.port";
-
- private final MonitorListenerImpl monitor = new MonitorListenerImpl();
- private IsisSystem system;
-
- @Override
- protected int getPort() {
- return IsisContext.getConfiguration().getInteger(PORT, DEFAULT_PORT);
- }
-
- @Override
- protected boolean handleRequest(final PrintWriter writer, final String request) throws IOException {
- final String query = URLDecoder.decode(request, "UTF-8");
-
- if (query.equalsIgnoreCase("bye")) {
- writer.println("Disconnecting...");
- return false;
- } else if (query.equalsIgnoreCase("shutdown")) {
- writer.println("Shutting down system...");
- system.shutdown();
- exitSystem();
- return false;
- }
-
- monitor.writeTextPage(query, writer);
- writer.print("shutdown bye]\n#");
- writer.flush();
- return true;
- }
-
- @SuppressWarnings(value = "DM_EXIT")
- private void exitSystem() {
- System.exit(0);
- }
-
- @Override
- public void setTarget(final IsisSystem system) {
- this.system = system;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/AWTConsole.java
----------------------------------------------------------------------
diff --git a/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/AWTConsole.java b/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/AWTConsole.java
deleted file mode 100644
index d7c1aaf..0000000
--- a/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/AWTConsole.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.isis.runtimes.dflt.monitoring.systemconsole;
-
-import java.awt.BorderLayout;
-import java.awt.Button;
-import java.awt.Dimension;
-import java.awt.Frame;
-import java.awt.Insets;
-import java.awt.Panel;
-import java.awt.Rectangle;
-import java.awt.TextArea;
-import java.awt.Toolkit;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
-
-public class AWTConsole extends Frame implements ServerConsole {
- private static final long serialVersionUID = 1L;
- private final static Logger LOG = Logger.getLogger(AWTConsole.class);
- public static final String WIDTH = "isis.awt-console.width";
- public static final String HEIGHT = "isis.awt-console.height";
- public static final int DEFAULT_WIDTH = 600;
- public static final int DEFAULT_HEIGHT = 350;
- private Server server;
- private TextArea log;
- private Button quit;
-
- public AWTConsole() {
- super("Object Server Console");
- buildGUI();
- setVisible(true);
- ;
- }
-
- /**
- *
- */
- private void addButtons() {
- final Panel p = new Panel();
-
- p.setLayout(new java.awt.GridLayout(1, 0, 10, 0));
- add(p, BorderLayout.SOUTH);
- Button b;
-
- p.add(b = new Button("Blank"));
- b.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- clearLog();
- }
- });
-
- // debug
- p.add(b = new Button("Classes"));
- b.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- listClasses();
- }
- });
-
- p.add(b = new Button("Cache"));
- b.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- listCachedObjects();
- }
- });
-
- p.add(b = new Button("C/Cache"));
- b.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- clearCache();
- }
- });
-
- // quit
- p.add(quit = new Button("Quit"));
- quit.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- quit();
- }
- });
- }
-
- /**
- * LogWindow constructor comment.
- */
- private void buildGUI() {
- add(log = new TextArea());
- addButtons();
- final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
- final Dimension frameSize = new Dimension();
- final Insets insets = getInsets();
-
- frameSize.width = IsisContext.getConfiguration().getInteger(WIDTH, DEFAULT_WIDTH);
- frameSize.height = IsisContext.getConfiguration().getInteger(HEIGHT, DEFAULT_HEIGHT);
- final Rectangle bounds = new Rectangle(frameSize);
-
- bounds.x = screenSize.width - frameSize.width - insets.right;
- bounds.y = 0 + insets.top;
- setBounds(bounds);
- }
-
- private void clearCache() {
- }
-
- /**
- *
- * @param message
- * java.lang.String
- */
- private void clearLog() {
- log.setText("");
- }
-
- /**
- *
- */
- @Override
- public void close() {
- dispose();
- }
-
- @Override
- public void init(final Server server) {
- this.server = server;
- log("Console in control of " + server);
- }
-
- private void listCachedObjects() {
- /*
- * Enumeration e = server.getObjectStore().cache();
- *
- * log("Cached objects:-"); while (e.hasMoreElements()) { ObjectAdapter
- * object = (ObjectAdapter) e.nextElement();
- *
- * log(" " + object.getClassName() + "[" + (object.isResolved() ? "" :
- * "~") + object.getOid() + "] " + object.title()); } log();
- */
- }
-
- private void listClasses() {
- /*
- * try { Enumeration e = server.getObjectStore().classes();
- *
- * log("Loaded classes:-"); while (e.hasMoreElements()) {
- * ObjectSpecification object = (ObjectSpecification) e.nextElement();
- *
- * log(" " + object); } log(); } catch (ObjectStoreException e) {
- * LOG.error("Error listing classes " + e.getMessage()); }
- */
- }
-
- @Override
- public void log() {
- log.append("\n");
- }
-
- @Override
- public void log(final String message) {
- log.append(message + '\n');
- LOG.info(message);
- }
-
- /**
- *
- */
- public void quit() {
- server.shutdown();
- close();
- exitSystem();
- }
-
- private void exitSystem() {
- System.exit(0);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/FileConsole.java
----------------------------------------------------------------------
diff --git a/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/FileConsole.java b/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/FileConsole.java
deleted file mode 100644
index 076721d..0000000
--- a/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/FileConsole.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.isis.runtimes.dflt.monitoring.systemconsole;
-
-import java.io.DataOutputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Date;
-
-import org.apache.log4j.Logger;
-
-public class FileConsole implements ServerConsole {
- final static Logger LOG = Logger.getLogger(FileConsole.class);
- private DataOutputStream dos;
-
- @Override
- public void close() {
- }
-
- @Override
- public void init(final Server server) {
- }
-
- @Override
- public void log() {
- log("");
- }
-
- @Override
- public void log(final String message) {
- try {
- LOG.info(message);
- dos = new DataOutputStream(new FileOutputStream("log.xxx"));
- dos.writeBytes(new Date() + " " + message + '\n');
- dos.close();
- } catch (final IOException e) {
- LOG.error(e.getMessage(), e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/QuitListener.java
----------------------------------------------------------------------
diff --git a/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/QuitListener.java b/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/QuitListener.java
deleted file mode 100644
index 533cd30..0000000
--- a/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/QuitListener.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.isis.runtimes.dflt.monitoring.systemconsole;
-
-public interface QuitListener {
- public void classes();
-
- public void clear();
-
- public void collections();
-
- public void objects();
-
- public void shutdown();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/Server.java
----------------------------------------------------------------------
diff --git a/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/Server.java b/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/Server.java
deleted file mode 100644
index d7c6fc4..0000000
--- a/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/Server.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.isis.runtimes.dflt.monitoring.systemconsole;
-
-public interface Server {
-
- void shutdown();
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/ServerConsole.java
----------------------------------------------------------------------
diff --git a/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/ServerConsole.java b/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/ServerConsole.java
deleted file mode 100644
index b33450e..0000000
--- a/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/ServerConsole.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.isis.runtimes.dflt.monitoring.systemconsole;
-
-public interface ServerConsole {
-
- void close();
-
- void init(Server server);
-
- void log();
-
- void log(String message);
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/ServerResponse.java
----------------------------------------------------------------------
diff --git a/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/ServerResponse.java b/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/ServerResponse.java
deleted file mode 100644
index 85720d4..0000000
--- a/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/ServerResponse.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.isis.runtimes.dflt.monitoring.systemconsole;
-
-import java.io.Serializable;
-
-public abstract class ServerResponse implements Serializable {
- final static long serialVersionUID = 1L;
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/TerminalConsole.java
----------------------------------------------------------------------
diff --git a/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/TerminalConsole.java b/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/TerminalConsole.java
deleted file mode 100644
index ddfadfa..0000000
--- a/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/TerminalConsole.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.isis.runtimes.dflt.monitoring.systemconsole;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-import org.apache.log4j.Logger;
-
-/**
- * Marked as final because starts a thread in the {@link #TerminalConsole()
- * constructor}.
- */
-public final class TerminalConsole implements ServerConsole, Runnable {
- private static final Logger LOG = Logger.getLogger(TerminalConsole.class);
- private Server server;
- private boolean running = true;
-
- public TerminalConsole() {
- new Thread(this).start();
- }
-
- public void clear() {
- }
-
- @Override
- public void close() {
- running = false;
- }
-
- public void collections() {
- }
-
- @Override
- public void init(final Server server) {
- this.server = server;
- log("Control of " + server);
- }
-
- public void listClasses() {
- /*
- * try { Enumeration e = server.getObjectStore().classes();
- *
- * log("Loaded classes:-"); while (e.hasMoreElements()) {
- * ObjectSpecification object = (ObjectSpecification) e.nextElement();
- *
- * log(" " + object); } } catch (ObjectStoreException e) {
- * LOG.error("Error listing classes " + e.getMessage()); }
- */
- }
-
- @Override
- public void log() {
- log("");
- }
-
- @Override
- public void log(final String message) {
- LOG.info(message);
- System.out.println("> " + message);
- }
-
- public void objects() {
- }
-
- public void quit() {
- server.shutdown();
- server = null;
- running = false;
- }
-
- @Override
- public void run() {
- final BufferedReader dis = new BufferedReader(new InputStreamReader(System.in));
-
- try {
- while (running) {
- final String readLine = dis.readLine();
- if (readLine == null) {
- quit();
- continue;
- }
- final String s = readLine.toLowerCase();
-
- if (s.equals("")) {
- continue;
- } else if (s.equals("quit")) {
- quit();
- } else if (s.equals("classes")) {
- listClasses();
- } else {
- System.out.println("Commands: classes, quit");
- }
- }
- } catch (final IOException e) {
- quit();
- }
- exitSystem();
- }
-
- private void exitSystem() {
- System.exit(0);
- }
-
- public void start() {
- new Thread(this).start();
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/webapp/monitor/MonitorServlet.java
----------------------------------------------------------------------
diff --git a/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/webapp/monitor/MonitorServlet.java b/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/webapp/monitor/MonitorServlet.java
deleted file mode 100644
index c5eb3f3..0000000
--- a/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/webapp/monitor/MonitorServlet.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.isis.runtimes.dflt.webapp.monitor;
-
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.net.URLDecoder;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.isis.runtimes.dflt.monitoring.servermonitor.MonitorListenerImpl;
-
-public class MonitorServlet extends HttpServlet {
- private static final long serialVersionUID = 1L;
- private MonitorListenerImpl monitor;
-
- @Override
- protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {
- final String queryString = request.getQueryString();
- final String query = queryString == null ? "Overview" : URLDecoder.decode(queryString, "UTF-8");
- response.setContentType("text/html");
- final PrintWriter writer = new PrintWriter(new OutputStreamWriter(response.getOutputStream()));
- if (query.equals("Sessions")) {
- writer.println("<HTML><HEAD><TITLE>NOF System Monitor - " + "Sessions" + "</TITLE></HEAD>");
- writer.println("<BODY>");
-
- writer.println("<h1>" + "Sessions" + "</h1>");
- writer.println("<pre>");
- writer.println(listSessions());
- writer.println("</pre>");
- writer.println("</BODY></HTML>");
- } else {
- monitor.writeHtmlPage(query, writer);
- }
- writer.flush();
- }
-
- private static String listSessions() {
- final StringBuffer str = new StringBuffer();
- /*
- * final Iterator<?> it = SessionAccess.getSessions().iterator(); while
- * (it.hasNext()) { final HttpSession session = (HttpSession) it.next();
- * final String id = session.getId(); str.append(id); str.append(" \t");
- *
- * final long creationTime = session.getCreationTime(); str.append(new
- * Date(creationTime)); str.append(" \t");
- *
- * final long lastAccessedTime = session.getLastAccessedTime();
- * str.append(new Date(lastAccessedTime)); str.append(" \t");
- *
- * final AuthenticationSession nofSession = (AuthenticationSession)
- * session.getAttribute("NOF_SESSION_ATTRIBUTE"); if (nofSession !=
- * null) { str.append(nofSession.getUserName()); }
- *
- * str.append("\n"); }
- */
- return str.toString();
- }
-
- @Override
- public void init(final ServletConfig servletConfig) throws ServletException {
- super.init(servletConfig);
- monitor = new MonitorListenerImpl();
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/webapp/monitor/WebServerMonitorInstaller.java
----------------------------------------------------------------------
diff --git a/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/webapp/monitor/WebServerMonitorInstaller.java b/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/webapp/monitor/WebServerMonitorInstaller.java
deleted file mode 100644
index 2f8612d..0000000
--- a/component/viewer/html/monitoring/src/main/java/org/apache/isis/runtimes/dflt/webapp/monitor/WebServerMonitorInstaller.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.isis.runtimes.dflt.webapp.monitor;
-
-import org.apache.isis.runtimes.dflt.runtime.installerregistry.installerapi.IsisViewerInstallerAbstract;
-import org.apache.isis.runtimes.dflt.runtime.viewer.IsisViewer;
-import org.apache.isis.runtimes.dflt.runtime.viewer.web.WebAppSpecification;
-import org.apache.isis.runtimes.dflt.runtime.web.EmbeddedWebViewer;
-
-public class WebServerMonitorInstaller extends IsisViewerInstallerAbstract {
-
- public WebServerMonitorInstaller() {
- super("web-monitor");
- }
-
- @Override
- public IsisViewer doCreateViewer() {
- return new EmbeddedWebViewer() {
- @Override
- public WebAppSpecification getWebAppSpecification() {
- final WebAppSpecification requirements = new WebAppSpecification();
- requirements.addServletSpecification(MonitorServlet.class, "/monitor/*");
- return requirements;
- }
- };
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/MonitorServlet.java
----------------------------------------------------------------------
diff --git a/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/MonitorServlet.java b/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/MonitorServlet.java
new file mode 100644
index 0000000..1642a84
--- /dev/null
+++ b/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/MonitorServlet.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.isis.viewer.html.monitoring;
+
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.net.URLDecoder;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.isis.viewer.html.monitoring.servermonitor.MonitorListenerImpl;
+
+public class MonitorServlet extends HttpServlet {
+ private static final long serialVersionUID = 1L;
+ private MonitorListenerImpl monitor;
+
+ @Override
+ protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {
+ final String queryString = request.getQueryString();
+ final String query = queryString == null ? "Overview" : URLDecoder.decode(queryString, "UTF-8");
+ response.setContentType("text/html");
+ final PrintWriter writer = new PrintWriter(new OutputStreamWriter(response.getOutputStream()));
+ if (query.equals("Sessions")) {
+ writer.println("<HTML><HEAD><TITLE>NOF System Monitor - " + "Sessions" + "</TITLE></HEAD>");
+ writer.println("<BODY>");
+
+ writer.println("<h1>" + "Sessions" + "</h1>");
+ writer.println("<pre>");
+ writer.println(listSessions());
+ writer.println("</pre>");
+ writer.println("</BODY></HTML>");
+ } else {
+ monitor.writeHtmlPage(query, writer);
+ }
+ writer.flush();
+ }
+
+ private static String listSessions() {
+ final StringBuffer str = new StringBuffer();
+ /*
+ * final Iterator<?> it = SessionAccess.getSessions().iterator(); while
+ * (it.hasNext()) { final HttpSession session = (HttpSession) it.next();
+ * final String id = session.getId(); str.append(id); str.append(" \t");
+ *
+ * final long creationTime = session.getCreationTime(); str.append(new
+ * Date(creationTime)); str.append(" \t");
+ *
+ * final long lastAccessedTime = session.getLastAccessedTime();
+ * str.append(new Date(lastAccessedTime)); str.append(" \t");
+ *
+ * final AuthenticationSession nofSession = (AuthenticationSession)
+ * session.getAttribute("NOF_SESSION_ATTRIBUTE"); if (nofSession !=
+ * null) { str.append(nofSession.getUserName()); }
+ *
+ * str.append("\n"); }
+ */
+ return str.toString();
+ }
+
+ @Override
+ public void init(final ServletConfig servletConfig) throws ServletException {
+ super.init(servletConfig);
+ monitor = new MonitorListenerImpl();
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/WebServerMonitorInstaller.java
----------------------------------------------------------------------
diff --git a/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/WebServerMonitorInstaller.java b/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/WebServerMonitorInstaller.java
new file mode 100644
index 0000000..bf2d9d2
--- /dev/null
+++ b/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/WebServerMonitorInstaller.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.isis.viewer.html.monitoring;
+
+import org.apache.isis.core.runtime.installerregistry.installerapi.IsisViewerInstallerAbstract;
+import org.apache.isis.core.runtime.viewer.IsisViewer;
+import org.apache.isis.core.runtime.viewer.web.WebAppSpecification;
+import org.apache.isis.core.runtime.web.EmbeddedWebViewer;
+
+public class WebServerMonitorInstaller extends IsisViewerInstallerAbstract {
+
+ public WebServerMonitorInstaller() {
+ super("web-monitor");
+ }
+
+ @Override
+ public IsisViewer doCreateViewer() {
+ return new EmbeddedWebViewer() {
+ @Override
+ public WebAppSpecification getWebAppSpecification() {
+ final WebAppSpecification requirements = new WebAppSpecification();
+ requirements.addServletSpecification(MonitorServlet.class, "/monitor/*");
+ return requirements;
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/servermonitor/AbstractServerMonitor.java
----------------------------------------------------------------------
diff --git a/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/servermonitor/AbstractServerMonitor.java b/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/servermonitor/AbstractServerMonitor.java
new file mode 100644
index 0000000..ad1e1f1
--- /dev/null
+++ b/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/servermonitor/AbstractServerMonitor.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.isis.viewer.html.monitoring.servermonitor;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.SocketTimeoutException;
+import java.net.UnknownHostException;
+
+import org.apache.log4j.Logger;
+
+import org.apache.isis.core.commons.config.ConfigurationConstants;
+import org.apache.isis.core.runtime.services.InitialisationException;
+import org.apache.isis.core.runtime.system.IsisSystem;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+
+public abstract class AbstractServerMonitor {
+ private static final Logger LOG = Logger.getLogger(AbstractServerMonitor.class);
+ private static final String ADDRESS = ConfigurationConstants.ROOT + "monitor.address";
+ private boolean acceptConnection = true;
+
+ public void listen() {
+ final String hostAddress = IsisContext.getConfiguration().getString(ADDRESS);
+ InetAddress address;
+ try {
+ address = hostAddress == null ? null : InetAddress.getByName(hostAddress);
+ final int port = getPort();
+ final ServerSocket serverSocket = new ServerSocket(port, 2, address);
+ serverSocket.setSoTimeout(5000);
+ LOG.info("waiting for monitor connection on " + serverSocket);
+ while (acceptConnection) {
+ Socket client = null;
+ try {
+ client = serverSocket.accept();
+ LOG.info("client connection on " + client);
+ } catch (final SocketTimeoutException ignore) {
+ // ignore
+ continue;
+ } catch (final IOException e) {
+ LOG.error("request failed", e);
+ continue;
+ }
+ try {
+ handleRequest(client);
+ } catch (final Exception e) {
+ LOG.error("request failed", e);
+ }
+ }
+ } catch (final UnknownHostException e) {
+ throw new InitialisationException(e);
+ } catch (final IOException e) {
+ throw new InitialisationException(e);
+ }
+ }
+
+ protected abstract int getPort();
+
+ private void handleRequest(final Socket socket) throws IOException {
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
+ final PrintWriter writer = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()));
+ String request;
+ do {
+ request = reader.readLine();
+ } while (handleRequest(writer, request));
+ writer.close();
+ reader.close();
+ }
+
+ public abstract void setTarget(IsisSystem system);
+
+ public void shutdown() {
+ acceptConnection = false;
+ }
+
+ protected abstract boolean handleRequest(PrintWriter writer, String request) throws IOException;
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/servermonitor/HttpServerMonitor.java
----------------------------------------------------------------------
diff --git a/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/servermonitor/HttpServerMonitor.java b/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/servermonitor/HttpServerMonitor.java
new file mode 100644
index 0000000..94a15a1
--- /dev/null
+++ b/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/servermonitor/HttpServerMonitor.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.isis.viewer.html.monitoring.servermonitor;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.URLDecoder;
+import java.util.StringTokenizer;
+
+import org.apache.log4j.Logger;
+
+import org.apache.isis.core.commons.config.ConfigurationConstants;
+import org.apache.isis.core.runtime.system.IsisSystem;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+
+public class HttpServerMonitor extends AbstractServerMonitor {
+ private static final Logger LOG = Logger.getLogger(HttpServerMonitor.class);
+ private static final int DEFAULT_PORT = 8081;
+ private static final String PORT = ConfigurationConstants.ROOT + "monitor.http.port";
+ private final MonitorListenerImpl monitor = new MonitorListenerImpl();
+
+ @Override
+ protected int getPort() {
+ return IsisContext.getConfiguration().getInteger(PORT, DEFAULT_PORT);
+ }
+
+ @Override
+ protected boolean handleRequest(final PrintWriter writer, final String request) throws IOException {
+ if (request == null || request.length() == 0) {
+ LOG.info("Connection dropped");
+ return false;
+ }
+ final StringTokenizer st = new StringTokenizer(request);
+ if (st.countTokens() != 3) {
+ httpErrorResponse(writer, 444, "Unparsable input " + request);
+ return false;
+ }
+
+ final String type = st.nextToken();
+ if (!type.equals("GET")) {
+ httpErrorResponse(writer, 400, "Invalid method " + type);
+ return false;
+ }
+
+ String query = st.nextToken();
+ query = URLDecoder.decode(query, "UTF-8");
+
+ if (query.equals("/")) {
+ query = "/monitor";
+ }
+
+ if (query.startsWith("/monitor")) {
+ query = query.substring("/monitor".length());
+
+ if (query.startsWith("?")) {
+ query = query.substring(1);
+ }
+
+ monitor.writeHtmlPage(query, writer);
+ } else {
+ httpErrorResponse(writer, 404, "Failed to find " + query);
+
+ writer.println("[Request: HTTP/1.0 200");
+ writer.println("Content-Type: text/html");
+ writer.println("]");
+ }
+ return false;
+ }
+
+ private void httpErrorResponse(final PrintWriter writer, final int errorNo, final String response) {
+ writer.println("HTTP/1.0 " + errorNo + " " + response);
+ writer.println("Content-Type: text/html");
+ writer.println("");
+
+ writer.println("<HTML><HEAD><TITLE>Error " + errorNo + " - " + response + "</TITLE></HEAD>");
+ writer.println("<BODY><h1>" + errorNo + " - " + response + "</h1>");
+ writer.println("</BODY></HTML>");
+
+ writer.flush();
+ }
+
+ @Override
+ public void setTarget(final IsisSystem system) {
+ // monitor.setTarget(system);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/servermonitor/Monitor.java
----------------------------------------------------------------------
diff --git a/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/servermonitor/Monitor.java b/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/servermonitor/Monitor.java
new file mode 100644
index 0000000..9f794d1
--- /dev/null
+++ b/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/servermonitor/Monitor.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.isis.viewer.html.monitoring.servermonitor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.apache.isis.core.commons.debug.DebuggableWithTitle;
+
+public class Monitor {
+ private static final Logger LOG = Logger.getLogger(Monitor.class);
+ private static List<MonitorListener> listeners = new ArrayList<MonitorListener>();
+
+ public static void addListener(final MonitorListener listener) {
+ listeners.add(listener);
+ }
+
+ public static void removeListener(final MonitorListener listener) {
+ listeners.remove(listener);
+ }
+
+ public static void addEvent(final String category, final String message) {
+ addEvent(category, message, null);
+ }
+
+ public static void addEvent(final String category, final String message, final DebuggableWithTitle[] debug) {
+ final MonitorEvent event = new MonitorEvent(category, message, debug);
+ LOG.info(event);
+ dispatchEvent(event);
+ }
+
+ private static void dispatchEvent(final MonitorEvent event) {
+ for (final MonitorListener listener : listeners) {
+ listener.postEvent(event);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/servermonitor/MonitorEvent.java
----------------------------------------------------------------------
diff --git a/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/servermonitor/MonitorEvent.java b/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/servermonitor/MonitorEvent.java
new file mode 100644
index 0000000..a1ebe62
--- /dev/null
+++ b/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/servermonitor/MonitorEvent.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.isis.viewer.html.monitoring.servermonitor;
+
+import org.apache.isis.core.commons.debug.DebugString;
+import org.apache.isis.core.commons.debug.DebuggableWithTitle;
+
+public class MonitorEvent {
+ private static int nextSerialId = 1;
+ private final int serialId = nextSerialId++;
+ private final String message;
+ private final String category;
+ private final DebugString debug;
+
+ public MonitorEvent(final String category, final String message, final DebuggableWithTitle[] debugDetails) {
+ this.message = message;
+ this.category = category;
+ debug = new DebugString();
+ try {
+ if (debugDetails != null) {
+ for (final DebuggableWithTitle info : debugDetails) {
+ debug.appendTitle(info.debugTitle());
+ debug.indent();
+ info.debugData(debug);
+ debug.unindent();
+ }
+ }
+ } catch (final RuntimeException e) {
+ debug.appendException(e);
+ }
+ }
+
+ public String getCategory() {
+ return category;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public int getSerialId() {
+ return serialId;
+ }
+
+ public String getDebug() {
+ return debug.toString();
+ }
+
+ @Override
+ public String toString() {
+ return category + ": " + message;
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/servermonitor/MonitorListener.java
----------------------------------------------------------------------
diff --git a/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/servermonitor/MonitorListener.java b/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/servermonitor/MonitorListener.java
new file mode 100644
index 0000000..981e297
--- /dev/null
+++ b/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/servermonitor/MonitorListener.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.isis.viewer.html.monitoring.servermonitor;
+
+public interface MonitorListener {
+ void postEvent(MonitorEvent event);
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/servermonitor/MonitorListenerImpl.java
----------------------------------------------------------------------
diff --git a/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/servermonitor/MonitorListenerImpl.java b/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/servermonitor/MonitorListenerImpl.java
new file mode 100644
index 0000000..9f70741
--- /dev/null
+++ b/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/servermonitor/MonitorListenerImpl.java
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.isis.viewer.html.monitoring.servermonitor;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.isis.core.commons.debug.DebugString;
+import org.apache.isis.core.commons.debug.DebuggableWithTitle;
+import org.apache.isis.core.commons.ensure.Assert;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+
+public class MonitorListenerImpl implements MonitorListener {
+ private final List<MonitorEvent> requests = new ArrayList<MonitorEvent>();
+
+ public MonitorListenerImpl() {
+ org.apache.isis.viewer.html.monitoring.servermonitor.Monitor.addListener(this);
+ }
+
+ @Override
+ public void postEvent(final MonitorEvent event) {
+ // TODO use a stack of limited size so we have FIFO list
+ if (requests.size() > 50) {
+ requests.remove(0);
+ }
+ requests.add(event);
+ }
+
+ public void writeHtmlPage(final String section, final PrintWriter writer) throws IOException {
+ Assert.assertNotNull(section);
+ Assert.assertNotNull(writer);
+ final String sectionName = section.equals("") ? "Overview" : section;
+
+ writer.println("<HTML><HEAD><TITLE>NOF System Monitor - " + sectionName + "</TITLE></HEAD>");
+ writer.println("<BODY>");
+
+ writer.println("<h1>" + sectionName + "</h1>");
+
+ final StringBuffer navigation = new StringBuffer("<p>");
+ // final String[] options = target.debugSectionNames();
+ final DebuggableWithTitle[] infos = IsisContext.debugSystem();
+ for (int i = 0; i < infos.length; i++) {
+ final String name = infos[i].debugTitle();
+ appendNavigationLink(navigation, name, i > 0);
+ }
+ appendNavigationLink(navigation, "Requests", true);
+ navigation.append("</p>");
+
+ writer.println(navigation);
+ writer.println("<pre>");
+ if (sectionName.equals("Requests")) {
+ int i = 1;
+ for (final MonitorEvent event : requests) {
+ writer.print("<a href=\"monitor?request=" + event.getSerialId() + "\">");
+ writer.print(i++ + ". " + event);
+ writer.println("</a>");
+ }
+ } else if (sectionName.startsWith("request=")) {
+ final int requestId = Integer.valueOf(sectionName.substring("request=".length())).intValue();
+ for (final MonitorEvent request : requests) {
+ if (request.getSerialId() == requestId) {
+ writer.println(request.getDebug());
+ break;
+ }
+ }
+ } else {
+ for (final DebuggableWithTitle info : infos) {
+ if (info.debugTitle().equals(sectionName)) {
+ // TODO use an HTML debug string
+ final DebugString debug = new DebugString();
+ info.debugData(debug);
+ writer.println(debug.toString());
+ break;
+ }
+ }
+ }
+ writer.println("</pre>");
+
+ writer.println(navigation);
+ writer.println("</BODY></HTML>");
+ }
+
+ private void appendNavigationLink(final StringBuffer navigation, final String name, final boolean appendDivider) throws UnsupportedEncodingException {
+ if (appendDivider) {
+ navigation.append(" | ");
+ }
+ navigation.append("<a href=\"monitor?");
+ navigation.append(URLEncoder.encode(name, "UTF-8"));
+ navigation.append("\">");
+ navigation.append(name);
+ navigation.append("</a>");
+ }
+
+ public void writeTextPage(final String section, final PrintWriter writer) throws IOException {
+ Assert.assertNotNull(section);
+ Assert.assertNotNull(writer);
+ final String sectionName = section.equals("") ? "Overview" : section;
+
+ writer.println(sectionName);
+
+ final DebuggableWithTitle[] infos = IsisContext.debugSystem();
+ if (sectionName.equals("Events")) {
+ int i = 1;
+ for (final MonitorEvent event : requests) {
+ writer.println(i++ + ". " + event);
+ }
+ // TODO add clause for request
+ } else {
+ for (final DebuggableWithTitle info : infos) {
+ if (info.debugTitle().equals(sectionName)) {
+ final DebugString debug = new DebugString();
+ info.debugData(debug);
+ writer.println(debug.toString());
+ }
+ }
+ }
+
+ writer.print("[Options: ");
+ // final String[] options = target.debugSectionNames();
+ for (final DebuggableWithTitle info : infos) {
+ writer.print(info.debugTitle() + " ");
+ }
+ // writer.println();
+ }
+ /*
+ * public void setTarget(final DebugSelection debugInfo2) { target =
+ * debugInfo2; }
+ */
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/servermonitor/SocketServerMonitor.java
----------------------------------------------------------------------
diff --git a/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/servermonitor/SocketServerMonitor.java b/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/servermonitor/SocketServerMonitor.java
new file mode 100644
index 0000000..0ff6ab7
--- /dev/null
+++ b/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/servermonitor/SocketServerMonitor.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.isis.viewer.html.monitoring.servermonitor;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.URLDecoder;
+
+import org.apache.isis.core.commons.config.ConfigurationConstants;
+import org.apache.isis.core.runtime.system.IsisSystem;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+
+public class SocketServerMonitor extends AbstractServerMonitor {
+ private static final int DEFAULT_PORT = 8009;
+ private static final String PORT = ConfigurationConstants.ROOT + "monitor.telnet.port";
+
+ private final MonitorListenerImpl monitor = new MonitorListenerImpl();
+ private IsisSystem system;
+
+ @Override
+ protected int getPort() {
+ return IsisContext.getConfiguration().getInteger(PORT, DEFAULT_PORT);
+ }
+
+ @Override
+ protected boolean handleRequest(final PrintWriter writer, final String request) throws IOException {
+ final String query = URLDecoder.decode(request, "UTF-8");
+
+ if (query.equalsIgnoreCase("bye")) {
+ writer.println("Disconnecting...");
+ return false;
+ } else if (query.equalsIgnoreCase("shutdown")) {
+ writer.println("Shutting down system...");
+ system.shutdown();
+ exitSystem();
+ return false;
+ }
+
+ monitor.writeTextPage(query, writer);
+ writer.print("shutdown bye]\n#");
+ writer.flush();
+ return true;
+ }
+
+ @SuppressWarnings(value = "DM_EXIT")
+ private void exitSystem() {
+ System.exit(0);
+ }
+
+ @Override
+ public void setTarget(final IsisSystem system) {
+ this.system = system;
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/systemconsole/AWTConsole.java
----------------------------------------------------------------------
diff --git a/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/systemconsole/AWTConsole.java b/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/systemconsole/AWTConsole.java
new file mode 100644
index 0000000..5c4a6c3
--- /dev/null
+++ b/component/viewer/html/monitoring/src/main/java/org/apache/isis/viewer/html/monitoring/systemconsole/AWTConsole.java
@@ -0,0 +1,201 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.isis.viewer.html.monitoring.systemconsole;
+
+import java.awt.BorderLayout;
+import java.awt.Button;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.Insets;
+import java.awt.Panel;
+import java.awt.Rectangle;
+import java.awt.TextArea;
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import org.apache.log4j.Logger;
+
+import org.apache.isis.core.runtime.system.context.IsisContext;
+
+public class AWTConsole extends Frame implements ServerConsole {
+ private static final long serialVersionUID = 1L;
+ private final static Logger LOG = Logger.getLogger(AWTConsole.class);
+ public static final String WIDTH = "isis.awt-console.width";
+ public static final String HEIGHT = "isis.awt-console.height";
+ public static final int DEFAULT_WIDTH = 600;
+ public static final int DEFAULT_HEIGHT = 350;
+ private Server server;
+ private TextArea log;
+ private Button quit;
+
+ public AWTConsole() {
+ super("Object Server Console");
+ buildGUI();
+ setVisible(true);
+ ;
+ }
+
+ /**
+ *
+ */
+ private void addButtons() {
+ final Panel p = new Panel();
+
+ p.setLayout(new java.awt.GridLayout(1, 0, 10, 0));
+ add(p, BorderLayout.SOUTH);
+ Button b;
+
+ p.add(b = new Button("Blank"));
+ b.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(final ActionEvent e) {
+ clearLog();
+ }
+ });
+
+ // debug
+ p.add(b = new Button("Classes"));
+ b.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(final ActionEvent e) {
+ listClasses();
+ }
+ });
+
+ p.add(b = new Button("Cache"));
+ b.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(final ActionEvent e) {
+ listCachedObjects();
+ }
+ });
+
+ p.add(b = new Button("C/Cache"));
+ b.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(final ActionEvent e) {
+ clearCache();
+ }
+ });
+
+ // quit
+ p.add(quit = new Button("Quit"));
+ quit.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(final ActionEvent e) {
+ quit();
+ }
+ });
+ }
+
+ /**
+ * LogWindow constructor comment.
+ */
+ private void buildGUI() {
+ add(log = new TextArea());
+ addButtons();
+ final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ final Dimension frameSize = new Dimension();
+ final Insets insets = getInsets();
+
+ frameSize.width = IsisContext.getConfiguration().getInteger(WIDTH, DEFAULT_WIDTH);
+ frameSize.height = IsisContext.getConfiguration().getInteger(HEIGHT, DEFAULT_HEIGHT);
+ final Rectangle bounds = new Rectangle(frameSize);
+
+ bounds.x = screenSize.width - frameSize.width - insets.right;
+ bounds.y = 0 + insets.top;
+ setBounds(bounds);
+ }
+
+ private void clearCache() {
+ }
+
+ /**
+ *
+ * @param message
+ * java.lang.String
+ */
+ private void clearLog() {
+ log.setText("");
+ }
+
+ /**
+ *
+ */
+ @Override
+ public void close() {
+ dispose();
+ }
+
+ @Override
+ public void init(final Server server) {
+ this.server = server;
+ log("Console in control of " + server);
+ }
+
+ private void listCachedObjects() {
+ /*
+ * Enumeration e = server.getObjectStore().cache();
+ *
+ * log("Cached objects:-"); while (e.hasMoreElements()) { ObjectAdapter
+ * object = (ObjectAdapter) e.nextElement();
+ *
+ * log(" " + object.getClassName() + "[" + (object.isResolved() ? "" :
+ * "~") + object.getOid() + "] " + object.title()); } log();
+ */
+ }
+
+ private void listClasses() {
+ /*
+ * try { Enumeration e = server.getObjectStore().classes();
+ *
+ * log("Loaded classes:-"); while (e.hasMoreElements()) {
+ * ObjectSpecification object = (ObjectSpecification) e.nextElement();
+ *
+ * log(" " + object); } log(); } catch (ObjectStoreException e) {
+ * LOG.error("Error listing classes " + e.getMessage()); }
+ */
+ }
+
+ @Override
+ public void log() {
+ log.append("\n");
+ }
+
+ @Override
+ public void log(final String message) {
+ log.append(message + '\n');
+ LOG.info(message);
+ }
+
+ /**
+ *
+ */
+ public void quit() {
+ server.shutdown();
+ close();
+ exitSystem();
+ }
+
+ private void exitSystem() {
+ System.exit(0);
+ }
+}