cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [1/5] git commit: Polish the log code of netty-server
Date Fri, 14 Mar 2014 12:18:15 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 926ba99bf -> eaf416c0d


Polish the log code of netty-server


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/e8aced67
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/e8aced67
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/e8aced67

Branch: refs/heads/master
Commit: e8aced67f49eaefc5868ae5bc1a59f69a7b777fb
Parents: 53d4e06
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Fri Mar 14 16:19:48 2014 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Fri Mar 14 20:16:46 2014 +0800

----------------------------------------------------------------------
 .../http/netty/server/Messages.properties       | 25 ++++++++++++++++++++
 .../netty/server/NettyHttpContextHandler.java   |  7 ++++++
 .../server/NettyHttpServerEngineFactory.java    |  5 ++--
 .../netty/server/NettyHttpServletHandler.java   |  6 +++--
 4 files changed, 39 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/e8aced67/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/Messages.properties
----------------------------------------------------------------------
diff --git a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/Messages.properties
b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/Messages.properties
new file mode 100644
index 0000000..82551e2
--- /dev/null
+++ b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/Messages.properties
@@ -0,0 +1,25 @@
+#
+#
+#    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.
+#
+#
+UNEXPECTED_EXCEPCTION_IN_NETTY_SERVLET_HANDLER = Unexpected exception from downstream in
Netty servlet handler, due to: {0}.
+NO_NETTY_SERVLET_HANDLER_FOUND = No Netty servlet handler found for url: {0}.
+CREATING_NETTY_SERVER_ENGINE = Creating Netty HTTP Server Engine for port: {0}.
+STOPPING_NETTY_SERVER_ENGINE = Stopping Jetty HTTP Server Engine on port: {0}.
+REMOVE_HANDLER_FAILED_MSG = Could not remove cxf netty handler from Netty server: {0}

http://git-wip-us.apache.org/repos/asf/cxf/blob/e8aced67/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpContextHandler.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpContextHandler.java
b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpContextHandler.java
index d2c72fd..a7a6da0 100644
--- a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpContextHandler.java
+++ b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpContextHandler.java
@@ -24,14 +24,19 @@ import java.io.IOException;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
 
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.transport.http.netty.server.servlet.NettyServletContext;
 
 public class NettyHttpContextHandler {
+    private static final Logger LOG =
+            LogUtils.getL7dLogger(NettyHttpContextHandler.class);
     private final ServletContext servletContext;
     private List<NettyHttpHandler> nettyHttpHandlerList = new CopyOnWriteArrayList<NettyHttpHandler>();
 
@@ -66,6 +71,8 @@ public class NettyHttpContextHandler {
         NettyHttpHandler handler = getNettyHttpHandler(urlName);
         if (handler != null) {
             nettyHttpHandlerList.remove(handler);
+        } else {
+            LOG.log(Level.WARNING, "REMOVE_HANDLER_FAILED_MSG",  urlName);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/e8aced67/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServerEngineFactory.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServerEngineFactory.java
b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServerEngineFactory.java
index 153f756..43fcb5d 100644
--- a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServerEngineFactory.java
+++ b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServerEngineFactory.java
@@ -25,6 +25,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import javax.annotation.Resource;
@@ -171,7 +172,7 @@ public class NettyHttpServerEngineFactory implements BusLifeCycleListener
{
 
     public synchronized NettyHttpServerEngine createNettyHttpServerEngine(String host, int
port,
                                                                           String protocol)
throws IOException {
-        LOG.fine("Creating Netty HTTP Server Engine for port " + port + ".");
+        LOG.log(Level.FINE, "CREATING_NETTY_SERVER_ENGINE",  port);
         TLSServerParameters tlsServerParameters = null;
         if (protocol.equals("https") && tlsServerParametersMap != null) {
             tlsServerParameters = tlsServerParametersMap.get(port);
@@ -199,7 +200,7 @@ public class NettyHttpServerEngineFactory implements BusLifeCycleListener
{
     public static synchronized void destroyForPort(int port) {
         NettyHttpServerEngine ref = portMap.remove(port);
         if (ref != null) {
-            LOG.fine("Stopping Jetty HTTP Server Engine on port " + port + ".");
+            LOG.log(Level.FINE, "STOPPING_NETTY_SERVER_ENGINE", port);
             try {
                 ref.shutdown();
             } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/e8aced67/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServletHandler.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServletHandler.java
b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServletHandler.java
index f77426d..5cbaa32 100644
--- a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServletHandler.java
+++ b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServletHandler.java
@@ -24,7 +24,9 @@ import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.transport.http.netty.server.interceptor.NettyInterceptor;
 import org.apache.cxf.transport.http.netty.server.servlet.NettyHttpServletRequest;
 import org.apache.cxf.transport.http.netty.server.servlet.NettyServletResponse;
@@ -108,7 +110,7 @@ public class NettyHttpServletHandler extends ChannelInboundHandlerAdapter
{
             handleHttpServletRequest(ctx, request, nettyHttpContextHandler);
         } else {
             throw new RuntimeException(
-                    "No handler found for uri: " + request.getUri());
+                    new Fault(new Message("NO_NETTY_SERVLET_HANDLER_FOUND", LOG , request.getUri())));
         }
     }
 
@@ -159,7 +161,7 @@ public class NettyHttpServletHandler extends ChannelInboundHandlerAdapter
{
     @Override
     public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
{
         
-        LOG.log(Level.SEVERE, "Unexpected exception from downstream.", cause);
+        LOG.log(Level.SEVERE, "UNEXPECTED_EXCEPCTION_IN_NETTY_SERVLET_HANDLER", cause);
 
         interceptOnRequestFailed(ctx, cause);
 


Mime
View raw message