cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r673167 [2/6] - in /cxf/trunk: parent/ rt/frontend/jaxrs/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ rt/frontend...
Date Tue, 01 Jul 2008 18:41:29 GMT
Copied: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/VariantListBuilderImpl.java (from r651969, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/VariantListBuilderImpl.java)
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/VariantListBuilderImpl.java?p2=cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/VariantListBuilderImpl.java&p1=cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/VariantListBuilderImpl.java&r1=651969&r2=673167&rev=673167&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/VariantListBuilderImpl.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/VariantListBuilderImpl.java Tue Jul  1 11:41:24 2008
@@ -18,7 +18,7 @@
  */
 
 
-package org.apache.cxf.jaxrs.provider;
+package org.apache.cxf.jaxrs.impl;
 
 import java.util.ArrayList;
 import java.util.Arrays;

Added: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/AbstractThreadLocalProxy.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/AbstractThreadLocalProxy.java?rev=673167&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/AbstractThreadLocalProxy.java (added)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/AbstractThreadLocalProxy.java Tue Jul  1 11:41:24 2008
@@ -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 org.apache.cxf.jaxrs.impl.tl;
+
+
+public class AbstractThreadLocalProxy<T> implements ThreadLocalProxy<T> {
+
+    private ThreadLocal<T> infos = new ThreadLocal<T>();
+    
+    protected AbstractThreadLocalProxy() {
+        
+    }
+    
+    public T get() {
+        return infos.get();
+    }
+
+    public void remove() {
+        infos.remove();
+    }
+
+    public void set(T value) {
+        infos.set(value);
+    }
+}

Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/AbstractThreadLocalProxy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/AbstractThreadLocalProxy.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalContextResolver.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalContextResolver.java?rev=673167&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalContextResolver.java (added)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalContextResolver.java Tue Jul  1 11:41:24 2008
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.jaxrs.impl.tl;
+
+import javax.ws.rs.ext.ContextResolver;
+
+public class ThreadLocalContextResolver extends AbstractThreadLocalProxy<ContextResolver> 
+    implements ContextResolver {
+
+    @SuppressWarnings("unchecked")
+    public Object getContext(Class type) {
+        return get().getContext(type);
+    }
+
+}

Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalContextResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalContextResolver.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalHttpHeaders.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalHttpHeaders.java?rev=673167&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalHttpHeaders.java (added)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalHttpHeaders.java Tue Jul  1 11:41:24 2008
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.cxf.jaxrs.impl.tl;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.ws.rs.core.Cookie;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+
+public class ThreadLocalHttpHeaders extends AbstractThreadLocalProxy<HttpHeaders> 
+    implements HttpHeaders {
+
+    public List<MediaType> getAcceptableMediaTypes() {
+        return get().getAcceptableMediaTypes();
+    }
+
+    public Map<String, Cookie> getCookies() {
+        return get().getCookies();
+    }
+
+    public String getLanguage() {
+        return get().getLanguage();
+    }
+
+    public MediaType getMediaType() {
+        return get().getMediaType();
+    }
+
+    public MultivaluedMap<String, String> getRequestHeaders() {
+        return get().getRequestHeaders();
+    }
+
+    public List<String> getAcceptableLanguages() {
+        return get().getAcceptableLanguages();
+    }
+
+    public List<String> getRequestHeader(String name) {
+        return get().getRequestHeader(name);
+    }
+
+}

Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalHttpHeaders.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalHttpHeaders.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalHttpServletRequest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalHttpServletRequest.java?rev=673167&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalHttpServletRequest.java (added)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalHttpServletRequest.java Tue Jul  1 11:41:24 2008
@@ -0,0 +1,260 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.jaxrs.impl.tl;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.security.Principal;
+import java.util.Enumeration;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletInputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+public class ThreadLocalHttpServletRequest extends AbstractThreadLocalProxy<HttpServletRequest> 
+    implements HttpServletRequest {
+
+    public String getAuthType() {
+        return get().getAuthType();
+    }
+
+    public String getContextPath() {
+        return get().getContextPath();
+    }
+
+    public Cookie[] getCookies() {
+        return get().getCookies();
+    }
+
+    public long getDateHeader(String name) {
+        return get().getDateHeader(name);
+    }
+
+    public String getHeader(String name) {
+        return get().getHeader(name);
+    }
+
+    public Enumeration getHeaderNames() {
+        return get().getHeaderNames();
+    }
+
+    public Enumeration getHeaders(String name) {
+        return get().getHeaders(name);
+    }
+
+    public int getIntHeader(String name) {
+        return get().getIntHeader(name);
+    }
+
+    public String getMethod() {
+        return get().getMethod();
+    }
+
+    public String getPathInfo() {
+        return get().getPathInfo();
+    }
+
+    public String getPathTranslated() {
+        return get().getPathTranslated();
+    }
+
+    public String getQueryString() {
+        return get().getQueryString();
+    }
+
+    public String getRemoteUser() {
+        return get().getRemoteUser();
+    }
+
+    public String getRequestURI() {
+        return get().getRequestURI();
+    }
+
+    public StringBuffer getRequestURL() {
+        return get().getRequestURL();
+    }
+
+    public String getRequestedSessionId() {
+        return get().getRequestedSessionId();
+    }
+
+    public String getServletPath() {
+        return get().getServletPath();
+    }
+
+    public HttpSession getSession() {
+        return get().getSession();
+    }
+
+    public HttpSession getSession(boolean create) {
+        return get().getSession(create);
+    }
+
+    public Principal getUserPrincipal() {
+        return get().getUserPrincipal();
+    }
+
+    public boolean isRequestedSessionIdFromCookie() {
+        return get().isRequestedSessionIdFromCookie();
+    }
+
+    public boolean isRequestedSessionIdFromURL() {
+        return get().isRequestedSessionIdFromURL();
+    }
+
+    @SuppressWarnings("deprecation")
+    public boolean isRequestedSessionIdFromUrl() {
+        return get().isRequestedSessionIdFromUrl();
+    }
+
+    public boolean isRequestedSessionIdValid() {
+        return get().isRequestedSessionIdValid();
+    }
+
+    public boolean isUserInRole(String role) {
+        return get().isUserInRole(role);
+    }
+
+    public Object getAttribute(String name) {
+        return get().getAttribute(name);
+    }
+
+    public Enumeration getAttributeNames() {
+        return get().getAttributeNames();
+    }
+
+    public String getCharacterEncoding() {
+        return get().getCharacterEncoding();
+    }
+
+    public int getContentLength() {
+        return get().getContentLength();
+    }
+
+    public String getContentType() {
+        return get().getContentType();
+    }
+
+    public ServletInputStream getInputStream() throws IOException {
+        return get().getInputStream();
+    }
+
+    public String getLocalAddr() {
+        return get().getLocalAddr();
+    }
+
+    public String getLocalName() {
+        return get().getLocalName();
+    }
+
+    public int getLocalPort() {
+        return get().getLocalPort();
+    }
+
+    public Locale getLocale() {
+        return get().getLocale();
+    }
+
+    public Enumeration getLocales() {
+        return get().getLocales();
+    }
+
+    public String getParameter(String name) {
+        return get().getParameter(name);
+    }
+
+    public Map getParameterMap() {
+        return get().getParameterMap();
+    }
+
+    public Enumeration getParameterNames() {
+        return get().getParameterNames();
+    }
+
+    public String[] getParameterValues(String name) {
+        return get().getParameterValues(name);
+    }
+
+    public String getProtocol() {
+        return get().getProtocol();
+    }
+
+    public BufferedReader getReader() throws IOException {
+        return get().getReader();
+    }
+
+    @SuppressWarnings("deprecation")
+    public String getRealPath(String path) {
+        return get().getRealPath(path);
+    }
+
+    public String getRemoteAddr() {
+        return get().getRemoteAddr();
+    }
+
+    public String getRemoteHost() {
+        return get().getRemoteHost();
+    }
+
+    public int getRemotePort() {
+        return get().getRemotePort();
+    }
+
+    public RequestDispatcher getRequestDispatcher(String path) {
+        return get().getRequestDispatcher(path);
+    }
+
+    public String getScheme() {
+        return get().getScheme();
+    }
+
+    public String getServerName() {
+        return get().getServerName();
+    }
+
+    public int getServerPort() {
+        return get().getServerPort();
+    }
+
+    public boolean isSecure() {
+        return get().isSecure();
+    }
+
+    public void removeAttribute(String name) {
+        get().removeAttribute(name);
+
+    }
+
+    public void setAttribute(String name, Object o) {
+        get().setAttribute(name, o);
+
+    }
+
+    public void setCharacterEncoding(String env) throws UnsupportedEncodingException {
+        get().setCharacterEncoding(env);
+
+    }
+
+}

Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalHttpServletRequest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalHttpServletRequest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalMessageBodyWorkers.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalMessageBodyWorkers.java?rev=673167&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalMessageBodyWorkers.java (added)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalMessageBodyWorkers.java Tue Jul  1 11:41:24 2008
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.jaxrs.impl.tl;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.MessageBodyWorkers;
+import javax.ws.rs.ext.MessageBodyWriter;
+
+public class ThreadLocalMessageBodyWorkers extends AbstractThreadLocalProxy<MessageBodyWorkers>
+       implements MessageBodyWorkers {
+
+    public <T> MessageBodyReader<T> getMessageBodyReader(Class<T> type, 
+                                                         Type genericType, 
+                                                         Annotation[] annotations,
+                                                         MediaType mediaType) {
+        return get().getMessageBodyReader(type, genericType, annotations, mediaType);
+    }
+
+    public <T> MessageBodyWriter<T> getMessageBodyWriter(Class<T> type, 
+                                                         Type genericType, 
+                                                         Annotation[] annotations,
+                                                         MediaType mediaType) {
+        return get().getMessageBodyWriter(type, genericType, annotations, mediaType);
+    }
+
+}

Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalMessageBodyWorkers.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalMessageBodyWorkers.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalProxy.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalProxy.java?rev=673167&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalProxy.java (added)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalProxy.java Tue Jul  1 11:41:24 2008
@@ -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 org.apache.cxf.jaxrs.impl.tl;
+
+public interface ThreadLocalProxy<T> {
+    void set(T value);
+    T get(); 
+    void remove();
+}

Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalProxy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalProxy.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalRequest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalRequest.java?rev=673167&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalRequest.java (added)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalRequest.java Tue Jul  1 11:41:24 2008
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.jaxrs.impl.tl;
+
+import java.util.Date;
+import java.util.List;
+
+import javax.ws.rs.core.EntityTag;
+import javax.ws.rs.core.Request;
+import javax.ws.rs.core.Response.ResponseBuilder;
+import javax.ws.rs.core.Variant;
+
+public class ThreadLocalRequest extends AbstractThreadLocalProxy<Request> 
+    implements Request {
+
+    public ResponseBuilder evaluatePreconditions(EntityTag eTag) {
+        return get().evaluatePreconditions(eTag);
+    }
+
+    public ResponseBuilder evaluatePreconditions(Date lastModified) {
+        return get().evaluatePreconditions(lastModified);
+    }
+
+    public ResponseBuilder evaluatePreconditions(Date lastModified, EntityTag eTag) {
+        return get().evaluatePreconditions(lastModified, eTag);
+    }
+
+    public Variant selectVariant(List<Variant> vars) throws IllegalArgumentException {
+        return get().selectVariant(vars);
+    }
+
+}

Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalRequest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalRequest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalSecurityContext.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalSecurityContext.java?rev=673167&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalSecurityContext.java (added)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalSecurityContext.java Tue Jul  1 11:41:24 2008
@@ -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 org.apache.cxf.jaxrs.impl.tl;
+
+import java.security.Principal;
+
+import javax.ws.rs.core.SecurityContext;
+
+public class ThreadLocalSecurityContext extends AbstractThreadLocalProxy<SecurityContext> 
+    implements SecurityContext {
+
+    public String getAuthenticationScheme() {
+        return get().getAuthenticationScheme();
+    }
+
+    public Principal getUserPrincipal() {
+        return get().getUserPrincipal();
+    }
+
+    public boolean isSecure() {
+        return get().isSecure();
+    }
+
+    public boolean isUserInRole(String role) {
+        return get().isUserInRole(role);
+    }
+
+}

Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalSecurityContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalSecurityContext.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalUriInfo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalUriInfo.java?rev=673167&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalUriInfo.java (added)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalUriInfo.java Tue Jul  1 11:41:24 2008
@@ -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 org.apache.cxf.jaxrs.impl.tl;
+
+import java.net.URI;
+import java.util.List;
+
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.PathSegment;
+import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.core.UriInfo;
+
+public class ThreadLocalUriInfo extends AbstractThreadLocalProxy<UriInfo> 
+                                    implements UriInfo {
+
+    
+    public URI getAbsolutePath() {
+        return get().getAbsolutePath();
+    }
+
+    public UriBuilder getAbsolutePathBuilder() {
+        return get().getAbsolutePathBuilder();
+    }
+
+    public List<String> getAncestorResourceURIs() {
+        return get().getAncestorResourceURIs();
+    }
+
+    public List<Object> getAncestorResources() {
+        return get().getAncestorResources();
+    }
+
+    public URI getBaseUri() {
+        return get().getBaseUri();
+    }
+
+    public UriBuilder getBaseUriBuilder() {
+        return get().getBaseUriBuilder();
+    }
+
+    public String getPath() {
+        return get().getPath();
+    }
+
+    public String getPath(boolean decode) {
+        return get().getPath(decode);
+    }
+
+    public List<PathSegment> getPathSegments() {
+        return get().getPathSegments();
+    }
+
+    public List<PathSegment> getPathSegments(boolean decode) {
+        return get().getPathSegments(decode);
+    }
+
+    public MultivaluedMap<String, String> getQueryParameters() {
+        return get().getQueryParameters();
+    }
+
+    public MultivaluedMap<String, String> getQueryParameters(boolean decode) {
+        return get().getQueryParameters(decode);
+    }
+
+    public URI getRequestUri() {
+        return get().getRequestUri();
+    }
+
+    public UriBuilder getRequestUriBuilder() {
+        return get().getRequestUriBuilder();
+    }
+
+    public MultivaluedMap<String, String> getPathParameters() {
+        return get().getPathParameters();
+    }
+
+    public MultivaluedMap<String, String> getPathParameters(boolean decode) {
+        return get().getPathParameters(decode);
+    }
+
+    public List<String> getAncestorResourceURIs(boolean decode) {
+        return get().getAncestorResourceURIs(decode);
+    }
+
+    public String getPathExtension() {
+        return get().getPathExtension();
+    }
+
+    public UriBuilder getPlatonicRequestUriBuilder() {
+        return get().getPlatonicRequestUriBuilder();
+    }
+
+}

Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalUriInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalUriInfo.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java?rev=673167&r1=673166&r2=673167&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java Tue Jul  1 11:41:24 2008
@@ -23,19 +23,24 @@
 import java.util.ResourceBundle;
 import java.util.logging.Logger;
 
