cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomek...@apache.org
Subject svn commit: r1080895 - in /cxf/trunk/rt/management-web: ./ src/test/gwt-debug/ src/test/gwt-debug/WEB-INF/ src/test/gwt-debug/org/ src/test/gwt-debug/org/apache/ src/test/gwt-debug/org/apache/cxf/ src/test/gwt-debug/org/apache/cxf/management/ src/test/...
Date Sat, 12 Mar 2011 08:57:22 GMT
Author: tomekopo
Date: Sat Mar 12 08:57:21 2011
New Revision: 1080895

URL: http://svn.apache.org/viewvc?rev=1080895&view=rev
Log:
Added helper classes and static files to support debug mode for GWT application

Added:
    cxf/trunk/rt/management-web/README.txt
    cxf/trunk/rt/management-web/src/test/gwt-debug/
    cxf/trunk/rt/management-web/src/test/gwt-debug/WEB-INF/
    cxf/trunk/rt/management-web/src/test/gwt-debug/WEB-INF/web.xml
    cxf/trunk/rt/management-web/src/test/gwt-debug/generate.html
    cxf/trunk/rt/management-web/src/test/gwt-debug/org/
    cxf/trunk/rt/management-web/src/test/gwt-debug/org/apache/
    cxf/trunk/rt/management-web/src/test/gwt-debug/org/apache/cxf/
    cxf/trunk/rt/management-web/src/test/gwt-debug/org/apache/cxf/management/
    cxf/trunk/rt/management-web/src/test/gwt-debug/org/apache/cxf/management/web/
    cxf/trunk/rt/management-web/src/test/gwt-debug/org/apache/cxf/management/web/logging/
    cxf/trunk/rt/management-web/src/test/gwt-debug/org/apache/cxf/management/web/logging/Generate.java
    cxf/trunk/rt/management-web/src/test/gwt-debug/org/apache/cxf/management/web/logging/MockApp.java
    cxf/trunk/rt/management-web/src/test/resources/
Modified:
    cxf/trunk/rt/management-web/pom.xml

Added: cxf/trunk/rt/management-web/README.txt
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/management-web/README.txt?rev=1080895&view=auto
==============================================================================
--- cxf/trunk/rt/management-web/README.txt (added)
+++ cxf/trunk/rt/management-web/README.txt Sat Mar 12 08:57:21 2011
@@ -0,0 +1,19 @@
+Debug mode
+----------
+
+Run application:
+
+1) To run LogBorwser in the debug mode, you must type in the terminal:
+    mvn clean gwt:run -Pdev
+2) Open new browser's window and go to: 
+    http://127.0.0.1:8888/logbrowser/LogBrowser.html?gwt.codesvr=127.0.0.1:9997
+3) Use "admin", as login and password, to sign in.
+
+Configure settings:
+
+4) Add new endpoint with URL:
+    http://127.0.0.1:8888/log/logs
+5) Generate entry logs by interacting with URL:
+    http://127.0.0.1:8888/generate.html
+
+Enjoy!
\ No newline at end of file

Modified: cxf/trunk/rt/management-web/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/management-web/pom.xml?rev=1080895&r1=1080894&r2=1080895&view=diff
==============================================================================
--- cxf/trunk/rt/management-web/pom.xml (original)
+++ cxf/trunk/rt/management-web/pom.xml Sat Mar 12 08:57:21 2011
@@ -179,7 +179,7 @@
             </plugin>
         </plugins>
     </build>
-<!--
+
     <profiles>
         <profile>
             <id>dev</id>
@@ -197,9 +197,9 @@
                                 <configuration>
                                     <outputDirectory>${gwt.hostedmode.dir}</outputDirectory>
                                     <resources>
-                                        <resource>
-                                            <directory>${project.basedir}/src/test/resources</directory>
-                                        </resource>
+                                       <resource>
+                                          <directory>${project.basedir}/src/test/gwt-debug</directory>
+                                       </resource>
                                     </resources>
                                 </configuration>
                             </execution>
@@ -219,7 +219,7 @@
                                 </goals>
                                 <configuration>
                                     <sources>
-                                        <source>${project.basedir}/src/test/java</source>
+                                        <source>${project.basedir}/src/test/gwt-debug</source>
                                     </sources>
                                 </configuration>
                             </execution>
@@ -229,6 +229,5 @@
             </build>
         </profile>
     </profiles>
--->
 
 </project>

