wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r818698 - in /incubator/wink/trunk: wink-common/src/main/resources/org/apache/wink/common/internal/i18n/ wink-server/src/main/java/org/apache/wink/server/internal/handlers/ wink-server/src/main/java/org/apache/wink/server/internal/servlet/
Date Fri, 25 Sep 2009 02:15:40 GMT
Author: bluk
Date: Fri Sep 25 02:15:39 2009
New Revision: 818698

URL: http://svn.apache.org/viewvc?rev=818698&view=rev
Log:
Add debug statements to servlet/filters in server

Modified:
    incubator/wink/trunk/wink-common/src/main/resources/org/apache/wink/common/internal/i18n/resource.properties
    incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/CreateInvocationParametersHandler.java
    incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/AbstractRestServlet.java
    incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/AdminServlet.java
    incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/RestFilter.java
    incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/RestServlet.java

Modified: incubator/wink/trunk/wink-common/src/main/resources/org/apache/wink/common/internal/i18n/resource.properties
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/resources/org/apache/wink/common/internal/i18n/resource.properties?rev=818698&r1=818697&r2=818698&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/resources/org/apache/wink/common/internal/i18n/resource.properties
(original)
+++ incubator/wink/trunk/wink-common/src/main/resources/org/apache/wink/common/internal/i18n/resource.properties
Fri Sep 25 02:15:39 2009
@@ -123,4 +123,11 @@
 # Server Handlers
 checkLocationHeaderHandlerIllegalArg=Mandatory 'Location' header was not set for status code
%1$s
 populateResponseMediaTypeHandlerFromCompatibleMessageBodyWriters=Content-Type not specified
