You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wink.apache.org by ng...@apache.org on 2009/06/23 07:41:55 UTC
svn commit: r787557 [3/12] - in /incubator/wink/contrib/ibm-jaxrs: ./ lib/
src/ src/com/ src/com/ibm/ src/com/ibm/ws/ src/com/ibm/ws/jaxrs/
src/com/ibm/ws/jaxrs/annotations/ src/com/ibm/ws/jaxrs/context/
src/com/ibm/ws/jaxrs/core/ src/com/ibm/ws/jaxrs/...
Added: incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/handler/internal/ResourceSelector.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/handler/internal/ResourceSelector.java?rev=787557&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/handler/internal/ResourceSelector.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/handler/internal/ResourceSelector.java Tue Jun 23 05:41:49 2009
@@ -0,0 +1,203 @@
+/*
+ * 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 com.ibm.ws.jaxrs.handler.internal;
+
+import java.util.List;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.cxf.jaxrs.impl.MetadataMap;
+import org.apache.cxf.jaxrs.model.ClassResourceInfo;
+import org.apache.cxf.jaxrs.model.OperationResourceInfo;
+import org.apache.cxf.jaxrs.model.URITemplate;
+import org.apache.cxf.jaxrs.utils.JAXRSUtils;
+
+import com.ibm.ws.jaxrs.context.ContextConstants;
+import com.ibm.ws.jaxrs.context.RESTContext;
+import com.ibm.ws.jaxrs.engine.RESTConstants;
+import com.ibm.ws.jaxrs.engine.RESTEngineUtils;
+import com.ibm.ws.jaxrs.engine.ResourceInvoker;
+import com.ibm.ws.jaxrs.handler.RESTSystemHandler;
+import com.ibm.ws.jaxrs.i18n.Messages;
+import com.ibm.ws.jaxrs.metadata.RESTMetaData;
+
+/**
+ * This class is an inbound handler that is used to target both the
+ * root-level resource class and the initial method that will be called.
+ *
+ */
+public class ResourceSelector implements RESTSystemHandler {
+
+ private static final Log log = LogFactory.getLog(ResourceSelector.class);
+
+ public int getInboundPriority() {
+ return 1000;
+ }
+
+ /**
+ * This handler will not run on the outbound flow.
+ */
+ public int getOutboundPriority() {
+ return Integer.MAX_VALUE;
+ }
+
+ public void invoke(RESTContext context) throws Exception {
+ if (log.isDebugEnabled()) {
+ log.debug("ResourceSelector.invoke(): entry");
+ }
+
+ String flow = (String) context
+ .getProperty(ContextConstants.MESSAGE_FLOW);
+ ClassResourceInfo resource = (ClassResourceInfo) context
+ .getProperty(ContextConstants.ROOT_RESOURCE);
+ OperationResourceInfo opInfo = null;
+ boolean optionsResponseSet = false;
+
+ // only proceed if this is the inbound flow
+ if (RESTConstants.MESSAGE_FLOW_INBOUND.equals(flow) && resource == null) {
+ String acceptTypes = (String) context
+ .getProperty(ContextConstants.HTTP_ACCEPT_HEADER);
+ String httpMethod = (String) context
+ .getProperty(ContextConstants.HTTP_METHOD);
+ String contentType = (String) context
+ .getProperty(ContextConstants.CONTENT_TYPE);
+ String pathInfo = (String) context
+ .getProperty(ContextConstants.HTTP_PATH_INFO);
+
+ // Now lets find which Class-level resource matches what the request URI
+ String path = (String) context
+ .getProperty(ContextConstants.HTTP_PATH_RESOURCE);
+ if (path == null) {
+ if (log.isDebugEnabled()) {
+ log
+ .debug("Setting encoded path information to the decoded value: "
+ + pathInfo);
+ }
+ path = pathInfo;
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("Request Information: ");
+ log.debug("HTTP REQUEST METHOD = " + httpMethod);
+ log.debug("CONTENT TYPE = " + contentType);
+ log.debug("ACCEPT TYPE = " + acceptTypes);
+ log.debug("PATH INFO = " + pathInfo);
+ log.debug("RESOURCE PATH = " + path);
+ }
+
+ RESTMetaData metadata = (RESTMetaData) context
+ .getProperty(ContextConstants.REST_METADATA);
+ List<ClassResourceInfo> resources = metadata.getClassInfoList();
+ if (resources.size() <= 0) {
+ Response rsp = Response.status(Response.Status.NOT_FOUND)
+ .build();
+ throw new WebApplicationException(new RuntimeException(
+ "No resources are available in this module."), rsp);
+ }
+
+ MultivaluedMap<String, String> values = new MetadataMap<String, String>();
+ resource = JAXRSUtils.selectResourceClass(resources, path, values);
+
+ if (resource == null) {
+ resource = JAXRSUtils.selectResourceClassFromAliases(resources,
+ path, values, context);
+ if (resource == null) {
+ if ("OPTIONS".equalsIgnoreCase(httpMethod)) {
+ RESTContext response = ResourceInvoker
+ .handleOptionsRequest(context);
+ context.setProperty(
+ ContextConstants.OPTIONS_RESPONSE_CONTEXT,
+ response);
+ optionsResponseSet = true;
+ } else {
+ Response rsp = Response.status(
+ Response.Status.NOT_FOUND).build();
+ throw new WebApplicationException(new RuntimeException(
+ Messages.getMessage("resourceNotFound", path)),
+ rsp);
+ }
+ }
+ }
+
+ if (!optionsResponseSet) {
+ if (log.isDebugEnabled()) {
+ log.debug("Root resource ["
+ + resource.getResourceClass().getName() + "]");
+ }
+ context.setProperty(ContextConstants.ROOT_RESOURCE, resource);
+
+ // add the resource and its path to our context
+ RESTEngineUtils.addMatchedResource(resource.getServiceClass(),
+ context);
+
+ // add the matched URI to list
+ String matchedAliasPath = (String) context
+ .getProperty(ContextConstants.MATCHED_ALIAS_PATH);
+ if (matchedAliasPath != null) {
+ RESTEngineUtils.addMatchedUri(matchedAliasPath, context);
+ } else if (resource.getPath() != null) {
+ RESTEngineUtils.addMatchedUri(resource.getPath(), context);
+ }
+
+ context.setProperty(ContextConstants.TEMPLATE_VALUES, values);
+
+ List<MediaType> acceptContentTypes = JAXRSUtils
+ .sortMediaTypes(acceptTypes);
+ context.setProperty(ContextConstants.ACCEPT_CONTENT_TYPES,
+ acceptContentTypes);
+
+ opInfo = JAXRSUtils.findTargetMethod(resource, values
+ .getFirst(URITemplate.FINAL_MATCH_GROUP), httpMethod,
+ values, contentType, acceptContentTypes);
+
+ // add the matched URI and property if we found it, otherwise do nothing, this may
+ // be an options request, in either case we'll let the invocation handler report
+ // an error if appropriate
+ if (opInfo != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Target method httpMethod: "
+ + opInfo.getHttpMethod() + " Java method: "
+ + opInfo.getMethodToInvoke().getName());
+ }
+ RESTEngineUtils.addMatchedUri(JAXRSUtils
+ .getPathForOperation(values
+ .getFirst(URITemplate.FINAL_MATCH_GROUP),
+ pathInfo), context);
+ context.setProperty(ContextConstants.OPERATION_RESOURCE,
+ opInfo);
+ }
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("Options request at context root level");
+ }
+ }
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("ResourceSelector.invoke(): exit");
+ }
+ }
+
+}
Added: incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/handler/internal/ResponseHandler.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/handler/internal/ResponseHandler.java?rev=787557&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/handler/internal/ResponseHandler.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/handler/internal/ResponseHandler.java Tue Jun 23 05:41:49 2009
@@ -0,0 +1,76 @@
+/*
+ * 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 com.ibm.ws.jaxrs.handler.internal;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.cxf.jaxrs.utils.JAXRSUtils;
+
+import com.ibm.ws.jaxrs.context.ContextConstants;
+import com.ibm.ws.jaxrs.context.RESTContext;
+import com.ibm.ws.jaxrs.engine.RESTConstants;
+import com.ibm.ws.jaxrs.handler.RESTSystemHandler;
+
+/**
+ * This is the system handler that will be responsible for driving the
+ * processing of a response from our REST runtime.
+ *
+ */
+public class ResponseHandler implements RESTSystemHandler {
+
+ private static final Log log = LogFactory.getLog(ResponseHandler.class);
+
+ /**
+ * This handler will not run on the inbound side
+ */
+ public int getInboundPriority() {
+ return Integer.MAX_VALUE;
+ }
+
+ /**
+ * This handler will be the first executed on the outbound side.
+ */
+ public int getOutboundPriority() {
+ return 0;
+ }
+
+ /**
+ * This method will handle the processing of a response that is present
+ * on the response RESTContext.
+ */
+ public void invoke(RESTContext context) throws Exception {
+ if (log.isDebugEnabled()) {
+ log.debug("ResponseHandler.invoke(): entry");
+ }
+
+ String flow = (String) context
+ .getProperty(ContextConstants.MESSAGE_FLOW);
+
+ // only act on response
+ if (RESTConstants.MESSAGE_FLOW_OUTBOUND.equals(flow)) {
+ JAXRSUtils.processResponse(context);
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("ResponseHandler.invoke(): exit");
+ }
+ }
+
+}
Added: incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/i18n/MessageBundle.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/i18n/MessageBundle.java?rev=787557&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/i18n/MessageBundle.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/i18n/MessageBundle.java Tue Jun 23 05:41:49 2009
@@ -0,0 +1,177 @@
+/*
+ * 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 com.ibm.ws.jaxrs.i18n;
+
+import java.text.MessageFormat;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * Accept parameters for ProjectResourceBundle, but defer object instantiation (and therefore
+ * resource bundle loading) until required.
+ */
+public class MessageBundle {
+ private boolean loaded = false;
+
+ private ProjectResourceBundle _resourceBundle = null;
+
+ private final String projectName;
+ private final String packageName;
+ private final String resourceName;
+ private final Locale locale;
+ private final ClassLoader classLoader;
+ private final ResourceBundle parent;
+
+ public final ProjectResourceBundle getResourceBundle() {
+ if (!loaded) {
+ _resourceBundle = ProjectResourceBundle.getBundle(projectName,
+ packageName, resourceName, locale, classLoader, parent);
+ loaded = true;
+ }
+ return _resourceBundle;
+ }
+
+ /** Construct a new ExtendMessages */
+ public MessageBundle(String projectName, String packageName, String resourceName, Locale locale, ClassLoader classLoader, ResourceBundle parent) throws MissingResourceException {
+ this.projectName = projectName;
+ this.packageName = packageName;
+ this.resourceName = resourceName;
+ this.locale = locale;
+ this.classLoader = classLoader;
+ this.parent = parent;
+ }
+
+ /**
+ * Gets a string message from the resource bundle for the given key
+ *
+ * @param key The resource key
+ * @return The message
+ */
+ public String getMessage(String key) throws MissingResourceException {
+ return getMessage(key, (String[]) null);
+ }
+
+ /**
+ * <p>Gets a string message from the resource bundle for the given key. The message may contain
+ * variables that will be substituted with the given arguments. Variables have the format:</p>
+ * <dir> This message has two variables: {0} and {1} </dir>
+ *
+ * @param key The resource key
+ * @param arg0 The argument to place in variable {0}
+ * @return The message
+ */
+ public String getMessage(String key, String arg0)
+ throws MissingResourceException {
+ return getMessage(key, new String[] { arg0 });
+ }
+
+ /**
+ * <p>Gets a string message from the resource bundle for the given key. The message may contain
+ * variables that will be substituted with the given arguments. Variables have the format:</p>
+ * <dir> This message has two variables: {0} and {1} </dir>
+ *
+ * @param key The resource key
+ * @param arg0 The argument to place in variable {0}
+ * @param arg1 The argument to place in variable {1}
+ * @return The message
+ */
+ public String getMessage(String key, String arg0, String arg1)
+ throws MissingResourceException {
+ return getMessage(key, new String[] { arg0, arg1 });
+ }
+
+ /**
+ * <p>Gets a string message from the resource bundle for the given key. The message may contain
+ * variables that will be substituted with the given arguments. Variables have the format:</p>
+ * <dir> This message has two variables: {0} and {1} </dir>
+ *
+ * @param key The resource key
+ * @param arg0 The argument to place in variable {0}
+ * @param arg1 The argument to place in variable {1}
+ * @param arg2 The argument to place in variable {2}
+ * @return The message
+ */
+ public String getMessage(String key, String arg0, String arg1, String arg2)
+ throws MissingResourceException {
+ return getMessage(key, new String[] { arg0, arg1, arg2 });
+ }
+
+ /**
+ * <p>Gets a string message from the resource bundle for the given key. The message may contain
+ * variables that will be substituted with the given arguments. Variables have the format:</p>
+ * <dir> This message has two variables: {0} and {1} </dir>
+ *
+ * @param key The resource key
+ * @param arg0 The argument to place in variable {0}
+ * @param arg1 The argument to place in variable {1}
+ * @param arg2 The argument to place in variable {2}
+ * @param arg3 The argument to place in variable {3}
+ * @return The message
+ */
+ public String getMessage(String key, String arg0, String arg1, String arg2, String arg3)
+ throws MissingResourceException {
+ return getMessage(key, new String[] { arg0, arg1, arg2, arg3 });
+ }
+
+ /**
+ * <p>Gets a string message from the resource bundle for the given key. The message may contain
+ * variables that will be substituted with the given arguments. Variables have the format:</p>
+ * <dir> This message has two variables: {0} and {1} </dir>
+ *
+ * @param key The resource key
+ * @param arg0 The argument to place in variable {0}
+ * @param arg1 The argument to place in variable {1}
+ * @param arg2 The argument to place in variable {2}
+ * @param arg3 The argument to place in variable {3}
+ * @param arg4 The argument to place in variable {4}
+ * @return The message
+ */
+ public String getMessage(String key, String arg0, String arg1, String arg2, String arg3, String arg4)
+ throws MissingResourceException {
+ return getMessage(key, new String[] { arg0, arg1, arg2, arg3, arg4 });
+ }
+
+ /**
+ * <p>Gets a string message from the resource bundle for the given key. The message may contain
+ * variables that will be substituted with the given arguments. Variables have the format:</p>
+ * <dir> This message has two variables: {0} and {1} </dir>
+ *
+ * @param key The resource key
+ * @param array An array of objects to place in corresponding variables
+ * @return The message
+ */
+ public String getMessage(String key, String[] array)
+ throws MissingResourceException {
+ String msg = null;
+ if (getResourceBundle() != null) {
+ msg = getResourceBundle().getString(key);
+ }
+
+ if (msg == null) {
+ throw new MissingResourceException("Cannot find resource key \""
+ + key + "\" in base name "
+ + getResourceBundle().getResourceName(),
+ getResourceBundle().getResourceName(), key);
+ }
+
+ return MessageFormat.format(msg, (Object[]) array);
+ }
+}
Added: incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/i18n/Messages.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/i18n/Messages.java?rev=787557&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/i18n/Messages.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/i18n/Messages.java Tue Jun 23 05:41:49 2009
@@ -0,0 +1,291 @@
+/*
+ * 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 com.ibm.ws.jaxrs.i18n;
+
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages {
+ private static final Class thisClass = Messages.class;
+
+ private static final String projectName = MessagesConstants.projectName;
+
+ private static final String resourceName = MessagesConstants.resourceName;
+ private static final Locale locale = MessagesConstants.locale;
+
+ public static final String DEFAULT_MESSAGE_BUNDLE_KEY = "default";
+ private static final String NO_MESSAGE_BUNDLE = "Message Bundle is not available";
+
+ private static final String packageName = getPackage(thisClass.getName());
+ private static final ClassLoader classLoader = thisClass.getClassLoader();
+
+ private static final ResourceBundle parent = (MessagesConstants.rootPackageName
+ .equals(packageName)) ? null : MessagesConstants.rootBundle;
+
+ private static HashMap messageBundleMap = new HashMap();
+
+ static {
+ MessageBundle defaultMessageBundle = new MessageBundle(projectName,
+ packageName, resourceName, locale, classLoader, parent);
+ addMessageBundle(DEFAULT_MESSAGE_BUNDLE_KEY, defaultMessageBundle);
+ }
+
+ /**
+ * To add a new Message Bundle to the MessageBundle list.
+ *
+ * @param messageBundleKey The key which will be used to refer to this message bundle later.
+ * @param messageBundle The message bundle.
+ */
+ public static void addMessageBundle(String messageBundleKey, MessageBundle messageBundle) {
+ messageBundleMap.put(messageBundleKey, messageBundle);
+ }
+
+ /**
+ * Get a message from resource.properties from the package of the given object.
+ *
+ * @param key The resource key
+ * @return The formatted message
+ */
+ public static String getMessage(String key) throws MissingResourceException {
+ MessageBundle messageBundle = getMessageBundle(DEFAULT_MESSAGE_BUNDLE_KEY);
+ return messageBundle.getMessage(key);
+ }
+
+ /**
+ * Get a message from resource.properties from the package of the given object.
+ *
+ * @param key The resource key
+ * @param arg0 The argument to place in variable {0}
+ * @return The formatted message
+ */
+ public static String getMessage(String key, String arg0)
+ throws MissingResourceException {
+ MessageBundle messageBundle = getMessageBundle(DEFAULT_MESSAGE_BUNDLE_KEY);
+ return messageBundle.getMessage(key, arg0);
+ }
+
+ /**
+ * Get a message from resource.properties from the package of the given object.
+ *
+ * @param key The resource key
+ * @param arg0 The argument to place in variable {0}
+ * @param arg1 The argument to place in variable {1}
+ * @return The formatted message
+ */
+ public static String getMessage(String key, String arg0, String arg1)
+ throws MissingResourceException {
+ MessageBundle messageBundle = getMessageBundle(DEFAULT_MESSAGE_BUNDLE_KEY);
+ return messageBundle.getMessage(key, arg0, arg1);
+ }
+
+ /**
+ * Get a message from resource.properties from the package of the given object.
+ *
+ * @param key The resource key
+ * @param arg0 The argument to place in variable {0}
+ * @param arg1 The argument to place in variable {1}
+ * @param arg2 The argument to place in variable {2}
+ * @return The formatted message
+ */
+ public static String getMessage(String key, String arg0, String arg1, String arg2)
+ throws MissingResourceException {
+ MessageBundle messageBundle = getMessageBundle(DEFAULT_MESSAGE_BUNDLE_KEY);
+ return messageBundle.getMessage(key, arg0, arg1, arg2);
+ }
+
+ /**
+ * Get a message from resource.properties from the package of the given object.
+ *
+ * @param key The resource key
+ * @param arg0 The argument to place in variable {0}
+ * @param arg1 The argument to place in variable {1}
+ * @param arg2 The argument to place in variable {2}
+ * @param arg3 The argument to place in variable {3}
+ * @return The formatted message
+ */
+ public static String getMessage(String key, String arg0, String arg1, String arg2, String arg3)
+ throws MissingResourceException {
+ MessageBundle messageBundle = getMessageBundle(DEFAULT_MESSAGE_BUNDLE_KEY);
+ return messageBundle.getMessage(key, arg0, arg1, arg2, arg3);
+ }
+
+ /**
+ * Get a message from resource.properties from the package of the given object.
+ *
+ * @param key The resource key
+ * @param arg0 The argument to place in variable {0}
+ * @param arg1 The argument to place in variable {1}
+ * @param arg2 The argument to place in variable {2}
+ * @param arg3 The argument to place in variable {3}
+ * @param arg4 The argument to place in variable {4}
+ * @return The formatted message
+ */
+ public static String getMessage(String key, String arg0, String arg1, String arg2, String arg3, String arg4)
+ throws MissingResourceException {
+ MessageBundle messageBundle = getMessageBundle(DEFAULT_MESSAGE_BUNDLE_KEY);
+ return messageBundle.getMessage(key, arg0, arg1, arg2, arg3, arg4);
+ }
+
+ /**
+ * Get a message from resource.properties from the package of the given object.
+ *
+ * @param key The resource key
+ * @param args An array of objects to place in corresponding variables
+ * @return The formatted message
+ */
+ public static String getMessage(String key, String[] args)
+ throws MissingResourceException {
+ MessageBundle messageBundle = getMessageBundle(DEFAULT_MESSAGE_BUNDLE_KEY);
+ return messageBundle.getMessage(key, args);
+ }
+
+ public static ResourceBundle getResourceBundle() {
+ MessageBundle messageBundle = getMessageBundle(DEFAULT_MESSAGE_BUNDLE_KEY);
+ return messageBundle.getResourceBundle();
+ }
+
+ public static MessageBundle getMessageBundle() {
+ MessageBundle messageBundle = getMessageBundle(DEFAULT_MESSAGE_BUNDLE_KEY);
+ return messageBundle;
+ }
+
+ public static MessageBundle getMessageBundle(String messageBundleKey) {
+ MessageBundle messageBundle = (MessageBundle) messageBundleMap
+ .get(messageBundleKey);
+ return messageBundle;
+ }
+
+ /**
+ * Get a message from resource.properties from the package of the given object.
+ *
+ * @param messageBundleKey The key for getting the correct message bundle.
+ * @param key The resource key
+ * @return The formatted message
+ */
+ public static String getMessageFromBundle(String messageBundleKey, String key)
+ throws MissingResourceException, Exception {
+ MessageBundle messageBundle = getMessageBundle(messageBundleKey);
+ if (messageBundle == null)
+ throw new Exception(NO_MESSAGE_BUNDLE);
+
+ return messageBundle.getMessage(key);
+ }
+
+ /**
+ * Get a message from resource.properties from the package of the given object.
+ *
+ * @param messageBundleKey The key for getting the correct message bundle.
+ * @param key The resource key
+ * @param arg0 The argument to place in variable {0}
+ * @return The formatted message
+ */
+ public static String getMessageFromBundle(String messageBundleKey, String key, String arg0)
+ throws MissingResourceException, Exception {
+ MessageBundle messageBundle = getMessageBundle(messageBundleKey);
+ if (messageBundle == null)
+ throw new Exception(NO_MESSAGE_BUNDLE);
+
+ return messageBundle.getMessage(key, arg0);
+ }
+
+ /**
+ * Get a message from resource.properties from the package of the given object.
+ *
+ * @param messageBundleKey The key for getting the correct message bundle.
+ * @param key The resource key
+ * @param arg0 The argument to place in variable {0}
+ * @param arg1 The argument to place in variable {1}
+ * @return The formatted message
+ */
+ public static String getMessageFromBundle(String messageBundleKey, String key, String arg0, String arg1)
+ throws MissingResourceException, Exception {
+ MessageBundle messageBundle = getMessageBundle(messageBundleKey);
+ if (messageBundle == null)
+ throw new Exception(NO_MESSAGE_BUNDLE);
+
+ return messageBundle.getMessage(key, arg0, arg1);
+ }
+
+ /**
+ * Get a message from resource.properties from the package of the given object.
+ *
+ * @param messageBundleKey The key for getting the correct message bundle.
+ * @param key The resource key
+ * @param arg0 The argument to place in variable {0}
+ * @param arg1 The argument to place in variable {1}
+ * @param arg2 The argument to place in variable {2}
+ * @return The formatted message
+ */
+ public static String getMessageFromBundle(String messageBundleKey, String key, String arg0, String arg1, String arg2)
+ throws MissingResourceException, Exception {
+ MessageBundle messageBundle = getMessageBundle(messageBundleKey);
+ if (messageBundle == null)
+ throw new Exception(NO_MESSAGE_BUNDLE);
+
+ return messageBundle.getMessage(key, arg0, arg1, arg2);
+ }
+
+ /**
+ * Get a message from resource.properties from the package of the given object.
+ *
+ * @param messageBundleKey The key for getting the correct message bundle.
+ * @param key The resource key
+ * @param arg0 The argument to place in variable {0}
+ * @param arg1 The argument to place in variable {1}
+ * @param arg2 The argument to place in variable {2}
+ * @param arg3 The argument to place in variable {3}
+ * @return The formatted message
+ */
+ public static String getMessageFromBundle(String messageBundleKey, String key, String arg0, String arg1, String arg2, String arg3)
+ throws MissingResourceException, Exception {
+ MessageBundle messageBundle = getMessageBundle(messageBundleKey);
+ if (messageBundle == null)
+ throw new Exception(NO_MESSAGE_BUNDLE);
+
+ return messageBundle.getMessage(key, arg0, arg1, arg2, arg3);
+ }
+
+ /**
+ * Get a message from resource.properties from the package of the given object.
+ *
+ * @param messageBundleKey The key for getting the correct message bundle.
+ * @param key The resource key
+ * @param arg0 The argument to place in variable {0}
+ * @param arg1 The argument to place in variable {1}
+ * @param arg2 The argument to place in variable {2}
+ * @param arg3 The argument to place in variable {3}
+ * @param arg4 The argument to place in variable {4}
+ * @return The formatted message
+ */
+ public static String getMessageFromBundle(String messageBundleKey, String key, String arg0, String arg1, String arg2, String arg3, String arg4)
+ throws MissingResourceException, Exception {
+ MessageBundle messageBundle = getMessageBundle(messageBundleKey);
+ if (messageBundle == null)
+ throw new Exception(NO_MESSAGE_BUNDLE);
+
+ return messageBundle.getMessage(key, arg0, arg1, arg2, arg3, arg4);
+ }
+
+ private static String getPackage(String name) {
+ return name.substring(0, name.lastIndexOf('.')).intern();
+ }
+}
Added: incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/i18n/MessagesConstants.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/i18n/MessagesConstants.java?rev=787557&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/i18n/MessagesConstants.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/i18n/MessagesConstants.java Tue Jun 23 05:41:49 2009
@@ -0,0 +1,36 @@
+/*
+ * 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 com.ibm.ws.jaxrs.i18n;
+
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+public class MessagesConstants {
+ public static final String projectName = "com.ibm.ws.jaxrs".intern();
+ public static final String resourceName = "resource".intern();
+ public static final Locale locale = null;
+
+ public static final String rootPackageName = "com.ibm.ws.jaxrs.i18n"
+ .intern();
+
+ public static final ResourceBundle rootBundle = ProjectResourceBundle
+ .getBundle(projectName, rootPackageName, resourceName, locale,
+ MessagesConstants.class.getClassLoader(), null);
+}
Added: incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/i18n/ProjectResourceBundle.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/i18n/ProjectResourceBundle.java?rev=787557&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/i18n/ProjectResourceBundle.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/i18n/ProjectResourceBundle.java Tue Jun 23 05:41:49 2009
@@ -0,0 +1,406 @@
+/*
+ * 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 com.ibm.ws.jaxrs.i18n;
+
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * <p>Wrapper class for resource bundles. Property files are used to store resource strings, which
+ * are the only types of resources available. Property files can inherit properties from other files
+ * so that a base property file can be used and a small number of properties can be over-ridden by
+ * another property file. For example you may create an english version of a resource file named
+ * "resource.properties". You then decide that the British English version of all of the properties
+ * except one are the same, so there is no need to redefine all of the properties in
+ * "resource_en_GB", just the one that is different.</p> <p>The basename is the name of the property
+ * file without the ".properties" extension.</p> <p>Properties will be cached for performance.<p>
+ * <p>Property values stored in the property files can also contain dynamic variables. Any dynamic
+ * variable defined in PropertiesUtil.getVariableValue() can be used (such as {date}), as well as
+ * arguments in the form {0}, {1}, etc. Argument values are specified in the various overloaded
+ * getString() methods.</p>
+ */
+public class ProjectResourceBundle extends ResourceBundle {
+ private static final Log log = LogFactory
+ .getLog(ProjectResourceBundle.class);
+
+ // The static cache of ResourceBundles.
+ // The key is the 'basename + locale + default locale'
+ // The element is a ResourceBundle object
+ private static final Hashtable bundleCache = new Hashtable();
+
+ private static final Locale defaultLocale = Locale.getDefault();
+
+ private final ResourceBundle resourceBundle;
+ private final String resourceName;
+
+ @Override
+ protected Object handleGetObject(String key)
+ throws MissingResourceException {
+ if (log.isDebugEnabled()) {
+ log.debug(this.toString() + "::handleGetObject(" + key + ")");
+ }
+ Object obj;
+ try {
+ obj = resourceBundle.getObject(key);
+ } catch (MissingResourceException e) {
+ /* catch missing resource, ignore, & return null
+ * if this method doesn't return null, then parents
+ * are not searched
+ */
+ obj = null;
+ }
+ return obj;
+ }
+
+ @Override
+ public Enumeration getKeys() {
+ Enumeration myKeys = resourceBundle.getKeys();
+ if (parent == null) {
+ return myKeys;
+ }
+
+ final HashSet set = new HashSet();
+ while (myKeys.hasMoreElements()) {
+ set.add(myKeys.nextElement());
+ }
+
+ Enumeration pKeys = parent.getKeys();
+ while (pKeys.hasMoreElements()) {
+ set.add(pKeys.nextElement());
+ }
+
+ return new Enumeration() {
+ private Iterator it = set.iterator();
+
+ public boolean hasMoreElements() {
+ return it.hasNext();
+ }
+
+ public Object nextElement() {
+ return it.next();
+ }
+ };
+ }
+
+ /**
+ * Construct a new ProjectResourceBundle
+ *
+ * @param projectName The name of the project to which the class belongs. It must be a proper
+ * prefix of the caller's package.
+ * @param packageName The package name to further construct the basename.
+ * @param resourceName The name of the resource without the ".properties" extension
+ * @throws MissingResourceException if projectName is not a prefix of the caller's package name,
+ * or if the resource could not be found/loaded.
+ */
+ public static ProjectResourceBundle getBundle(String projectName, String packageName, String resourceName)
+ throws MissingResourceException {
+ return getBundle(projectName, packageName, resourceName, null, null,
+ null);
+ }
+
+ /**
+ * Construct a new ProjectResourceBundle
+ *
+ * @param projectName The name of the project to which the class belongs. It must be a proper
+ * prefix of the caller's package.
+ * @param caller The calling class.
+ * @param resourceName The name of the resource without the ".properties" extension
+ * @throws MissingResourceException if projectName is not a prefix of the caller's package name,
+ * or if the resource could not be found/loaded.
+ */
+ public static ProjectResourceBundle getBundle(String projectName, Class caller, String resourceName, Locale locale)
+ throws MissingResourceException {
+ return getBundle(projectName, caller, resourceName, locale, null);
+ }
+
+ /**
+ * Construct a new ProjectResourceBundle
+ *
+ * @param projectName The name of the project to which the class belongs. It must be a proper
+ * prefix of the caller's package.
+ * @param packageName The package name to construct base name.
+ * @param resourceName The name of the resource without the ".properties" extension
+ * @param locale The locale
+ * @throws MissingResourceException if projectName is not a prefix of the caller's package name,
+ * or if the resource could not be found/loaded.
+ */
+ public static ProjectResourceBundle getBundle(String projectName, String packageName, String resourceName, Locale locale, ClassLoader loader)
+ throws MissingResourceException {
+ return getBundle(projectName, packageName, resourceName, locale,
+ loader, null);
+ }
+
+ /**
+ * Construct a new ProjectResourceBundle
+ *
+ * @param projectName The name of the project to which the class belongs. It must be a proper
+ * prefix of the caller's package.
+ * @param caller The calling class. This is used to get the package name to further
+ * construct the basename as well as to get the proper ClassLoader.
+ * @param resourceName The name of the resource without the ".properties" extension
+ * @param locale The locale
+ * @param extendsBundle If non-null, then this ExtendMessages will default to extendsBundle.
+ * @throws MissingResourceException if projectName is not a prefix of the caller's package name,
+ * or if the resource could not be found/loaded.
+ */
+ public static ProjectResourceBundle getBundle(String projectName, Class caller, String resourceName, Locale locale, ResourceBundle extendsBundle)
+ throws MissingResourceException {
+ return getBundle(projectName, getPackage(caller.getClass().getName()),
+ resourceName, locale, caller.getClass().getClassLoader(),
+ extendsBundle);
+ }
+
+ /**
+ * Construct a new ProjectResourceBundle
+ *
+ * @param projectName The name of the project to which the class belongs. It must be a proper
+ * prefix of the caller's package.
+ * @param validatedPackageName The package name to further construct the basename.
+ * @param resourceName The name of the resource without the ".properties" extension
+ * @param locale The locale
+ * @param extendsBundle If non-null, then this ExtendMessages will default to extendsBundle.
+ * @throws MissingResourceException if projectName is not a prefix of the caller's package name,
+ * or if the resource could not be found/loaded.
+ */
+ public static ProjectResourceBundle getBundle(String projectName, String packageName, String resourceName, Locale locale, ClassLoader loader, ResourceBundle extendsBundle)
+ throws MissingResourceException {
+ if (log.isDebugEnabled()) {
+ log.debug("getBundle(" + projectName + "," + packageName + ","
+ + resourceName + "," + String.valueOf(locale) + ",...)");
+ }
+
+ Context context = new Context();
+ context.setLocale(locale);
+ context.setLoader(loader);
+ context.setProjectName(projectName);
+ context.setResourceName(resourceName);
+ context.setParentBundle(extendsBundle);
+
+ String validatedPackageName = context.validate(packageName);
+
+ ProjectResourceBundle bundle = null;
+ try {
+ bundle = getBundle(context, validatedPackageName);
+ } catch (RuntimeException e) {
+ log.debug("Exception: ", e);
+ throw e;
+ }
+
+ if (bundle == null) {
+ throw new MissingResourceException("Cannot find resource '"
+ + validatedPackageName + '.' + resourceName + "'",
+ resourceName, "");
+ }
+
+ return bundle;
+ }
+
+ /**
+ * get bundle... - check cache - try up hierarchy - if at top of hierarchy, use (link to)
+ * context.getParentBundle()
+ */
+ private static synchronized ProjectResourceBundle getBundle(Context context, String packageName)
+ throws MissingResourceException {
+ String cacheKey = context.getCacheKey(packageName);
+
+ ProjectResourceBundle prb = (ProjectResourceBundle) bundleCache
+ .get(cacheKey);
+
+ if (prb == null) {
+ String name = packageName + '.' + context.getResourceName();
+ ResourceBundle rb = context.loadBundle(packageName);
+ ResourceBundle parent = context.getParentBundle(packageName);
+
+ if (rb != null) {
+ prb = new ProjectResourceBundle(name, rb);
+ prb.setParent(parent);
+ if (log.isDebugEnabled()) {
+ log.debug("Created " + prb + ", linked to parent "
+ + String.valueOf(parent));
+ }
+ } else {
+ if (parent != null) {
+ if (parent instanceof ProjectResourceBundle) {
+ prb = (ProjectResourceBundle) parent;
+ } else {
+ prb = new ProjectResourceBundle(name, parent);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Root package not found, cross link to "
+ + parent);
+ }
+ }
+ }
+ if (prb != null) {
+ // Cache the resource
+ bundleCache.put(cacheKey, prb);
+ }
+ }
+ return prb;
+ }
+
+ private static String getPackage(String name) {
+ return name.substring(0, name.lastIndexOf('.')).intern();
+ }
+
+ /** Construct a new ProjectResourceBundle */
+ private ProjectResourceBundle(String name, ResourceBundle bundle) throws MissingResourceException {
+ this.resourceBundle = bundle;
+ this.resourceName = name;
+ }
+
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ /** Clears the internal cache */
+ // public static void clearCache() {
+ // bundleCache.clear();
+ // }
+ @Override
+ public String toString() {
+ return resourceName;
+ }
+
+ private static class Context {
+ private Locale _locale;
+ private ClassLoader _loader;
+ private String _projectName;
+ private String _resourceName;
+ private ResourceBundle _parent;
+
+ void setLocale(Locale l) {
+ /* 1. Docs indicate that if locale is not specified,
+ * then the default local is used in it's place.
+ * 2. A null value for locale is invalid.
+ *
+ * Therefore, default...
+ */
+ _locale = (l == null) ? defaultLocale : l;
+ }
+
+ void setLoader(ClassLoader l) {
+ _loader = (l != null) ? l : this.getClass().getClassLoader();
+ if (_loader == null) {
+ _loader = ClassLoader.getSystemClassLoader();
+ }
+ }
+
+ void setProjectName(String name) {
+ _projectName = name.intern();
+ }
+
+ void setResourceName(String name) {
+ _resourceName = name.intern();
+ }
+
+ void setParentBundle(ResourceBundle b) {
+ _parent = b;
+ }
+
+ Locale getLocale() {
+ return _locale;
+ }
+
+ ClassLoader getLoader() {
+ return _loader;
+ }
+
+ String getProjectName() {
+ return _projectName;
+ }
+
+ String getResourceName() {
+ return _resourceName;
+ }
+
+ ResourceBundle getParentBundle() {
+ return _parent;
+ }
+
+ String getCacheKey(String packageName) {
+ String loaderName = (_loader == null) ? "" : (":" + _loader
+ .hashCode());
+ return packageName + "." + _resourceName + ":" + _locale + ":"
+ + defaultLocale + loaderName;
+ }
+
+ ResourceBundle loadBundle(String packageName) {
+ try {
+ return ResourceBundle.getBundle(packageName + '.'
+ + _resourceName, _locale, _loader);
+ } catch (MissingResourceException e) {
+ // Deliberately surpressing print stack.. just the string for info.
+ log.debug("loadBundle: Ignoring MissingResourceException: "
+ + e.getMessage());
+ }
+ return null;
+ }
+
+ ResourceBundle getParentBundle(String packageName) {
+ ResourceBundle p;
+ if (!packageName.equals(_projectName)) {
+ p = getBundle(this, getPackage(packageName));
+ } else {
+ p = _parent;
+ _parent = null;
+ }
+ return p;
+ }
+
+ String validate(final String packageName)
+ throws MissingResourceException {
+ if (_projectName == null || _projectName.length() == 0) {
+ log.debug("Project name not specified");
+ throw new MissingResourceException(
+ "Project name not specified", "", "");
+ }
+
+ if (packageName == null || packageName.length() == 0) {
+ log.debug("Package name not specified");
+ throw new MissingResourceException("Package not specified",
+ packageName, "");
+ }
+ String validatedPackageName = packageName.intern();
+
+ /* Ensure that project is a proper prefix of class.
+ * Terminate project name with '.' to ensure proper match.
+ */
+ if (!validatedPackageName.equals(_projectName)
+ && !validatedPackageName.startsWith(_projectName + '.')) {
+ log.debug("Project not a prefix of Package");
+ throw new MissingResourceException("Project '" + _projectName
+ + "' must be a prefix of Package '"
+ + validatedPackageName + "'", validatedPackageName
+ + '.' + _resourceName, "");
+ }
+
+ return validatedPackageName;
+ }
+ }
+}
Added: incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/i18n/resource.properties
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/i18n/resource.properties?rev=787557&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/i18n/resource.properties (added)
+++ incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/i18n/resource.properties Tue Jun 23 05:41:49 2009
@@ -0,0 +1,51 @@
+# Messages for the JAX-RS runtime
+
+contextInjectionFail=Invalid request for context information.
+resourceNotFound=A resource could not be targetted for the {0} request path.
+methodNotFound=A resource operation could not be targetted for the {0} request path.
+subResourceDataNotFound=Subresource metadata was not found for the {0} class.
+methodNotValid=The {0} method in the {1} class was not a valid resource method.
+methodNotPublic=The {0} method in the {1} class is not public and cannot be a resource method.
+methodInvalidAnnot00=The {0} method in the {1} class has more than one HTTP request designator annotation. At most, one is allowed.
+resourceNotFound00=The target resource class, {0}, cannot handle {1} request sent to URL {2} for request content type {3}. Please ensure that the class has the proper JAX-RS annotations to handle a {1} request.
+inboundContextFail00=The inbound RESTContext contains no properties.
+inboundContextFail01=The inbound RESTContext does not contain a request path.
+inboundContextFail02=The inbound RESTContext does not contain an HTTP method.
+inboundContextFail03=The inbound RESTContext does not contain an OutputStream.
+inboundContextFail04=The inbound RESTContext does not contain a request URL.
+inboundContextFail05=The inbound RESTContext does not contain an integration key.
+invalidMetaData00=JAX-RS metadata could not be built for the {0} request.
+invalidMetaData01=The {0} com.ibm.ws.jaxrs.integration.ApplicationProvider did not return a valid list of javax.ws.rs.core.Application subclasses, and a configuration file was not found.
+invalidIntRegistryKey=A null key was provided to the com.ibm.ws.jaxrs.integration.IntegrationRegistry.
+injectionFail=An error occurred while performing injection on the {0} class.
+invalidCstr=A valid constructor was not found for the {0} JAX-RS resource class. Make sure that constructors contain only parameters annotated with JSR-311 annotations or that there is a zero argument public constructor.
+multipleCstrs=Multiple suitable constructors were found for the {0} JAX-RS resource class. This could lead to indeterminant behavior.
+multipleResourceClasses00=More than one instance of the {0} class was found in the {1} singleton list.
+multipleResourceClasses01=The {0} JAX-RS class will be ignored because it was already returned in the singleton list.
+noClassFound=A class could not be found for instantiation.
+invalidInput00=Input type {0} not supported.
+subResourceNotInXML=The {0} subresource class specified by the {1} subresource locator in the {2} class was not found in the ibm-jaxrs.xml.
+providerNotCretaed=The {0} JAX-RS provider could not be created.
+jaxbContextFail=The JAXB Context could not be created.
+pathAnnotFail00=The {0} @Path value was found in the following classes: {1}. Values must be unique among classes in an application.
+pathAnnotFail01=The {0} @Path value was found on the {1} methods in the {2} class. Values must be unique on methods within the same class unless they map to different HTTP request methods.
+invalidSingletonAnnot=The {0} field in the {1} class is annotated with the {2} annotation. This annotation is invalid because the class is a singleton.
+multipleRequestDesignators=The annotation for the {0} HTTP method was found on the {1} methods in the {2} class. The annotation should only appear on a single method within the class unless there are different @Path, @Consumes, or @Produces annotations on the methods.
+invalidEntityParam00=More than one entity parameter was found on the {0} method in the {1} class. At most, one entity parameter is allowed.
+invalidEntityParam01=The {0} method in the {1} class contains an entity parameter that is not a javax.ws.rs.core.MultivaluedMap and at least one @FormParam annotated parameter.
+genericValidationError=An error occurred validating JAX-RS artifacts in the application. Check the logs for further information.
+processAppError=An error occurred processing the {0} javax.ws.core.Application subclass.
+servletResponseNotAvailable=The com.ibm.ws.jaxrs.web.ServletResponseWriter was called, but an HttpServletResponse was not available.
+responseNotAvailable=The com.ibm.ws.jaxrs.web.ServletResponseWriter was called, but a Response was not available.
+nullInput=Null arguments not excepted.
+invalidETag=The {0} ETag header is incorrectly formatted.
+invalidMIMEType=The {0} media type header is incorrectly formatted.
+invalidSetCookie=The {0} Set-Cookie header is incorrectly formatted.
+statusCodeInvalid=The {0} HTTP response status code is invalid.
+uriBuildFail=A valid URI cannot be built.
+sourceCreateFail=A javax.xml.transform.Source object could not be created.
+resourceInvocationFail=Resource invocation failed.
+badParamType=The {0} type was unmarshalled from the request entity, but the type was not compatible with the {1} method parameter.
+writerNotFound=A MessageBodyWriter was not found for the {0} request sent to the {1} path. The method invoked was {2}, which returns type {3}.
+readerOrHandlerNotFound=A MessageBodyReader or DataHandler could not be found for the {0} request sent to the {1} path. The method invoked was {2}, which receives parameter type {3} as media type {4}
+badJSONSyntax=An error occurred parsing the JSON String representation. Ensure that the JSON structure is well-formed.
\ No newline at end of file
Added: incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/injection/ThreadLocalContextResolver.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/injection/ThreadLocalContextResolver.java?rev=787557&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/injection/ThreadLocalContextResolver.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/injection/ThreadLocalContextResolver.java Tue Jun 23 05:41:49 2009
@@ -0,0 +1,38 @@
+/*
+ * 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 com.ibm.ws.jaxrs.injection;
+
+import javax.ws.rs.ext.ContextResolver;
+
+import org.apache.cxf.jaxrs.impl.tl.AbstractThreadLocalProxy;
+
+/**
+ * This class will be the thread local delegate for a ContextResolver
+ * object. When a ContextResolver is requested via the @Context annotation,
+ * an instance will be stored on thread local and accessed through this class.
+ *
+ */
+public class ThreadLocalContextResolver<T> extends AbstractThreadLocalProxy<ContextResolver<T>> implements ContextResolver<T> {
+
+ public T getContext(Class<?> type) {
+ return get().getContext(type);
+ }
+
+}
Added: incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/injection/ThreadLocalHttpServletResponse.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/injection/ThreadLocalHttpServletResponse.java?rev=787557&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/injection/ThreadLocalHttpServletResponse.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/injection/ThreadLocalHttpServletResponse.java Tue Jun 23 05:41:49 2009
@@ -0,0 +1,185 @@
+/*
+ * 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 com.ibm.ws.jaxrs.injection;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Locale;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.cxf.jaxrs.impl.tl.AbstractThreadLocalProxy;
+
+/**
+ * This class will be the thread local delegate for an HttpServletResponse
+ * object. When an HttpServletResponse is requested via the @Context
+ * annotation, an instance will be stored on thread local and accessed
+ * through this class.
+ *
+ */
+public class ThreadLocalHttpServletResponse extends AbstractThreadLocalProxy<HttpServletResponse> implements HttpServletResponse {
+
+ public void addCookie(Cookie cookie) {
+ get().addCookie(cookie);
+ }
+
+ public void addDateHeader(String key, long value) {
+ get().addDateHeader(key, value);
+ }
+
+ public void addHeader(String key, String value) {
+ get().addHeader(key, value);
+ }
+
+ public void addIntHeader(String key, int value) {
+ get().addIntHeader(key, value);
+ }
+
+ public boolean containsHeader(String key) {
+ return get().containsHeader(key);
+ }
+
+ @SuppressWarnings("deprecation")
+ public String encodeRedirectUrl(String url) {
+ return get().encodeRedirectUrl(url);
+ }
+
+ public String encodeRedirectURL(String url) {
+ return get().encodeRedirectURL(url);
+ }
+
+ @SuppressWarnings("deprecation")
+ public String encodeUrl(String url) {
+ return get().encodeUrl(url);
+ }
+
+ public String encodeURL(String url) {
+ return get().encodeRedirectURL(url);
+ }
+
+ public void sendError(int status, String error) throws IOException {
+ get().sendError(status, error);
+
+ }
+
+ public void sendError(int status) throws IOException {
+ get().sendError(status);
+ }
+
+ public void sendRedirect(String url) throws IOException {
+ get().sendRedirect(url);
+ }
+
+ public void setDateHeader(String key, long value) {
+ get().setDateHeader(key, value);
+ }
+
+ public void setHeader(String key, String value) {
+ get().setHeader(key, value);
+ }
+
+ public void setIntHeader(String key, int value) {
+ get().setIntHeader(key, value);
+ }
+
+ @SuppressWarnings("deprecation")
+ public void setStatus(int status, String msg) {
+ get().setStatus(status, msg);
+ }
+
+ public void setStatus(int status) {
+ get().setStatus(status);
+ }
+
+ public void disable() {
+ get().disable();
+ }
+
+ public void enable() {
+ get().enable();
+ }
+
+ public void flushBuffer() throws IOException {
+ get().flushBuffer();
+ }
+
+ public int getBufferSize() {
+ return get().getBufferSize();
+ }
+
+ public String getCharacterEncoding() {
+ return get().getCharacterEncoding();
+ }
+
+ public String getContentType() {
+ return get().getContentType();
+ }
+
+ public Locale getLocale() {
+ return get().getLocale();
+ }
+
+ public ServletOutputStream getOutputStream() throws IOException {
+ return get().getOutputStream();
+ }
+
+ public PrintWriter getWriter() throws IOException {
+ return get().getWriter();
+ }
+
+ public boolean isCommitted() {
+ return get().isCommitted();
+ }
+
+ public boolean isDisabled() {
+ return get().isDisabled();
+ }
+
+ public void reset() {
+ get().reset();
+ }
+
+ public void resetBuffer() {
+ get().resetBuffer();
+ }
+
+ public void setBufferSize(int size) {
+ get().setBufferSize(size);
+ }
+
+ public void setCharacterEncoding(String charEncoding) {
+ get().setCharacterEncoding(charEncoding);
+ }
+
+ public void setContentLength(int length) {
+ get().setContentLength(length);
+ }
+
+ public void setContentType(String contentType) {
+ get().setContentType(contentType);
+ }
+
+ public void setLocale(Locale locale) {
+ get().setLocale(locale);
+ }
+
+}
Added: incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/injection/ThreadLocalProviders.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/injection/ThreadLocalProviders.java?rev=787557&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/injection/ThreadLocalProviders.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/injection/ThreadLocalProviders.java Tue Jun 23 05:41:49 2009
@@ -0,0 +1,58 @@
+/*
+ * 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 com.ibm.ws.jaxrs.injection;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.ext.ContextResolver;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Providers;
+
+import org.apache.cxf.jaxrs.impl.tl.AbstractThreadLocalProxy;
+
+/**
+ * This class will be the thread local delegate for a Providers implementation
+ * object. When a Providers object is requested via the @Context annotation,
+ * an instance will be stored on thread local and accessed through this class.
+ *
+ */
+public class ThreadLocalProviders extends AbstractThreadLocalProxy<Providers> implements Providers {
+
+ public <T> ContextResolver<T> getContextResolver(Class<T> clazz, MediaType mediaType) {
+ return get().getContextResolver(clazz, mediaType);
+ }
+
+ public <T extends Throwable> ExceptionMapper<T> getExceptionMapper(Class<T> clazz) {
+ return get().getExceptionMapper(clazz);
+ }
+
+ public <T> MessageBodyReader<T> getMessageBodyReader(Class<T> clazz, Type type, Annotation[] annotations, MediaType mediaType) {
+ return get().getMessageBodyReader(clazz, type, annotations, mediaType);
+ }
+
+ public <T> MessageBodyWriter<T> getMessageBodyWriter(Class<T> clazz, Type type, Annotation[] annotations, MediaType mediaType) {
+ return get().getMessageBodyWriter(clazz, type, annotations, mediaType);
+ }
+
+}
Added: incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/injection/ThreadLocalServletConfig.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/injection/ThreadLocalServletConfig.java?rev=787557&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/injection/ThreadLocalServletConfig.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/injection/ThreadLocalServletConfig.java Tue Jun 23 05:41:49 2009
@@ -0,0 +1,54 @@
+/*
+ * 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 com.ibm.ws.jaxrs.injection;
+
+import java.util.Enumeration;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+
+import org.apache.cxf.jaxrs.impl.tl.AbstractThreadLocalProxy;
+
+/**
+ * This class will be the thread local delegate for a ServletConfig
+ * object. When a ServletConfig is requested via the @Context annotation,
+ * an instance will be stored on thread local and accessed through
+ * this class.
+ *
+ */
+public class ThreadLocalServletConfig extends AbstractThreadLocalProxy<ServletConfig> implements ServletConfig {
+
+ public String getInitParameter(String paramName) {
+ return get().getInitParameter(paramName);
+ }
+
+ public Enumeration getInitParameterNames() {
+ return get().getInitParameterNames();
+ }
+
+ public ServletContext getServletContext() {
+ return get().getServletContext();
+ }
+
+ public String getServletName() {
+ return get().getServletName();
+ }
+
+}
Added: incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/injection/ThreadLocalServletContext.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/injection/ThreadLocalServletContext.java?rev=787557&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/injection/ThreadLocalServletContext.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/injection/ThreadLocalServletContext.java Tue Jun 23 05:41:49 2009
@@ -0,0 +1,171 @@
+/*
+ * 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 com.ibm.ws.jaxrs.injection;
+
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.EnumSet;
+import java.util.Enumeration;
+import java.util.Map;
+import java.util.Set;
+
+import javax.servlet.DispatcherType;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+
+import org.apache.cxf.jaxrs.impl.tl.AbstractThreadLocalProxy;
+
+/**
+ * This class will be the thread local delegate for a ServletContext
+ * object. When a ServletContext is requested via the @Context annotation,
+ * an instance will be stored on thread local and accessed through
+ * this class.
+ *
+ */
+public class ThreadLocalServletContext extends AbstractThreadLocalProxy<ServletContext> implements ServletContext {
+
+ public void addFilter(String arg0, String arg1, String arg2, Map<String, String> arg3)
+ throws IllegalArgumentException, IllegalStateException {
+ get().addFilter(arg0, arg1, arg2, arg3);
+ }
+
+ public void addFilterMapping(String arg0, String[] arg1, String[] arg2, EnumSet<DispatcherType> arg3, boolean arg4)
+ throws IllegalArgumentException, IllegalStateException {
+ get().addFilterMapping(arg0, arg1, arg2, arg3, arg4);
+ }
+
+ public void addServlet(String arg0, String arg1, String arg2, Map<String, String> arg3, int arg4)
+ throws IllegalArgumentException, IllegalStateException {
+ get().addServlet(arg0, arg1, arg2, arg3, arg4);
+ }
+
+ public void addServletMapping(String servlet, String[] mappings)
+ throws IllegalArgumentException, IllegalStateException {
+ get().addServletMapping(servlet, mappings);
+ }
+
+ public Object getAttribute(String name) {
+ return get().getAttribute(name);
+ }
+
+ public Enumeration getAttributeNames() {
+ return get().getAttributeNames();
+ }
+
+ public ServletContext getContext(String key) {
+ return get().getContext(key);
+ }
+
+ public String getContextPath() {
+ return get().getContextPath();
+ }
+
+ public String getInitParameter(String paramName) {
+ return get().getInitParameter(paramName);
+ }
+
+ public Enumeration getInitParameterNames() {
+ return get().getInitParameterNames();
+ }
+
+ public int getMajorVersion() {
+ return get().getMajorVersion();
+ }
+
+ public String getMimeType(String key) {
+ return get().getMimeType(key);
+ }
+
+ public int getMinorVersion() {
+ return get().getMinorVersion();
+ }
+
+ public RequestDispatcher getNamedDispatcher(String dispatcher) {
+ return get().getNamedDispatcher(dispatcher);
+ }
+
+ public String getRealPath(String key) {
+ return get().getRealPath(key);
+ }
+
+ public RequestDispatcher getRequestDispatcher(String key) {
+ return get().getRequestDispatcher(key);
+ }
+
+ public URL getResource(String resource) throws MalformedURLException {
+ return get().getResource(resource);
+ }
+
+ public InputStream getResourceAsStream(String resource) {
+ return get().getResourceAsStream(resource);
+ }
+
+ public Set getResourcePaths(String key) {
+ return get().getResourcePaths(key);
+ }
+
+ public String getServerInfo() {
+ return get().getServerInfo();
+ }
+
+ @SuppressWarnings("deprecation")
+ public Servlet getServlet(String servlet) throws ServletException {
+ return get().getServlet(servlet);
+ }
+
+ public String getServletContextName() {
+ return get().getServletContextName();
+ }
+
+ @SuppressWarnings("deprecation")
+ public Enumeration getServletNames() {
+ return get().getServletNames();
+ }
+
+ @SuppressWarnings("deprecation")
+ public Enumeration getServlets() {
+ return get().getServlets();
+ }
+
+ @SuppressWarnings("deprecation")
+ public void log(Exception error, String msg) {
+ get().log(error, msg);
+ }
+
+ public void log(String msg, Throwable error) {
+ get().log(msg, error);
+ }
+
+ public void log(String msg) {
+ get().log(msg);
+ }
+
+ public void removeAttribute(String key) {
+ get().removeAttribute(key);
+ }
+
+ public void setAttribute(String key, Object attr) {
+ get().setAttribute(key, attr);
+ }
+
+}
Added: incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/integration/ApplicationProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/integration/ApplicationProvider.java?rev=787557&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/integration/ApplicationProvider.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/integration/ApplicationProvider.java Tue Jun 23 05:41:49 2009
@@ -0,0 +1,41 @@
+/*
+ * 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 com.ibm.ws.jaxrs.integration;
+
+import java.util.List;
+
+import javax.ws.rs.core.Application;
+
+import com.ibm.ws.jaxrs.context.RESTContext;
+
+/**
+ * Implementations of this interface will provide a list of JAX-RS
+ * Application subclasses to the JAX-RS runtime.
+ *
+ */
+public interface ApplicationProvider {
+
+ /**
+ * Called by the JAX-RS runtime to get a list of JAX-RS Application subclasses.
+ */
+ public List<Application> getApplicationClasses(RESTContext context)
+ throws Exception;
+
+}
Added: incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/integration/DefaultApplication.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/integration/DefaultApplication.java?rev=787557&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/integration/DefaultApplication.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/integration/DefaultApplication.java Tue Jun 23 05:41:49 2009
@@ -0,0 +1,53 @@
+/*
+ * 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 com.ibm.ws.jaxrs.integration;
+
+import java.util.Set;
+
+import javax.ws.rs.core.Application;
+
+/**
+ * An implementation of the Application class used in situations where
+ * classes are discovered by a different means than the Application
+ * subclass resolution.
+ *
+ */
+public class DefaultApplication extends Application {
+
+ private Set<Class<?>> classes;
+
+ private Set<Object> singletons;
+
+ public DefaultApplication(Set<Class<?>> classes, Set<Object> singletons) {
+ this.classes = classes;
+ this.singletons = singletons;
+ }
+
+ @Override
+ public Set<Class<?>> getClasses() {
+ return classes;
+ }
+
+ @Override
+ public Set<Object> getSingletons() {
+ return singletons;
+ }
+
+}
Added: incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/integration/DefaultJAXRSProviderCacheProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/integration/DefaultJAXRSProviderCacheProvider.java?rev=787557&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/integration/DefaultJAXRSProviderCacheProvider.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/integration/DefaultJAXRSProviderCacheProvider.java Tue Jun 23 05:41:49 2009
@@ -0,0 +1,45 @@
+/*
+ * 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 com.ibm.ws.jaxrs.integration;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.apache.cxf.jaxrs.provider.ProviderFactory;
+
+public class DefaultJAXRSProviderCacheProvider implements JAXRSProviderCacheProvider {
+
+ final private ConcurrentMap<Object, ProviderFactory> cache = new ConcurrentHashMap<Object, ProviderFactory>();
+
+ public void cacheProviderFactory(Object key, ProviderFactory pf) {
+ if(key == null) {
+ return;
+ }
+ cache.put(key, pf);
+ }
+
+ public ProviderFactory getProviderFactory(Object key) {
+ if (key == null) {
+ return null;
+ }
+ return cache.get(key);
+ }
+
+}
Added: incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/integration/DefaultResponseWriter.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/integration/DefaultResponseWriter.java?rev=787557&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/integration/DefaultResponseWriter.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/src/com/ibm/ws/jaxrs/integration/DefaultResponseWriter.java Tue Jun 23 05:41:49 2009
@@ -0,0 +1,77 @@
+/*
+ * 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 com.ibm.ws.jaxrs.integration;
+
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.activation.DataContentHandler;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+
+import com.ibm.ws.jaxrs.context.ContextConstants;
+import com.ibm.ws.jaxrs.context.RESTContext;
+
+/**
+ * This is the default implementation of the ResponseWriter interface
+ * supplied by the core runtime. It will simply serialize the response
+ * to the OutputStream provided.
+ *
+ */
+public class DefaultResponseWriter implements ResponseWriter {
+
+ /**
+ * Called before the serialization. Nothing to do here.
+ */
+ public void preWrite(RESTContext context) throws Exception {
+ // no op
+ }
+
+ /**
+ * Calls the 'dataHandler' to serialize its contents to the OutputStream.
+ */
+ public void writeWithDataHandler(RESTContext context, Object object, String mimeType, DataContentHandler contentHandler, OutputStream os)
+ throws Exception {
+ contentHandler.writeTo(object, mimeType, os);
+ }
+
+ /**
+ * Writes the 'responseObject' to the provided OutputStream.
+ */
+ public void writeWithEntityProvider(RESTContext context, MessageBodyWriter writer, Object responseObject, Class<?> clazz, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> headers, OutputStream os)
+ throws Exception {
+ writer.writeTo(responseObject, clazz, type, annotations, mediaType,
+ headers, os);
+ }
+
+ /**
+ * Called after the serialization. Nothing to do here.
+ */
+ public void postWrite(RESTContext context) throws Exception {
+ OutputStream os = (OutputStream) context
+ .getProperty(ContextConstants.RESPONSE_OUTPUT_STREAM);
+ if (os != null) {
+ os.flush();
+ }
+ }
+
+}