You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by bl...@apache.org on 2010/03/22 19:18:36 UTC
svn commit: r926237 [2/2] - in /cxf/sandbox/geronimo-jaxrs_1.1_spec: ./ src/
src/main/ src/main/java/ src/main/java/javax/ src/main/java/javax/ws/
src/main/java/javax/ws/rs/ src/main/java/javax/ws/rs/core/
src/main/java/javax/ws/rs/ext/
Added: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/MediaType.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/MediaType.java?rev=926237&view=auto
==============================================================================
--- cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/MediaType.java (added)
+++ cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/MediaType.java Mon Mar 22 18:18:35 2010
@@ -0,0 +1,221 @@
+/*
+ * 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 javax.ws.rs.core;
+
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Map;
+import java.util.TreeMap;
+
+import javax.ws.rs.ext.RuntimeDelegate;
+import javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate;
+
+public class MediaType {
+ public static final String APPLICATION_ATOM_XML =
+ "application/atom+xml";
+
+ public static final MediaType APPLICATION_ATOM_XML_TYPE =
+ new MediaType(
+ "application",
+ "atom+xml");
+ public static final String APPLICATION_FORM_URLENCODED =
+ "application/x-www-form-urlencoded";
+ public static final MediaType APPLICATION_FORM_URLENCODED_TYPE =
+ new MediaType(
+ "application",
+ "x-www-form-urlencoded");
+ public static final String APPLICATION_JSON =
+ "application/json";
+ public static final MediaType APPLICATION_JSON_TYPE =
+ new MediaType(
+ "application",
+ "json");
+ public static final String APPLICATION_OCTET_STREAM =
+ "application/octet-stream";
+ public static final MediaType APPLICATION_OCTET_STREAM_TYPE =
+ new MediaType(
+ "application",
+ "octet-stream");
+ public static final String APPLICATION_SVG_XML =
+ "application/svg+xml";
+ public static final MediaType APPLICATION_SVG_XML_TYPE =
+ new MediaType(
+ "application",
+ "svg+xml");
+ public static final String APPLICATION_XHTML_XML =
+ "application/xhtml+xml";
+ public static final MediaType APPLICATION_XHTML_XML_TYPE =
+ new MediaType(
+ "application",
+ "xhtml+xml");
+ public static final String APPLICATION_XML =
+ "application/xml";
+ public static final MediaType APPLICATION_XML_TYPE =
+ new MediaType(
+ "application",
+ "xml");
+ public static final String MEDIA_TYPE_WILDCARD = "*";
+ public static final String MULTIPART_FORM_DATA =
+ "multipart/form-data";
+ public static final MediaType MULTIPART_FORM_DATA_TYPE =
+ new MediaType(
+ "multipart",
+ "form-data");
+ public static final String TEXT_HTML = "text/html";
+ public static final MediaType TEXT_HTML_TYPE =
+ new MediaType(
+ "text",
+ "html");
+ public static final String TEXT_PLAIN = "text/plain";
+ public static final MediaType TEXT_PLAIN_TYPE =
+ new MediaType(
+ "text",
+ "plain");
+ public static final String TEXT_XML = "text/xml";
+ public static final MediaType TEXT_XML_TYPE =
+ new MediaType(
+ "text",
+ "xml");
+ public static final String WILDCARD = "*/*";
+ public static final MediaType WILDCARD_TYPE =
+ new MediaType(
+ "*",
+ "*");
+
+ private final String type;
+ private final String subtype;
+ private final Map<String, String> params;
+
+ private static final HeaderDelegate<MediaType> delegate =
+ RuntimeDelegate
+ .getInstance()
+ .createHeaderDelegate(MediaType.class);
+
+ public MediaType(String type, String subtype, Map<String, String> parameters) {
+ if (type == null) {
+ this.type = MEDIA_TYPE_WILDCARD;
+ } else {
+ this.type = type;
+ }
+
+ if (subtype == null) {
+ this.subtype = MEDIA_TYPE_WILDCARD;
+ } else {
+ this.subtype = subtype;
+ }
+
+ if (parameters == null) {
+ this.params = Collections.emptyMap();
+ } else {
+ // need to use a temporary map here since for some reason the ordering is important.
+ Map<String, String> temp = new TreeMap<String, String>(new Comparator<String>() {
+ public int compare(String o1, String o2) {
+ return o1.compareToIgnoreCase(o2);
+ }
+ });
+ // need to put in as all lower case keys for comparisons, hashcode, and output
+ for (String key : parameters.keySet()) {
+ temp.put(key.toLowerCase(), parameters.get(key));
+ }
+ this.params = Collections.unmodifiableMap(temp);
+ }
+ }
+
+ public MediaType(String type, String subtype) {
+ this(type, subtype, null);
+ }
+
+ public MediaType() {
+ this(MEDIA_TYPE_WILDCARD, MEDIA_TYPE_WILDCARD);
+ }
+
+ public static MediaType valueOf(String type) throws java.lang.IllegalArgumentException {
+ return delegate.fromString(type);
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public boolean isWildcardType() {
+ return MEDIA_TYPE_WILDCARD.equals(getType());
+ }
+
+ public String getSubtype() {
+ return subtype;
+ }
+
+ public boolean isWildcardSubtype() {
+ return MEDIA_TYPE_WILDCARD.equals(getSubtype());
+ }
+
+ public Map<String, String> getParameters() {
+ return params;
+ }
+
+ public boolean isCompatible(MediaType other) {
+ if (other == null) {
+ return false;
+ }
+ if (isWildcardType() || other.isWildcardType()) {
+ return true;
+ }
+ if (isWildcardSubtype() || other.isWildcardSubtype()) {
+ return getType().equalsIgnoreCase(other.getType());
+ }
+ return getType().equalsIgnoreCase(other.getType()) && getSubtype().equalsIgnoreCase(other
+ .getSubtype());
+ }
+
+ @Override
+ public boolean equals(java.lang.Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (!(obj instanceof MediaType)) {
+ return false;
+ }
+
+ MediaType other = (MediaType)obj;
+
+ return getType().equalsIgnoreCase(other.getType()) && getSubtype().equalsIgnoreCase(other
+ .getSubtype())
+ && getParameters().equals(other.getParameters());
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 17;
+ // be sure to lowercase for comparisions
+
+ // be careful about hash code. since not guaranteed that this is a final
+ // class, need to use methods. methods do not guarantee lowercase
+ result = 31 * result + getType().toLowerCase().hashCode();
+ result = 31 * result + getSubtype().toLowerCase().hashCode();
+ result = 31 * result + getParameters().hashCode();
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return delegate.toString(this);
+ }
+}
Propchange: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/MediaType.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/MultivaluedMap.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/MultivaluedMap.java?rev=926237&view=auto
==============================================================================
--- cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/MultivaluedMap.java (added)
+++ cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/MultivaluedMap.java Mon Mar 22 18:18:35 2010
@@ -0,0 +1,31 @@
+/*
+ * 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 javax.ws.rs.core;
+
+import java.util.List;
+import java.util.Map;
+
+public interface MultivaluedMap<K, V> extends Map<K, List<V>> {
+ public void add(K key, V value);
+
+ public V getFirst(K key);
+
+ public void putSingle(K key, V value);
+}
Propchange: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/MultivaluedMap.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/NewCookie.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/NewCookie.java?rev=926237&view=auto
==============================================================================
--- cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/NewCookie.java (added)
+++ cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/NewCookie.java Mon Mar 22 18:18:35 2010
@@ -0,0 +1,188 @@
+/*
+ * 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 javax.ws.rs.core;
+
+import javax.ws.rs.ext.RuntimeDelegate;
+import javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate;
+
+public class NewCookie extends Cookie {
+ public static final int DEFAULT_MAX_AGE = -1;
+
+ private final String comment;
+ private final int maxAge;
+ private final boolean isSecure;
+
+ public NewCookie(String name, String value) {
+ this(name, value, null, null, null, DEFAULT_MAX_AGE, false);
+ }
+
+ public NewCookie(String name,
+ String value,
+ String path,
+ String domain,
+ String comment,
+ int maxAge,
+ boolean isSecure) {
+ this(name, value, path, domain, DEFAULT_VERSION, comment, maxAge, isSecure);
+ }
+
+ public NewCookie(String name,
+ String value,
+ String path,
+ String domain,
+ int version,
+ String comment,
+ int maxAge,
+ boolean isSecure) {
+ super(name, value, path, domain, version);
+ this.comment = comment;
+ this.maxAge = maxAge;
+ this.isSecure = isSecure;
+ }
+
+ public NewCookie(Cookie cookie) {
+ this(cookie, null, DEFAULT_MAX_AGE, false);
+ }
+
+ public NewCookie(Cookie cookie, String comment, int maxAge, boolean isSecure) {
+ super(cookie.getName(), cookie.getValue(), cookie.getPath(), cookie.getDomain(), cookie
+ .getVersion());
+ this.comment = comment;
+ this.maxAge = maxAge;
+ this.isSecure = isSecure;
+ }
+
+ @Override
+ public boolean equals(java.lang.Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj == null) {
+ return false;
+ }
+
+ // note that this must be a NewCookie exactly
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+
+ NewCookie other = (NewCookie)obj;
+ if (!getName().equals(other.getName())) {
+ return false;
+ }
+
+ if (getVersion() != other.getVersion()) {
+ return false;
+ }
+
+ if (isSecure != other.isSecure) {
+ return false;
+ }
+
+ if (maxAge != other.maxAge) {
+ return false;
+ }
+
+ String value = getValue();
+ if (value == null) {
+ if (other.getValue() != null) {
+ return false;
+ }
+ } else {
+ if (!value.equals(other.getValue())) {
+ return false;
+ }
+ }
+
+ String path = getPath();
+ if (path == null) {
+ if (other.getPath() != null) {
+ return false;
+ }
+ } else {
+ if (!path.equals(other.getPath())) {
+ return false;
+ }
+ }
+
+ String domain = getDomain();
+ if (domain == null) {
+ if (other.getDomain() != null) {
+ return false;
+ }
+ } else {
+ if (!domain.equals(other.getDomain())) {
+ return false;
+ }
+ }
+
+ if (comment == null) {
+ if (other.comment != null) {
+ return false;
+ }
+ } else {
+ if (!comment.equals(other.comment)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = super.hashCode();
+ result = 31 * result + ((comment == null) ? 0 : comment.hashCode());
+ result = 31 * result + maxAge;
+ result = 31 * result + ((isSecure) ? 1 : 0);
+ return result;
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+ public int getMaxAge() {
+ return maxAge;
+ }
+
+ public boolean isSecure() {
+ return isSecure;
+ }
+
+ public Cookie toCookie() {
+ return new Cookie(getName(), getValue(), getPath(), getDomain(), getVersion());
+ }
+
+ private static final HeaderDelegate<NewCookie> headerDelegate =
+ RuntimeDelegate
+ .getInstance()
+ .createHeaderDelegate(NewCookie.class);
+
+ @Override
+ public String toString() {
+ return headerDelegate.toString(this);
+ }
+
+ public static NewCookie valueOf(String value) {
+ return headerDelegate.fromString(value);
+ }
+}
Propchange: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/NewCookie.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/PathSegment.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/PathSegment.java?rev=926237&view=auto
==============================================================================
--- cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/PathSegment.java (added)
+++ cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/PathSegment.java Mon Mar 22 18:18:35 2010
@@ -0,0 +1,26 @@
+/*
+ * 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 javax.ws.rs.core;
+
+public interface PathSegment {
+ public MultivaluedMap<String, String> getMatrixParameters();
+
+ public String getPath();
+}
Propchange: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/PathSegment.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/Request.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/Request.java?rev=926237&view=auto
==============================================================================
--- cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/Request.java (added)
+++ cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/Request.java Mon Mar 22 18:18:35 2010
@@ -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 javax.ws.rs.core;
+
+import java.util.Date;
+import java.util.List;
+
+public interface Request {
+ public Response.ResponseBuilder evaluatePreconditions(Date lastModified);
+
+ public Response.ResponseBuilder evaluatePreconditions(Date lastModified,
+ EntityTag entityTag);
+
+ public Response.ResponseBuilder evaluatePreconditions(EntityTag entityTag);
+
+ public String getMethod();
+
+ public Variant selectVariant(List<Variant> variants);
+}
Propchange: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/Request.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/Response.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/Response.java?rev=926237&view=auto
==============================================================================
--- cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/Response.java (added)
+++ cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/Response.java Mon Mar 22 18:18:35 2010
@@ -0,0 +1,248 @@
+/*
+ * 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 javax.ws.rs.core;
+
+import java.net.URI;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+
+import javax.ws.rs.ext.RuntimeDelegate;
+
+public abstract class Response {
+
+ private final static RuntimeDelegate delegate = RuntimeDelegate.getInstance();
+
+ public abstract static class ResponseBuilder {
+ protected ResponseBuilder() {
+ // do nothing
+ }
+
+ public abstract Response build();
+
+ public abstract Response.ResponseBuilder cacheControl(CacheControl value);
+
+ @Override
+ public abstract Response.ResponseBuilder clone();
+
+ public abstract Response.ResponseBuilder contentLocation(URI value);
+
+ public abstract Response.ResponseBuilder cookie(NewCookie... values);
+
+ public abstract Response.ResponseBuilder entity(Object value);
+
+ public abstract Response.ResponseBuilder expires(Date value);
+
+ public abstract Response.ResponseBuilder header(String name, Object value);
+
+ public abstract Response.ResponseBuilder language(Locale value);
+
+ public abstract Response.ResponseBuilder language(String value);
+
+ public abstract Response.ResponseBuilder lastModified(Date value);
+
+ public abstract Response.ResponseBuilder location(URI value);
+
+ protected static Response.ResponseBuilder newInstance() {
+ return delegate.createResponseBuilder();
+ }
+
+ public abstract Response.ResponseBuilder status(int value);
+
+ public Response.ResponseBuilder status(Response.Status value) {
+ return delegate.createResponseBuilder().status(value.getStatusCode());
+ }
+
+ public abstract Response.ResponseBuilder tag(EntityTag value);
+
+ public abstract Response.ResponseBuilder tag(String value);
+
+ public abstract Response.ResponseBuilder type(MediaType value);
+
+ public abstract Response.ResponseBuilder type(String type);
+
+ public abstract Response.ResponseBuilder variant(Variant value);
+
+ public abstract Response.ResponseBuilder variants(List<Variant> values);
+ }
+
+ public static enum Status {
+ ACCEPTED(Family.SUCCESSFUL, 202, "Accepted"), BAD_REQUEST(Family.CLIENT_ERROR, 400,
+ "Bad Request"), CONFLICT(Family.CLIENT_ERROR, 409, "Conflict"), CREATED(
+ Family.SUCCESSFUL, 201, "Created"), FORBIDDEN(Family.CLIENT_ERROR, 403, "Forbidden"), GONE(
+ Family.CLIENT_ERROR, 410, "Gone"), INTERNAL_SERVER_ERROR(Family.SERVER_ERROR, 500,
+ "Internal Server Error"), MOVED_PERMANENTLY(Family.REDIRECTION, 301,
+ "Moved Permanently"), NO_CONTENT(Family.SUCCESSFUL, 204, "No Content"), NOT_ACCEPTABLE(
+ Family.CLIENT_ERROR, 406, "Not Acceptable"), NOT_FOUND(Family.CLIENT_ERROR, 404,
+ "Not Found"), NOT_MODIFIED(Family.REDIRECTION, 304, "Not Modified"), OK(
+ Family.SUCCESSFUL, 200, "OK"), PRECONDITION_FAILED(Family.CLIENT_ERROR, 412,
+ "Precondition Failed"), SEE_OTHER(Family.REDIRECTION, 303, "See Other"), SERVICE_UNAVAILABLE(
+ Family.SERVER_ERROR, 503, "Service Unavailable"), TEMPORARY_REDIRECT(
+ Family.REDIRECTION, 307, "Temporary Redirect"), UNAUTHORIZED(Family.CLIENT_ERROR, 401,
+ "Unauthorized"), UNSUPPORTED_MEDIA_TYPE(Family.CLIENT_ERROR, 415,
+ "Unsupported Media Type"), ;
+ private final Family family;
+ private final int statusCode;
+ private final String reasonPhrase;
+
+ private Status(Family family, int statusCode, String reasonPhrase) {
+ this.family = family;
+ this.statusCode = statusCode;
+ this.reasonPhrase = reasonPhrase;
+ }
+
+ public static enum Family {
+ CLIENT_ERROR, INFORMATIONAL, OTHER, REDIRECTION, SERVER_ERROR, SUCCESSFUL
+ }
+
+ public static Status fromStatusCode(int statusCode) {
+ for (Status s : values()) {
+ if (s.getStatusCode() == statusCode) {
+ return s;
+ }
+ }
+ return null;
+ }
+
+ public int getStatusCode() {
+ return statusCode;
+ }
+
+ public Response.Status.Family getFamily() {
+ return family;
+ }
+
+ @Override
+ public String toString() {
+ return reasonPhrase;
+ }
+ }
+
+ protected Response() {
+ // do nothing
+ }
+
+ public static Response.ResponseBuilder created(java.net.URI location) {
+ if (location == null) {
+ throw new IllegalArgumentException();
+ }
+ return status(Status.CREATED).location(location);
+ }
+
+ public static Response.ResponseBuilder fromResponse(Response response) {
+ ResponseBuilder builder = delegate.createResponseBuilder();
+ builder.status(response.getStatus());
+ builder.entity(response.getEntity());
+ MultivaluedMap<String, Object> metadata = response.getMetadata();
+ for (String key : metadata.keySet()) {
+ List<Object> values = metadata.get(key);
+ for (Object value : values) {
+ builder.header(key, value);
+ }
+ }
+ return builder;
+ }
+
+ public abstract Object getEntity();
+
+ public abstract MultivaluedMap<String, Object> getMetadata();
+
+ public abstract int getStatus();
+
+ public static Response.ResponseBuilder noContent() {
+ return status(Status.NO_CONTENT);
+ }
+
+ public static Response.ResponseBuilder notAcceptable(List<Variant> values) {
+ ResponseBuilder builder = status(Status.NOT_ACCEPTABLE);
+ if (values == null) {
+ return builder.variants(Collections.EMPTY_LIST);
+ }
+ return builder.variants(values);
+ }
+
+ public static Response.ResponseBuilder notModified() {
+ return status(Status.NOT_MODIFIED);
+ }
+
+ public static Response.ResponseBuilder notModified(EntityTag value) {
+ if (value == null) {
+ throw new IllegalArgumentException();
+ }
+ return status(Status.NOT_MODIFIED).tag(value);
+ }
+
+ public static Response.ResponseBuilder notModified(String value) {
+ if (value == null) {
+ throw new IllegalArgumentException();
+ }
+ return status(Status.NOT_MODIFIED).tag(value);
+ }
+
+ public static Response.ResponseBuilder ok() {
+ return status(Status.OK);
+ }
+
+ public static Response.ResponseBuilder ok(Object entity) {
+ return status(Status.OK).entity(entity);
+ }
+
+ public static Response.ResponseBuilder ok(Object entity, MediaType mediaType) {
+ return status(Status.OK).entity(entity).type(mediaType);
+ }
+
+ public static Response.ResponseBuilder ok(Object entity, String mediaType) {
+ return status(Status.OK).entity(entity).type(mediaType);
+ }
+
+ public static Response.ResponseBuilder ok(Object entity, Variant variant) {
+ return status(Status.OK).entity(entity).variant(variant);
+ }
+
+ public static Response.ResponseBuilder seeOther(URI location) {
+ if (location == null) {
+ throw new IllegalArgumentException();
+ }
+ return status(Status.SEE_OTHER).location(location);
+ }
+
+ public static Response.ResponseBuilder serverError() {
+ return status(Status.INTERNAL_SERVER_ERROR);
+ }
+
+ public static Response.ResponseBuilder status(int status) {
+ if (status < 100 || status > 599) {
+ throw new IllegalArgumentException();
+ }
+ return ResponseBuilder.newInstance().status(status);
+ }
+
+ public static Response.ResponseBuilder status(Response.Status status) {
+ if (status == null) {
+ throw new IllegalArgumentException();
+ }
+ return ResponseBuilder.newInstance().status(status);
+ }
+
+ public static Response.ResponseBuilder temporaryRedirect(URI location) {
+ return status(Status.TEMPORARY_REDIRECT).location(location);
+ }
+}
Propchange: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/Response.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/SecurityContext.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/SecurityContext.java?rev=926237&view=auto
==============================================================================
--- cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/SecurityContext.java (added)
+++ cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/SecurityContext.java Mon Mar 22 18:18:35 2010
@@ -0,0 +1,37 @@
+/*
+ * 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 javax.ws.rs.core;
+
+import java.security.Principal;
+
+public interface SecurityContext {
+ public static final java.lang.String BASIC_AUTH = "BASIC";
+ public static final java.lang.String CLIENT_CERT_AUTH = "CLIENT_CERT";
+ public static final java.lang.String DIGEST_AUTH = "DIGEST";
+ public static final java.lang.String FORM_AUTH = "FORM";
+
+ public String getAuthenticationScheme();
+
+ public Principal getUserPrincipal();
+
+ public boolean isSecure();
+
+ public boolean isUserInRole(String role);
+}
Propchange: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/SecurityContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/StreamingOutput.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/StreamingOutput.java?rev=926237&view=auto
==============================================================================
--- cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/StreamingOutput.java (added)
+++ cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/StreamingOutput.java Mon Mar 22 18:18:35 2010
@@ -0,0 +1,27 @@
+/*
+ * 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 javax.ws.rs.core;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+public interface StreamingOutput {
+ public void write(OutputStream os) throws IOException;
+}
Propchange: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/StreamingOutput.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/UriBuilder.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/UriBuilder.java?rev=926237&view=auto
==============================================================================
--- cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/UriBuilder.java (added)
+++ cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/UriBuilder.java Mon Mar 22 18:18:35 2010
@@ -0,0 +1,110 @@
+/*
+ * 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 javax.ws.rs.core;
+
+import java.lang.reflect.Method;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Map;
+
+import javax.ws.rs.ext.RuntimeDelegate;
+
+public abstract class UriBuilder {
+ protected UriBuilder() {
+ super();
+ }
+
+ public static UriBuilder fromPath(String value) {
+ return newInstance().replacePath(value);
+ }
+
+ public static UriBuilder fromResource(Class<?> resourceClass) {
+ return newInstance().path(resourceClass);
+ }
+
+ public static UriBuilder fromUri(String value) {
+ try {
+ return fromUri(new URI(value));
+ } catch (NullPointerException e) {
+ throw new IllegalArgumentException(e);
+ } catch (URISyntaxException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public static UriBuilder fromUri(URI uri) {
+ return newInstance().uri(uri);
+ }
+
+ private final static RuntimeDelegate delegate = RuntimeDelegate.getInstance();
+
+ protected static UriBuilder newInstance() {
+ return delegate.createUriBuilder();
+ }
+
+ public abstract java.net.URI build(Object... values);
+
+ public abstract java.net.URI buildFromEncoded(Object... values);
+
+ public abstract java.net.URI buildFromEncodedMap(Map<String, ? extends Object> values);
+
+ public abstract java.net.URI buildFromMap(Map<String, ? extends Object> values);
+
+ @Override
+ public abstract UriBuilder clone();
+
+ public abstract UriBuilder fragment(String value);
+
+ public abstract UriBuilder host(String value);
+
+ public abstract UriBuilder matrixParam(String name, Object... values);
+
+ public abstract UriBuilder path(Class<?> resourceClass);
+
+ public abstract UriBuilder path(Class<?> resourceClass, String resourceMethodName);
+
+ public abstract UriBuilder path(Method resourceMethod);
+
+ public abstract UriBuilder path(String value);
+
+ public abstract UriBuilder port(int port);
+
+ public abstract UriBuilder queryParam(String name, Object... values);
+
+ public abstract UriBuilder replaceMatrix(String value);
+
+ public abstract UriBuilder replaceMatrixParam(String name, Object... values);
+
+ public abstract UriBuilder replacePath(String value);
+
+ public abstract UriBuilder replaceQuery(String value);
+
+ public abstract UriBuilder replaceQueryParam(String name, Object... values);
+
+ public abstract UriBuilder scheme(String value);
+
+ public abstract UriBuilder schemeSpecificPart(String value);
+
+ public abstract UriBuilder segment(String... values);
+
+ public abstract UriBuilder uri(URI value);
+
+ public abstract UriBuilder userInfo(String value);
+}
Propchange: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/UriBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/UriBuilderException.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/UriBuilderException.java?rev=926237&view=auto
==============================================================================
--- cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/UriBuilderException.java (added)
+++ cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/UriBuilderException.java Mon Mar 22 18:18:35 2010
@@ -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 javax.ws.rs.core;
+
+public class UriBuilderException extends RuntimeException {
+
+ private static final long serialVersionUID = 956255903370721193L;
+
+ public UriBuilderException() {
+ super();
+ }
+
+ public UriBuilderException(String msg) {
+ super(msg);
+ }
+
+ public UriBuilderException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+
+ public UriBuilderException(Throwable cause) {
+ super((cause == null ? null : cause.toString()), cause);
+ }
+}
Propchange: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/UriBuilderException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/UriInfo.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/UriInfo.java?rev=926237&view=auto
==============================================================================
--- cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/UriInfo.java (added)
+++ cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/UriInfo.java Mon Mar 22 18:18:35 2010
@@ -0,0 +1,59 @@
+/*
+ * 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 javax.ws.rs.core;
+
+import java.net.URI;
+import java.util.List;
+
+public interface UriInfo {
+ public URI getAbsolutePath();
+
+ public UriBuilder getAbsolutePathBuilder();
+
+ public URI getBaseUri();
+
+ public UriBuilder getBaseUriBuilder();
+
+ public List<Object> getMatchedResources();
+
+ public List<String> getMatchedURIs();
+
+ public List<String> getMatchedURIs(boolean decode);
+
+ public String getPath();
+
+ public String getPath(boolean decode);
+
+ public MultivaluedMap<String, String> getPathParameters();
+
+ public MultivaluedMap<String, String> getPathParameters(boolean decode);
+
+ public List<PathSegment> getPathSegments();
+
+ public List<PathSegment> getPathSegments(boolean decode);
+
+ public MultivaluedMap<String, String> getQueryParameters();
+
+ public MultivaluedMap<String, String> getQueryParameters(boolean decode);
+
+ public URI getRequestUri();
+
+ public UriBuilder getRequestUriBuilder();
+}
Propchange: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/UriInfo.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/Variant.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/Variant.java?rev=926237&view=auto
==============================================================================
--- cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/Variant.java (added)
+++ cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/Variant.java Mon Mar 22 18:18:35 2010
@@ -0,0 +1,142 @@
+/*
+ * 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 javax.ws.rs.core;
+
+import java.util.Locale;
+
+import javax.ws.rs.ext.RuntimeDelegate;
+
+public class Variant {
+ public abstract static class VariantListBuilder {
+ protected VariantListBuilder() {
+ /* do nothing */
+ }
+
+ public abstract Variant.VariantListBuilder add();
+
+ public abstract java.util.List<Variant> build();
+
+ public abstract Variant.VariantListBuilder encodings(String... values);
+
+ public abstract Variant.VariantListBuilder languages(Locale... values);
+
+ public abstract Variant.VariantListBuilder mediaTypes(MediaType... values);
+
+ private final static RuntimeDelegate delegate = RuntimeDelegate.getInstance();
+
+ public static Variant.VariantListBuilder newInstance() {
+ return delegate.createVariantListBuilder();
+ }
+ }
+
+ public static Variant.VariantListBuilder encodings(String... values) {
+ return VariantListBuilder.newInstance().encodings(values);
+ }
+
+ public static Variant.VariantListBuilder languages(java.util.Locale... values) {
+ return VariantListBuilder.newInstance().languages(values);
+ }
+
+ public static Variant.VariantListBuilder mediaTypes(MediaType... values) {
+ return VariantListBuilder.newInstance().mediaTypes(values);
+ }
+
+ private final MediaType mediaType;
+ private final Locale language;
+ private final String encoding;
+
+ public Variant(MediaType mediaType, Locale language, String encoding) {
+ if (mediaType == null && language == null && encoding == null) {
+ throw new IllegalArgumentException();
+ }
+
+ this.mediaType = mediaType;
+ this.language = language;
+ this.encoding = encoding;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+
+ if (!(obj instanceof Variant)) {
+ return false;
+ }
+
+ Variant other = (Variant)obj;
+
+ String encoding = getEncoding();
+ if (encoding == null) {
+ if (other.getEncoding() != null) {
+ return false;
+ }
+ } else {
+ if (!encoding.equals(other.getEncoding())) {
+ return false;
+ }
+ }
+
+ Locale locale = getLanguage();
+ if (locale == null) {
+ if (other.getLanguage() != null) {
+ return false;
+ }
+ } else {
+ if (!locale.equals(other.getLanguage())) {
+ return false;
+ }
+ }
+
+ MediaType mt = getMediaType();
+ if (mt == null) {
+ if (other.getMediaType() != null) {
+ return false;
+ }
+ } else {
+ return mt.equals(other.getMediaType());
+ }
+
+ return true;
+ }
+
+ public String getEncoding() {
+ return encoding;
+ }
+
+ public java.util.Locale getLanguage() {
+ return language;
+ }
+
+ public MediaType getMediaType() {
+ return mediaType;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 17;
+ result = 31 * result + ((language == null) ? 0 : language.hashCode());
+ result = 31 * result + ((encoding == null) ? 0 : encoding.hashCode());
+ result = 31 * result + ((mediaType == null) ? 0 : mediaType.hashCode());
+ return result;
+ }
+
+}
Propchange: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/core/Variant.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/ContextResolver.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/ContextResolver.java?rev=926237&view=auto
==============================================================================
--- cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/ContextResolver.java (added)
+++ cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/ContextResolver.java Mon Mar 22 18:18:35 2010
@@ -0,0 +1,24 @@
+/*
+ * 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 javax.ws.rs.ext;
+
+public interface ContextResolver<T> {
+ public T getContext(Class<?> rawType);
+}
Propchange: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/ContextResolver.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/ExceptionMapper.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/ExceptionMapper.java?rev=926237&view=auto
==============================================================================
--- cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/ExceptionMapper.java (added)
+++ cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/ExceptionMapper.java Mon Mar 22 18:18:35 2010
@@ -0,0 +1,26 @@
+/*
+ * 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 javax.ws.rs.ext;
+
+import javax.ws.rs.core.Response;
+
+public interface ExceptionMapper<T extends Throwable> {
+ public Response toResponse(T throwable);
+}
Propchange: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/ExceptionMapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/MessageBodyReader.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/MessageBodyReader.java?rev=926237&view=auto
==============================================================================
--- cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/MessageBodyReader.java (added)
+++ cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/MessageBodyReader.java Mon Mar 22 18:18:35 2010
@@ -0,0 +1,42 @@
+/*
+ * 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 javax.ws.rs.ext;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+
+public interface MessageBodyReader<T> {
+ public boolean isReadable(Class<?> rawType,
+ Type genericType,
+ Annotation[] annotations,
+ MediaType mediaType);
+
+ public T readFrom(Class<T> rawType,
+ Type genericType,
+ Annotation[] annotations,
+ MediaType mediaType,
+ MultivaluedMap<String, String> httpHeaders,
+ InputStream entityStream) throws IOException;
+}
Propchange: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/MessageBodyReader.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/MessageBodyWriter.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/MessageBodyWriter.java?rev=926237&view=auto
==============================================================================
--- cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/MessageBodyWriter.java (added)
+++ cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/MessageBodyWriter.java Mon Mar 22 18:18:35 2010
@@ -0,0 +1,50 @@
+/*
+ * 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 javax.ws.rs.ext;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+
+public interface MessageBodyWriter<T> {
+
+ public long getSize(T t,
+ Class<?> rawType,
+ Type genericType,
+ Annotation[] annotations,
+ MediaType mediaType);
+
+ public boolean isWriteable(Class<?> rawType,
+ Type genericType,
+ Annotation[] annotations,
+ MediaType mediaType);
+
+ public void writeTo(T t,
+ Class<?> rawType,
+ Type genericType,
+ Annotation[] annotations,
+ MediaType mediaType,
+ MultivaluedMap<String, Object> httpHeaders,
+ OutputStream entityStream) throws IOException;
+}
Propchange: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/MessageBodyWriter.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/Provider.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/Provider.java?rev=926237&view=auto
==============================================================================
--- cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/Provider.java (added)
+++ cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/Provider.java Mon Mar 22 18:18:35 2010
@@ -0,0 +1,33 @@
+/*
+ * 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 javax.ws.rs.ext;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(value = ElementType.TYPE)
+@Retention(value = RetentionPolicy.RUNTIME)
+@Documented
+public @interface Provider {
+
+}
Propchange: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/Provider.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/Providers.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/Providers.java?rev=926237&view=auto
==============================================================================
--- cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/Providers.java (added)
+++ cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/Providers.java Mon Mar 22 18:18:35 2010
@@ -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 javax.ws.rs.ext;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.core.MediaType;
+
+public interface Providers {
+ public <T> ContextResolver<T> getContextResolver(Class<T> rawType, MediaType mediaType);
+
+ public <T extends Throwable> ExceptionMapper<T> getExceptionMapper(Class<T> rawType);
+
+ public <T> MessageBodyReader<T> getMessageBodyReader(Class<T> rawType,
+ Type genericType,
+ Annotation[] annotations,
+ MediaType mediaType);
+
+ public <T> MessageBodyWriter<T> getMessageBodyWriter(Class<T> rawType,
+ Type genericType,
+ Annotation[] annotations,
+ MediaType mediaType);
+}
Propchange: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/Providers.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/RuntimeDelegate.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/RuntimeDelegate.java?rev=926237&view=auto
==============================================================================
--- cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/RuntimeDelegate.java (added)
+++ cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/RuntimeDelegate.java Mon Mar 22 18:18:35 2010
@@ -0,0 +1,231 @@
+/*
+ * 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 javax.ws.rs.ext;
+
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.ReflectPermission;
+import java.util.Properties;
+
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.core.Variant;
+
+public abstract class RuntimeDelegate {
+ public static final String JAXRS_RUNTIME_DELEGATE_PROPERTY = "javax.ws.rs.ext.RuntimeDelegate";
+
+ public static interface HeaderDelegate<T> {
+ public T fromString(String str);
+
+ public String toString(T obj);
+ }
+
+ protected RuntimeDelegate() {
+ // do nothing
+ }
+
+ public abstract <T> T createEndpoint(Application app, java.lang.Class<T> type);
+
+ public abstract UriBuilder createUriBuilder();
+
+ public abstract Variant.VariantListBuilder createVariantListBuilder();
+
+ public abstract <T> RuntimeDelegate.HeaderDelegate<T> createHeaderDelegate(Class<T> headerType);
+
+ public abstract Response.ResponseBuilder createResponseBuilder();
+
+ private static volatile RuntimeDelegate delegate;
+
+ public static void setInstance(RuntimeDelegate delegate) throws SecurityException {
+ SecurityManager secManager = System.getSecurityManager();
+ if (secManager != null) {
+ secManager.checkPermission(new ReflectPermission("suppressAccessChecks"));
+ }
+ RuntimeDelegate.delegate = delegate;
+ }
+
+ public static RuntimeDelegate getInstance() {
+ if (delegate != null) {
+ return delegate;
+ }
+
+ // cannot synchronize on any instance so synchronize on class
+ synchronized (RuntimeDelegate.class) {
+ if (delegate != null) {
+ return delegate;
+ }
+
+ String className = null;
+ InputStream is = null;
+
+ // try META-INF/services/javax.ws.rs.ext.RuntimeDelegate
+ try {
+ is =
+ Thread.currentThread().getContextClassLoader()
+ .getResourceAsStream("META-INF/services/javax.ws.rs.ext.RuntimeDelegate");
+ if (is != null) {
+ BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+ try {
+ className = br.readLine();
+ if (className != null && !"".equals(className)) {
+ Class<?> delegateClass = null;
+ try {
+ delegateClass =
+ Class.forName(className, true, Thread.currentThread()
+ .getContextClassLoader());
+ delegate = (RuntimeDelegate)delegateClass.newInstance();
+ return delegate;
+ } catch (ClassNotFoundException e) {
+ // try Class.forName
+ try {
+ delegateClass = Class.forName(className);
+ delegate = (RuntimeDelegate)delegateClass.newInstance();
+ return delegate;
+ } catch (ClassNotFoundException e1) {
+ // do nothing
+ }
+ }
+ }
+ } catch (IOException e) {
+ // do nothing
+ } catch (InstantiationException e) {
+ // do nothing
+ } catch (IllegalAccessException e) {
+ // do nothing
+ }
+ }
+ } catch (SecurityException e) {
+ // do nothing
+ } catch (UnsupportedEncodingException e) {
+ // do nothing
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ // do nothing
+ }
+ is = null;
+ }
+ }
+
+ // try ${java.home}/lib/jaxrs.properties
+ try {
+ is = new FileInputStream(System.getProperty("java.home") + "/lib/jaxrs.properties");
+ if (is != null) {
+ Properties props = new Properties();
+ try {
+ props.load(is);
+ className = props.getProperty("javax.ws.rs.ext.RuntimeDelegate");
+ if (className != null && !"".equals(className)) {
+ Class<?> delegateClass;
+ try {
+ delegateClass =
+ Class.forName(className, true, Thread.currentThread()
+ .getContextClassLoader());
+ delegate = (RuntimeDelegate)delegateClass.newInstance();
+ return delegate;
+ } catch (ClassNotFoundException e) {
+ // try Class.forName
+ try {
+ delegateClass = Class.forName(className);
+ delegate = (RuntimeDelegate)delegateClass.newInstance();
+ return delegate;
+ } catch (ClassNotFoundException e1) {
+ // do nothing
+ }
+ }
+ }
+ } catch (IOException e) {
+ // do nothing
+ } catch (InstantiationException e) {
+ // do nothing
+ } catch (IllegalAccessException e) {
+ // do nothing
+ }
+ }
+ } catch (SecurityException e) {
+ // do nothing
+ } catch (FileNotFoundException e) {
+ // do nothing
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ // do nothing
+ }
+ is = null;
+ }
+ }
+
+ // try system property
+ try {
+ className = System.getProperty("javax.ws.rs.ext.RuntimeDelegate");
+ } catch (SecurityException e) {
+ // do nothing
+ }
+
+ // if the system property is null or empty go ahead and use the
+ // default implementation class name
+
+ if (className == null || "".equals(className)) {
+ // dunno which should be the default. this might be interesting
+ // for OSGi purposes later to somehow set the
+ // "current implementation" to be the current default. dunno if
+ // spec allows for that
+ className = "org.apache.wink.common.internal.runtime.RuntimeDelegateImpl";
+ }
+ Class<?> delegateClass;
+ try {
+ try {
+ delegateClass =
+ Class.forName(className, true, Thread.currentThread()
+ .getContextClassLoader());
+ delegate = (RuntimeDelegate)delegateClass.newInstance();
+ return delegate;
+ } catch (ClassNotFoundException e) {
+ // try Class.forName
+ try {
+ delegateClass = Class.forName(className);
+ delegate = (RuntimeDelegate)delegateClass.newInstance();
+ return delegate;
+ } catch (ClassNotFoundException e1) {
+ // do nothing
+ }
+ }
+ } catch (SecurityException e) {
+ // do nothing
+ } catch (InstantiationException e) {
+ // do nothing
+ } catch (IllegalAccessException e) {
+ // do nothing
+ }
+
+ return delegate;
+ }
+ }
+}
Propchange: cxf/sandbox/geronimo-jaxrs_1.1_spec/src/main/java/javax/ws/rs/ext/RuntimeDelegate.java
------------------------------------------------------------------------------
svn:eol-style = native