via Response object or via @Produces annotation so automatically setting via generic-type
compatible MessageBodyWriter providers
-populateResponseMediaTypeHandlerNoAcceptableResponse=No acceptable concrete Content-Types,
so sending a 406 Not Acceptable response to the client.
\ No newline at end of file
+populateResponseMediaTypeHandlerNoAcceptableResponse=No acceptable concrete Content-Types,
so sending a 406 Not Acceptable response to the client.
+
+# Servlet/Filter Messages
+restServletJAXRSApplicationInitParam=Using application class {} named in init-param {}
+restServletWinkApplicationInitParam=Using application classes {} named in init-param {}
+restServletUseDeploymentConfigurationParam=Using deployment configuration class {} named
in init-param {}
+restServletUsePropertiesFileAtLocation=Using properties file at {} named in init-param {}
+adminServletRequestProcessorInitBeforeAdmin=Request processor should be initialized prior
calling to admin servlet.
\ No newline at end of file

Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/CreateInvocationParametersHandler.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/CreateInvocationParametersHandler.java?rev=818698&r1=818697&r2=818698&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/CreateInvocationParametersHandler.java
(original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/CreateInvocationParametersHandler.java
Fri Sep 25 02:15:39 2009
@@ -40,7 +40,7 @@
 
         // create and save the invocation parameters for the found method
         List<Injectable> formal = result.getMethod().getMetadata().getFormalParameters();
-        logger.debug("Formal Injectable parameters listis: {}", formal);
+        logger.debug("Formal Injectable parameters list is: {}", formal);
         Object[] parameters = InjectableFactory.getInstance().instantiate(formal, context);
         logger.debug("Actual parameters list to inject is: {}", parameters);
         result.setInvocationParameters(parameters);

Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/AbstractRestServlet.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/AbstractRestServlet.java?rev=818698&r1=818697&r2=818698&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/AbstractRestServlet.java
(original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/AbstractRestServlet.java
Fri Sep 25 02:15:39 2009
@@ -23,12 +23,18 @@
 import javax.servlet.http.HttpServlet;
 
 import org.apache.wink.server.internal.RequestProcessor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Base class for RestServlet and AdminServlet
  */
 public abstract class AbstractRestServlet extends HttpServlet {
 
+    private final Logger        logger                      =
+                                                                LoggerFactory
+                                                                    .getLogger(AbstractRestServlet.class);
+
     private static final String REQUEST_PROCESSOR_ATTRIBUTE = "requestProcessorAttribute";
     private static final long   serialVersionUID            = 7721777326714438571L;
     private String              requestProcessorAttribute;
@@ -37,6 +43,7 @@
     public void init() throws ServletException {
         super.init();
         requestProcessorAttribute = getInitParameter(REQUEST_PROCESSOR_ATTRIBUTE);
+        logger.debug("Request processor attribute is {} for {}", requestProcessorAttribute,
this);
     }
 
     protected RequestProcessor getRequestProcessor() {

Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/AdminServlet.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/AdminServlet.java?rev=818698&r1=818697&r2=818698&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/AdminServlet.java
(original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/AdminServlet.java
Fri Sep 25 02:15:39 2009
@@ -37,6 +37,7 @@
 import javax.xml.bind.Marshaller;
 
 import org.apache.wink.common.http.HttpStatus;
+import org.apache.wink.common.internal.i18n.Messages;
 import org.apache.wink.common.internal.model.admin.MatrixParameters;
 import org.apache.wink.common.internal.model.admin.Parameter;
 import org.apache.wink.common.internal.model.admin.QueryParameters;
@@ -90,8 +91,8 @@
 
         RequestProcessor requestProcessor = getRequestProcessor();
         if (requestProcessor == null) {
-            throw new ServletException(
-                                       "Request processor should be initialized prior calling
to admin servlet.");
+            throw new ServletException(Messages
+                .getMessage("adminServletRequestProcessorInitBeforeAdmin"));
         }
         ResourceRegistry registry = requestProcessor.getConfiguration().getResourceRegistry();
 
@@ -254,7 +255,7 @@
         uri2ResourceMap.clear();
         for (MethodMetadata subResourceMethod : subResourceMethods) {
             UriTemplateProcessor uriTemplate = record.getTemplateProcessor();
-            String uri = SLASH + uriTemplate.getTemplate() +SLASH+ subResourceMethod.getPath();
+            String uri = SLASH + uriTemplate.getTemplate() + SLASH + subResourceMethod.getPath();
             org.apache.wink.common.internal.model.admin.Methods xmlSRM =
                 createXMLSubResourceMethod(subResourceMethod);
             addResourceMethods(uri2ResourceMap, uri, xmlSRM);

Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/RestFilter.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/RestFilter.java?rev=818698&r1=818697&r2=818698&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/RestFilter.java
(original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/RestFilter.java
Fri Sep 25 02:15:39 2009
@@ -35,6 +35,8 @@
 import javax.servlet.http.HttpServletResponseWrapper;
 
 import org.apache.wink.server.internal.DeploymentConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * <p>
@@ -46,10 +48,14 @@
  */
 public class RestFilter implements Filter {
 
-    private RestServlet restServlet;
+    private RestServlet  restServlet;
+
+    private final Logger logger = LoggerFactory.getLogger(RestFilter.class);
 
     private static class FilteredHttpServletResponse extends HttpServletResponseWrapper {
 
+        private final Logger logger = LoggerFactory.getLogger(FilteredHttpServletResponse.class);
+
         public FilteredHttpServletResponse(HttpServletResponse response) {
             super(response);
         }
@@ -60,12 +66,14 @@
         public void setStatus(int statusCode) {
             super.setStatus(statusCode);
             this.statusCode = statusCode;
+            logger.debug("FilteredHttpServletResponse set status code to {}", statusCode);
         }
 
         @Override
         public void setStatus(int statusCode, String msg) {
             super.setStatus(statusCode, msg);
             this.statusCode = statusCode;
+            logger.debug("FilteredHttpServletResponse set status code to {}", statusCode);
         }
 
         int getStatusCode() {
@@ -91,10 +99,16 @@
                  * directly), then the status code is like the filter was never
                  * invoked
                  */
+                logger
+                    .debug("Filter {} did not match a resource so letting request continue
on FilterChain {}",
+                           this,
+                           chain);
                 httpServletResponse.setStatus(HttpServletResponse.SC_OK);
                 chain.doFilter(servletRequest, servletResponse);
             }
         } else {
+            logger
+                .debug("Filter {} did not expect a non-HttpServletRequest and/or non-HttpServletResponse
but letting chain continue");
             chain.doFilter(servletRequest, servletResponse);
         }
     }
@@ -121,6 +135,8 @@
     public void init(final FilterConfig filterConfig) throws ServletException {
         restServlet = new RestServletForFilter(filterConfig);
 
+        logger.debug("Initializing RestFilter {} with {} config and {} servlet", new Object[]
{
+            this, filterConfig, restServlet});
         restServlet.init(new ServletConfig() {
 
             public String getServletName() {
@@ -142,6 +158,7 @@
     }
 
     public void destroy() {
+        logger.debug("Destroying RestFilter {}", this);
         restServlet.destroy();
     }
 }

Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/RestServlet.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/RestServlet.java?rev=818698&r1=818697&r2=818698&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/RestServlet.java
(original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/RestServlet.java
Fri Sep 25 02:15:39 2009
@@ -73,6 +73,8 @@
     @Override
     public void init() throws ServletException {
 
+        logger.debug("Initializing {} servlet", this);
+
         try {
             super.init();
             // try to get the request processor
@@ -107,6 +109,7 @@
         InstantiationException, IllegalAccessException, IOException {
         DeploymentConfiguration deploymentConfiguration = getDeploymentConfiguration();
         RequestProcessor requestProcessor = new RequestProcessor(deploymentConfiguration);
+        logger.debug("Creating request processor {} for servlet {}", requestProcessor, this);
         deploymentConfiguration.addApplication(getApplication());
         return requestProcessor;
     }
@@ -123,10 +126,15 @@
 
     protected Properties getProperties() throws IOException {
         Properties defaultProperties = loadProperties(PROPERTIES_DEFAULT_FILE, null);
+        logger.debug("Default properties {} used in RestServlet {}", defaultProperties, this);
         String propertiesLocation = getInitParameter(PROPERTIES_INIT_PARAM);
         if (propertiesLocation != null) {
+            logger.info(Messages.getMessage("restServletUsePropertiesFileAtLocation"),
+                        propertiesLocation,
+                        PROPERTIES_INIT_PARAM);
             return loadProperties(propertiesLocation, defaultProperties);
         }
+        logger.debug("Final properties {} used in RestServlet {}", defaultProperties, this);
         return defaultProperties;
     }
 
@@ -134,6 +142,9 @@
         throws ClassNotFoundException, InstantiationException, IllegalAccessException {
         String initParameter = getInitParameter(DEPLYMENT_CONF_PARAM);
         if (initParameter != null) {
+            logger.info(Messages.getMessage("restServletUseDeploymentConfigurationParam"),
+                        initParameter,
+                        DEPLYMENT_CONF_PARAM);
             Class<?> confClass = Class.forName(initParameter);
             return (DeploymentConfiguration)confClass.newInstance();
         }
@@ -146,6 +157,9 @@
         Class<? extends Application> appClass = null;
         String initParameter = getInitParameter(APPLICATION_INIT_PARAM);
         if (initParameter != null) {
+            logger.info(Messages.getMessage("restServletJAXRSApplicationInitParam"),
+                        initParameter,
+                        APPLICATION_INIT_PARAM);
             appClass = (Class<Application>)Class.forName(initParameter);
             return appClass.newInstance();
         }
@@ -153,6 +167,9 @@
         if (appLocationParameter == null) {
             logger.warn(Messages.getMessage("propertyNotDefined"), APP_LOCATION_PARAM);
         }
+        logger.info(Messages.getMessage("restServletWinkApplicationInitParam"),
+                    initParameter,
+                    APP_LOCATION_PARAM);
         return new ServletWinkApplication(getServletContext(), appLocationParameter);
     }
 



Mime
View raw message