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 2011/04/29 07:03:15 UTC
svn commit: r1097683 - in
/incubator/isis/trunk/runtimes/dflt/monitoring/src: main/ main/java/
main/java/META-INF/ main/java/org/ main/java/org/apache/
main/java/org/apache/isis/ main/java/org/apache/isis/runtimes/
main/java/org/apache/isis/runtimes/df...
Author: danhaywood
Date: Fri Apr 29 05:03:14 2011
New Revision: 1097683
URL: http://svn.apache.org/viewvc?rev=1097683&view=rev
Log:
ISIS-90: oops, forgot to check in the new runtimes.dflt:monitoring module
Added:
incubator/isis/trunk/runtimes/dflt/monitoring/src/main/
incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/
incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/META-INF/
incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/META-INF/MANIFEST.MF
incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/
incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/
incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/
incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/
incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/
incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/
incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/
incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/AbstractServerMonitor.java
incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/HttpServerMonitor.java
incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/Monitor.java
incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/MonitorEvent.java
incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/MonitorListener.java
incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/MonitorListenerImpl.java
incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/SocketServerMonitor.java
incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/
incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/AWTConsole.java
incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/FileConsole.java
incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/QuitListener.java
incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/Server.java
incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/ServerConsole.java
incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/ServerResponse.java
incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/TerminalConsole.java
incubator/isis/trunk/runtimes/dflt/monitoring/src/main/resources/
incubator/isis/trunk/runtimes/dflt/monitoring/src/site/
incubator/isis/trunk/runtimes/dflt/monitoring/src/site/apt/
incubator/isis/trunk/runtimes/dflt/monitoring/src/site/apt/index.apt
incubator/isis/trunk/runtimes/dflt/monitoring/src/site/apt/jottings.apt
incubator/isis/trunk/runtimes/dflt/monitoring/src/site/site.xml
incubator/isis/trunk/runtimes/dflt/monitoring/src/test/
incubator/isis/trunk/runtimes/dflt/monitoring/src/test/java/
incubator/isis/trunk/runtimes/dflt/monitoring/src/test/resources/
Added: incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/META-INF/MANIFEST.MF?rev=1097683&view=auto
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/META-INF/MANIFEST.MF (added)
+++ incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/META-INF/MANIFEST.MF Fri Apr 29 05:03:14 2011
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Added: incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/AbstractServerMonitor.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/AbstractServerMonitor.java?rev=1097683&view=auto
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/AbstractServerMonitor.java (added)
+++ incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/AbstractServerMonitor.java Fri Apr 29 05:03:14 2011
@@ -0,0 +1,102 @@
+/*
+ * 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.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.runtimes.dflt.runtime.services.InitialisationException;
+import org.apache.isis.runtimes.dflt.runtime.system.IsisSystem;
+import org.apache.isis.runtimes.dflt.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;
+}
+
Added: incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/HttpServerMonitor.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/HttpServerMonitor.java?rev=1097683&view=auto
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/HttpServerMonitor.java (added)
+++ incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/HttpServerMonitor.java Fri Apr 29 05:03:14 2011
@@ -0,0 +1,108 @@
+/*
+ * 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);
+ }
+
+}
+
Added: incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/Monitor.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/Monitor.java?rev=1097683&view=auto
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/Monitor.java (added)
+++ incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/Monitor.java Fri Apr 29 05:03:14 2011
@@ -0,0 +1,58 @@
+/*
+ * 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, DebuggableWithTitle[] debug) {
+ final MonitorEvent event = new MonitorEvent(category, message, debug);
+ LOG.info(event);
+ dispatchEvent(event);
+ }
+
+ private static void dispatchEvent(final MonitorEvent event) {
+ for(MonitorListener listener: listeners) {
+ listener.postEvent(event);
+ }
+ }
+}
+
Added: incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/MonitorEvent.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/MonitorEvent.java?rev=1097683&view=auto
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/MonitorEvent.java (added)
+++ incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/MonitorEvent.java Fri Apr 29 05:03:14 2011
@@ -0,0 +1,73 @@
+/*
+ * 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.DebuggableWithTitle;
+import org.apache.isis.core.commons.debug.DebugString;
+
+
+public class MonitorEvent {
+ private static int nextSerialId = 1;
+ private final int serialId = nextSerialId++;
+ private final String message;
+ private final String category;
+ private DebugString debug;
+
+ public MonitorEvent(final String category, final String message, DebuggableWithTitle[] debugDetails) {
+ this.message = message;
+ this.category = category;
+ debug = new DebugString();
+ try {
+ if (debugDetails != null) {
+ for (DebuggableWithTitle info : debugDetails) {
+ debug.appendTitle(info.debugTitle());
+ debug.indent();
+ info.debugData(debug);
+ debug.unindent();
+ }
+ }
+ } catch (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;
+ }
+}
+
Added: incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/MonitorListener.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/MonitorListener.java?rev=1097683&view=auto
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/MonitorListener.java (added)
+++ incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/MonitorListener.java Fri Apr 29 05:03:14 2011
@@ -0,0 +1,26 @@
+/*
+ * 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);
+}
+
Added: incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/MonitorListenerImpl.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/MonitorListenerImpl.java?rev=1097683&view=auto
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/MonitorListenerImpl.java (added)
+++ incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/MonitorListenerImpl.java Fri Apr 29 05:03:14 2011
@@ -0,0 +1,154 @@
+/*
+ * 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.DebuggableWithTitle;
+import org.apache.isis.core.commons.debug.DebugString;
+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);
+ }
+
+ 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();
+ DebuggableWithTitle[] infos = IsisContext.debugSystem();
+ for (int i = 0; i < infos.length; i++) {
+ 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(MonitorEvent event: requests) {
+ writer.print("<a href=\"monitor?request=" + event.getSerialId() +"\">");
+ writer.print(i++ + ". " + event);
+ writer.println("</a>");
+ }
+ } else if (sectionName.startsWith("request=")) {
+ int requestId = Integer.valueOf(sectionName.substring("request=".length())).intValue();
+ for (MonitorEvent request : requests) {
+ if (request.getSerialId() == requestId) {
+ writer.println(request.getDebug());
+ break;
+ }
+ }
+ } else {
+ for (int i = 0; i < infos.length; i++) {
+ if(infos[i].debugTitle().equals(sectionName)) {
+ // TODO use an HTML debug string
+ final DebugString debug = new DebugString();
+ infos[i].debugData(debug);
+ writer.println(debug.toString());
+ break;
+ }
+ }
+ }
+ writer.println("</pre>");
+
+ writer.println(navigation);
+ writer.println("</BODY></HTML>");
+ }
+
+ private void appendNavigationLink(final StringBuffer navigation, String name, 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);
+
+ DebuggableWithTitle[] infos = IsisContext.debugSystem();
+ if (sectionName.equals("Events")) {
+ int i = 1;
+ for(MonitorEvent event: requests) {
+ writer.println(i++ + ". " + event);
+ }
+ // TODO add clause for request
+ } else {
+ for (int i = 0; i < infos.length; i++) {
+ if(infos[i].debugTitle().equals(sectionName)) {
+ final DebugString debug = new DebugString();
+ infos[i].debugData(debug);
+ writer.println(debug.toString());
+ }
+ }
+ }
+
+ writer.print("[Options: ");
+// final String[] options = target.debugSectionNames();
+ for (int i = 0; i < infos.length; i++) {
+ writer.print(infos[i].debugTitle() + " ");
+ }
+ //writer.println();
+ }
+/*
+ public void setTarget(final DebugSelection debugInfo2) {
+ target = debugInfo2;
+ }
+ */
+}
+
Added: incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/SocketServerMonitor.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/SocketServerMonitor.java?rev=1097683&view=auto
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/SocketServerMonitor.java (added)
+++ incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/servermonitor/SocketServerMonitor.java Fri Apr 29 05:03:14 2011
@@ -0,0 +1,76 @@
+/*
+ * 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;
+
+import edu.umd.cs.findbugs.annotations.SuppressWarnings;
+
+
+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 {
+ 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;
+ }
+}
+
Added: incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/AWTConsole.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/AWTConsole.java?rev=1097683&view=auto
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/AWTConsole.java (added)
+++ incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/AWTConsole.java Fri Apr 29 05:03:14 2011
@@ -0,0 +1,203 @@
+/*
+ * 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.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.log4j.Logger;
+
+import edu.umd.cs.findbugs.annotations.SuppressWarnings;
+
+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();
+ }
+
+ @SuppressWarnings(value = "DM_EXIT")
+ private void exitSystem() {
+ System.exit(0);
+ }
+}
Added: incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/FileConsole.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/FileConsole.java?rev=1097683&view=auto
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/FileConsole.java (added)
+++ incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/FileConsole.java Fri Apr 29 05:03:14 2011
@@ -0,0 +1,54 @@
+/*
+ * 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;
+
+ public void close() {}
+
+ public void init(final Server server) {}
+
+ public void log() {
+ log("");
+ }
+
+ 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);
+ }
+ }
+}
+
Added: incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/QuitListener.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/QuitListener.java?rev=1097683&view=auto
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/QuitListener.java (added)
+++ incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/QuitListener.java Fri Apr 29 05:03:14 2011
@@ -0,0 +1,34 @@
+/*
+ * 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();
+}
+
Added: incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/Server.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/Server.java?rev=1097683&view=auto
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/Server.java (added)
+++ incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/Server.java Fri Apr 29 05:03:14 2011
@@ -0,0 +1,28 @@
+/*
+ * 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();
+
+}
+
Added: incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/ServerConsole.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/ServerConsole.java?rev=1097683&view=auto
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/ServerConsole.java (added)
+++ incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/ServerConsole.java Fri Apr 29 05:03:14 2011
@@ -0,0 +1,33 @@
+/*
+ * 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);
+}
+
Added: incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/ServerResponse.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/ServerResponse.java?rev=1097683&view=auto
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/ServerResponse.java (added)
+++ incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/ServerResponse.java Fri Apr 29 05:03:14 2011
@@ -0,0 +1,29 @@
+/*
+ * 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;
+}
+
Added: incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/TerminalConsole.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/TerminalConsole.java?rev=1097683&view=auto
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/TerminalConsole.java (added)
+++ incubator/isis/trunk/runtimes/dflt/monitoring/src/main/java/org/apache/isis/runtimes/dflt/monitoring/systemconsole/TerminalConsole.java Fri Apr 29 05:03:14 2011
@@ -0,0 +1,128 @@
+/*
+ * 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;
+
+import edu.umd.cs.findbugs.annotations.SuppressWarnings;
+
+/**
+ * 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) {
+ 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();
+ }
+
+ @SuppressWarnings(value = "DM_EXIT")
+ private void exitSystem() {
+ System.exit(0);
+ }
+
+ public void start() {
+ new Thread(this).start();
+ }
+}
Added: incubator/isis/trunk/runtimes/dflt/monitoring/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/monitoring/src/site/apt/index.apt?rev=1097683&view=auto
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/monitoring/src/site/apt/index.apt (added)
+++ incubator/isis/trunk/runtimes/dflt/monitoring/src/site/apt/index.apt Fri Apr 29 05:03:14 2011
@@ -0,0 +1,31 @@
+~~ 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.
+
+
+
+Monitoring Support
+
+ The <monitoring> module is a small module that provides monitoring tools
+ for the <default runtime>.
+
+ []
+
+Documentation
+
+ See the {{{../index.html}default runtime}} documentation
+ ({{{../docbkx/html/guide/isis-default-runtime.html}HTML}} or
+ {{{../docbkx/pdf/isis-default-runtime.pdf}PDF}}).
\ No newline at end of file
Added: incubator/isis/trunk/runtimes/dflt/monitoring/src/site/apt/jottings.apt
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/monitoring/src/site/apt/jottings.apt?rev=1097683&view=auto
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/monitoring/src/site/apt/jottings.apt (added)
+++ incubator/isis/trunk/runtimes/dflt/monitoring/src/site/apt/jottings.apt Fri Apr 29 05:03:14 2011
@@ -0,0 +1,43 @@
+~~ 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.
+
+
+
+Jottings
+
+ This page is to capture any random jottings relating to this module prior
+ to being moved into formal documentation.
+
+Support for viewer config files
+
+ The "Installer" architecture will automatically load configFiles, following
+ the convention "xxx_yyy.properties". When run from org.apache.isis.Isis or
+ org.apache.isis.WebServer, a "viewer installer" is also specified, meaning
+ that a config file for this viewer is also loaded (eg viewer_html.properties).
+ However, while IsisWebAppBootstrapper uses the installer architecture for
+ "back-end" components (security, persistor etc), it is not used for the viewers.
+
+ Therefore, the IsisWebAppBootstrapper will load additional config files for
+ viewers if required, by searching for the "isis.viewers" context-param.
+
+ For example:
+
+ <context-param>
+ <param-name>isis.viewers</param-name>
+ <param-value>restful</param-value>
+ </context-param>
+
\ No newline at end of file
Added: incubator/isis/trunk/runtimes/dflt/monitoring/src/site/site.xml
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/monitoring/src/site/site.xml?rev=1097683&view=auto
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/monitoring/src/site/site.xml (added)
+++ incubator/isis/trunk/runtimes/dflt/monitoring/src/site/site.xml Fri Apr 29 05:03:14 2011
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<project>
+
+ <body>
+ <breadcrumbs>
+ <item name="Monitoring" href="index.html"/>
+ </breadcrumbs>
+
+ <menu name="Monitoring">
+ <item name="About" href="index.html" />
+ <item name="Jottings" href="jottings.html" />
+ </menu>
+
+ <menu name="Default Runtime">
+ <item name="Implementation" href="../runtime/index.html" />
+ <item name="Objectstores" href="../objectstores/index.html" />
+ <item name="Profilestores" href="../profilestores/index.html" />
+ <item name="Bytecode" href="../bytecode/index.html" />
+ <item name="Monitoring" href="../monitoring/index.html" />
+ <item name="Webapp Support" href="../webapp/index.html" />
+ <item name="Webserver" href="../webserver/index.html" />
+ <item name="Remoting" href="../remoting/index.html" />
+ </menu>
+
+ <menu name="Maven Reports" ref="reports" />
+ </body>
+</project>