wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jra...@apache.org
Subject svn commit: r1027186 - in /incubator/wink/trunk/wink-common/src/main: java/org/apache/wink/common/internal/ java/org/apache/wink/common/internal/application/ java/org/apache/wink/common/internal/lifecycle/ java/org/apache/wink/common/internal/providers...
Date Mon, 25 Oct 2010 16:32:46 GMT
Author: jramos
Date: Mon Oct 25 16:32:45 2010
New Revision: 1027186

URL: http://svn.apache.org/viewvc?rev=1027186&view=rev
Log:
[Wink-323] Logging improvements for wink-common

Modified:
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/UriBuilderImpl.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/application/ApplicationFileLoader.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/application/ApplicationValidator.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/lifecycle/CreationUtils.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/lifecycle/LifecycleManagersRegistry.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/AssetProvider.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/FileProvider.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/json/JAXBArrayJSONProvider.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/AbstractJAXBProvider.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/JAXBXmlProvider.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/AbstractMetadata.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/AbstractMetadataCollector.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/ApplicationMetadataCollector.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/ConstructorMetadata.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/MethodMetadata.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/ProviderMetadataCollector.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/ResourceMetadataCollector.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/multipart/OutPart.java
    incubator/wink/trunk/wink-common/src/main/resources/org/apache/wink/common/internal/i18n/resource.properties

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/UriBuilderImpl.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/UriBuilderImpl.java?rev=1027186&r1=1027185&r2=1027186&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/UriBuilderImpl.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/UriBuilderImpl.java Mon Oct 25 16:32:45 2010
@@ -351,7 +351,7 @@ public class UriBuilderImpl extends UriB
                 return uri;
             } catch (URISyntaxException e) {
                 throw new IllegalArgumentException(Messages
-                    .getMessage("isInvalid", "schemeSpecificPart"), e); //$NON-NLS-1$ //$NON-NLS-2$
+                    .getMessage("isInvalid", "schemeSpecificPart", schemeSpecificPart), e); //$NON-NLS-1$ //$NON-NLS-2$
             }
         }
 
@@ -610,7 +610,7 @@ public class UriBuilderImpl extends UriB
         isFirstCall = false;
         Path pathAnnotation = ((Class<?>)resource).getAnnotation(Path.class);
         if (pathAnnotation == null) {
-            throw new IllegalArgumentException(Messages.getMessage("resourceNotAnnotated", "Path")); //$NON-NLS-1$ //$NON-NLS-2$
+            throw new IllegalArgumentException(Messages.getMessage("resourceNotAnnotated", "@javax.ws.rs.Path", resource)); //$NON-NLS-1$ //$NON-NLS-2$
         }
         String path = pathAnnotation.value();
         logger.trace("path annotation value is {}", path); //$NON-NLS-1$
@@ -627,7 +627,7 @@ public class UriBuilderImpl extends UriB
         }
         Path pathAnnotation = method.getAnnotation(Path.class);
         if (pathAnnotation == null) {
-            throw new IllegalArgumentException(Messages.getMessage("methodNotAnnotated", "Path")); //$NON-NLS-1$ //$NON-NLS-2$
+            throw new IllegalArgumentException(Messages.getMessage("methodNotAnnotated", "@javax.ws.rs.Path", method)); //$NON-NLS-1$ //$NON-NLS-2$
         }
         String path = pathAnnotation.value();
         logger.trace("path method annotation is {}", path); //$NON-NLS-1$
@@ -655,14 +655,14 @@ public class UriBuilderImpl extends UriB
                 if (pathAnnotation != null) {
                     if (foundMethod != null) {
                         throw new IllegalArgumentException(Messages
-                            .getMessage("moreThanOneMethodAnnotated", "Path")); //$NON-NLS-1$ //$NON-NLS-2$
+                            .getMessage("moreThanOneMethodAnnotated", "@javax.ws.rs.Path", method, resource)); //$NON-NLS-1$ //$NON-NLS-2$
                     }
                     foundMethod = m;
                 }
             }
         }
         if (foundMethod == null) {
-            throw new IllegalArgumentException(Messages.getMessage("noMethodAnnotated", "Path")); //$NON-NLS-1$ //$NON-NLS-2$
+            throw new IllegalArgumentException(Messages.getMessage("noMethodAnnotated", "@javax.ws.rs.Path", method, resource)); //$NON-NLS-1$ //$NON-NLS-2$
         }
         path(foundMethod);
         logger.trace("path() exit"); //$NON-NLS-1$
@@ -675,7 +675,7 @@ public class UriBuilderImpl extends UriB
             logger.trace("port({}) entry", port); //$NON-NLS-1$
         }
         if (port < -1) {
-            throw new IllegalArgumentException(Messages.getMessage("invalidPort")); //$NON-NLS-1$
+            throw new IllegalArgumentException(Messages.getMessage("invalidPort", String.valueOf(port))); //$NON-NLS-1$
         }
         this.port = port;
         logger.trace("port() exit"); //$NON-NLS-1$
