You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wink.apache.org by jr...@apache.org on 2010/10/26 21:52:56 UTC
svn commit: r1027712 [1/5] - in /incubator/wink/trunk:
wink-client-apache-httpclient/ wink-client/ wink-common/
wink-common/src/main/java/org/apache/wink/common/internal/registry/
wink-common/src/main/resources/org/apache/wink/common/internal/i18n/ win...
Author: jramos
Date: Tue Oct 26 19:52:54 2010
New Revision: 1027712
URL: http://svn.apache.org/viewvc?rev=1027712&view=rev
Log:
[Wink-323] Logging improvements for wink-server.
This includes improved logging, debug, and trace for providers, resources, requests, and response.
Also some additional messages and improvements to existing messages in the messages file.
Added:
incubator/wink/trunk/wink-component-test-support/src/main/java/org/apache/wink/logging/InMemoryHandler.java
incubator/wink/trunk/wink-component-test-support/src/main/java/org/slf4j/impl/
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/log/
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/log/LogUtilities.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/log/Providers.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/log/Requests.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/log/ResourceInvocation.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/log/Resources.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/log/Responses.java
incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/log/
incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/log/RequestsTest.java
incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/registry/MissingPathOrProviderWarningTest.java
incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/DebugContextResolverThrowsExceptionTest.java
incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/DebugHandlerThrowsExceptionTest.java
incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/DebugMultipleProvidersAppStartupTest.java
incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/DebugMultipleResourcesAppStartupTest.java
incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/DebugNoMessageBodyWriter500Test.java
incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/DebugNoProvidersAppStartupTest.java
incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/DebugNoResourcesAppStartupTest.java
incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/DebugOneProviderOnlyAppStartupTest.java
incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/DebugOneResourceOnlyAppStartupTest.java
incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/DebugProviderThrowsExceptionTest.java
incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/DebugResourceThrowsExceptionTest.java
incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/DebugSimpleRequestTest.java
incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/DebugSimpleResponseTest.java
incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/InfoMultipleProvidersAppStartupTest.java
incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/InfoMultipleResourcesAppStartupTest.java
incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/InfoNoMessageBodyWriter500Test.java
incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/InfoNoProvidersAppStartupTest.java
incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/InfoNoResourcesAppStartupTest.java
incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/InfoOneProviderOnlyAppStartupTest.java
incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/InfoOneResourceOnlyAppStartupTest.java
incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/WarnProviderDoesNotImplementInterfaceTest.java
incubator/wink/trunk/wink-server/src/test/resources/org/apache/wink/server/serviceability/
incubator/wink/trunk/wink-server/src/test/resources/org/apache/wink/server/serviceability/DebugHandlerThrowsExceptionTest.properties
Removed:
incubator/wink/trunk/wink-component-test-support/src/main/java/org/apache/wink/logging/WinkLoggerAdapter.java
incubator/wink/trunk/wink-component-test-support/src/main/java/org/apache/wink/logging/WinkLoggerFactory.java
Modified:
incubator/wink/trunk/wink-client-apache-httpclient/pom.xml
incubator/wink/trunk/wink-client/pom.xml
incubator/wink/trunk/wink-common/pom.xml
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/ProvidersRegistry.java
incubator/wink/trunk/wink-common/src/main/resources/org/apache/wink/common/internal/i18n/resource.properties
incubator/wink/trunk/wink-component-test-support/src/main/java/org/apache/wink/logging/WinkLogHandler.java
incubator/wink/trunk/wink-component-test-support/src/main/resources/logging.properties
incubator/wink/trunk/wink-examples/pom.xml
incubator/wink/trunk/wink-providers/pom.xml
incubator/wink/trunk/wink-server/pom.xml
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/handlers/AbstractHandlersChain.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/DeploymentConfiguration.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/RequestProcessor.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/application/ApplicationProcessor.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/FindRootResourceHandler.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/FlushResultHandler.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/InvokeMethodHandler.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/OptionsMethodHandler.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/PopulateErrorResponseHandler.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/PopulateResponseMediaTypeHandler.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/registry/ResourceRecord.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/registry/ServerInjectableFactory.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/RestServlet.java
incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/serviceability/ServiceabilityTest.java
Modified: incubator/wink/trunk/wink-client-apache-httpclient/pom.xml
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-client-apache-httpclient/pom.xml?rev=1027712&r1=1027711&r2=1027712&view=diff
==============================================================================
--- incubator/wink/trunk/wink-client-apache-httpclient/pom.xml (original)
+++ incubator/wink/trunk/wink-client-apache-httpclient/pom.xml Tue Oct 26 19:52:54 2010
@@ -56,6 +56,11 @@
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
<dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.apache.wink</groupId>
<artifactId>wink-component-test-support</artifactId>
<scope>test</scope>
Modified: incubator/wink/trunk/wink-client/pom.xml
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-client/pom.xml?rev=1027712&r1=1027711&r2=1027712&view=diff
==============================================================================
--- incubator/wink/trunk/wink-client/pom.xml (original)
+++ incubator/wink/trunk/wink-client/pom.xml Tue Oct 26 19:52:54 2010
@@ -47,6 +47,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>xmlunit</groupId>
Modified: incubator/wink/trunk/wink-common/pom.xml
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/pom.xml?rev=1027712&r1=1027711&r2=1027712&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/pom.xml (original)
+++ incubator/wink/trunk/wink-common/pom.xml Tue Oct 26 19:52:54 2010
@@ -43,6 +43,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>xmlunit</groupId>
Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/ProvidersRegistry.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/ProvidersRegistry.java?rev=1027712&r1=1027711&r2=1027712&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/ProvidersRegistry.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/ProvidersRegistry.java Tue Oct 26 19:52:54 2010
@@ -31,6 +31,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
@@ -760,9 +761,9 @@ public class ProvidersRegistry {
}
public Set<MediaType> getProvidersMediaTypes(Class<?> type) {
- Set<MediaType> mediaTypes = new HashSet<MediaType>();
+ Set<MediaType> mediaTypes = new LinkedHashSet<MediaType>();
- l1: for (Entry<MediaType, HashSet<PriorityObjectFactory<T>>> entry : data.entrySet()) {
+ l1: for (Entry<MediaType, HashSet<PriorityObjectFactory<T>>> entry : entrySet) {
MediaType mediaType = entry.getKey();
Set<PriorityObjectFactory<T>> set = entry.getValue();
for (PriorityObjectFactory<T> t : set) {
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=1027712&r1=1027711&r2=1027712&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 Tue Oct 26 19:52:54 2010
@@ -16,37 +16,35 @@
# under the License.
# Class and Method Validation
-classNotAProvider=The {0} class is not a provider. The runtime is ignoring this class. Add a @javax.ws.rs.ext.Provider annotation to the class.
-classNotAResourceNorProvider=The {0} class is neither a resource nor a provider. The runtime is ignoring this class. Add either a @javax.ws.rs.Path or a @javax.ws.rs.core.Provider annotation to the class.
-classNotADynamicResourceNorResourceNorProvider=The {0} class is not a dynamic resource, resource, or provider. The runtime is ignoring this class. Add the appropriate JAX-RS annotation to this class.
+classNotAProvider=The {0} class is not annotated with @javax.ws.rs.ext.Provider and is being returned by a javax.ws.rs.core.Application subclass. The runtime is ignoring this class. Add a @javax.ws.rs.ext.Provider annotation to the class.
+classNotAResourceNorProvider=The {0} class is neither a resource nor a provider. The runtime is ignoring this class. It was returned from a javax.ws.rs.core.Application subclass. Add either a @javax.ws.rs.Path or a @javax.ws.rs.core.Provider annotation to the class.
+classNotADynamicResourceNorResourceNorProvider=The {0} class is not a dynamic resource, resource, or provider. The runtime is ignoring this class. It was returned from a org.apache.wink.common.WinkApplication. Implement the org.apache.wink.common.DynamicResource interface to make it a dynamic resource, or add either a @javax.ws.rs.Path or a @javax.ws.rs.core.Provider annotation to the class to make it a resource or provider.
classAlreadyAdded=The class {0} was already added to the JAX-RS runtime. The runtime is ignoring this value. Check that this class was not returned in the javax.ws.rs.core.Application subclass getSingletons() and getClasses() methods.
-classNotValid=The class {0} can only have one of the following declarations: {1} {2} {3} . Ensure that the class has only one annotation.
-classIsUnknownProvider=The @javax.ws.rs.ext.Provider annotated class {0} does not implement a recognized Provider interface. Verify that the class implements javax.ws.rs.ext.ContextResolver, javax.ws.rs.ext.ExceptionMapper, javax.ws.rs.ext.MessageBodyReader, or javax.ws.rs.ext.MessageBodyWriter.
+classNotValid=The class {0} can only have one of the following declarations: {1} {2} {3} . Ensure that the class has only one annotation. If the class has only one annotation, ensure that it does not also implement the {2} interface.
+classIsUnknownProvider=The @javax.ws.rs.ext.Provider annotated class {0} does not implement a recognized Provider interface. The runtime is ignoring this class. Verify that the class implements javax.ws.rs.ext.ContextResolver, javax.ws.rs.ext.ExceptionMapper, javax.ws.rs.ext.MessageBodyReader, or javax.ws.rs.ext.MessageBodyWriter.
isNotAClassWithMsgFormat=The {0} is not a class or the class has unresolved dependencies. The runtime is ignoring this value.
resourceClassNotValid=The resource class {0} is not a valid resource. The runtime environment is ignoring this value. Ensure that the resource class has a @javax.ws.rs.Path annotation and that the annotation has a unique value.
rootResourceInstanceIsAnInvalidResource=The root resource {0} instance is not a valid resource. Ensure that the resource instance has a @javax.ws.rs.Path annotation and that the annotation has a unique value.
classInstantiationExceptionWithMsgFormat=The runtime environment failed to instantiate the {0} class. Ensure that the class is not abstract, has a valid constructor, has the right visibility, and is not an inner member class.
classIllegalAccessWithMsgFormat=The runtime environment encountered an illegal access exception to {0}. Ensure that the class is not abstract, has a valid constructor, has the right visibility, and is not an inner member class.
-loadingClassToApplication=The class {0} was added to the application.
-loadingApplication=The runtime is loading the application from {0}
+loadingClassToApplication=The class {0} was added to the JAX-RS application.
+loadingApplication=The runtime is loading the JAX-RS application from {0}
exceptionOccurredDuringClassProcessing=An exception occurred during processing of the {0} class. This class is ignored.
listExceptionDuringClassProcessing=The following exception occurred during processing of class:
exceptionOccurredDuringSingletonProcessing=An exception occurred during processing of the {0} singleton. This singleton is ignored
-listExceptionDuringSingletonProcessing=The following exception occurred during processing of class:
exceptionOccurredDuringInstanceProcessing=An exception occurred during processing of the {0} instance. This instance is ignored.
-listExceptionDuringInstanceProcessing=The following exception occurred during processing of instance:
methodNotAnnotatedCorrectly=The method {0} in the {1} class is not annotated with an HTTP method designator or the @javax.ws.rs.Path annotation. This method is ignored. Annotate this method with a single @javax.ws.rs.GET, @javax.ws.rs.POST, @javax.ws.rs.PUT, @javax.ws.rs.DELETE or any other @javax.ws.rs.HttpMethod annnotation if this method should be a JAX-RS resource method.
subresourceLocatorIllegalEntityParameter=The {0} sub-resource locator contains an illegal entity parameter. The locator is ignored. Remove the entity parameter from the sub-resource locator method definition.
subresourceLocatorAnnotatedConsumesProduces=The {0} sub-resource locator is annotated with @javax.ws.rs.Consumes/@javax.ws.rs.Produces. These annotations are ignored for sub-resource locators.
# Loading config
-configNotFound=The system could not find {0}. This value is ignored.
-exceptionClosingFile=An exception occured when closing a file.
+configNotFound=The system could not find the JAX-RS application config file {0}. This value is ignored.
+exceptionClosingFile=An exception occured when closing the file.
propertyNotDefined=The {0} property was not defined.
alternateShortcutMapLoadFailure=The system failed to load the alternateShortcutMap.
-alternateShortcutMapCloseFailure=An exception occurred when closing the file:
+alternateShortcutMapCloseFailure=An exception occurred when closing the alternate shortcut file:
# Provider Information
uploadDirDoesNotExist=The upload directory {0} does not exist or is not a directory. The entity is uploaded to a default temporary directory defined by the JVM system property "java.io.tmpdir". Create the upload directory and verify that the file permissions are set appropriately.
@@ -55,7 +53,7 @@ cannotUseFileAsResponse=The system canno
jaxbObjectFactoryInstantiate=The system failed to instantiate the object factory for the following class: {0}.
# internals
-mediaTypeSetAlreadyContains=The internal Providers MediaTypeSet already contains the {0} ObjectFactory. This internal warning may be ignored.
+mediaTypeSetAlreadyContains=The internal Providers MediaTypeSet already contains the {0} ObjectFactory.
invalidServletContextAccessor=The context access for the {0} attribute must be for either javax.servlet.http.HttpServletRequest or javax.servlet.http.HttpServletResponse.
# writing
@@ -75,7 +73,7 @@ injectionFailureSingleton=The system can
assetLocatorMethodMoreThanOneEntityParam=The {0} asset locator method has more than one entity parameter. You must use only one entity parameter.
assetMethodInvokeError=An error occurred when the system invoked the {0} asset method.
assetMustHavePublicConstructor=The {0} asset cannot be instantiated. Verify that your assets have a default public constructor defined.
-assetCannotInstantiate=The {0} asset cannot be instantiated.
+assetCannotInstantiate=The {0} asset cannot be instantiated. Verify that your assets have a default public constructor defined.
# JSON Provider
jsonFailWriteJSONObject=The system cannot write the JSONObject to the HTTP response. Verify that the JSONObject is valid.
@@ -94,13 +92,13 @@ jaxbCreateDefaultJAXBElement=The system
# Failure Messages
mediaTypeWrongFormat=The {0} is not a valid MediaType format. You must use the following format: type/subtype.
unhandledExceptionToContainer=An unhandled exception occurred which will be propagated to the container.
-exceptionOccurredDuringInvocation=The following error occurred during the invocation of the handlers chain: {0} while processing {1} request sent to {2}
+exceptionOccurredDuringInvocation=The following error occurred during the invocation of the handlers chain: {0} with message ''{1}'' while processing {2} request sent to {3}
# Contexts
-uriBadBaseURI=The following base URI is not valid: {0}
+uriBadBaseURI=The following base URI syntax is not valid: {0}
# Error Flow
-exceptionOccurredDuringExceptionMapper=An exception occurred while processing the toResponse method of the ExceptionMapper.
+exceptionOccurredDuringExceptionMapper=An exception occurred while processing the toResponse method of the {0} ExceptionMapper.
# WebDAV
webDAVNoEditOrSelfLink=The {0} resource did not set an edit or selflink.
@@ -127,15 +125,15 @@ clientNoReaderForTypeAndMediaType=A java
# Server Handlers
checkLocationHeaderHandlerIllegalArg=The required Location header was not set for the following status code: {0}
-populateResponseMediaTypeHandlerFromCompatibleMessageBodyWriters=The Content-Type header was not specified on the javax.ws.rs.core..Response object or using a @javax.ws.rs.Produces annotation. Therefore, the Content-Type was automatically set using the compatible javax.ws.rs.ext.MessageBodyWriter providers.
+populateResponseMediaTypeHandlerFromCompatibleMessageBodyWriters=The Content-Type header was not specified on the javax.ws.rs.core.Response object or using a @javax.ws.rs.Produces annotation. Therefore, the Content-Type was automatically set using the compatible javax.ws.rs.ext.MessageBodyWriter providers.
populateResponseMediaTypeHandlerNoAcceptableResponse=The client did not list any compatible media types in the Accept request header. The service is automatically sending a HTTP 406 Not Acceptable response to the client.
# Servlet/Filter Messages
-restServletJAXRSApplicationInitParam=The system is using the {0} application class that is named in the {1} init-param initialization parameter.
-restServletWinkApplicationInitParam=The system is using the {0} application class named in the {1} init-param initialization parameter.
+restServletJAXRSApplicationInitParam=The system is using the {0} JAX-RS application class that is named in the {1} init-param initialization parameter.
+restServletWinkApplicationInitParam=The system is using the {0} JAX-RS application class named in the {1} init-param initialization parameter.
restServletUseDeploymentConfigurationParam=The system is using the {0} deployment configuration class named in the {1} init-param initialization parameter.
restServletUsePropertiesFileAtLocation=The system is using the properties file located at {0} named in the {1} init-param initialization parameter.
-restServletRequestProcessorCouldNotBeCreated=The system cannot create the RequestProcessor. Verify that the application configuration is correct.
+restServletRequestProcessorCouldNotBeCreated=The system cannot create the RequestProcessor. Verify that the JAX-RS application configuration is correct.
adminServletRequestProcessorInitBeforeAdmin=The request processor cannot be initialized. Verify that you initialization the request processor before calling the AdminServlet.
adminServletFailCreateJAXBForAdminServlet=The JAXBContext for the AdminServlet class cannot be created. Verify that the required libraries are available.
adminServletFailMarshalObject=The {0} object cannot be marshaled from JAXB into XML content. Verify that the required libraries are available.
@@ -143,35 +141,38 @@ adminServletFailMarshalObject=The {0} ob
# Server
cannotGetOutputStreamSinceWriterRequested=The system cannot obtain the java.io.OutputStream because a java.io.Writer was already requested. Verify that no java.io.Writer was requested before the java.io.OutputStream.
writerCannotGetWriterSinceOutputStreamRequested=The system cannot obtain the java.io.Writer since a java.io.OutputStream was already requested. Verify that no java.io.OutputStream was requested before the java.io.Writer.
-rootResourceCollectionListIsNull=The CollectionList is null. Verify that the application was correctly configured.
+rootResourceCollectionListIsNull=The CollectionList is null. Verify that the JAX-RS application was correctly configured.
parameterHttpsIsEmptyOrNotInitialized=The httpsURI parameter is empty or it is not initialized.
parameterHttpIsEmptyOrNotInitialized=The httpURI parameter is empty or it is not initialized.
uriInfoInvalidURI=A URI was specified with syntax that is not valid. Verify that the URI is valid.
methodCallOutsideScopeOfRequestContext=A method call was made outside the scope of a request context. Verify that the method is called within the context of a JAX-RS request.
+# JCDI
+jcdiSingletonObjectFactoryCannotInstantiateInstance=Cannot create an instance of the JCDI managed bean class {0}. Verify that the bean is a singleton or is annotated with @javax.enterprise.context.ApplicationScoped.
+
# others
-methodCannotHandleType=The method cannot handle {0}.
+methodCannotHandleType=The system cannot determine the class of type {0}.
missingVariable=The {0} variable is missing. Verify that null is not being passed in.
-valueAtIndexIsNull=The value argument at {0} index is null. Verify that the argument at the index specified is not null.
+valueAtIndexIsNull=The value argument at index {0} is null. Verify that the argument at the index specified is not null.
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.
+resourceNotAnnotated=The resource class {1} is not annotated with the {0} annotation.
+methodNotAnnotated=The method {1} is not annotated with the {0} annotation.
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.
-variableIsNull=The value of the {0} variable is null.
+invalidPort=The port value of {0} is not valid. Verify that the port specified was correct.
+isInvalid=The {0} value of {1} is invalid.
+segmentAtIndexIsNull=The segment at index {0} is null. Specify a non-null value at that index.
+variableIsNull=The value of the {0} variable is null. Specify a non-null value.
variableNotSuppliedAValue=The {0} variable was not supplied a value. Provide a value for this variable.
-patternNotCompiled=The pattern not compiled.
+patternNotCompiled=The pattern is not compiled. Compile the pattern with the compile method.
syntaxErrorInvalidTemplateForm=The {0} value contains a syntax error that results in an invalid template form. Verify that the value is a valid template.
valueFromMethodMustBeType=The value that is returned from the {0} method must be of the following type: {1}
notASupportedResourceMethodParam=The {0} type is not a supported resource method parameter.
cannotConvertValueFromTo=The system cannot convert the {0} value to {1}.
-cannotCreateFactoryForClass=A factory for the {0} class cannot be created.
+cannotCreateFactoryForClass=A factory for the {0} class cannot be created. Ensure that it is a valid provider, resource, or JAX-RS application sub-class.
cannotCreateDefaultFactoryForDR=The default factory for the {0} DynamicResource cannot be created.
-cannotCreateDefaultFactoryFor=iThe default factory for the {0} class cannot be created.
+cannotCreateDefaultFactoryFor=The default factory for the {0} class cannot be created.
cookieCannotContainAddlVers=The cookie cannot contain an additional $Version value: {0}
cookieMustStartWithVersion=The cookie must start with a $Version: {0}
cookieDoesNotContainNAMEVALUE=The {0} cookie does not contain a NAME+VALUE.
@@ -187,19 +188,19 @@ cannotMixInlineAndOutOfLine=Do not mix a
failedToCreateJAXBContextFor=The JAXBContext cannot be created for {0}.
contentMayHaveInlineOrOutContent=The content element might have either inline or out-of-line content.
typeAttribMustHaveValidMimeType=The type attribute of the content element must be a valid mime type when the content is out-of-line.
-noValidConstructorFoundFor=A valid constructor could not be found {0}.
+noValidConstructorFoundFor=A valid constructor could not be found for class {0}. Verify that the class has a valid constructor and is not a Java inner class.
unsupportedOperator=The {0} is an unsupported operator.
errorSettingUpAtom=An error occurred setting up the Atom JAXB utilities: {0}
errorOccurredProcessingRequest=An error occurred while processing a request.
-conflictingParameterAnnotations=There are conflicting parameter annotations for {0}. Be sure that the parameter has the correct annotations.
+conflictingParameterAnnotations=There are conflicting parameter annotations for {0}. Two or more parameter annotations are used. Be sure only one annotation is used.
couldNotFindWriter=The system could not find a writer for {0} and {1}. Locate a DataSourceProvider for the JavaBeans Activation Framework (JAF).
cannotCastTo=The system cannot cast {0} to {1}.
mediaTypeHeaderNull=The MediaType header is null.
multiPartStreamAlreadyClosed=The stream is already closed. The PartInputStream is not accessible after moving to the next part.
lastMatchWasUnsuccessful=The last match was unsuccessful.
variableContainsMoreThanOneValueForJoinOperator=The {0} variable contains more than one value for the join operator.
-matchedSuffixMustEndWith=The matched suffix must end with '{0}'.
-matchedSuffixMustStartWith=The matched suffix must start with '{0}'.
+matchedSuffixMustEndWith=The matched suffix must end with ''{0}''.
+matchedSuffixMustStartWith=The matched suffix must start with ''{0}''.
listOperatorMustHaveOnlyOneVariable=The list operator must only have one variable.
suffixOperatorMustOnlyHaveOneVariable=The suffix operator must have only one variable.
prefixOperatorMustHaveOnlyOneVariable=The prefix operator must have only one variable.
@@ -207,21 +208,26 @@ missingClientAuthenticationCredentialFor
missingClientAuthenticationCredentialForProxyUser=The client authentication is missing a credential for proxy user: {0}
serviceFailedToAuthenticateUser=The service failed to authenticate user: {0}
serviceFailedToAuthenticateProxyUser=The proxy failed to authenticate proxy user: {0}
-providerShouldBeAnnotatedDirectly=The @javax.ws.rs.ext.Provider annotation was found on a superclass or interface on the {0} class. Annotate @javax.ws.rs.ext.Provider on the provider class directly to ensure portability between environments.
-rootResourceShouldBeAnnotatedDirectly=The @javax.ws.rs.Path annotation was found on a superclass or interface on the {0} class. Annotate @javax.ws.rs.Path on the root resource class directly to ensure portability between environments.
+providerShouldBeAnnotatedDirectly=The @javax.ws.rs.ext.Provider annotation was found on the superclass or interface {1} of the {0} class. Annotate @javax.ws.rs.ext.Provider on the provider class directly to ensure portability between environments.
+rootResourceShouldBeAnnotatedDirectly=The @javax.ws.rs.Path annotation was found on the superclass or interface {1} of the {0} class. Annotate @javax.ws.rs.Path on the root resource class directly to ensure portability between environments.
providerIsInterfaceOrAbstract=A @javax.ws.rs.ext.Provider annotation was found on {0} which is an interface or an abstract class and is being ignored. Annotate @javax.ws.rs.ext.Provider on the provider implementation or base class directly and return that in your javax.ws.rs.core.Application subclass.
entityRefsNotSupported=Entity references are not supported in XML documents due to possible security vulnerabilities.
entityRefsNotSupportedSunJDK5=Entity references are not supported in XML documents due to possible security vulnerabilities. Sun JDK5 does not support the necessary feature to prevent a NullPointerException. See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6181020
saxParseException=The system cannot parse the XML content into a {0} instance. Verify that the XML content is valid.
saxParserConfigurationException=The system cannot configure the SAX parser with the given configuration parameter.
badXMLReaderInitialStart=The XMLStreamReader instance has already been partially processed.
+exceptionDuringInjection=Exception encountered during JCDI injection
+couldNotFindBeanManager=Could not find BeanManager.
processingRequestTo=Processing {0} request to {1}, source content type is {2}, acceptable media types include {3}
-registeredResources=Registered resources: {0}
+registeredResources=Registered JAX-RS resources: {0}
followingProviders=The following JAX-RS providers are registered: {0}
followingProvidersUserDefined=The following user-defined JAX-RS providers are registered: {0}
-applicationProcessed=The following application has been processed: {0}
-multipleHttpMethodAnnotations=Multiple http method annotations on method {0} in class {1}
+applicationProcessed=The following JAX-RS application has been processed: {0}
+multipleHttpMethodAnnotations=Multiple javax.ws.rs.HttpMethod annotations on method {0} in class {1} were found. Use only a single annotation on the method.
resourceMethodMoreThanOneEntityParam=The {0} method has more than one entity parameter. You must use only one entity parameter.
-exceptionDuringInjection=Exception encountered during JCDI injection
-couldNotFindBeanManager=Could not find BeanManager.
-jcdiSingletonObjectFactoryCannotInstantiateInstance=Cannot create an instance of the JCDI managed bean class {0}. Verify that the bean is a singleton or is annotated with @javax.enterprise.context.ApplicationScoped.
+serverRegisterJAXRSResourceWithPath=The server has registered the JAX-RS resource class {0} with @Path({1}).
+noJAXRSApplicationDefinedProviders=There are no custom JAX-RS providers defined in the application.
+registeredJAXRSProviderWithMediaTypeAndAllGenericType=The class {0} was registered as a JAX-RS {1} provider for all Java types and {2} media types.
+registeredJAXRSProviderWithMediaType=The class {0} was registered as a JAX-RS {1} provider for {2} Java types and {3} media types.
+registeredJAXRSProviderWithoutMediaType=The class {0} was registered as a JAX-RS {1} provider for {2} Java types.
+registeredJAXRSProviderWithoutMediaTypeAndAllGenericType=The class {0} was registered as a JAX-RS {1} provider for all Java types.
Added: incubator/wink/trunk/wink-component-test-support/src/main/java/org/apache/wink/logging/InMemoryHandler.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-component-test-support/src/main/java/org/apache/wink/logging/InMemoryHandler.java?rev=1027712&view=auto
==============================================================================
--- incubator/wink/trunk/wink-component-test-support/src/main/java/org/apache/wink/logging/InMemoryHandler.java (added)
+++ incubator/wink/trunk/wink-component-test-support/src/main/java/org/apache/wink/logging/InMemoryHandler.java Tue Oct 26 19:52:54 2010
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.wink.logging;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Handler;
+import java.util.logging.LogRecord;
+
+public class InMemoryHandler extends Handler {
+
+ private List<LogRecord> records = new ArrayList<LogRecord>();
+
+ @Override
+ public void close() throws SecurityException {
+ /* do nothing */
+ }
+
+ @Override
+ public void flush() {
+ /* do nothing */
+ }
+
+ @Override
+ public void publish(LogRecord record) {
+ records.add(record);
+ }
+
+ /**
+ * Returns a live List of the records.
+ */
+ public List<LogRecord> getRecords() {
+ return records;
+ }
+}
Modified: incubator/wink/trunk/wink-component-test-support/src/main/java/org/apache/wink/logging/WinkLogHandler.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-component-test-support/src/main/java/org/apache/wink/logging/WinkLogHandler.java?rev=1027712&r1=1027711&r2=1027712&view=diff
==============================================================================
--- incubator/wink/trunk/wink-component-test-support/src/main/java/org/apache/wink/logging/WinkLogHandler.java (original)
+++ incubator/wink/trunk/wink-component-test-support/src/main/java/org/apache/wink/logging/WinkLogHandler.java Tue Oct 26 19:52:54 2010
@@ -21,28 +21,33 @@
package org.apache.wink.logging;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogRecord;
+import java.util.logging.Logger;
public class WinkLogHandler extends Handler {
-
+
public enum LEVEL {
INFO, DEBUG, TRACE
}
- static private ArrayList<LogRecord> logRecords = new ArrayList<LogRecord>();
- static boolean storeLogsOn = false;
- static LEVEL level;
-
+ static private List<LogRecord> logRecords = new ArrayList<LogRecord>();
+ static boolean storeLogsOn = false;
+ static LEVEL level;
+
@Override
public void close() throws SecurityException {
+ /* do nothing */
}
@Override
public void flush() {
+ /* do nothing */
}
-
+
public static Level getLogLevel() {
if (level != null) {
if (level.equals(LEVEL.INFO)) {
@@ -68,42 +73,74 @@ public class WinkLogHandler extends Hand
}
}
}
-
+
+ private static WinkLogHandler handler;
+
/**
* turns logging capture on
*/
public static void turnLoggingCaptureOn(LEVEL _level) {
+ Logger logger = Logger.getLogger("org.apache.wink");
+
+ if (handler == null) {
+ handler = new WinkLogHandler();
+ handler.setLevel(Level.FINEST);
+ }
+ Handler[] handlers = logger.getHandlers();
+
+ clearRecords();
+ if (handlers == null || !Arrays.asList(handlers).contains(handler)) {
+ logger.addHandler(handler);
+ }
+
+ switch(_level) {
+ case INFO:
+ logger.setLevel(Level.INFO);
+ break;
+ case DEBUG:
+ logger.setLevel(Level.FINE);
+ break;
+ case TRACE:
+ logger.setLevel(Level.FINEST);
+ break;
+ }
+
level = _level;
storeLogsOn = true;
}
-
+
/**
* turns logging capture off
*/
public static void turnLoggingCaptureOff() {
+ Logger logger = Logger.getLogger("org.apache.wink");
+ logger.removeHandler(handler);
+ logger.setLevel(Level.OFF);
storeLogsOn = false;
level = null;
}
-
+
/**
- * get all captured LogRecords. It is recommended that you inspect the returned list,
- * perform the desired asserts, then call clearRecords to clean up the list prior to the
- * next test that may wish to also capture logging.
+ * get all captured LogRecords. It is recommended that you inspect the
+ * returned list, perform the desired asserts, then call clearRecords to
+ * clean up the list prior to the next test that may wish to also capture
+ * logging.
*
* @return ArrayList of LogRecords captured
*/
- public static ArrayList<LogRecord> getRecords() {
+ public static List<LogRecord> getRecords() {
return logRecords;
}
-
+
/**
- * Get only the records associated with the logger for a particular name. Typically, this will
- * be the class name of the production class under test.
+ * Get only the records associated with the logger for a particular name.
+ * Typically, this will be the class name of the production class under
+ * test.
*
* @param logName
* @return filtered ArrayList of LogRecords captured
*/
- public static ArrayList<LogRecord> getRecordsFilteredBy(String logName) {
+ public static List<LogRecord> getRecordsFilteredBy(String logName) {
ArrayList<LogRecord> filtered = new ArrayList<LogRecord>();
for (int i = 0; i < logRecords.size(); i++) {
if (logRecords.get(i).getLoggerName().equals(logName)) {
@@ -112,10 +149,11 @@ public class WinkLogHandler extends Hand
}
return filtered;
}
-
+
/**
- * Clear all logRecords from the captured list. It is recommended that test methods do this
- * to clean up prior to the next test that may wish to also capture logging.
+ * Clear all logRecords from the captured list. It is recommended that test
+ * methods do this to clean up prior to the next test that may wish to also
+ * capture logging.
*/
public static void clearRecords() {
logRecords.clear();
Modified: incubator/wink/trunk/wink-component-test-support/src/main/resources/logging.properties
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-component-test-support/src/main/resources/logging.properties?rev=1027712&r1=1027711&r2=1027712&view=diff
==============================================================================
--- incubator/wink/trunk/wink-component-test-support/src/main/resources/logging.properties (original)
+++ incubator/wink/trunk/wink-component-test-support/src/main/resources/logging.properties Tue Oct 26 19:52:54 2010
@@ -21,13 +21,13 @@
handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler
# Set the default logging level for the root logger
-.level = DEBUG
+.level = INFO
# Set the default logging level for new ConsoleHandler instances
-java.util.logging.ConsoleHandler.level = DEBUG
+java.util.logging.ConsoleHandler.level = ALL
# Set the default logging level for new FileHandler instances
-java.util.logging.FileHandler.level = DEBUG
+java.util.logging.FileHandler.level = ALL
# Set the default formatter for new ConsoleHandler instances
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
Modified: incubator/wink/trunk/wink-examples/pom.xml
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/pom.xml?rev=1027712&r1=1027711&r2=1027712&view=diff
==============================================================================
--- incubator/wink/trunk/wink-examples/pom.xml (original)
+++ incubator/wink/trunk/wink-examples/pom.xml Tue Oct 26 19:52:54 2010
@@ -36,7 +36,14 @@
<module>core</module>
<module>client</module>
<module>ext</module>
- </modules>
+ </modules>
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
<!-- The definition for the repositories was added to enable building the examples from the distribution zip (the parent will be located through this definition) -->
<!--
<repositories>
Modified: incubator/wink/trunk/wink-providers/pom.xml
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/pom.xml?rev=1027712&r1=1027711&r2=1027712&view=diff
==============================================================================
--- incubator/wink/trunk/wink-providers/pom.xml (original)
+++ incubator/wink/trunk/wink-providers/pom.xml Tue Oct 26 19:52:54 2010
@@ -45,5 +45,10 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
Modified: incubator/wink/trunk/wink-server/pom.xml
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/pom.xml?rev=1027712&r1=1027711&r2=1027712&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/pom.xml (original)
+++ incubator/wink/trunk/wink-server/pom.xml Tue Oct 26 19:52:54 2010
@@ -66,6 +66,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>xmlunit</groupId>
@@ -108,6 +109,12 @@
<version>2.5.1</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.jmock</groupId>
+ <artifactId>jmock-legacy</artifactId>
+ <version>2.5.1</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/handlers/AbstractHandlersChain.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/handlers/AbstractHandlersChain.java?rev=1027712&r1=1027711&r2=1027712&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/handlers/AbstractHandlersChain.java (original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/handlers/AbstractHandlersChain.java Tue Oct 26 19:52:54 2010
@@ -57,7 +57,9 @@ public abstract class AbstractHandlersCh
// get the next handler from the chain to handle
T handler = iterator.next();
// invoke the handler
- logger.trace("Invoking handler: {}", handler.getClass().getName()); //$NON-NLS-1$
+ if(logger.isTraceEnabled()) {
+ logger.trace("Invoking handler: {}", handler.getClass().getName()); //$NON-NLS-1$
+ }
handle(handler, context);
} finally {
// set the iterator back one handler on the chain so the same
Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/DeploymentConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/DeploymentConfiguration.java?rev=1027712&r1=1027711&r2=1027712&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/DeploymentConfiguration.java (original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/DeploymentConfiguration.java Tue Oct 26 19:52:54 2010
@@ -69,6 +69,9 @@ import org.apache.wink.server.internal.h
import org.apache.wink.server.internal.handlers.PopulateResponseMediaTypeHandler;
import org.apache.wink.server.internal.handlers.PopulateResponseStatusHandler;
import org.apache.wink.server.internal.handlers.SearchResultHandler;
+import org.apache.wink.server.internal.log.Requests;
+import org.apache.wink.server.internal.log.ResourceInvocation;
+import org.apache.wink.server.internal.log.Responses;
import org.apache.wink.server.internal.registry.ResourceRegistry;
import org.apache.wink.server.internal.registry.ServerInjectableFactory;
import org.slf4j.Logger;
@@ -160,6 +163,44 @@ public class DeploymentConfiguration imp
initAlternateShortcutMap();
initMediaTypeMapper();
initHandlers();
+
+ // this next code is to dump the config to trace after initialization
+ if (logger.isDebugEnabled()) {
+ try {
+ logger.debug("Configuration Settings:");
+ logger.trace("Request Handlers Chain : {}", requestHandlersChain);
+ logger.trace("Response Handlers Chain: {}", responseHandlersChain);
+ logger.trace("Error Handlers Chain: {}", errorHandlersChain);
+ logger.debug("Request User Handlers: {}", String
+ .format("%1$s", requestUserHandlers));
+ logger.debug("Response User Handlers: {}", String.format("%1$s",
+ responseUserHandlers));
+ logger.debug("Error User Handlers: {}", String.format("%1$s", errorUserHandlers));
+ logger.trace("LifecycleManagerRegistry: {}", this.ofFactoryRegistry
+ .getLifecycleManagers());
+ logger.debug("MediaTypeMapper: {}", this.mediaTypeMapper); // TODO
+ // add
+ // toString
+ // method
+ // for
+ // MediaTypeMapper
+ logger.debug("AlternateShortcutMap: {}", this.alternateShortcutMap);
+ logger.debug("Properties: {}", this.properties);
+ logger.trace("ServletConfig: {}", this.servletConfig);
+ logger.trace("ServletContext: {}", this.servletContext);
+ logger.trace("FilterConfig: {}", this.filterConfig);
+ logger.trace("Applications: {}", this.applications);
+ List<String> httpMethodOverrideHeadersList = new ArrayList<String>();
+ if (this.httpMethodOverrideHeaders != null) {
+ for (int i = 0; i < this.httpMethodOverrideHeaders.length; ++i)
+ httpMethodOverrideHeadersList.add(this.httpMethodOverrideHeaders[i]);
+ }
+ logger.debug("HttpMethodOverrideHeaders: {}", httpMethodOverrideHeadersList);
+ } catch (Exception e) {
+ // make sure we don't fail in case anything wrong happens here
+ logger.debug("An Exception occurred when logging the configuration {}", e);
+ }
+ }
}
public RequestHandlersChain getRequestHandlersChain() {
@@ -465,8 +506,11 @@ public class DeploymentConfiguration imp
*
* @see initRequestUserHandlers
*/
+ @SuppressWarnings("unchecked")
protected RequestHandlersChain initRequestHandlersChain() {
RequestHandlersChain handlersChain = new RequestHandlersChain();
+ handlersChain.addHandler(createHandler(Requests.class));
+ handlersChain.addHandler(createHandler(ResourceInvocation.class));
handlersChain.addHandler(createHandler(SearchResultHandler.class));
handlersChain.addHandler(createHandler(OptionsMethodHandler.class));
handlersChain.addHandler(createHandler(HeadMethodHandler.class));
@@ -529,6 +573,7 @@ public class DeploymentConfiguration imp
*/
protected ResponseHandlersChain initResponseHandlersChain() {
ResponseHandlersChain handlersChain = new ResponseHandlersChain();
+ handlersChain.addHandler(createHandler(Responses.class));
handlersChain.addHandler(createHandler(PopulateResponseStatusHandler.class));
handlersChain.addHandler(createHandler(PopulateResponseMediaTypeHandler.class));
if (responseUserHandlers != null) {
@@ -550,6 +595,11 @@ public class DeploymentConfiguration imp
*/
protected ResponseHandlersChain initErrorHandlersChain() {
ResponseHandlersChain handlersChain = new ResponseHandlersChain();
+
+ Responses responsesHandler = createHandler(Responses.class);
+ responsesHandler.setIsErrorFlow(true);
+ handlersChain.addHandler(responsesHandler);
+
handlersChain.addHandler(createHandler(PopulateErrorResponseHandler.class));
handlersChain.addHandler(createHandler(PopulateResponseStatusHandler.class));
PopulateResponseMediaTypeHandler populateMediaTypeHandler =
@@ -567,7 +617,7 @@ public class DeploymentConfiguration imp
return handlersChain;
}
- private <T extends Handler> T createHandler(Class<T> cls) {
+ protected <T extends Handler> T createHandler(Class<T> cls) {
try {
T handler = cls.newInstance();
logger.trace("Calling {}.init(Properties)", cls); //$NON-NLS-1$
Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/RequestProcessor.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/RequestProcessor.java?rev=1027712&r1=1027711&r2=1027712&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/RequestProcessor.java (original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/RequestProcessor.java Tue Oct 26 19:52:54 2010
@@ -36,6 +36,7 @@ import javax.ws.rs.core.Response.Status;
import org.apache.wink.common.RuntimeContext;
import org.apache.wink.common.WinkApplication;
+import org.apache.wink.common.internal.application.ApplicationExceptionAttribute;
import org.apache.wink.common.internal.i18n.Messages;
import org.apache.wink.common.internal.runtime.RuntimeContextTLS;
import org.apache.wink.server.internal.application.ServletApplicationFileLoader;
@@ -58,21 +59,22 @@ public class RequestProcessor {
private static final Logger logger =
LoggerFactory
.getLogger(RequestProcessor.class);
- private static final String PROPERTY_ROOT_RESOURCE_NONE = "none"; //$NON-NLS-1$
- private static final String PROPERTY_ROOT_RESOURCE_ATOM = "atom"; //$NON-NLS-1$
- private static final String PROPERTY_ROOT_RESOURCE_ATOM_HTML = "atom+html"; //$NON-NLS-1$
+ private static final String PROPERTY_ROOT_RESOURCE_NONE = "none"; //$NON-NLS-1$
+ private static final String PROPERTY_ROOT_RESOURCE_ATOM = "atom"; //$NON-NLS-1$
+ private static final String PROPERTY_ROOT_RESOURCE_ATOM_HTML = "atom+html"; //$NON-NLS-1$
private static final String PROPERTY_ROOT_RESOURCE_DEFAULT =
PROPERTY_ROOT_RESOURCE_ATOM_HTML;
- private static final String PROPERTY_ROOT_RESOURCE = "wink.rootResource"; //$NON-NLS-1$
+ private static final String PROPERTY_ROOT_RESOURCE = "wink.rootResource"; //$NON-NLS-1$
private static final String PROPERTY_ROOT_RESOURCE_CSS =
- "wink.serviceDocumentCssPath"; //$NON-NLS-1$
+ "wink.serviceDocumentCssPath"; //$NON-NLS-1$
private static final String PROPERTY_LOAD_WINK_APPLICATIONS =
- "wink.loadApplications"; //$NON-NLS-1$
+ "wink.loadApplications"; //$NON-NLS-1$
- private final DeploymentConfiguration configuration;
+ // keep track of whether an application-originated exception has already been logged so we don't
+ // accidentally log sensitive application stack information
+ private boolean alreadyLogged = false;
- private String requestString; // save off the request string in case we need to log it
- private String requestMethod; // save off the request method in case we need to log it
+ private final DeploymentConfiguration configuration;
public RequestProcessor(DeploymentConfiguration configuration) {
this.configuration = configuration;
@@ -139,24 +141,55 @@ public class RequestProcessor {
public void handleRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException {
try {
- requestMethod = request.getMethod();
- requestString = request.getRequestURL().toString();
- requestString += ((request.getQueryString() != null && request.getQueryString().length() > 0) ? ("?" + request.getQueryString()) : ""); //$NON-NLS-1$ $NON-NLS-2$
if (logger.isDebugEnabled()) {
- logger.debug(Messages.getMessage("processingRequestTo", requestMethod, requestString, request.getContentType(), request.getHeader("Accept"))); //$NON-NLS-1$ $NON-NLS-2$
+ String requestMethod = request.getMethod();
+ String requestString = request.getRequestURL().toString();
+ requestString +=
+ ((request.getQueryString() != null && request.getQueryString().length() > 0)
+ ? ("?" + request.getQueryString()) : ""); //$NON-NLS-1$ $NON-NLS-2$
+ logger
+ .debug(Messages
+ .getMessage("processingRequestTo", requestMethod, requestString, request.getContentType(), request.getHeader("Accept"))); //$NON-NLS-1$ $NON-NLS-2$
}
handleRequestWithoutFaultBarrier(request, response);
} catch (Throwable t) {
// exception was not handled properly
- if (logger.isTraceEnabled()) {
- logger.trace(Messages.getMessage("unhandledExceptionToContainer"), t); //$NON-NLS-1$
+ ApplicationExceptionAttribute appEx = null;
+ RuntimeContext runtimeContext = RuntimeContextTLS.getRuntimeContext();
+ if (runtimeContext != null) {
+ appEx = runtimeContext.getAttribute(ApplicationExceptionAttribute.class);
+ }
+ if (appEx != null && (appEx.getDebugMsg() != null)) {
+ // This exception originated from an application class, such as a resource or provider
+ // See unittest class DebugResourceThrowsExceptionTest.
+ if (logger.isDebugEnabled()) {
+ logger.debug(appEx.getDebugMsg());
+ }
+ // although we may not have actually called the logger, we want to prevent logging sensitive application stack
+ alreadyLogged = true;
} else {
- if (logger.isInfoEnabled()) {
- logger.info(Messages.getMessage("unhandledExceptionToContainer")); //$NON-NLS-1$
+ if (logger.isTraceEnabled()) {
+ if (alreadyLogged) {
+ // don't log possibly sensitive application stack
+ logger.trace(Messages.getMessage("unhandledExceptionToContainer")); //$NON-NLS-1$
+ } else {
+ logger.trace(Messages.getMessage("unhandledExceptionToContainer"), t); //$NON-NLS-1$
+ }
+ } else {
+ if (logger.isErrorEnabled()) {
+ if (alreadyLogged) {
+ // don't log possibly sensitive application stack
+ logger.error(Messages.getMessage("unhandledExceptionToContainer")); //$NON-NLS-1$
+ } else {
+ logger.error(Messages.getMessage("unhandledExceptionToContainer"), t); //$NON-NLS-1$
+ }
+ }
}
}
+ // reset flag:
+ alreadyLogged = false;
if (t instanceof RuntimeException) {
- // let the servlet container to handle the runtime exception
+ // let the servlet container handle the runtime exception
throw (RuntimeException)t;
}
throw new ServletException(t);
@@ -190,7 +223,7 @@ public class RequestProcessor {
RuntimeContext originalContext = RuntimeContextTLS.getRuntimeContext();
ServerMessageContext msgContext = null;
try {
- logException(t);
+ logException(t, request);
msgContext = createMessageContext(request, response);
RuntimeContextTLS.setRuntimeContext(msgContext);
msgContext.setResponseEntity(t);
@@ -236,8 +269,28 @@ public class RequestProcessor {
}
}
- private void logException(Throwable t) {
+ private void logException(Throwable t, HttpServletRequest request) {
+ ApplicationExceptionAttribute appEx = RuntimeContextTLS.getRuntimeContext().getAttribute(ApplicationExceptionAttribute.class);
+
+ if (appEx != null && (appEx.getDebugMsg() != null)) {
+ // This exception originated from an application class, such as a resource or provider
+ // See unittest class DebugResourceThrowsExceptionTest.
+ if (logger.isDebugEnabled()) {
+ logger.debug(appEx.getDebugMsg());
+ }
+ // although we may not have actually called the logger, we want to prevent logging sensitive application stack
+ alreadyLogged = true;
+ return;
+ }
+
String messageFormat;
+
+ String requestMethod = request.getMethod();
+ String requestString = request.getRequestURL().toString();
+ requestString +=
+ ((request.getQueryString() != null && request.getQueryString().length() > 0)
+ ? ("?" + request.getQueryString()) : ""); //$NON-NLS-1$ $NON-NLS-2$
+
if (t instanceof WebApplicationException) {
WebApplicationException wae = (WebApplicationException)t;
int statusCode = wae.getResponse().getStatus();
@@ -248,28 +301,38 @@ public class RequestProcessor {
statusSep = " - "; //$NON-NLS-1$
statusMessage = status.toString();
}
+
String exceptionName =
- String.format("%s (%d%s%s)", t.getClass().getSimpleName(), statusCode, statusSep, statusMessage); //$NON-NLS-1$
- messageFormat = Messages.getMessage("exceptionOccurredDuringInvocation", exceptionName, requestMethod, requestString); //$NON-NLS-1$
+ String
+ .format("%s (%d%s%s)", t.getClass().getSimpleName(), statusCode, statusSep, statusMessage); //$NON-NLS-1$
+ messageFormat =
+ Messages
+ .getMessage("exceptionOccurredDuringInvocation", exceptionName, wae.getMessage(), requestMethod, requestString); //$NON-NLS-1$
} else {
- messageFormat = Messages.getMessage("exceptionOccurredDuringInvocation", t.getClass().getSimpleName(), requestMethod, requestString); //$NON-NLS-1$
+ messageFormat =
+ Messages
+ .getMessage("exceptionOccurredDuringInvocation", t.getClass().getSimpleName(), t.getMessage(), requestMethod, requestString); //$NON-NLS-1$
}
if (logger.isDebugEnabled()) {
logger.debug(messageFormat, t);
ResourceRegistry rr = this.configuration.getResourceRegistry();
List<ResourceRecord> resourceRecords = rr.getRecords();
StringBuffer sb = new StringBuffer();
+ String newLine = System.getProperty("line.separator"); //$NON-NLS-1$
for (ResourceRecord record : resourceRecords) {
- sb.append("\n " + record.toString()); //$NON-NLS-1$
+ sb.append(newLine + " " + record.toString()); //$NON-NLS-1$
}
- logger.debug(Messages.getMessage("registeredResources", (sb.toString().length() > 0) ? sb.toString() : "{}")); //$NON-NLS-1$ $NON-NLS-2$
- logger.debug(this.configuration.getProvidersRegistry().getLogFormattedProvidersList(true));
+ logger
+ .debug(Messages
+ .getMessage("registeredResources", (sb.toString().length() > 0) ? sb.toString() : "{}")); //$NON-NLS-1$ $NON-NLS-2$
+ logger.debug(this.configuration.getProvidersRegistry()
+ .getLogFormattedProvidersList(true));
} else {
- logger.info(messageFormat);
+ logger.info(messageFormat); // TODO should we log all the 404s?
}
}
- private ServerMessageContext createMessageContext(HttpServletRequest request,
+ private ServerMessageContext createMessageContext(HttpServletRequest request,
HttpServletResponse response) {
ServerMessageContext messageContext =
new ServerMessageContext(request, response, configuration);
@@ -302,4 +365,5 @@ public class RequestProcessor {
new Object[] {this, attributeName, servletContext});
servletContext.setAttribute(attributeName, this);
}
+
}
Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/application/ApplicationProcessor.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/application/ApplicationProcessor.java?rev=1027712&r1=1027711&r2=1027712&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/application/ApplicationProcessor.java (original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/application/ApplicationProcessor.java Tue Oct 26 19:52:54 2010
@@ -20,7 +20,6 @@
package org.apache.wink.server.internal.application;
import java.lang.reflect.Modifier;
-import java.util.List;
import java.util.Set;
import javax.ws.rs.core.Application;
@@ -30,7 +29,6 @@ import org.apache.wink.common.internal.i
import org.apache.wink.common.internal.registry.ProvidersRegistry;
import org.apache.wink.common.internal.registry.metadata.ProviderMetadataCollector;
import org.apache.wink.common.internal.registry.metadata.ResourceMetadataCollector;
-import org.apache.wink.server.internal.registry.ResourceRecord;
import org.apache.wink.server.internal.registry.ResourceRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -57,9 +55,9 @@ public class ApplicationProcessor {
private final boolean isSystemApplication;
public ApplicationProcessor(Application application,
- ResourceRegistry resourceRegistry,
- ProvidersRegistry providersRegistry,
- boolean isSystemApplication) {
+ ResourceRegistry resourceRegistry,
+ ProvidersRegistry providersRegistry,
+ boolean isSystemApplication) {
super();
this.application = application;
this.resourceRegistry = resourceRegistry;
@@ -93,16 +91,11 @@ public class ApplicationProcessor {
}
// always produce INFO output after completing application processing:
- logger.info(Messages.getMessage("applicationProcessed", application.getClass().getName())); //$NON-NLS-1$
- List<ResourceRecord> resourceRecords = resourceRegistry.getRecords();
- StringBuffer sb = new StringBuffer();
- for (ResourceRecord record : resourceRecords) {
- sb.append("\n " + record.toString()); //$NON-NLS-1$
- }
- logger.info(Messages.getMessage("registeredResources", (sb.length() > 0) ? sb.toString() : "{}")); //$NON-NLS-1$ $NON-NLS-2$
- logger.info(providersRegistry.getLogFormattedProvidersList(true));
- // done with INFO
-
+ if (!isSystemApplication && logger.isInfoEnabled()) {
+ logger.info(Messages
+ .getMessage("applicationProcessed", application.getClass().getName())); //$NON-NLS-1$
+ }
+
logger.trace("Processing of Application completed."); //$NON-NLS-1$
}
@@ -132,21 +125,31 @@ public class ApplicationProcessor {
} else {
if (logger.isWarnEnabled()) {
logger.warn(Messages
- .getMessage("classNotADynamicResourceNorResourceNorProvider", obj //$NON-NLS-1$
- .getClass().getName()));
+ .getMessage("classNotADynamicResourceNorResourceNorProvider", obj //$NON-NLS-1$
+ .getClass().getName()));
}
}
} catch (Exception e) {
- if (logger.isWarnEnabled()) {
- logger.warn(Messages.getMessage("exceptionOccurredDuringInstanceProcessing", obj //$NON-NLS-1$
- .getClass().getCanonicalName()));
- logger.warn(Messages.getMessage("listExceptionDuringInstanceProcessing"), e); //$NON-NLS-1$
+ if (logger.isErrorEnabled()) {
+ logger.error(Messages
+ .getMessage("exceptionOccurredDuringInstanceProcessing", obj //$NON-NLS-1$
+ .getClass().getCanonicalName()), e);
+
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug(Messages
+ .getMessage("exceptionOccurredDuringInstanceProcessing", obj //$NON-NLS-1$
+ .getClass().getCanonicalName()), e);
}
} catch (NoClassDefFoundError e) {
- if (logger.isWarnEnabled()) {
- logger.warn(Messages.getMessage("exceptionOccurredDuringInstanceProcessing", obj //$NON-NLS-1$
- .getClass().getCanonicalName()));
- logger.warn(Messages.getMessage("listExceptionDuringInstanceProcessing"), e); //$NON-NLS-1$
+ if (logger.isErrorEnabled()) {
+ logger.error(Messages.getMessage("exceptionOccurredDuringInstanceProcessing", //$NON-NLS-1$
+ obj.getClass().getCanonicalName()), e);
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug(Messages
+ .getMessage("exceptionOccurredDuringInstanceProcessing", obj //$NON-NLS-1$
+ .getClass().getCanonicalName()), e);
}
}
}
@@ -155,9 +158,10 @@ public class ApplicationProcessor {
private void processClasses(Set<Class<?>> classes, double priority) {
for (Class<?> cls : classes) {
+
try {
logger.trace("Processing class: {}", cls); //$NON-NLS-1$
-
+
int modifiers = cls.getModifiers();
if (Modifier.isInterface(modifiers) || Modifier.isAbstract(modifiers)) {
logger
@@ -175,20 +179,27 @@ public class ApplicationProcessor {
} else {
if (logger.isWarnEnabled()) {
logger.warn(Messages.getMessage("classNotAResourceNorProvider", cls //$NON-NLS-1$
- .getName()));
+ .getName()));
}
}
} catch (Exception e) {
- if (logger.isWarnEnabled()) {
- logger.warn(Messages.getMessage("exceptionOccurredDuringClassProcessing", cls //$NON-NLS-1$
- .getName()));
- logger.warn(Messages.getMessage("listExceptionDuringClassProcessing"), e); //$NON-NLS-1$
+ if (logger.isErrorEnabled()) {
+ logger.error(Messages.getMessage("exceptionOccurredDuringClassProcessing", cls //$NON-NLS-1$
+ .getName()), e);
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug(Messages.getMessage("exceptionOccurredDuringClassProcessing", cls //$NON-NLS-1$
+ .getCanonicalName()), e);
}
} catch (NoClassDefFoundError e) {
- if (logger.isWarnEnabled()) {
- logger.warn(Messages.getMessage("exceptionOccurredDuringClassProcessing", cls //$NON-NLS-1$
- .getCanonicalName()));
- logger.warn(Messages.getMessage("listExceptionDuringClassProcessing"), e); //$NON-NLS-1$
+ if (logger.isErrorEnabled()) {
+ logger.error(Messages.getMessage("exceptionOccurredDuringClassProcessing", cls //$NON-NLS-1$
+ .getCanonicalName()), e);
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(Messages.getMessage("exceptionOccurredDuringClassProcessing", cls //$NON-NLS-1$
+ .getCanonicalName()), e);
}
}
}
@@ -209,21 +220,32 @@ public class ApplicationProcessor {
providersRegistry.addProvider(obj, priority, isSystemApplication);
} else {
if (logger.isWarnEnabled()) {
- logger
- .warn(Messages.getMessage("classNotAResourceNorProvider", obj.getClass())); //$NON-NLS-1$
+ logger.warn(Messages
+ .getMessage("classNotAResourceNorProvider", obj.getClass())); //$NON-NLS-1$
}
}
} catch (Exception e) {
- if (logger.isWarnEnabled()) {
- logger.warn(Messages.getMessage("exceptionOccurredDuringSingletonProcessing", obj //$NON-NLS-1$
- .getClass().getCanonicalName()));
- logger.warn(Messages.getMessage("listExceptionDuringSingletonProcessing"), e); //$NON-NLS-1$
+ if (logger.isErrorEnabled()) {
+ logger.warn(Messages
+ .getMessage("exceptionOccurredDuringSingletonProcessing", obj //$NON-NLS-1$
+ .getClass().getCanonicalName()), e);
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(Messages
+ .getMessage("exceptionOccurredDuringSingletonProcessing", obj //$NON-NLS-1$
+ .getClass().getCanonicalName()), e);
}
} catch (NoClassDefFoundError e) {
- if (logger.isWarnEnabled()) {
- logger.warn(Messages.getMessage("exceptionOccurredDuringSingletonProcessing", //$NON-NLS-1$
- obj.getClass().getCanonicalName()));
- logger.warn(Messages.getMessage("listExceptionDuringSingletonProcessing"), e); //$NON-NLS-1$
+ if (logger.isErrorEnabled()) {
+ logger.error(Messages.getMessage("exceptionOccurredDuringSingletonProcessing", //$NON-NLS-1$
+ obj.getClass().getCanonicalName()), e);
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(Messages
+ .getMessage("exceptionOccurredDuringSingletonProcessing", obj //$NON-NLS-1$
+ .getClass().getCanonicalName()), e);
}
}
}
Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/FindRootResourceHandler.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/FindRootResourceHandler.java?rev=1027712&r1=1027711&r2=1027712&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/FindRootResourceHandler.java (original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/FindRootResourceHandler.java Tue Oct 26 19:52:54 2010
@@ -63,7 +63,9 @@ public class FindRootResourceHandler imp
registry.getMatchingRootResources(strippedPath, isContinuedSearchPolicy);
logger.trace("Found resource instances: {}", matchedResources); //$NON-NLS-1$
if (matchedResources.size() == 0) {
- logger.trace("No resource found matching {}", context.getUriInfo().getPath(false)); //$NON-NLS-1$
+ if(logger.isTraceEnabled()) {
+ logger.trace("No resource found matching {}", context.getUriInfo().getPath(false)); //$NON-NLS-1$
+ }
SearchResult result =
new SearchResult(new WebApplicationException(Response.Status.NOT_FOUND));
context.setAttribute(SearchResult.class, result);
Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/FlushResultHandler.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/FlushResultHandler.java?rev=1027712&r1=1027711&r2=1027712&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/FlushResultHandler.java (original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/FlushResultHandler.java Tue Oct 26 19:52:54 2010
@@ -46,6 +46,8 @@ import javax.ws.rs.ext.RuntimeDelegate.H
import org.apache.wink.common.internal.MultivaluedMapImpl;
import org.apache.wink.common.internal.i18n.Messages;
import org.apache.wink.common.internal.runtime.RuntimeContextTLS;
+import org.apache.wink.common.utils.ProviderUtils;
+import org.apache.wink.common.utils.ProviderUtils.PROVIDER_EXCEPTION_ORIGINATOR;
import org.apache.wink.server.handlers.AbstractHandler;
import org.apache.wink.server.handlers.MessageContext;
import org.apache.wink.server.internal.contexts.RequestImpl;
@@ -147,22 +149,36 @@ public class FlushResultHandler extends
// use the provider to write the entity
if (messageBodyWriter != null) {
- logger.trace("Serialization using provider {}", messageBodyWriter.getClass().getName()); //$NON-NLS-1$
+ if (logger.isTraceEnabled()) {
+ logger
+ .trace("Serialization using provider {}", messageBodyWriter.getClass().getName()); //$NON-NLS-1$
+ }
final MultivaluedMap<String, Object> headers = httpHeaders;
- long size =
- messageBodyWriter.getSize(entity,
- rawType,
- genericType,
- declaredAnnotations,
- responseMediaType);
+ long size;
+ try {
+ size =
+ messageBodyWriter.getSize(entity,
+ rawType,
+ genericType,
+ declaredAnnotations,
+ responseMediaType);
+ } catch (RuntimeException e) {
+ ProviderUtils.logUserProviderException(e,
+ messageBodyWriter,
+ PROVIDER_EXCEPTION_ORIGINATOR.getSize,
+ new Object[] {entity, rawType, genericType,
+ declaredAnnotations, responseMediaType},
+ context);
+ throw e;
+ }
if (logger.isTraceEnabled()) {
logger.trace("{}@{}.getSize({}, {}, {}, {}, {}) returned {}", new Object[] { //$NON-NLS-1$
messageBodyWriter.getClass().getName(),
Integer.toHexString(System.identityHashCode(messageBodyWriter)),
- entity, rawType, genericType, declaredAnnotations,
- responseMediaType, size});
+ Integer.toHexString(System.identityHashCode(entity)), rawType,
+ genericType, declaredAnnotations, responseMediaType, size});
}
if (size >= 0) {
headers.putSingle(HttpHeaders.CONTENT_LENGTH, String.valueOf(size));
@@ -175,16 +191,29 @@ public class FlushResultHandler extends
.trace("{}@{}.writeTo({}, {}, {}, {}, {}, {}, {}) being called", new Object[] { //$NON-NLS-1$
messageBodyWriter.getClass().getName(),
Integer.toHexString(System.identityHashCode(messageBodyWriter)),
- entity, rawType, genericType, declaredAnnotations,
- responseMediaType, httpHeaders, outputStream});
+ Integer.toHexString(System.identityHashCode(entity)), rawType,
+ genericType, declaredAnnotations, responseMediaType, httpHeaders,
+ outputStream});
+ }
+ try {
+ messageBodyWriter.writeTo(entity,
+ rawType,
+ genericType,
+ declaredAnnotations,
+ responseMediaType,
+ httpHeaders,
+ outputStream);
+ } catch (RuntimeException e) {
+ ProviderUtils
+ .logUserProviderException(e,
+ messageBodyWriter,
+ ProviderUtils.PROVIDER_EXCEPTION_ORIGINATOR.writeTo,
+ new Object[] {entity, rawType, genericType,
+ declaredAnnotations, responseMediaType,
+ httpHeaders, outputStream},
+ context);
+ throw e;
}
- messageBodyWriter.writeTo(entity,
- rawType,
- genericType,
- declaredAnnotations,
- responseMediaType,
- httpHeaders,
- outputStream);
logger.trace("Flushing headers if not written"); //$NON-NLS-1$
outputStream.flushHeaders();
return;
@@ -213,16 +242,19 @@ public class FlushResultHandler extends
throw new WebApplicationException(500);
}
- logger.trace("Serialization using data content handler {}", dataContentHandler.getClass() //$NON-NLS-1$
- .getName());
+ if (logger.isTraceEnabled()) {
+ logger
+ .trace("Serialization using data content handler {}", dataContentHandler.getClass() //$NON-NLS-1$
+ .getName());
+ }
FlushHeadersOutputStream outputStream =
new FlushHeadersOutputStream(httpResponse, httpHeaders, responseMediaType);
if (logger.isTraceEnabled()) {
logger.trace("{}@{}.writeTo({}, {}, {}) being called", new Object[] { //$NON-NLS-1$
dataContentHandler.getClass().getName(),
- Integer.toHexString(System.identityHashCode(dataContentHandler)), entity,
- responseMediaType.toString(), outputStream});
+ Integer.toHexString(System.identityHashCode(dataContentHandler)),
+ entity, responseMediaType.toString(), outputStream});
}
dataContentHandler
.writeTo(entity,
Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/InvokeMethodHandler.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/InvokeMethodHandler.java?rev=1027712&r1=1027711&r2=1027712&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/InvokeMethodHandler.java (original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/InvokeMethodHandler.java Tue Oct 26 19:52:54 2010
@@ -27,7 +27,7 @@ import org.apache.wink.common.internal.a
import org.apache.wink.common.internal.log.LogUtils;
import org.apache.wink.server.handlers.AbstractHandler;
import org.apache.wink.server.handlers.MessageContext;
-//import org.apache.wink.server.internal.log.ResourceInvocation.ResourceInvocationData;
+import org.apache.wink.server.internal.log.ResourceInvocation.ResourceInvocationData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -55,11 +55,11 @@ public class InvokeMethodHandler extends
Integer.toHexString(System.identityHashCode(instance)),
Arrays.toString(parameters)});
}
-// ResourceInvocationData resInvocationData =
-// context.getAttribute(ResourceInvocationData.class);
-// if (resInvocationData != null) {
-// resInvocationData.addInvocation(context);
-// }
+ ResourceInvocationData resInvocationData =
+ context.getAttribute(ResourceInvocationData.class);
+ if (resInvocationData != null) {
+ resInvocationData.addInvocation(context);
+ }
Object result = javaMethod.invoke(instance, parameters);
context.setResponseEntity(result);
} catch (InvocationTargetException ite) {
Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/OptionsMethodHandler.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/OptionsMethodHandler.java?rev=1027712&r1=1027711&r2=1027712&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/OptionsMethodHandler.java (original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/OptionsMethodHandler.java Tue Oct 26 19:52:54 2010
@@ -55,6 +55,7 @@ public class OptionsMethodHandler implem
// get supported HTTP methods
ResourceRegistry resourceRegistry = context.getAttribute(ResourceRegistry.class);
Set<String> httpMethods = resourceRegistry.getOptions(searchResult.getResource());
+
logger
.trace("Invoking OPTIONS request handled by runtime with {} resource and {} HTTP methods", //$NON-NLS-1$
searchResult.getResource(),
Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/PopulateErrorResponseHandler.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/PopulateErrorResponseHandler.java?rev=1027712&r1=1027711&r2=1027712&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/PopulateErrorResponseHandler.java (original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/PopulateErrorResponseHandler.java Tue Oct 26 19:52:54 2010
@@ -42,7 +42,7 @@ public class PopulateErrorResponseHandle
Object result = context.getResponseEntity();
if (result instanceof WebApplicationException) {
handleWebApplicationException(context, (WebApplicationException)result);
- } else {
+ } else if(result instanceof Throwable) {
Throwable exception = (Throwable)result;
ExceptionMapper<Throwable> provider =
(ExceptionMapper<Throwable>)findProvider(context, exception);
@@ -59,7 +59,7 @@ public class PopulateErrorResponseHandle
try {
return provider.toResponse(exception);
} catch (Throwable e) {
- logger.error(Messages.getMessage("exceptionOccurredDuringExceptionMapper"), e); //$NON-NLS-1$
+ logger.error(Messages.getMessage("exceptionOccurredDuringExceptionMapper", provider.getClass().getName()), e); //$NON-NLS-1$
return RUNTIME_DELEGATE.createResponseBuilder().status(500).build();
}
}