Added: cxf/trunk/rt/management-web/src/test/gwt-debug/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/management-web/src/test/gwt-debug/WEB-INF/web.xml?rev=1080895&view=auto
==============================================================================
--- cxf/trunk/rt/management-web/src/test/gwt-debug/WEB-INF/web.xml (added)
+++ cxf/trunk/rt/management-web/src/test/gwt-debug/WEB-INF/web.xml Sat Mar 12 08:57:21 2011
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE web-app
+        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+        "http://java.sun.com/dtd/web-app_2_3.dtd">
+
+<web-app>
+
+    <welcome-file-list>
+        <welcome-file>logbrowser/LogBrowser.html</welcome-file>
+    </welcome-file-list>
+
+	<servlet>
+		<servlet-name>Generate</servlet-name>
+		<display-name>Generate log entry</display-name>
+		<servlet-class>
+			org.apache.cxf.management.web.logging.Generate
+		</servlet-class>
+		<load-on-startup>1</load-on-startup>
+	</servlet>
+
+    <servlet>
+        <servlet-name>MockApp</servlet-name>
+        <display-name>MockApp</display-name>
+        <servlet-class>
+            org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet
+        </servlet-class>
+        <init-param>
+            <param-name>javax.ws.rs.Application</param-name>
+            <param-value>
+                org.apache.cxf.management.web.logging.MockApp
+            </param-value>
+        </init-param>
+        <init-param>
+            <param-name>jaxrs.inInterceptors</param-name>
+            <param-value>
+                org.apache.cxf.interceptor.LoggingInInterceptor
+            </param-value>
+        </init-param>
+        <init-param>
+            <param-name>jaxrs.outInterceptors</param-name>
+            <param-value>
+                org.apache.cxf.interceptor.LoggingOutInterceptor
+            </param-value>
+        </init-param>
+        <load-on-startup>2</load-on-startup>
+    </servlet>
+
+	<servlet-mapping>
+		<servlet-name>Generate</servlet-name>
+		<url-pattern>/generate.do</url-pattern>
+	</servlet-mapping>
+
+    <servlet-mapping>
+        <servlet-name>MockApp</servlet-name>
+        <url-pattern>/log/*</url-pattern>
+    </servlet-mapping>
+</web-app>

Added: cxf/trunk/rt/management-web/src/test/gwt-debug/generate.html
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/management-web/src/test/gwt-debug/generate.html?rev=1080895&view=auto
==============================================================================
--- cxf/trunk/rt/management-web/src/test/gwt-debug/generate.html (added)
+++ cxf/trunk/rt/management-web/src/test/gwt-debug/generate.html Sat Mar 12 08:57:21 2011
@@ -0,0 +1,67 @@
+<!--
+  ~ 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.
+  -->
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+    <title>Generate log entry</title>
+    <style type="text/css">
+        label {
+        width: 5em;
+        float: left;
+        text-align: right;
+        margin-right: 0.5em;
+        display: block
+        }
+        .submit input {
+        margin-left: 8em;
+        }
+    </style>
+</head>
+<body>
+<form action="generate.do" method="get">
+    <p>
+        <label for="level">Level:</label>
+        <select id="level" name="level">
+            <option value="debug">DEBUG</option>
+            <option value="info">INFO</option>
+            <option value="warning">WARNING</option>
+            <option value="error">ERROR</option>
+        </select>
+    </p>
+
+    <p>
+        <label for="copies">Copies:</label>
+        <input id="copies" name="copies" type="text" size="2" value="1"/>
+    </p>
+
+    <p>
+        <label for="message">Message:</label>
+        <textarea id="message" name="message" rows="10" cols="80"></textarea>
+    </p>
+
+    <p>
+        <label for="exceptionMessage">Exception message:</label>
+        <textarea id="exceptionMessage" name="exceptionMessage" rows="10" cols="80"></textarea>
+    </p>
+
+    <p class="submit"><input type="submit" value="Generate"/></p>
+</form>
+</body>
+</html>
\ No newline at end of file

Added: cxf/trunk/rt/management-web/src/test/gwt-debug/org/apache/cxf/management/web/logging/Generate.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/management-web/src/test/gwt-debug/org/apache/cxf/management/web/logging/Generate.java?rev=1080895&view=auto
==============================================================================
--- cxf/trunk/rt/management-web/src/test/gwt-debug/org/apache/cxf/management/web/logging/Generate.java
(added)
+++ cxf/trunk/rt/management-web/src/test/gwt-debug/org/apache/cxf/management/web/logging/Generate.java
Sat Mar 12 08:57:21 2011
@@ -0,0 +1,100 @@
+/**
+ * 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.cxf.management.web.logging;
+
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.cxf.common.logging.LogUtils;
+
+public class Generate extends HttpServlet {
+    private static final Logger LOGGER = LogUtils.getL7dLogger(Generate.class);
+
+    private static final String LEVEL = "level";
+    private static final String MESSAGE = "message";
+    private static final String COPIES = "copies";
+    private static final String EXCEPTION_MESSAGE = "exceptionMessage";
+    private static final String FORM_URL = "./generate.html";
+
+    private enum Levels {
+        DEBUG,
+        INFO,
+        WARNING,
+        ERROR;
+    }
+
+    public void doGet(final HttpServletRequest request, final HttpServletResponse response)
+        throws ServletException, IOException {
+
+        final String level = request.getParameter(LEVEL) != null
+            ? request.getParameter(LEVEL).toLowerCase() : null;
+        final String message = request.getParameter(MESSAGE);
+        final String exceptionMessage = request.getParameter(EXCEPTION_MESSAGE);
+
+        int copies;
+        try {
+            copies = Integer.valueOf(request.getParameter(COPIES));
+            if (copies < 0) {
+                copies = 1;
+            }
+        } catch (NumberFormatException e) {
+            copies = 1;
+        }
+
+        assert copies >= 1;
+        assert level != null && !"".equals(level);
+
+        if (name(Levels.DEBUG).equals(level)) {
+            log(Level.FINE, message, exceptionMessage, copies);
+        } else if (name(Levels.INFO).equals(level)) {
+            log(Level.INFO, message, exceptionMessage, copies);
+        } else if (name(Levels.WARNING).equals(level)) {
+            log(Level.WARNING, message, exceptionMessage, copies);
+        } else if (name(Levels.ERROR).equals(level)) {
+            log(Level.SEVERE, message, exceptionMessage, copies);
+        }
+
+        response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
+        response.setHeader("Location", FORM_URL);
+        response.setContentType("text/html");
+    }
+
+    private static void log(final Level level, final String message,
+                            final String exceptionMessage, final int copies) {
+        if (message != null && !"".equals(message)) {
+            for (int i = 0; i < copies; i++) {
+                if (exceptionMessage != null && !"".equals(exceptionMessage)) {
+                    LOGGER.log(level, message, new Exception(exceptionMessage));
+                } else {
+                    LOGGER.log(level, message);
+                }
+            }
+        }
+    }
+
+    private static String name(final Levels level) {
+        return level.name().toLowerCase();
+    }
+}

Added: cxf/trunk/rt/management-web/src/test/gwt-debug/org/apache/cxf/management/web/logging/MockApp.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/management-web/src/test/gwt-debug/org/apache/cxf/management/web/logging/MockApp.java?rev=1080895&view=auto
==============================================================================
--- cxf/trunk/rt/management-web/src/test/gwt-debug/org/apache/cxf/management/web/logging/MockApp.java
(added)
+++ cxf/trunk/rt/management-web/src/test/gwt-debug/org/apache/cxf/management/web/logging/MockApp.java
Sat Mar 12 08:57:21 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.cxf.management.web.logging;
+
+import java.util.HashSet;
+import java.util.Set;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.cxf.jaxrs.provider.AtomEntryProvider;
+import org.apache.cxf.jaxrs.provider.AtomFeedProvider;
+import org.apache.cxf.management.web.browser.bootstrapping.BootstrapStorage;
+import org.apache.cxf.management.web.browser.bootstrapping.SimpleXMLSettingsStorage;
+import org.apache.cxf.management.web.logging.atom.AtomPullServer;
+
+@Provider
+public class MockApp extends Application {
+    private static final AtomPullServer LOGS;
+
+    static {
+        LOGS = new AtomPullServer();
+        LOGS.setLogger("org.apache.cxf.management.web.logging.Generate");
+        LOGS.init();
+    }
+
+    private static final AtomFeedProvider FEED = new AtomFeedProvider();
+    private static final AtomEntryProvider ENTRY = new AtomEntryProvider();
+
+    private static final BootstrapStorage BOOTSTRAP_STORAGE =
+        new BootstrapStorage(new SimpleXMLSettingsStorage());
+
+    private static final BootstrapStorage.SettingsProvider SETTINGS =
+        new BootstrapStorage.SettingsProvider();
+    
+    @Override
+    public Set<Class<?>> getClasses() {        
+        Set<Class<?>> classes = new HashSet<Class<?>>();
+        classes.add(AtomPullServer.class);
+        classes.add(AtomFeedProvider.class);
+        classes.add(AtomEntryProvider.class);
+        classes.add(BootstrapStorage.class);
+        classes.add(BootstrapStorage.SettingsProvider.class);
+        return classes;
+    }
+
+    @Override
+    public Set<Object> getSingletons() {
+        Set<Object> classes = new HashSet<Object>();
+        classes.add(LOGS);
+        classes.add(FEED);
+        classes.add(ENTRY);
+        classes.add(BOOTSTRAP_STORAGE);
+        classes.add(SETTINGS);
+        return classes;
+    }
+}



Mime
View raw message