@@ -868,7 +868,7 @@ public class UriBuilderImpl extends UriB
             uri = new URI(scheme, ssp, fragment);
         } catch (URISyntaxException e) {
             throw new IllegalArgumentException(Messages
-                .getMessage("isInvalid", "schemeSpecificPart"), e); //$NON-NLS-1$ //$NON-NLS-2$
+                .getMessage("isInvalid", "schemeSpecificPart", schemeSpecificPart), e); //$NON-NLS-1$ //$NON-NLS-2$
         }
 
         resetSchemeSpecificPart();

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/application/ApplicationFileLoader.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/application/ApplicationFileLoader.java?rev=1027186&r1=1027185&r2=1027186&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/application/ApplicationFileLoader.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/application/ApplicationFileLoader.java Mon Oct 25 16:32:45 2010
@@ -146,8 +146,8 @@ public class ApplicationFileLoader {
                         logger.trace("ClassNotFoundException while loading class", e); //$NON-NLS-1$
                     }
                 } catch (NoClassDefFoundError e) {
-                    if (logger.isTraceEnabled()) {
-                        logger.trace(Messages
+                    if (logger.isErrorEnabled()) {
+                        logger.error(Messages
                             .getMessage("classInstantiationExceptionWithMsgFormat", line), e); //$NON-NLS-1$
                     }
                 }

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/application/ApplicationValidator.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/application/ApplicationValidator.java?rev=1027186&r1=1027185&r2=1027186&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/application/ApplicationValidator.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/application/ApplicationValidator.java Mon Oct 25 16:32:45 2010
@@ -91,7 +91,7 @@ public class ApplicationValidator {
 
     /**
      * Validates that class has only one of the following: Path, Provider,
-     * DispatchedPath, DynamicResource
+     * DynamicResource
      * 
      * @param cls
      * @return
@@ -112,9 +112,10 @@ public class ApplicationValidator {
         if (!valid) {
             if (logger.isWarnEnabled()) {
                 logger.warn(Messages.getMessage("classNotValid", //$NON-NLS-1$
-                                                cls.getName(), Path.class.getName(),
-                                                    DynamicResource.class.getName(),
-                                                    Provider.class.getName()));
+                                                cls.getName(),
+                                                Path.class.getName(),
+                                                DynamicResource.class.getName(),
+                                                Provider.class.getName()));
             }
         }
 

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/lifecycle/CreationUtils.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/lifecycle/CreationUtils.java?rev=1027186&r1=1027185&r2=1027186&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/lifecycle/CreationUtils.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/lifecycle/CreationUtils.java Mon Oct 25 16:32:45 2010
@@ -38,8 +38,12 @@ import org.apache.wink.common.internal.r
 import org.apache.wink.common.internal.registry.InjectableFactory;
 import org.apache.wink.common.internal.registry.metadata.ClassMetadata;
 import org.apache.wink.common.internal.registry.metadata.ConstructorMetadata;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class CreationUtils {
+    
+    private static final Logger logger = LoggerFactory.getLogger(CreationUtils.class);
 
     private CreationUtils() {
     }
@@ -79,12 +83,15 @@ public class CreationUtils {
                                     ClassMetadata metadata,
                                     RuntimeContext runtimeContext) throws IOException,
         PrivilegedActionException {
+        logger.trace("entry {} {} {}", new Object[]{object, metadata, runtimeContext});
 
         List<Injectable> injectableFields = metadata.getInjectableFields();
+        logger.trace("injectableFields are {}", injectableFields);
         for (Injectable injectableData : injectableFields) {
 
             Object value = injectableData.getValue(runtimeContext);
             Member member = injectableData.getMember();
+            logger.trace("Processing value {} and member {}", value, member);
             if (member instanceof Field) {
                 injectField(object, value, (Field)member);
             } else if (member instanceof Method) {
@@ -94,10 +101,12 @@ public class CreationUtils {
                 throw new WebApplicationException();
             }
         }
+        logger.trace("exit");
     }
 
     static void invokeMethod(final Object object, final Object value, final Method method)
         throws PrivilegedActionException {
+        logger.trace("entry {} {} {}", new Object[]{object, value, method});
         AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
 
             public Object run() throws Exception {
@@ -109,7 +118,7 @@ public class CreationUtils {
                 return null;
             }
         });
-
+        logger.trace("exit");
     }
 
     static void injectField(final Object object, final Object value, final Field field)

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/lifecycle/LifecycleManagersRegistry.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/lifecycle/LifecycleManagersRegistry.java?rev=1027186&r1=1027185&r2=1027186&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/lifecycle/LifecycleManagersRegistry.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/lifecycle/LifecycleManagersRegistry.java Mon Oct 25 16:32:45 2010
@@ -19,7 +19,9 @@
  *******************************************************************************/
 package org.apache.wink.common.internal.lifecycle;
 
+import java.util.Collections;
 import java.util.LinkedList;
+import java.util.List;
 
 /**
  * Registry of LifecycleManagers
@@ -82,4 +84,8 @@ public class LifecycleManagersRegistry {
 
         return defaultFactoryFactory.createObjectFactory(cls);
     }
+    
+    public List<LifecycleManager<?>> getLifecycleManagers() {
+        return Collections.unmodifiableList(this.store);
+    }
 }

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/AssetProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/AssetProvider.java?rev=1027186&r1=1027185&r2=1027186&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/AssetProvider.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/AssetProvider.java Mon Oct 25 16:32:45 2010
@@ -115,13 +115,13 @@ public class AssetProvider implements Me
         } catch (IllegalArgumentException e) {
             if (logger.isErrorEnabled()) {
                 logger.error(Messages
-                    .getMessage("assetMethodInvokeError", method.getMethod().getName())); //$NON-NLS-1$
+                    .getMessage("assetMethodInvokeError", method.getMethod().getName()), e); //$NON-NLS-1$
             }
             throw new WebApplicationException(e);
         } catch (IllegalAccessException e) {
             if (logger.isErrorEnabled()) {
                 logger.error(Messages
-                    .getMessage("assetMethodInvokeError", method.getMethod().getName())); //$NON-NLS-1$
+                    .getMessage("assetMethodInvokeError", method.getMethod().getName()), e); //$NON-NLS-1$
             }
             throw new WebApplicationException(e);
         } catch (InvocationTargetException e) {
@@ -131,7 +131,7 @@ public class AssetProvider implements Me
             }
             if (logger.isErrorEnabled()) {
                 logger.error(Messages
-                    .getMessage("assetMethodInvokeError", method.getMethod().getName())); //$NON-NLS-1$
+                    .getMessage("assetMethodInvokeError", method.getMethod().getName()), e); //$NON-NLS-1$
             }
             throw new WebApplicationException(targetException);
         }
@@ -179,19 +179,19 @@ public class AssetProvider implements Me
             }
             if (logger.isErrorEnabled()) {
                 logger.error(Messages
-                    .getMessage("assetMethodInvokeError", method.getMethod().getName())); //$NON-NLS-1$
+                    .getMessage("assetMethodInvokeError", method.getMethod().getName()), e); //$NON-NLS-1$
             }
             throw new WebApplicationException(e);
         } catch (InstantiationException e) {
             if (logger.isErrorEnabled()) {
-                logger.error(Messages.getMessage("assetMustHavePublicConstructor", type.getName())); //$NON-NLS-1$
+                logger.error(Messages.getMessage("assetMustHavePublicConstructor", type.getName()), e); //$NON-NLS-1$
             }
             throw new WebApplicationException(e);
 
         } catch (Exception e) {
             if (logger.isErrorEnabled()) {
                 logger.error(Messages
-                    .getMessage("assetMethodInvokeError", method.getMethod().getName())); //$NON-NLS-1$
+                    .getMessage("assetMethodInvokeError", method.getMethod().getName()), e); //$NON-NLS-1$
             }
             throw new WebApplicationException(e);
         }
@@ -240,19 +240,19 @@ public class AssetProvider implements Me
         // verify that the asset has a default public constructor
         try {
             if (assetType.getConstructor() == null) {
-                if (logger.isInfoEnabled()) {
-                    logger.info(Messages.getMessage("assetCannotInstantiate", assetType.getName())); //$NON-NLS-1$
+                if (logger.isWarnEnabled()) {
+                    logger.warn(Messages.getMessage("assetCannotInstantiate", assetType.getName())); //$NON-NLS-1$
                 }
                 return false;
             }
         } catch (SecurityException e) {
-            if (logger.isInfoEnabled()) {
-                logger.info(Messages.getMessage("assetCannotInstantiate", assetType.getName())); //$NON-NLS-1$
+            if (logger.isWarnEnabled()) {
+                logger.warn(Messages.getMessage("assetCannotInstantiate", assetType.getName()), e); //$NON-NLS-1$
             }
             return false;
         } catch (NoSuchMethodException e) {
-            if (logger.isInfoEnabled()) {
-                logger.info(Messages.getMessage("assetCannotInstantiate", assetType.getName())); //$NON-NLS-1$
+            if (logger.isWarnEnabled()) {
+                logger.warn(Messages.getMessage("assetCannotInstantiate", assetType.getName()), e); //$NON-NLS-1$
             }
             return false;
         }

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/FileProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/FileProvider.java?rev=1027186&r1=1027185&r2=1027186&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/FileProvider.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/FileProvider.java Mon Oct 25 16:32:45 2010
@@ -84,7 +84,7 @@ public class FileProvider implements Mes
                 public Object run() throws IOException {
                     if (!t.canRead() || t.isDirectory()) {
                         if(logger.isWarnEnabled()) {
-                            logger.warn(Messages.getMessage("cannotUseFileAsResponse", //$NON-NLS-1$
+                            logger.error(Messages.getMessage("cannotUseFileAsResponse", //$NON-NLS-1$
                                                             t.getAbsoluteFile()));
                         }
                         throw new WebApplicationException();
@@ -130,7 +130,7 @@ public class FileProvider implements Mes
             if (!dir.exists() || !dir.isDirectory()) {
                 dir = null;
                 if (logger.isWarnEnabled()) {
-                    logger.warn(Messages.getMessage("uploadDirDoesNotExist", uploadDir)); //$NON-NLS-1$
+                    logger.error(Messages.getMessage("uploadDirDoesNotExist", uploadDir)); //$NON-NLS-1$
                 }
                 throw new WebApplicationException();
 

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/json/JAXBArrayJSONProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/json/JAXBArrayJSONProvider.java?rev=1027186&r1=1027185&r2=1027186&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/json/JAXBArrayJSONProvider.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/json/JAXBArrayJSONProvider.java Mon Oct 25 16:32:45 2010
@@ -57,11 +57,13 @@ public class JAXBArrayJSONProvider exten
 
     protected volatile MessageBodyReader<Object> readerProvider = null;
     protected volatile MessageBodyWriter<Object> writerProvider = null;
-    
-    private static final Logger logger = LoggerFactory.getLogger(JAXBArrayJSONProvider.class);
+
+    private static final Logger                  logger         =
+                                                                    LoggerFactory
+                                                                        .getLogger(JAXBArrayJSONProvider.class);
 
     @Context
-    Providers                           injectedProviders;
+    Providers                                    injectedProviders;
 
     public boolean isReadable(Class<?> type,
                               Type genericType,
@@ -96,7 +98,10 @@ public class JAXBArrayJSONProvider exten
                                                        theType,
                                                        annotations,
                                                        mediaType);
-            logger.trace("readerProvider was {} of type {}", System.identityHashCode(readerProvider), readerProvider.getClass().getName()); //$NON-NLS-1$
+            if (logger.isTraceEnabled()) {
+                logger
+                    .trace("readerProvider was {} of type {}", System.identityHashCode(readerProvider), readerProvider.getClass().getName()); //$NON-NLS-1$
+            }
         }
         Queue<String> queue = new LinkedList<String>();
         List<Object> collection = new ArrayList<Object>();
@@ -167,7 +172,10 @@ public class JAXBArrayJSONProvider exten
                                                        theType,
                                                        annotations,
                                                        mediaType);
-            logger.trace("writerProvider was {} of type {}", System.identityHashCode(writerProvider), writerProvider.getClass().getName()); //$NON-NLS-1$
+            if (logger.isTraceEnabled()) {
+                logger
+                    .trace("writerProvider was {} of type {}", System.identityHashCode(writerProvider), writerProvider.getClass().getName()); //$NON-NLS-1$
+            }
         }
         entityStream.write("[".getBytes()); //$NON-NLS-1$
         int i = 0;

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/AbstractJAXBProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/AbstractJAXBProvider.java?rev=1027186&r1=1027185&r2=1027186&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/AbstractJAXBProvider.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/AbstractJAXBProvider.java Mon Oct 25 16:32:45 2010
@@ -64,6 +64,7 @@ import org.apache.wink.common.internal.u
 import org.apache.wink.common.model.JAXBUnmarshalOptions;
 import org.apache.wink.common.model.XmlFormattingOptions;
 import org.apache.wink.common.utils.ProviderUtils;
+import org.apache.wink.common.utils.ProviderUtils.PROVIDER_EXCEPTION_ORIGINATOR;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -106,16 +107,18 @@ public abstract class AbstractJAXBProvid
     // of which is unique per class object being (un)marshalled. In Axis2, the
     // JAXBContext instances cover the entire application space, thus
     // it was safe to cache them in a static field.
-    private Pool<JAXBContext, Marshaller>                         mpool                     =
-                                                                                                new Pool<JAXBContext, Marshaller>();
-    private Pool<JAXBContext, Unmarshaller>                       upool                     =
-                                                                                                new Pool<JAXBContext, Unmarshaller>();
-                                                                                                
-
-    // For performance, it might seem advantageous to use a static XMLInputFactory instance.  However, this was shown to
-    // be problematic on the Sun StAX parser (which is a fork of Apache Xerces) under load stress test.  So we use ThreadLocal.
-    private static ThreadLocal<XMLInputFactory> xmlInputFactory = new ThreadLocal<XMLInputFactory>();
-    
+    private Pool<JAXBContext, Marshaller>                            mpool                          =
+                                                                                                        new Pool<JAXBContext, Marshaller>();
+    private Pool<JAXBContext, Unmarshaller>                          upool                          =
+                                                                                                        new Pool<JAXBContext, Unmarshaller>();
+
+    // For performance, it might seem advantageous to use a static
+    // XMLInputFactory instance. However, this was shown to
+    // be problematic on the Sun StAX parser (which is a fork of Apache Xerces)
+    // under load stress test. So we use ThreadLocal.
+    private static ThreadLocal<XMLInputFactory>                      xmlInputFactory                =
+                                                                                                        new ThreadLocal<XMLInputFactory>();
+
     /**
      * This class is the key to the JAXBContext cache. It must be based on the
      * ContextResolver instance who created the JAXBContext and the type passed
@@ -124,8 +127,10 @@ public abstract class AbstractJAXBProvid
      * creates contexts between noon and 5:00pm. So, uhhh, don't do that.
      */
     private static class JAXBContextResolverKey {
-        private static final Logger logger = LoggerFactory.getLogger(JAXBContextResolverKey.class);
-        
+        private static final Logger            logger   =
+                                                            LoggerFactory
+                                                                .getLogger(JAXBContextResolverKey.class);
+
         protected ContextResolver<JAXBContext> _resolver;
         protected Type                         _type;
         private int                            hashCode = -1;
@@ -151,7 +156,8 @@ public abstract class AbstractJAXBProvid
                 ((obj._resolver == null) && (_resolver == null)) || ((obj._resolver != null) && (_resolver != null));
             logger.trace("null check result is {}", result); //$NON-NLS-1$
             // we can use hashCode() to compare _resolver
-            boolean finalResult = result && (obj.hashCode() == hashCode()) && (obj._type.equals(_type));
+            boolean finalResult =
+                result && (obj.hashCode() == hashCode()) && (obj._type.equals(_type));
             logger.trace("final result is {}", finalResult); //$NON-NLS-1$
             return finalResult;
         }
@@ -209,11 +215,11 @@ public abstract class AbstractJAXBProvid
     // JAXBContext cache can be turned off through system property
     static private final String                                          propVal          =
                                                                                               System
-                                                                                                  .getProperty("org.apache.wink.jaxbcontextcache"); //$NON-NLS-1$
+                                                                                                  .getProperty("org.apache.wink.jaxbcontextcache");        //$NON-NLS-1$
     // non-final, protected only to make it unittestable
     static protected boolean                                             contextCacheOn   =
                                                                                               !((propVal != null) && (propVal
-                                                                                                  .equalsIgnoreCase("off"))); //$NON-NLS-1$
+                                                                                                  .equalsIgnoreCase("off")));                              //$NON-NLS-1$
 
 /**
      * Get the unmarshaller. You must call {@link #releaseJAXBUnmarshaller(JAXBContext, Unmarshaller) to put it back
@@ -252,14 +258,14 @@ public abstract class AbstractJAXBProvid
 
         return unm;
     }
-    
+
     /**
      * skips START_DOCUMENT, COMMENTs, PIs, and checks for DTD
+     * 
      * @param reader
      * @throws XMLStreamException
      */
-    private static void checkForDTD(XMLStreamReader reader)
-            throws XMLStreamException {
+    private static void checkForDTD(XMLStreamReader reader) throws XMLStreamException {
         boolean supportDTD = false;
 
         int event = reader.getEventType();
@@ -268,7 +274,11 @@ public abstract class AbstractJAXBProvid
             // already been partially processed
             throw new XMLStreamException(Messages.getMessage("badXMLReaderInitialStart")); //$NON-NLS-1$
         }
-        while (event != XMLStreamReader.START_ELEMENT) {  // all StAX parsers require a START_ELEMENT.  See AbstractJAXBProviderTest class
+        while (event != XMLStreamReader.START_ELEMENT) { // all StAX parsers
+                                                         // require a
+                                                         // START_ELEMENT. See
+                                                         // AbstractJAXBProviderTest
+                                                         // class
             event = reader.next();
             if (event == XMLStreamReader.DTD) {
 
@@ -278,18 +288,21 @@ public abstract class AbstractJAXBProvid
                     Properties props = winkConfig.getProperties();
                     if (props != null) {
                         // use valueOf method to require the word "true"
-                        supportDTD = Boolean.valueOf(props.getProperty("wink.supportDTDEntityExpansion")); //$NON-NLS-1$
+                        supportDTD =
+                            Boolean.valueOf(props.getProperty("wink.supportDTDEntityExpansion")); //$NON-NLS-1$
                     }
                 }
                 if (!supportDTD) {
-                    throw new EntityReferenceXMLStreamException(Messages.getMessage("entityRefsNotSupported")); //$NON-NLS-1$
+                    throw new EntityReferenceXMLStreamException(Messages
+                        .getMessage("entityRefsNotSupported")); //$NON-NLS-1$
                 } else {
-                    logger.trace("DTD entity reference expansion is enabled.  This may present a security risk."); //$NON-NLS-1$
+                    logger
+                        .trace("DTD entity reference expansion is enabled.  This may present a security risk."); //$NON-NLS-1$
                 }
             }
         }
     }
-    
+
     private static XMLInputFactory getXMLInputFactory() {
         XMLInputFactory factory = xmlInputFactory.get();
         if (factory == null) {
@@ -298,7 +311,7 @@ public abstract class AbstractJAXBProvid
         }
         return factory;
     }
-    
+
     /**
      * A consistent place to get a properly configured XMLStreamReader.
      * 
@@ -306,15 +319,18 @@ public abstract class AbstractJAXBProvid
      * @return
      * @throws XMLStreamException
      */
-    protected static XMLStreamReader getXMLStreamReader(InputStream entityStream) throws XMLStreamException  {
-        // NOTE: createFilteredReader may appear to be more convenient, but it comes at the cost of
-        // performance.  This solution (to use checkForDTD) appears to be the best solution to preserve
+    protected static XMLStreamReader getXMLStreamReader(InputStream entityStream)
+        throws XMLStreamException {
+        // NOTE: createFilteredReader may appear to be more convenient, but it
+        // comes at the cost of
+        // performance. This solution (to use checkForDTD) appears to be the
+        // best solution to preserve
         // performance, but still achieve what we need to do.
         XMLStreamReader reader = getXMLInputFactory().createXMLStreamReader(entityStream);
         checkForDTD(reader);
         return reader;
     }
-    
+
     /**
      * A consistent place to get a properly configured XMLStreamReader.
      * 
@@ -322,15 +338,18 @@ public abstract class AbstractJAXBProvid
      * @return
      * @throws XMLStreamException
      */
-    protected static XMLStreamReader getXMLStreamReader(InputStreamReader entityStreamReader) throws XMLStreamException  {
-        // NOTE: createFilteredReader may appear to be more convenient, but it comes at the cost of
-        // performance.  This solution (to use checkForDTD) appears to be the best solution to preserve
+    protected static XMLStreamReader getXMLStreamReader(InputStreamReader entityStreamReader)
+        throws XMLStreamException {
+        // NOTE: createFilteredReader may appear to be more convenient, but it
+        // comes at the cost of
+        // performance. This solution (to use checkForDTD) appears to be the
+        // best solution to preserve
         // performance, but still achieve what we need to do.
         XMLStreamReader reader = getXMLInputFactory().createXMLStreamReader(entityStreamReader);
         checkForDTD(reader);
         return reader;
     }
-    
+
     protected static void closeXMLStreamReader(XMLStreamReader xmlStreamReader) {
         if (xmlStreamReader != null) {
             try {
@@ -481,7 +500,7 @@ public abstract class AbstractJAXBProvid
         }
         return type;
     }
-    
+
 
     public Class<?> getConcreteTypeFromTypeMap(Class<?> type, Annotation[] annotations) {
         Class<?> concreteType = jaxbTypeMapCache.get(type);
@@ -491,21 +510,21 @@ public abstract class AbstractJAXBProvid
         }
         return concreteType;
     }
-    
+
     @SuppressWarnings("unchecked")
     protected Object marshalWithXmlAdapter(Object obj, Type type, Annotation[] annotations) {
         if ((type == null) || (annotations == null)) {
             return obj;
         }
-        XmlJavaTypeAdapter xmlJavaTypeAdapter = getXmlJavaTypeAdapter(type,
-                annotations);
+        XmlJavaTypeAdapter xmlJavaTypeAdapter = getXmlJavaTypeAdapter(type, annotations);
         if (xmlJavaTypeAdapter != null) {
             try {
                 XmlAdapter xmlAdapter = xmlJavaTypeAdapter.value().newInstance();
                 return xmlAdapter.marshal(obj);
             } catch (Exception e) {
                 if (logger.isDebugEnabled()) {
-                    logger.debug("Could not marshal {} using {} due to exception:", new Object[]{obj, xmlJavaTypeAdapter.value().getName(), e});
+                    logger.debug("Could not marshal {} using {} due to exception:", new Object[] {
+                        obj, xmlJavaTypeAdapter.value().getName(), e});
                 }
             }
         }
@@ -545,28 +564,27 @@ public abstract class AbstractJAXBProvid
         }
         return xmlJavaTypeAdapter;
     }
-    
-    
+
     @SuppressWarnings("unchecked")
     protected Object unmarshalWithXmlAdapter(Object obj, Type type, Annotation[] annotations) {
         if ((type == null) || (annotations == null)) {
             return obj;
         }
-        XmlJavaTypeAdapter xmlJavaTypeAdapter = getXmlJavaTypeAdapter(type,
-                annotations);
+        XmlJavaTypeAdapter xmlJavaTypeAdapter = getXmlJavaTypeAdapter(type, annotations);
         if (xmlJavaTypeAdapter != null) {
             try {
                 XmlAdapter xmlAdapter = xmlJavaTypeAdapter.value().newInstance();
                 return xmlAdapter.unmarshal(obj);
             } catch (Exception e) {
                 if (logger.isDebugEnabled()) {
-                    logger.debug("Could not unmarshal {} using {} due to exception:", new Object[]{obj, xmlJavaTypeAdapter.value().getName(), e});
+                    logger.debug("Could not unmarshal {} using {} due to exception:", new Object[] {
+                        obj, xmlJavaTypeAdapter.value().getName(), e});
                 }
             }
         }
         return obj;
     }
-    
+
     public static boolean isJAXBObject(Class<?> type) {
         return isXMLRootElement(type) || isXMLType(type);
     }
@@ -637,7 +655,15 @@ public abstract class AbstractJAXBProvid
         }
 
         if (contextResolver != null) {
-            context = contextResolver.getContext(type);
+            try {
+                context = contextResolver.getContext(type);
+            } catch (RuntimeException e) {
+                ProviderUtils.logUserProviderException(e,
+                                                       contextResolver,
+                                                       PROVIDER_EXCEPTION_ORIGINATOR.getContext,
+                                                       new Object[] {type},
+                                                       RuntimeContextTLS.getRuntimeContext());
+            }
         }
 
         if (context == null) {
@@ -657,7 +683,8 @@ public abstract class AbstractJAXBProvid
         return context;
     }
 
-    private JAXBContext getDefaultContext(final Class<?> type, final Type genericType) throws JAXBException {
+    private JAXBContext getDefaultContext(final Class<?> type, final Type genericType)
+        throws JAXBException {
         logger.trace("getDefaultContext({}, {}) entry", type, genericType); //$NON-NLS-1$
         try {
             return AccessController.doPrivileged(new PrivilegedExceptionAction<JAXBContext>() {
@@ -693,9 +720,9 @@ public abstract class AbstractJAXBProvid
                     }
                     return context;
                 }
-                
+
             });
-        } catch(PrivilegedActionException e) {
+        } catch (PrivilegedActionException e) {
             throw (JAXBException)e.getException();
         }
     }

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/JAXBXmlProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/JAXBXmlProvider.java?rev=1027186&r1=1027185&r2=1027186&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/JAXBXmlProvider.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/JAXBXmlProvider.java Mon Oct 25 16:32:45 2010
@@ -180,7 +180,9 @@ public class JAXBXmlProvider extends Abs
         try {
             if (isJAXBObject(concreteType)) {
                 JAXBContext context = getContext(concreteType, genericType, mediaType);
-                logger.trace("using context {}@{} to get marshaller", context.getClass().getName(), System.identityHashCode(context)); //$NON-NLS-1$
+                if(logger.isTraceEnabled()) {
+                    logger.trace("using context {}@{} to get marshaller", context.getClass().getName(), System.identityHashCode(context)); //$NON-NLS-1$
+                }
                 Marshaller marshaller = getJAXBMarshaller(concreteType, context, mediaType);
                 Object entityToMarshal = getEntityToMarshal(t, concreteType);
 

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/AbstractMetadata.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/AbstractMetadata.java?rev=1027186&r1=1027185&r2=1027186&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/AbstractMetadata.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/AbstractMetadata.java Mon Oct 25 16:32:45 2010
@@ -29,8 +29,13 @@ import java.util.Set;
 
 import javax.ws.rs.core.MediaType;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 public abstract class AbstractMetadata {
 
+    private static final Logger logger            = LoggerFactory.getLogger(AbstractMetadata.class);
+
     private List<String>   paths;
     private Set<MediaType> consumes;
     private Set<MediaType> produces;
@@ -46,26 +51,38 @@ public abstract class AbstractMetadata {
     }
 
     public String getPath() {
+        logger.trace("getPath() entry");
         if (paths.size() == 0) {
+            logger.trace("getPath() exit returning null");
             return null;
         }
-        return paths.get(0);
+        String p = paths.get(0);
+        logger.trace("getPath() exit returning {}", p);
+        return p;
     }
 
     public void addPath(String path) {
+        logger.trace("addPath({}) entry", path);
         paths.add(path);
+        logger.trace("addPath() exit");
     }
 
     public void addPaths(Collection<String> paths) {
+        logger.trace("addPath({}) entry", paths);
         this.paths.addAll(paths);
+        logger.trace("addPath() exit", paths);
     }
 
     public void addConsumes(MediaType mt) {
+        logger.trace("addConsumes({}) entry", mt);
         consumes.add(mt);
+        logger.trace("addConsumes() exit");
     }
 
     public void addProduces(MediaType mt) {
+        logger.trace("addProduces({}) entry", mt);
         produces.add(mt);
+        logger.trace("addProduces() exit");
     }
 
     public List<String> getPaths() {
@@ -89,7 +106,9 @@ public abstract class AbstractMetadata {
     }
 
     public void setEncoded(boolean encoded) {
+        logger.trace("setEncoded({}) entry", encoded);
         this.encoded = encoded;
+        logger.trace("setEncoded({}) exit", encoded);
     }
 
     public boolean isEncoded() {
@@ -101,6 +120,8 @@ public abstract class AbstractMetadata {
     }
 
     public void setDefaultValue(String defaultValue) {
+        logger.trace("setDefaultValue({}) entry", defaultValue);
         this.defaultValue = defaultValue;
+        logger.trace("setDefaultValue() exit");        
     }
 }

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/AbstractMetadataCollector.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/AbstractMetadataCollector.java?rev=1027186&r1=1027185&r2=1027186&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/AbstractMetadataCollector.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/AbstractMetadataCollector.java Mon Oct 25 16:32:45 2010
@@ -43,8 +43,8 @@ import org.slf4j.LoggerFactory;
  */
 public abstract class AbstractMetadataCollector {
     
-    private static final Logger logger = LoggerFactory.getLogger(AbstractMetadataCollector.class);
-    
+    private static final Logger logger = LoggerFactory.getLogger(AbstractMetadataCollector.class); 
+
     private final ClassMetadata metadata;
 
     public AbstractMetadataCollector(Class<?> clazz) {
@@ -59,10 +59,13 @@ public abstract class AbstractMetadataCo
      * constructor only, when you override parseField() and set it to be final.
      */
     protected final void parseFields() {
+        logger.trace("parseFields() entry");
         Class<?> resourceClass = metadata.getResourceClass();
+        logger.trace("Class is {}", resourceClass);
 
         List<Injectable> injectableFields = metadata.getInjectableFields();
-        
+        logger.trace("Injectable fields: {}", injectableFields);
+
         // add fields
         while (resourceClass != Object.class && resourceClass != null) {
             for (Field field : resourceClass.getDeclaredFields()) {
@@ -103,6 +106,7 @@ public abstract class AbstractMetadataCo
                 }
             }
         }
+        logger.trace("parseFields() exit");
     }
 
     protected abstract Injectable parseAccessibleObject(AccessibleObject field, Type fieldType);
@@ -118,13 +122,16 @@ public abstract class AbstractMetadataCo
      * isConstructorParameterValid() and set it to be final.
      */
     protected final void parseConstructors() {
+        logger.trace("parseConstructors() entry");
         ConstructorMetadata constructorMetadata = new ConstructorMetadata();
         List<Injectable> formalParameters = new ArrayList<Injectable>();
         Class<?> resourceClass = metadata.getResourceClass();
 
         L1: for (Constructor<?> constructor : resourceClass.getDeclaredConstructors()) {
+            logger.trace("Constructor is {}", constructor);
             int modifiers = constructor.getModifiers();
             if (!Modifier.isPublic(modifiers)) {
+                logger.trace("Constructor is skipped because not public");
                 continue;
             }
 
@@ -174,14 +181,19 @@ public abstract class AbstractMetadataCo
             }
         }
 
+        logger.trace("Set constructor to {}", constructorMetadata);
         metadata.setConstructor(constructorMetadata);
+        logger.trace("parseConstructors() exit");
     }
 
     protected void parseEncoded(Class<?> cls) {
+        logger.trace("parseEncoded({}) entry", cls);
         Encoded encoded = cls.getAnnotation(Encoded.class);
         if (encoded != null) {
             metadata.setEncoded(true);
+            logger.trace("parseEncoded() setEncoded to true");
         }
+        logger.trace("parseEncoded() exit");
     }
 
     public ClassMetadata getMetadata() {

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/ApplicationMetadataCollector.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/ApplicationMetadataCollector.java?rev=1027186&r1=1027185&r2=1027186&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/ApplicationMetadataCollector.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/ApplicationMetadataCollector.java Mon Oct 25 16:32:45 2010
@@ -31,50 +31,66 @@ import org.apache.wink.common.internal.r
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-
 /**
  * Collects ClassMetadata from JAX-RS Application classes
  */
 public class ApplicationMetadataCollector extends AbstractMetadataCollector {
 
-    private static final Logger logger = LoggerFactory.getLogger(ApplicationMetadataCollector.class);
+    private static final Logger logger =
+                                           LoggerFactory
+                                               .getLogger(ApplicationMetadataCollector.class);
 
     private ApplicationMetadataCollector(Class<?> clazz) {
         super(clazz);
     }
 
     public static ClassMetadata collectMetadata(Class<?> clazz) {
+        logger.trace("collectMetadata({})", clazz);
         ApplicationMetadataCollector collector = new ApplicationMetadataCollector(clazz);
         collector.parseFields();
         collector.parseConstructors();
-        return collector.getMetadata();
+        ClassMetadata md = collector.getMetadata();
+        logger.trace("collectMetadata() exit returning {}", md);
+        return md;
     }
 
     @Override
     protected final Injectable parseAccessibleObject(AccessibleObject field, Type fieldType) {
+        logger.trace("parseAccessibleObject({}, {})", field, fieldType);
         Injectable injectable =
             InjectableFactory.getInstance().create(fieldType,
                                                    field.getAnnotations(),
                                                    (Member)field,
                                                    getMetadata().isEncoded(),
                                                    null);
+        logger.trace("Injectable is {}", injectable);
         if (injectable.getParamType() == Injectable.ParamType.ENTITY) {
             // EntityParam should be ignored for fields (see JSR-311 3.2)
+            logger.trace("parseAccessibleObject() returning null");
             return null;
         }
+        logger.trace("parseAccessibleObject() returning {}", injectable);
         return injectable;
     }
 
     @Override
     protected final boolean isConstructorParameterValid(Injectable fp) {
+        logger.trace("isConstructorParameterValid({}) entry", fp);
         // This method is declared as final, since parseConstructors(), which
         // calls it, is invoked from the constructor
-        return !(fp.getParamType() == Injectable.ParamType.ENTITY);
+        boolean ret = !(fp.getParamType() == Injectable.ParamType.ENTITY);
+        if (logger.isTraceEnabled()) {
+            logger.trace("isConstructorParameterValid() exit returning {}", ret);
+        }
+        return ret;
     }
-    
+
     @SuppressWarnings("unchecked")
     public static boolean isApplication(Class cls) {
-        return Application.class.isAssignableFrom(cls);
+        logger.trace("isApplication({}) entry", cls);
+        boolean ret = Application.class.isAssignableFrom(cls);
+        logger.trace("isApplication() exit returning {}", ret);
+        return ret;
     }
 
 }
\ No newline at end of file

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/ConstructorMetadata.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/ConstructorMetadata.java?rev=1027186&r1=1027185&r2=1027186&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/ConstructorMetadata.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/ConstructorMetadata.java Mon Oct 25 16:32:45 2010
@@ -25,8 +25,12 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.wink.common.internal.registry.Injectable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class ConstructorMetadata {
+    
+    private static Logger logger = LoggerFactory.getLogger(ConstructorMetadata.class);
 
     private Constructor<?>         constructor;
     private final List<Injectable> formalParameters;
@@ -42,7 +46,9 @@ public class ConstructorMetadata {
     }
 
     public void setConstructor(Constructor<?> constructor) {
+        logger.trace("setConstructor({}) entry", constructor);
         this.constructor = constructor;
+        logger.trace("setConstructor() exit");
     }
 
     public List<Injectable> getFormalParameters() {
@@ -50,7 +56,9 @@ public class ConstructorMetadata {
     }
 
     public void setEncoded(boolean encoded) {
+        logger.trace("setEncoded({}) entry", encoded);
         this.encoded = encoded;
+        logger.trace("setEncoded() exit");
     }
 
     public boolean isEncoded() {

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/MethodMetadata.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/MethodMetadata.java?rev=1027186&r1=1027185&r2=1027186&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/MethodMetadata.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/MethodMetadata.java Mon Oct 25 16:32:45 2010
@@ -70,7 +70,7 @@ public class MethodMetadata extends Abst
     public List<Injectable> getFormalParameters() {
         return formalParameters;
     }
-    
+
     @Override
     public Set<MediaType> getConsumes() {
         Set<MediaType> set = super.getConsumes();

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/ProviderMetadataCollector.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/ProviderMetadataCollector.java?rev=1027186&r1=1027185&r2=1027186&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/ProviderMetadataCollector.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/ProviderMetadataCollector.java Mon Oct 25 16:32:45 2010
@@ -43,6 +43,7 @@ public class ProviderMetadataCollector e
     }
 
     public static boolean isProvider(Class<?> cls) {
+        logger.trace("isProvider({}) entry", cls);
         /*
          * look for the Provider annotation on super classes (even though
          * @Provider does not have @java.lang.annotation.Inherited) in order to
@@ -50,6 +51,7 @@ public class ProviderMetadataCollector e
          */
         // return cls.getAnnotation(Provider.class) != null;
         if (cls == Object.class) {
+            logger.trace("isProvider() exit returning false");
             return false;
         }
 
@@ -57,6 +59,7 @@ public class ProviderMetadataCollector e
             if (logger.isWarnEnabled()) {
                 logger.warn(Messages.getMessage("providerIsInterfaceOrAbstract", cls)); //$NON-NLS-1$
             }
+            logger.trace("isProvider() exit returning false");
             return false;
         }
 
@@ -71,8 +74,9 @@ public class ProviderMetadataCollector e
             Class<?> superclass = declaringClass.getSuperclass();
             if (superclass != null && superclass.getAnnotation(Provider.class) != null) {
                 if (logger.isWarnEnabled()) {
-                    logger.warn(Messages.getMessage("providerShouldBeAnnotatedDirectly", cls)); //$NON-NLS-1$
+                    logger.warn(Messages.getMessage("providerShouldBeAnnotatedDirectly", cls, superclass)); //$NON-NLS-1$
                 }
+                logger.trace("isProvider({}) exit returning true", superclass);
                 return true;
             }
 
@@ -81,22 +85,27 @@ public class ProviderMetadataCollector e
             for (Class<?> interfaceClass : interfaces) {
                 if (interfaceClass.getAnnotation(Provider.class) != null) {
                     if (logger.isWarnEnabled()) {
-                        logger.warn(Messages.getMessage("providerShouldBeAnnotatedDirectly", cls)); //$NON-NLS-1$
+                        logger.warn(Messages.getMessage("providerShouldBeAnnotatedDirectly", cls, interfaceClass)); //$NON-NLS-1$
                     }
+                    logger.trace("isProvider({}) exit returning true", interfaceClass);
                     return true;
                 }
             }
             declaringClass = declaringClass.getSuperclass();
         }
-
+        logger.trace("isProvider() exit returning false");
         return false;
     }
 
     public static ClassMetadata collectMetadata(Class<?> clazz) {
+        logger.trace("collectMetadata({})", clazz);
         ProviderMetadataCollector collector = new ProviderMetadataCollector(clazz);
         collector.parseConstructors();
         collector.parseFields();
-        return collector.getMetadata();
+        
+        ClassMetadata md = collector.getMetadata();
+        logger.trace("collectMetadata() exit returning {}", md);
+        return md;
     }
 
     @Override

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/ResourceMetadataCollector.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/ResourceMetadataCollector.java?rev=1027186&r1=1027185&r2=1027186&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/ResourceMetadataCollector.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/ResourceMetadataCollector.java Mon Oct 25 16:32:45 2010
@@ -66,10 +66,13 @@ public class ResourceMetadataCollector e
 
     public static boolean isStaticResource(Class<?> cls) {
         if (Modifier.isInterface(cls.getModifiers()) || Modifier.isAbstract(cls.getModifiers())) {
+            logger.trace("isStaticResource() exit returning false because interface or abstract");
+
             return false;
         }
 
         if (cls.getAnnotation(Path.class) != null) {
+            logger.trace("isStaticResource() exit returning true");
             return true;
         }
 
@@ -80,8 +83,11 @@ public class ResourceMetadataCollector e
             Class<?> superclass = declaringClass.getSuperclass();
             if (superclass.getAnnotation(Path.class) != null) {
                 if (logger.isWarnEnabled()) {
-                    logger.warn(Messages.getMessage("rootResourceShouldBeAnnotatedDirectly", cls)); //$NON-NLS-1$
+                    logger.warn(Messages
+                        .getMessage("rootResourceShouldBeAnnotatedDirectly", cls, superclass)); //$NON-NLS-1$
                 }
+                logger.trace("isStaticResource() exit returning true because {} has @Path",
+                             superclass);
                 return true;
             }
 
@@ -91,13 +97,17 @@ public class ResourceMetadataCollector e
                 if (interfaceClass.getAnnotation(Path.class) != null) {
                     if (logger.isWarnEnabled()) {
                         logger.warn(Messages.getMessage("rootResourceShouldBeAnnotatedDirectly", //$NON-NLS-1$
-                                                        cls));
+                                                        cls,
+                                                        interfaceClass));
                     }
+                    logger.trace("isStaticResource() exit returning true because {} has @Path",
+                                 interfaceClass);
                     return true;
                 }
             }
             declaringClass = declaringClass.getSuperclass();
         }
+        logger.trace("isStaticResource() exit returning false");
         return false;
     }
 
@@ -106,12 +116,15 @@ public class ResourceMetadataCollector e
     }
 
     public static ClassMetadata collectMetadata(Class<?> clazz) {
+        logger.trace("collectMetadata({}) entry", clazz);
         ResourceMetadataCollector collector = new ResourceMetadataCollector(clazz);
         collector.parseClass();
         collector.parseFields();
         collector.parseConstructors();
         collector.parseMethods();
-        return collector.getMetadata();
+        ClassMetadata md = collector.getMetadata();
+        logger.trace("collectMetadata() exit returning {}", md);
+        return md;
     }
 
     @Override
@@ -135,7 +148,7 @@ public class ResourceMetadataCollector e
     }
 
     private boolean parseClass(Class<?> cls) {
-
+        logger.trace("parseClass({})", cls);
         boolean workspacePresent = parseWorkspace(cls);
         boolean pathPresent = parsePath(cls);
         boolean consumesPresent = parseClassConsumes(cls);
@@ -171,6 +184,7 @@ public class ResourceMetadataCollector e
         Path path = cls.getAnnotation(Path.class);
         if (path != null) {
             getMetadata().addPath(path.value());
+            logger.trace("parseClass() returning true for class direct");
             return true;
         }
 
@@ -182,6 +196,7 @@ public class ResourceMetadataCollector e
             path = superclass.getAnnotation(Path.class);
             if (path != null) {
                 getMetadata().addPath(path.value());
+                logger.trace("parseClass() returning true for superclass {}", superclass);
                 return true;
             }
 
@@ -191,31 +206,37 @@ public class ResourceMetadataCollector e
                 path = interfaceClass.getAnnotation(Path.class);
                 if (path != null) {
                     getMetadata().addPath(path.value());
+                    logger.trace("parseClass() returning true for interface {}", interfaceClass);
                     return true;
                 }
             }
             declaringClass = declaringClass.getSuperclass();
         }