+import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
 
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.jaxrs.JAXRSServiceImpl;
-import org.apache.cxf.jaxrs.JAXRSUtils;
-import org.apache.cxf.jaxrs.MetadataMap;
+import org.apache.cxf.jaxrs.ext.RequestHandler;
+import org.apache.cxf.jaxrs.impl.MetadataMap;
+import org.apache.cxf.jaxrs.impl.RequestPreprocessor;
+import org.apache.cxf.jaxrs.impl.UriInfoImpl;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
+import org.apache.cxf.jaxrs.model.ProviderInfo;
 import org.apache.cxf.jaxrs.model.URITemplate;
 import org.apache.cxf.jaxrs.provider.ProviderFactory;
-import org.apache.cxf.jaxrs.provider.SystemQueryHandler;
+import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.phase.Phase;
@@ -44,6 +49,7 @@
 public class JAXRSInInterceptor extends AbstractPhaseInterceptor<Message> {
 
     public static final String RELATIVE_PATH = "relative.path";
+    public static final String ROOT_RESOURCE_CLASS = "root.resource.class";
 
     private static final Logger LOG = LogUtils.getL7dLogger(JAXRSInInterceptor.class);
     private static final ResourceBundle BUNDLE = BundleUtils.getBundle(JAXRSInInterceptor.class);
@@ -53,6 +59,28 @@
     }
 
     public void handleMessage(Message message) {
+        
+        try {
+            processRequest(message);
+        } catch (RuntimeException ex) {
+            Response excResponse = JAXRSUtils.convertFaultToResponse(ex);
+            if (excResponse == null) {
+                ProviderFactory.getInstance().cleatThreadLocalProxies();
+                throw ex;
+            }
+            message.getExchange().put(Response.class, excResponse);
+        }
+        
+        
+    }
+    
+    private void processRequest(Message message) {
+        RequestPreprocessor rp = 
+            ProviderFactory.getInstance().getRequestPreprocessor();
+        if (rp != null) {
+            rp.preprocess(message, new UriInfoImpl(message, null));
+        }
+        
         String path = (String)message.get(Message.PATH_INFO);
         String address = (String)message.get(Message.BASE_PATH);
         String httpMethod = (String)message.get(Message.HTTP_REQUEST_METHOD);
@@ -79,51 +107,62 @@
             path = path + "/";
         }
         