-
+        logger.trace("parseClass() returning false");
         return false;
     }
 
     private void parseMethods() {
+        logger.trace("entry");
         F1: for (Method method : getMetadata().getResourceClass().getMethods()) {
             Class<?> declaringClass = method.getDeclaringClass();
             if (declaringClass == Object.class) {
                 continue F1;
             }
             MethodMetadata methodMetadata = createMethodMetadata(method);
+            logger.trace("Found methodMetadata {} for method {}", methodMetadata, method);
+
             if (methodMetadata != null) {
                 String path = methodMetadata.getPath();
                 String httpMethod = methodMetadata.getHttpMethod();
                 if (path != null) {
                     // sub-resource
                     if (httpMethod != null) {
+                        logger.trace("Was subresource method");
                         // sub-resource method
                         getMetadata().getSubResourceMethods().add(methodMetadata);
                     } else {
+                        logger.trace("Was subresource locator");
                         // sub-resource locator
                         // verify that the method does not take an entity
                         // parameter
@@ -244,15 +265,17 @@ public class ResourceMetadataCollector e
                         getMetadata().getSubResourceLocators().add(methodMetadata);
                     }
                 } else {
+                    logger.trace("Was resource method");
                     // resource method
                     getMetadata().getResourceMethods().add(methodMetadata);
                 }
             }
         }
+        logger.trace("exit");
     }
 
     private MethodMetadata createMethodMetadata(Method method) {
-
+        logger.trace("createMethodMetadata({})", method);
         int modifiers = method.getModifiers();
         // only public, non-static methods
         if (Modifier.isStatic(modifiers) || !Modifier.isPublic(modifiers)) {
@@ -306,7 +329,8 @@ public class ResourceMetadataCollector e
         // but keep the method params as the super may have declared a generic
         // type param
         if (!hasAnnotation) {
-
+            logger
+                .trace("Method did not directly have annotation so going up the class hierarchy chain");
             Class<?> declaringClass = method.getDeclaringClass();
 
             // try a superclass
@@ -316,6 +340,9 @@ public class ResourceMetadataCollector e
                 // stop with if the method found
                 if (createdMetadata != null) {
                     mergeFormalParameterMetadata(createdMetadata, method);
+                    logger.trace("createMethodMetadata() exit returning {} from superclass {}",
+                                 createdMetadata,
+                                 superclass);
                     return createdMetadata;
                 }
             }
@@ -327,11 +354,15 @@ public class ResourceMetadataCollector e
                 // stop with the first method found
                 if (createdMetadata != null) {
                     mergeFormalParameterMetadata(createdMetadata, method);
+                    logger.trace("createMethodMetadata() exit returning {} from interface {}",
+                                 createdMetadata,
+                                 interfaceClass);
                     return createdMetadata;
                 }
             }
 
             // annotations are not inherited. ignore this method.
+            logger.trace("createdMethodMetadata() returning null");
             return null;
         }
 
@@ -342,6 +373,7 @@ public class ResourceMetadataCollector e
             if (metadata.isEncoded() || defaultValue != null) {
                 // property methods may have @Encoded or @DefaultValue but
                 // are not HTTP methods/paths
+                logger.trace("createdMethodMetadata() returning null");
                 return null;
             }
             if (logger.isWarnEnabled()) {
@@ -349,21 +381,26 @@ public class ResourceMetadataCollector e
                                                 method.getName(),
                                                 method.getDeclaringClass().getCanonicalName()));
             }
+            logger.trace("createdMethodMetadata() returning null");
             return null;
         }
 
         parseMethodParameters(method, metadata);
 
+        logger.trace("createMethodMetadata() exit returning {}", metadata);
         return metadata;
     }
 
+    @SuppressWarnings("unchecked")
     private MethodMetadata createMethodMetadata(Class<?> declaringClass, Method method) {
+        logger.trace("createMethodMetadata({}, {}) entry", declaringClass, method);
         try {
             Method declaredMethod =
                 declaringClass.getDeclaredMethod(method.getName(), method.getParameterTypes());
             return createMethodMetadata(declaredMethod);
         } catch (SecurityException e) {
             // can't get to overriding method
+            logger.trace("createMethodMetadata() exit returning null because of SecurityException");
             return null;
         } catch (NoSuchMethodException e) {
             // see if declaringClass's declaredMethod uses generic parameters
@@ -387,14 +424,16 @@ public class ResourceMetadataCollector e
                             if (!clazz.isAssignableFrom(method.getParameterTypes()[i])) {
                                 matchFound = false;
                             }
-                            if (matchFound) {
-                                return createMethodMetadata(candidateMethod);
-                            }
+                        }
+                        if (matchFound) {
+                            return createMethodMetadata(candidateMethod);
                         }
                     }
                 }
             }
             // no overriding method exists