-        //TODO : make sure we do this parsing only once
-        MultivaluedMap<String, String> queries = 
-            JAXRSUtils.getStructuredParams((String)message.get(Message.QUERY_STRING), 
-                                            "&", true);
-        SystemQueryHandler sqh = ProviderFactory.getInstance().getQueryHandler(queries);
-        if (sqh != null) {
-            // TODO : if Response != null then make sure no invocations happen
-            // TODO : root resource class needs be selected earlier
-            sqh.handleQuery(message, null, queries);
+        
+        //1. Matching target resource class
+        Service service = message.getExchange().get(Service.class);
+        List<ClassResourceInfo> resources = ((JAXRSServiceImpl)service).getClassResourceInfos();
+
+        MultivaluedMap<String, String> values = new MetadataMap<String, String>();
+        ClassResourceInfo resource = JAXRSUtils.selectResourceClass(resources, path, values);
+        if (resource == null) {
+            org.apache.cxf.common.i18n.Message errorMsg = 
+                new org.apache.cxf.common.i18n.Message("NO_ROOT_EXC", 
+                                                   BUNDLE, 
+                                                   path);
+            LOG.severe(errorMsg.toString());
+            throw new Fault(errorMsg);
+        }
+        
+        List<ProviderInfo<RequestHandler>> shs = 
+            ProviderFactory.getInstance().getRequestHandlers();
+        for (ProviderInfo<RequestHandler> sh : shs) {
+            Response response = sh.getProvider().handleRequest(message, resource);
+            if (response != null) {
+                message.getExchange().put(Response.class, response);
+                return;
+            }
         }
         
-        String acceptContentTypes = (String)message.get(Message.ACCEPT_CONTENT_TYPE);
-        if (acceptContentTypes == null) {
-            acceptContentTypes = "*/*";
+        String acceptTypes = (String)message.get(Message.ACCEPT_CONTENT_TYPE);
+        if (acceptTypes == null) {
+            acceptTypes = "*/*";
         }
+        
+        List<MediaType> acceptContentTypes = JAXRSUtils.sortMediaTypes(acceptTypes);
         message.getExchange().put(Message.ACCEPT_CONTENT_TYPE, acceptContentTypes);
+        message.getExchange().put(ROOT_RESOURCE_CLASS, resource);
         
         LOG.fine("Request path is: " + path);
         LOG.fine("Request HTTP method is: " + httpMethod);
         LOG.fine("Request contentType is: " + requestContentType);
-        LOG.fine("Accept contentType is: " + acceptContentTypes);
+        LOG.fine("Accept contentType is: " + acceptTypes);
         
-        //1. Matching target resource classes and method
-        Service service = message.getExchange().get(Service.class);
-        List<ClassResourceInfo> resources = ((JAXRSServiceImpl)service).getClassResourceInfos();
-
-        MultivaluedMap<String, String> values = new MetadataMap<String, String>();
-        OperationResourceInfo ori = JAXRSUtils.findTargetResourceClass(resources, 
-                                                                       path, 
-                                                                       httpMethod, 
-                                                                       values,
-                                                                       requestContentType, 
-                                                                       acceptContentTypes);
+        
+        OperationResourceInfo ori = 
+            JAXRSUtils.findTargetMethod(resource, values.getFirst(URITemplate.FINAL_MATCH_GROUP), 
+                                       httpMethod, values, requestContentType, acceptContentTypes);
 
         if (ori == null) {
-            String errorMessage = "No operation found for path: " + path + ", contentType: " 
-                + requestContentType + ", Accept contentType: " + acceptContentTypes;
-            LOG.severe(errorMessage);
-            throw new Fault(new org.apache.cxf.common.i18n.Message("NO_OP_EXC", 
-                                                                   BUNDLE, 
-                                                                   path,
-                                                                   requestContentType,
-                                                                   acceptContentTypes));
+            org.apache.cxf.common.i18n.Message errorMsg = 
+                new org.apache.cxf.common.i18n.Message("NO_OP_EXC", 
+                                                   BUNDLE, 
+                                                   path,
+                                                   requestContentType,
+                                                   acceptTypes);
+            LOG.severe(errorMsg.toString());
+            throw new Fault(errorMsg);
         }
-        LOG.fine("Found operation: " + ori.getMethod().getName());
+        LOG.fine("Found operation: " + ori.getMethodToInvoke().getName());
         
         message.getExchange().put(OperationResourceInfo.class, ori);
         message.put(RELATIVE_PATH, values.getFirst(URITemplate.FINAL_MATCH_GROUP));

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java?rev=673167&r1=673166&r2=673167&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java Tue Jul  1 11:41:24 2008
@@ -21,11 +21,13 @@
 
 import java.io.IOException;
 import java.io.OutputStream;
+import java.lang.reflect.Method;
+import java.util.Collections;
 import java.util.List;
 import java.util.ResourceBundle;
 import java.util.logging.Logger;
 
-import javax.ws.rs.ProduceMime;
+import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.ext.MessageBodyWriter;
@@ -33,9 +35,12 @@
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor;
-import org.apache.cxf.jaxrs.JAXRSUtils;
+import org.apache.cxf.jaxrs.ext.ResponseHandler;
+import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
+import org.apache.cxf.jaxrs.model.ProviderInfo;
 import org.apache.cxf.jaxrs.provider.ProviderFactory;
+import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageContentsList;
@@ -51,6 +56,24 @@
 
     @SuppressWarnings("unchecked")
     public void handleMessage(Message message) {
+        
+        try {
+            processResponse(message);
+        } finally {
+            ProviderFactory.getInstance().cleatThreadLocalProxies();
+            ClassResourceInfo cri =
+                (ClassResourceInfo)message.getExchange().get(JAXRSInInterceptor.ROOT_RESOURCE_CLASS);
+            if (cri != null) {
+                cri.clearThreadLocalProxies();
+            }
+        }
+            
+
+    }
+    
+    @SuppressWarnings("unchecked")
+    private void processResponse(Message message) {
+        
         Exchange exchange = message.getExchange();
         OperationResourceInfo operation = (OperationResourceInfo)exchange.get(OperationResourceInfo.class
             .getName());
@@ -63,33 +86,54 @@
         if (objs == null || objs.size() == 0) {
             return;
         }
-
+        
         OutputStream out = message.getContent(OutputStream.class);
         
         if (objs.get(0) != null) {
             Object responseObj = objs.get(0);
+            Response response = null;
             if (objs.get(0) instanceof Response) {
-                Response response = (Response)responseObj;
-                
-                message.put(Message.RESPONSE_CODE, response.getStatus());
-                message.put(Message.PROTOCOL_HEADERS, response.getMetadata());
-                                
-                responseObj = response.getEntity();
-                if (responseObj == null) {
-                    return;
+                response = (Response)responseObj;
+            } else {    
+                response = Response.ok(responseObj).build();
+            }
+            
+            List<ProviderInfo<ResponseHandler>> handlers = 
+                ProviderFactory.getInstance().getResponseHandlers();
+            for (ProviderInfo<ResponseHandler> rh : handlers) {
+                Response r = rh.getProvider().handleResponse(message, operation, response);
+                if (r != null) {
+                    response = r;
                 }
-            } 
+            }
+            
+            message.put(Message.RESPONSE_CODE, response.getStatus());
+            message.put(Message.PROTOCOL_HEADERS, response.getMetadata());
+                            
+            responseObj = response.getEntity();
+            if (responseObj == null) {
+                return;
+            }
             
             Class targetType = responseObj.getClass();
             List<MediaType> availableContentTypes = 
-                computeAvailableContentTypes(message);  
+                computeAvailableContentTypes(message, response);  
+            
+            Method invoked = ((OperationResourceInfo)message.getExchange()
+                    .get(OperationResourceInfo.class)).getMethodToInvoke();
             
             MessageBodyWriter writer = null;
+            MediaType responseType = null;
             for (MediaType type : availableContentTypes) { 
                 writer = ProviderFactory.getInstance()
-                    .createMessageBodyWriter(targetType, type);
-                 
+                    .createMessageBodyWriter(targetType, 
+                          invoked.getGenericReturnType(), 
+                          invoked.getAnnotations(), 
+                          type,
+                          exchange.getInMessage());
+                
                 if (writer != null) {
+                    responseType = type;
                     break;
                 }
             }
@@ -98,16 +142,23 @@
                 message.put(Message.RESPONSE_CODE, 406);
                 writeResponseErrorMessage(out, 
                                           "NO_MSG_WRITER",
-                                          responseObj.getClass().getSimpleName());
+                                          invoked.getReturnType().getSimpleName());
                 return;
             }
             
             try {
                 LOG.fine("Response EntityProvider is: " + writer.getClass().getName());
-                MediaType mt = computeFinalContentTypes(availableContentTypes, writer);
-                LOG.fine("Response content type is: " + mt.toString());
-                message.put(Message.CONTENT_TYPE, mt.toString());
-                writer.writeTo(responseObj, mt, null, out);
+                writer.writeTo(responseObj, targetType, invoked.getGenericReturnType(), 
+                               invoked.getAnnotations(), 
+                               responseType, 
+                               response.getMetadata(), 
+                               out);
+                
+                responseType = checkFinalContentType(responseType);
+                LOG.fine("Response content type is: " + responseType.toString());
+                message.put(Message.CONTENT_TYPE, responseType.toString());
+                
+                
             } catch (IOException e) {
                 e.printStackTrace();
                 message.put(Message.RESPONSE_CODE, 500);
@@ -115,10 +166,12 @@
                                           responseObj.getClass().getSimpleName());
             }        
             
+        } else {
+            message.put(Message.RESPONSE_CODE, 204);
         }
-
     }
     
+    
     private void writeResponseErrorMessage(OutputStream out, String errorString, 
                                            String parameter) {
         try {
@@ -132,25 +185,30 @@
         }
     }
     
-    private List<MediaType> computeAvailableContentTypes(Message message) {
-        Exchange exchange = message.getExchange();
+    @SuppressWarnings("unchecked")
+    private List<MediaType> computeAvailableContentTypes(Message message, Response response) {
         
-        List<MediaType> methodMimeTypes = exchange.get(OperationResourceInfo.class).getProduceTypes();
-        String acceptContentTypes = (String)exchange.get(Message.ACCEPT_CONTENT_TYPE);
+        Object contentType = 
+            response.getMetadata().getFirst(HttpHeaders.CONTENT_TYPE);
+        Exchange exchange = message.getExchange();
+        List<MediaType> produceTypes = null;
+        if (contentType != null) {
+            produceTypes = Collections.singletonList(MediaType.valueOf(contentType.toString()));
+        } else {
+            produceTypes = exchange.get(OperationResourceInfo.class).getProduceTypes();
+        }
+        List<MediaType> acceptContentTypes = 
+            (List<MediaType>)exchange.get(Message.ACCEPT_CONTENT_TYPE);
         
-        List<MediaType> acceptValues = JAXRSUtils.parseMediaTypes(acceptContentTypes);
+        return JAXRSUtils.intersectMimeTypes(acceptContentTypes, produceTypes, true);
         
-        return JAXRSUtils.intersectMimeTypes(methodMimeTypes, acceptValues);        
     }
     
-    private MediaType computeFinalContentTypes(List<MediaType> produceContentTypes, 
-                                               MessageBodyWriter provider) {
-        List<MediaType> providerMimeTypes = 
-            JAXRSUtils.getProduceTypes(provider.getClass().getAnnotation(ProduceMime.class));
-                
-        List<MediaType> list = 
-            JAXRSUtils.intersectMimeTypes(produceContentTypes, providerMimeTypes);
-      
-        return list.get(0);      
+    private MediaType checkFinalContentType(MediaType mt) {
+        if (mt.isWildcardType() && mt.isWildcardSubtype()) {
+            return MediaType.APPLICATION_OCTET_STREAM_TYPE;
+        } else {
+            return mt;
+        }
     }
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/Messages.properties
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/Messages.properties?rev=673167&r1=673166&r2=673167&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/Messages.properties (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/Messages.properties Tue Jul  1 11:41:24 2008
@@ -19,6 +19,7 @@
 #
 #
 NO_OP_EXC =.No operation matching request path {0} is found, ContentType : {1}, Accept : {2}.
+NO_ROOT_EXC =.No root resource matching request path {0} is found.
 SERIALIZE_ERROR =.Error serializing the response, please check the server logs, response class : {0}.
 NO_MSG_WRITER =.No message body writer found for response class : {0}.
 NO_MSG_READER =.No message body reader found for request class : {0}.

Added: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java?rev=673167&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java (added)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java Tue Jul  1 11:41:24 2008
@@ -0,0 +1,197 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.jaxrs.model;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Resource;
+import javax.ws.rs.core.Context;
+
+import org.apache.cxf.jaxrs.impl.tl.ThreadLocalProxy;
+import org.apache.cxf.jaxrs.utils.AnnotationUtils;
+import org.apache.cxf.jaxrs.utils.InjectionUtils;
+
+public abstract class AbstractResourceInfo {
+    
+    private boolean root;
+    private Class<?> resourceClass;
+    private Class<?> serviceClass;
+    
+    private List<Field> contextFields;
+    private List<Field> resourceFields;
+    private Map<Class<?>, Method> contextMethods;
+    private Map<Field, ThreadLocalProxy> fieldProxyMap;
+    private Map<Field, ThreadLocalProxy> resourceProxyMap;
+    private Map<Method, ThreadLocalProxy> setterProxyMap;
+    
+    protected AbstractResourceInfo(Class<?> resourceClass, Class<?> serviceClass, boolean isRoot) {
+        this.serviceClass = serviceClass;
+        this.resourceClass = resourceClass;
+        root = isRoot;
+        if (root) {
+            initContextFields();
+            initContextSetterMethods();
+        }
+    }
+    
+    public Class<?> getServiceClass() {
+        return serviceClass;
+    }
+    
+    private void initContextFields() {
+        if (resourceClass == null || !root) {
+            return;
+        }
+        
+        
+        for (Field f : getServiceClass().getDeclaredFields()) {
+            for (Annotation a : f.getAnnotations()) {
+                if (a.annotationType() == Context.class) {
+                    if (contextFields == null) {
+                        contextFields = new ArrayList<Field>();
+                    }
+                    contextFields.add(f);
+                    if (fieldProxyMap == null) {
+                        fieldProxyMap = new HashMap<Field, ThreadLocalProxy>();
+                    }
+                    fieldProxyMap.put(f, InjectionUtils.createThreadLocalProxy(f.getType()));
+                } else if (a.annotationType() == Resource.class) {
+                    if (resourceFields == null) {
+                        resourceFields = new ArrayList<Field>();
+                    }
+                    resourceFields.add(f);
+                    if (resourceProxyMap == null) {
+                        resourceProxyMap = new HashMap<Field, ThreadLocalProxy>();
+                    }
+                    resourceProxyMap.put(f, InjectionUtils.createThreadLocalProxy(f.getType()));
+                }
+            }
+        }
+    }
+    
+    private void initContextSetterMethods() {
+        
+        for (Method m : getServiceClass().getMethods()) {
+        
+            if (!m.getName().startsWith("set") || m.getParameterTypes().length != 1) {
+                continue;
+            }
+            for (Annotation a : m.getAnnotations()) {
+                if (a.annotationType() == Context.class) {
+                    checkContextMethod(m);
+                    break;
+                }
+            }
+        }
+    }
+    
+    private void checkContextMethod(Method m) {
+        Class<?> type = m.getParameterTypes()[0];
+        if (AnnotationUtils.isContextClass(type)
+            && m.getName().equals("set" + type.getSimpleName())) {        
+            addContextMethod(type, m);
+        }
+    }
+    
+    @SuppressWarnings("unchecked")
+    public Map<Class<?>, Method> getContextMethods() {
+        return contextMethods == null ? Collections.EMPTY_MAP 
+                                      : Collections.unmodifiableMap(contextMethods);
+    }
+    
+    private void addContextMethod(Class<?> contextClass, Method m) {
+        if (contextMethods == null) {
+            contextMethods = new HashMap<Class<?>, Method>();
+        }
+        contextMethods.put(contextClass, m);
+        if (setterProxyMap == null) {
+            setterProxyMap = new HashMap<Method, ThreadLocalProxy>();
+        }
+        setterProxyMap.put(m, 
+             InjectionUtils.createThreadLocalProxy(m.getParameterTypes()[0]));
+    }
+    
+    public boolean isRoot() {
+        return root;
+    }
+    
+    public Class<?> getResourceClass() {
+        return resourceClass;
+    }
+    
+    public List<Field> getContextFields() {
+        return getList(contextFields);
+    }
+    
+    public List<Field> getResourceFields() {
+        return getList(resourceFields);
+    }
+    
+    private static List<Field> getList(List<Field> fields) {
+        List<Field> ret;
+        if (fields != null) {
+            ret = Collections.unmodifiableList(fields);
+        } else {
+            ret = Collections.emptyList();
+        }
+        return ret;
+    }
+    
+    @SuppressWarnings("unchecked")
+    public ThreadLocalProxy getContextFieldProxy(Field f) {
+        return fieldProxyMap == null ? null
+               : fieldProxyMap.get(f);
+    }
+    
+    @SuppressWarnings("unchecked")
+    public ThreadLocalProxy getResourceFieldProxy(Field f) {
+        return resourceProxyMap == null ? null
+               : resourceProxyMap.get(f);
+    }
+    
+    @SuppressWarnings("unchecked")
+    public ThreadLocalProxy getContextSetterProxy(Method m) {
+        return setterProxyMap == null ? null : setterProxyMap.get(m);
+    }
+    
+    public abstract boolean isSingleton();
+    
+    public void clearThreadLocalProxies() {
+        clearProxies(fieldProxyMap);
+        clearProxies(resourceProxyMap);
+        clearProxies(setterProxyMap);
+    }
+    
+    private static void clearProxies(Map<?, ThreadLocalProxy> tlps) {
+        if (tlps == null) {
+            return;
+        }
+        for (ThreadLocalProxy tlp : tlps.values()) {
+            tlp.remove();
+        }
+    }
+}

Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java?rev=673167&r1=673166&r2=673167&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java Tue Jul  1 11:41:24 2008
@@ -19,32 +19,32 @@
 
 package org.apache.cxf.jaxrs.model;
 
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Field;
+import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
-import javax.annotation.Resource;
 import javax.ws.rs.ConsumeMime;
+import javax.ws.rs.Encoded;
 import javax.ws.rs.Path;
 import javax.ws.rs.ProduceMime;
-import javax.ws.rs.core.Context;
 
-import org.apache.cxf.jaxrs.JAXRSUtils;
 import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
+import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
+import org.apache.cxf.jaxrs.utils.AnnotationUtils;
 
-public class ClassResourceInfo {
+public class ClassResourceInfo extends AbstractResourceInfo {
     
-    private boolean root;
-    private Class<?> resourceClass;
-    private Class<?> serviceClass;
     private URITemplate uriTemplate;
     private MethodDispatcher methodDispatcher;
     private ResourceProvider resourceProvider;
     private List<ClassResourceInfo> subClassResourceInfo = new ArrayList<ClassResourceInfo>();
-    private List<Field> httpContexts;
-    private List<Field> resources;
-
+   
+    private List<Field> paramFields;
+    private List<Method> paramMethods;
+    
     public ClassResourceInfo(Class<?> theResourceClass) {
         this(theResourceClass, false);
     }
@@ -58,23 +58,45 @@
     }
     
     public ClassResourceInfo(Class<?> theResourceClass, Class<?> theServiceClass, boolean theRoot) {
-        resourceClass = theResourceClass;
-        serviceClass = theServiceClass;
-        root = theRoot;
-        initHttpContexts();
-        initResources();
-    }
-
-    public boolean isRoot() {
-        return root;
+        super(theResourceClass, theServiceClass, theRoot);
+        if (theRoot) {
+            initParamFields();
+            initParamMethods();
+        }
     }
     
-    public Class<?> getResourceClass() {
-        return resourceClass;
+    private void initParamFields() {
+        if (getResourceClass() == null || !isRoot()) {
+            return;
+        }
+        
+        
+        for (Field f : getServiceClass().getDeclaredFields()) {
+            for (Annotation a : f.getAnnotations()) {
+                if (AnnotationUtils.isParamAnnotationClass(a.annotationType())) {
+                    if (paramFields == null) {
+                        paramFields = new ArrayList<Field>();
+                    }
+                    paramFields.add(f);
+                }
+            }
+        }
     }
     
-    public Class<?> getServiceClass() {
-        return serviceClass;
+    private void initParamMethods() {
+        
+        for (Method m : getServiceClass().getMethods()) {
+        
+            if (!m.getName().startsWith("set") || m.getParameterTypes().length != 1) {
+                continue;
+            }
+            for (Annotation a : m.getAnnotations()) {
+                if (AnnotationUtils.isParamAnnotationClass(a.annotationType())) {
+                    checkParamMethod(m, AnnotationUtils.getAnnotationValue(a));
+                    break;
+                }
+            }
+        }
     }
 
     public URITemplate getURITemplate() {
@@ -113,67 +135,50 @@
         resourceProvider = rp;
     }
     
-    private void initHttpContexts() {
-        if (resourceClass == null || !root) {
-            return;
-        }
-        httpContexts = new ArrayList<Field>();
-        Field[] fields = getServiceClass().getDeclaredFields();
-        
-        for (Field f : fields) {
-            Context context = f.getAnnotation(Context.class);
-            if (context != null) {
-                httpContexts.add(f);               
-            }
-        }
-    }
-
-    private void initResources() {
-        if (resourceClass == null || !root) {
-            return;
-        }
-        resources = new ArrayList<Field>();
-        Field[] fields = getServiceClass().getDeclaredFields();
-        
-        for (Field f : fields) {
-            Resource resource = f.getAnnotation(Resource.class);
-            if (resource != null) {
-                resources.add(f);               
-            }
-        }
-    }
-
     public ProduceMime getProduceMime() {
-        return (ProduceMime)JAXRSUtils.getClassAnnotation(getServiceClass(), ProduceMime.class);
+        return (ProduceMime)AnnotationUtils.getClassAnnotation(getServiceClass(), ProduceMime.class);
     }
     
     public ConsumeMime getConsumeMime() {
-        return (ConsumeMime)JAXRSUtils.getClassAnnotation(getServiceClass(), ConsumeMime.class);
+        return (ConsumeMime)AnnotationUtils.getClassAnnotation(getServiceClass(), ConsumeMime.class);
+    }
+    
+    public boolean isEncodedEnabled() {
+        return AnnotationUtils.getClassAnnotation(getServiceClass(), 
+                                                  Encoded.class) != null;
     }
     
     public Path getPath() {
-        return (Path)JAXRSUtils.getClassAnnotation(getServiceClass(), Path.class);
+        return (Path)AnnotationUtils.getClassAnnotation(getServiceClass(), Path.class);
     }
     
-    public List<Field> getHttpContexts() {
-        List<Field> ret;
-        if (httpContexts != null) {
-            ret = Collections.unmodifiableList(httpContexts);
-        } else {
-            ret = Collections.emptyList();
+    private void addParamMethod(Method m) {
+        if (paramMethods == null) {
+            paramMethods = new ArrayList<Method>();
         }
-        return ret;
+        paramMethods.add(m);
     }
     
-    public List<Field> getResources() {
-        List<Field> ret;
-        if (resources != null) {
-            ret = Collections.unmodifiableList(resources);
-        } else {
-            ret = Collections.emptyList();
-        }
-        return ret;
+    @SuppressWarnings("unchecked")
+    public List<Method> getParameterMethods() {
+        return paramMethods == null ? Collections.EMPTY_LIST 
+                                    : Collections.unmodifiableList(paramMethods);
     }
     
+    @SuppressWarnings("unchecked")
+    public List<Field> getParameterFields() {
+        return paramFields == null ? Collections.EMPTY_LIST 
+                                    : Collections.unmodifiableList(paramFields);
+    }
     
+    private void checkParamMethod(Method m, String value) {
+        if (m.getName().equalsIgnoreCase("set" + value)) {
+            addParamMethod(m);
+        }
+    }
+    
+    @Override
+    public boolean isSingleton() {
+        return resourceProvider instanceof SingletonResourceProvider;
+    }
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java?rev=673167&r1=673166&r2=673167&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java Tue Jul  1 11:41:24 2008
@@ -26,18 +26,23 @@
 import javax.ws.rs.ProduceMime;
 import javax.ws.rs.core.MediaType;
 
-import org.apache.cxf.jaxrs.JAXRSUtils;
+import org.apache.cxf.jaxrs.utils.AnnotationUtils;
+import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 
 public class OperationResourceInfo {
     private URITemplate uriTemplate;
     private ClassResourceInfo classResourceInfo;
-    private Method method;
+    private Method methodToInvoke;
+    private Method annotatedMethod;
     private String httpMethod;
-   
+    private List<MediaType> produceMimes;
+    private List<MediaType> consumeMimes;
 
     public OperationResourceInfo(Method m, ClassResourceInfo cri) {
-        method = m;
+        methodToInvoke = m;
+        annotatedMethod = m;
         classResourceInfo = cri;
+        checkMediaTypes();
     }
 
     public URITemplate getURITemplate() {
@@ -56,12 +61,12 @@
         classResourceInfo = c;
     }
 
-    public Method getMethod() {
-        return method;
+    public Method getMethodToInvoke() {
+        return methodToInvoke;
     }
 
-    public void setMethod(Method m) {
-        method = m;
+    public void setMethodToInvoke(Method m) {
+        methodToInvoke = m;
     }
 
     public String getHttpMethod() {
@@ -72,6 +77,15 @@
         httpMethod = m;
     }
     
+    public void setAnnotatedMethod(Method m) {
+        annotatedMethod = m;
+        checkMediaTypes();
+    }
+    
+    public Method getAnnotatedMethod() {
+        return annotatedMethod;
+    }
+    
     public boolean isSubResourceLocator() {
         return httpMethod == null ? true : false;
     }
@@ -79,25 +93,31 @@
     
     public List<MediaType> getProduceTypes() {
         
-        // this needs to be calculated on init
-        ProduceMime pm = 
-            (ProduceMime)JAXRSUtils.getMethodAnnotation(method, ProduceMime.class);
-        if (pm != null) {
-            return JAXRSUtils.getMediaTypes(pm.value());
-        }
-        
-        return JAXRSUtils.getProduceTypes(classResourceInfo.getProduceMime());
+        return produceMimes;
     }
     
     public List<MediaType> getConsumeTypes() {
         
-        // this needs to be calculated on init
-        ConsumeMime pm = 
-            (ConsumeMime)JAXRSUtils.getMethodAnnotation(method, ConsumeMime.class);
-        if (pm != null) {
-            return JAXRSUtils.getMediaTypes(pm.value());
+        return consumeMimes;
+    }
+    
+    private void checkMediaTypes() {
+        ConsumeMime cm = 
+            (ConsumeMime)AnnotationUtils.getMethodAnnotation(annotatedMethod, ConsumeMime.class);
+        if (cm != null) {
+            consumeMimes = JAXRSUtils.sortMediaTypes(JAXRSUtils.getMediaTypes(cm.value()));
+        } else if (classResourceInfo != null) {
+            consumeMimes = JAXRSUtils.sortMediaTypes(
+                               JAXRSUtils.getConsumeTypes(classResourceInfo.getConsumeMime()));
         }
         
-        return JAXRSUtils.getConsumeTypes(classResourceInfo.getConsumeMime());
+        ProduceMime pm = 
+            (ProduceMime)AnnotationUtils.getMethodAnnotation(annotatedMethod, ProduceMime.class);
+        if (pm != null) {
+            produceMimes = JAXRSUtils.sortMediaTypes(JAXRSUtils.getMediaTypes(pm.value()));
+        } else if (classResourceInfo != null) {
+            produceMimes = JAXRSUtils.sortMediaTypes(
+                               JAXRSUtils.getProduceTypes(classResourceInfo.getProduceMime()));
+        }
     }
 }

Added: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoComparator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoComparator.java?rev=673167&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoComparator.java (added)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoComparator.java Tue Jul  1 11:41:24 2008
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.jaxrs.model;
+
+import java.util.Comparator;
+import java.util.List;
+
+import javax.ws.rs.core.MediaType;
+
+import org.apache.cxf.jaxrs.utils.JAXRSUtils;
+
+public class OperationResourceInfoComparator implements Comparator<OperationResourceInfo> {
+    
+    public int compare(OperationResourceInfo e1, OperationResourceInfo e2) {
+        
+        if (e1.getHttpMethod() != null && e2.getHttpMethod() == null
+            || e1.getHttpMethod() == null && e2.getHttpMethod() != null) {
+            // subresource method takes precedence over a subresource locator
+            return e1.getHttpMethod() != null ? -1 : 1;
+        }
+        
+        if (e1.getHttpMethod() == null && e2.getHttpMethod() == null) {
+            // with two subresource locators, those with more capturing groups win
+            int g1 = e1.getURITemplate().getNumberOfGroups();
+            int g2 = e2.getURITemplate().getNumberOfGroups();
+            // descending order 
+            return g1 < g2 ? 1 : g1 > g2 ? -1 : 0;
+        }
+        
+        List<MediaType> mimeType1 = e1.getConsumeTypes();
+        List<MediaType> mimeType2 = e2.getConsumeTypes();
+        
+        // TODO: we actually need to check all consume and produce types here ?
+        int result = JAXRSUtils.compareMediaTypes(mimeType1.get(0), 
+                                                  mimeType2.get(0));
+        if (result == 0) {
+            //use the media type of output data as the secondary key.
+            List<MediaType> mimeTypeP1 = e1.getProduceTypes();
+            List<MediaType> mimeTypeP2 = e2.getProduceTypes();
+            result =  JAXRSUtils.compareMediaTypes(mimeTypeP1.get(0), 
+                                                mimeTypeP2.get(0));
+        }
+        
+        if (result == 0 && e1.getHttpMethod() != null && e2.getHttpMethod() != null) {
+            // we're comparing two resource methods with matching http methods and produce/consume types
+            int g1 = e1.getURITemplate().getNumberOfGroups();
+            int g2 = e2.getURITemplate().getNumberOfGroups();
+            // ascending order 
+            return g1 < g2 ? -1 : g1 > g2 ? 1 : 0;  
+        }
+
+        return result;
+    }
+
+}

Added: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ProviderInfo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ProviderInfo.java?rev=673167&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ProviderInfo.java (added)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ProviderInfo.java Tue Jul  1 11:41:24 2008
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.jaxrs.model;
+
+public class ProviderInfo<T> extends AbstractResourceInfo {
+
+    private T provider;
+    
+    public ProviderInfo(T provider) {
+        super(provider.getClass(), provider.getClass(), true);
+        this.provider = provider;
+    }
+    
+    @Override
+    public boolean isSingleton() {
+        return true;
+    }
+
+    public T getProvider() {
+        return provider;
+    }
+}

Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ProviderInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ProviderInfo.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java?rev=673167&r1=673166&r2=673167&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java Tue Jul  1 11:41:24 2008
@@ -51,9 +51,7 @@
 
     private final String template;
     private final String regexSuffix;
-    private final boolean endsWithSlash;
     private final List<String> templateVariables;
-    private final String templateRegex;
     private final Pattern templateRegexPattern;
 
     public URITemplate(String theTemplate) {
@@ -81,7 +79,7 @@
         templateVariables = Collections.unmodifiableList(names);
 
         int endPos = stringBuilder.length() - 1;
-        this.endsWithSlash = (endPos >= 0) ? stringBuilder.charAt(endPos) == '/' : false;
+        boolean endsWithSlash = (endPos >= 0) ? stringBuilder.charAt(endPos) == '/' : false;
         if (regexSuffix != null) {
             if (endsWithSlash) {
                 stringBuilder.deleteCharAt(endPos);
@@ -89,15 +87,17 @@
             stringBuilder.append(regexSuffix);
         }
 
-        templateRegex = stringBuilder.toString();
-        //System.out.println("----" + theTemplate + ": " + templateRegex);
-        templateRegexPattern = Pattern.compile(templateRegex);
+        templateRegexPattern = Pattern.compile(stringBuilder.toString());
     }
 
     public String getValue() {
         return template;
     }
     
+    public int getNumberOfGroups() {
+        return templateVariables.size();
+    }
+    
     private void copyURITemplateCharacters(String templateValue, int start, int end, StringBuilder b) {
         for (int i = start; i < end; i++) {
             char c = templateValue.charAt(i);
@@ -144,7 +144,7 @@
                                              Path path) {
         
         if (path == null) {
-            return new URITemplate("/", URITemplate.UNLIMITED_REGEX_SUFFIX);
+            return new URITemplate("/", URITemplate.LIMITED_REGEX_SUFFIX);
         }
         
         String pathValue = path.value();

Added: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java?rev=673167&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java (added)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java Tue Jul  1 11:41:24 2008
@@ -0,0 +1,182 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.jaxrs.provider;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Map;
+import java.util.WeakHashMap;
+import java.util.logging.Logger;
+
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.ext.ContextResolver;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.PackageUtils;
+import org.apache.cxf.jaxrs.utils.AnnotationUtils;
+import org.apache.cxf.jaxrs.utils.InjectionUtils;
+
+public abstract class AbstractJAXBProvider 
+    implements MessageBodyReader<Object>, MessageBodyWriter<Object> {
+    
+    private static final Logger LOG = LogUtils.getL7dLogger(AbstractJAXBProvider.class);
+
+    private static final String CHARSET_PARAMETER = "charset"; 
+
+    private static Map<String, JAXBContext> packageContexts = new WeakHashMap<String, JAXBContext>();
+    private static Map<Class<?>, JAXBContext> classContexts = new WeakHashMap<Class<?>, JAXBContext>();
+    
+    @Context protected ContextResolver<JAXBContext> resolver;
+    
+    public boolean isWriteable(Class<?> type, Type genericType, Annotation[] anns) {
+        return isSupported(type, genericType, anns)
+               || AnnotationUtils.getAnnotation(anns, XmlJavaTypeAdapter.class) != null;
+    }
+    
+    public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations) {
+        return isSupported(type, genericType, annotations);
+    }
+
+    public long getSize(Object o) {
+        return -1;
+    }
+
+    protected JAXBContext getJAXBContext(Class<?> type, Type genericType) throws JAXBException {
+        
+        if (resolver != null) {
+            JAXBContext context = resolver.getContext(type);
+            // it's up to the resolver to keep its contexts in a map
+            if (context != null) {
+                return context;
+            }
+        }
+        JAXBContext context = getPackageContext(type);
+        if (context == null && type != genericType) {
+            context = getPackageContext(InjectionUtils.getActualType(genericType));
+        }
+        
+        return context != null ? context : getClassContext(type);
+    }
+    
+    private JAXBContext getClassContext(Class<?> type) throws JAXBException {
+        synchronized (classContexts) {
+            JAXBContext context = classContexts.get(type);
+            if (context == null) {
+                context = JAXBContext.newInstance(type);
+                classContexts.put(type, context);
+            }
+            return context;
+        }
+    }
+    
+    private JAXBContext getPackageContext(Class<?> type) {
+        if (type == null) {
+            return null;
+        }
+        synchronized (packageContexts) {
+            String packageName = PackageUtils.getPackageName(type);
+            JAXBContext context = packageContexts.get(packageName);
+            if (context == null) {
+                try {
+                    context = JAXBContext.newInstance(packageName, type.getClassLoader());
+                    packageContexts.put(packageName, context);
+                    return context;
+                } catch (JAXBException ex) {
+                    LOG.warning("Error creating a JAXBContext using ObjectFactory : " 
+                                + ex.getMessage());
+                    return null;
+                }
+            }
+        }
+        return null;
+    }
+    
+    protected boolean isSupported(Class<?> type, Type genericType, Annotation[] annotations) {
+        
+        return type.getAnnotation(XmlRootElement.class) != null
+            || JAXBElement.class.isAssignableFrom(type)
+            || objectFactoryForClass(type)
+            || (type != genericType && objectFactoryForType(genericType));
+    
+    }
+    
+    private boolean objectFactoryForClass(Class<?> type) {
+        try {
+            return type.getClassLoader().loadClass(PackageUtils.getPackageName(type) 
+                                        + ".ObjectFactory") != null;
+        } catch (Exception ex) {
+            return false;
+        }
+    }
+    
+    private boolean objectFactoryForType(Type genericType) {
+        return objectFactoryForClass(InjectionUtils.getActualType(genericType));
+    }
+    
+    protected Marshaller createMarshaller(Object obj, Class<?> cls, Type genericType, MediaType m)
+        throws JAXBException {
+        
+        Class<?> objClazz = JAXBElement.class.isAssignableFrom(cls) 
+                            ? ((JAXBElement)obj).getDeclaredType() : cls;
+        JAXBContext context = getJAXBContext(objClazz, genericType);
+        Marshaller marshaller = context.createMarshaller();
+        String enc = m.getParameters().get(CHARSET_PARAMETER);
+        if (enc != null) {
+            marshaller.setProperty(Marshaller.JAXB_ENCODING, enc);
+        }
+        return marshaller;
+    }
+    
+    protected Class<?> getActualType(Class<?> type, Type genericType) {
+        Class<?> theType = null;
+        if (JAXBElement.class.isAssignableFrom(type)) {
+            theType = InjectionUtils.getActualType(genericType);
+        } else {
+            theType = type;
+        }
+        
+        return theType;
+    }
+    
+    @SuppressWarnings("unchecked")
+    protected Object checkAdapter(Object obj, Annotation[] anns) {
+        XmlJavaTypeAdapter typeAdapter = AnnotationUtils.getAnnotation(anns, XmlJavaTypeAdapter.class);
+        if (typeAdapter != null) {
+            try {
+                XmlAdapter xmlAdapter = typeAdapter.value().newInstance();
+                return xmlAdapter.marshal(obj);
+            } catch (Exception ex) {
+                LOG.warning("Problem using the XmlJavaTypeAdapter");
+                ex.printStackTrace();
+            }
+        }
+        return obj;
+    }
+}

Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomEntryProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomEntryProvider.java?rev=673167&r1=673166&r2=673167&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomEntryProvider.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomEntryProvider.java Tue Jul  1 11:41:24 2008
@@ -22,6 +22,8 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
 
 import javax.ws.rs.ConsumeMime;
 import javax.ws.rs.ProduceMime;
@@ -45,23 +47,16 @@
     private static final Abdera ATOM_ENGINE = new Abdera();
     private static final String JSON_TYPE = "application/json";
     
-    public Entry readFrom(Class<Entry> clazz, MediaType mt, 
-                          MultivaluedMap <String, String> headers, InputStream is)
-        throws IOException {
-        Document<Entry> doc = ATOM_ENGINE.getParser().parse(is);
-        return doc.getRoot();
+    public long getSize(Entry feed) {
+        return -1;
     }
 
-    public boolean isReadable(Class<?> type) {
-        return Entry.class.isAssignableFrom(type);
-    }
-    
-    public boolean isWriteable(Class<?> type) {
+    public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations) {
         return Entry.class.isAssignableFrom(type);
     }
 
-    public void writeTo(Entry entry, MediaType mt, 
-                        MultivaluedMap<String, Object> headers, OutputStream os)
+    public void writeTo(Entry entry, Class<?> clazz, Type type, Annotation[] a, 
+                        MediaType mt, MultivaluedMap<String, Object> headers, OutputStream os) 
         throws IOException {
         if (JSON_TYPE.equals(mt.toString())) {
             Writer w = ATOM_ENGINE.getWriterFactory().getWriter("json");
@@ -69,9 +64,17 @@
         } else {
             entry.writeTo(os);
         }
+        
     }
- 
-    public long getSize(Entry entry) {
-        return -1;
+
+    public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations) {
+        return Entry.class.isAssignableFrom(type);
+    }
+
+    public Entry readFrom(Class<Entry> clazz, Type t, Annotation[] a, MediaType mt, 
+                          MultivaluedMap<String, String> headers, InputStream is) 
+        throws IOException {
+        Document<Entry> doc = ATOM_ENGINE.getParser().parse(is);
+        return doc.getRoot();
     }
 }



Mime
View raw message