+            logger
+                .trace("createMethodMetadata() exit returning null because of NoSuchMethodException");
             return null;
         }
     }
@@ -470,6 +509,7 @@ public class ResourceMetadataCollector e
     }
 
     private void parseMethodParameters(Method method, MethodMetadata methodMetadata) {
+        logger.trace("parseMethodParameters({}, {}), entry", method, methodMetadata);
         Annotation[][] parameterAnnotations = method.getParameterAnnotations();
         Type[] paramTypes = getParamTypesFilterByXmlElementAnnotation(method);
         boolean entityParamExists = false;
@@ -492,15 +532,17 @@ public class ResourceMetadataCollector e
                 entityParamExists = true;
             }
             methodMetadata.getFormalParameters().add(fp);
+            logger.trace("Adding formal parameter {}", fp);
         }
+        logger.trace("parseMethodParameters(), exit");
     }
 
     private Type[] getParamTypesFilterByXmlElementAnnotation(Method method) {
         int index = 0;
         Type[] paramTypes = method.getGenericParameterTypes();
         Annotation[][] paramAnnotations = method.getParameterAnnotations();
-        for(Annotation[] annos: paramAnnotations) {
-            for(Annotation anno: annos) {
+        for (Annotation[] annos : paramAnnotations) {
+            for (Annotation anno : annos) {
                 if (anno.annotationType().equals(XmlElement.class)) {
                     XmlElement xmlElement = (XmlElement)anno;
                     Type type = xmlElement.type();

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/multipart/OutPart.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/multipart/OutPart.java?rev=1027186&r1=1027185&r2=1027186&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/multipart/OutPart.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/multipart/OutPart.java Mon Oct 25 16:32:45 2010
@@ -98,7 +98,7 @@ public class OutPart {
                     .valueOf(getContentType()));
             if (writer == null) {
                 logger
-                    .warn(Messages.getMessage("couldNotFindWriter", getBody().getClass(), //$NON-NLS-1$
+                    .error(Messages.getMessage("couldNotFindWriter", getBody().getClass(), //$NON-NLS-1$
                            getContentType()));
                 throw new WebApplicationException(500);
             }

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=1027186&r1=1027185&r2=1027186&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 Mon Oct 25 16:32:45 2010
@@ -157,8 +157,8 @@ valueAtIndexIsNull=The value argument at
 variableIsEmpty=The {0} variable is empty. Verify that the variable is not empty.
 resourceNotAnnotated=The resource is not annotated with the {0} annotation.
 methodNotAnnotated=The method is not annotated with the {0} annotation.
-moreThanOneMethodAnnotated=There is more than one method with the {0} annotation. Verify that the annotation is correctly annotated.
-noMethodAnnotated=A method with the {0} annotation does not exist.
+moreThanOneMethodAnnotated=There is more than one method with name {1} in resource {2} with the {0} annotation. Verify that the annotation is used on only one of the methods. 
+noMethodAnnotated=A method with name {1} in resource {2} with the {0} annotation does not exist.
 invalidPort=The port is not valid. Verify that the port specified was correct.
 isInvalid=The {0} value is invalid.
 segmentAtIndexIsNull=The segment at the {0} index is null.



Mime
View raw message