cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1383478 - in /cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs: client/spec/ impl/ provider/ utils/
Date Tue, 11 Sep 2012 16:56:59 GMT
Author: sergeyb
Date: Tue Sep 11 16:56:58 2012
New Revision: 1383478

URL: http://svn.apache.org/viewvc?rev=1383478&view=rev
Log:
[CXF-4455] Prototying the code for suporting client filters

Added:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientRequestContextImpl.java
  (with props)
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientResponseContextImpl.java
  (with props)
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AbstractRequestContextImpl.java
  (with props)
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AbstractResponseContextImpl.java
  (with props)
Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerRequestContextImpl.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerResponseContextImpl.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java

Added: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientRequestContextImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientRequestContextImpl.java?rev=1383478&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientRequestContextImpl.java
(added)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientRequestContextImpl.java
Tue Sep 11 16:56:58 2012
@@ -0,0 +1,126 @@
+/**
+ * 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.client.spec;
+
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.net.URI;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientRequestContext;
+import javax.ws.rs.client.Configuration;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+
+import org.apache.cxf.jaxrs.impl.AbstractRequestContextImpl;
+import org.apache.cxf.message.Message;
+
+public class ClientRequestContextImpl extends AbstractRequestContextImpl
+    implements ClientRequestContext {
+
+    public ClientRequestContextImpl(Message m,
+                                    boolean responseContext) {
+        super(m, responseContext);
+    }
+    
+    @Override
+    public Client getClient() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Configuration getConfiguration() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+    
+    @Override
+    public Object getEntity() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Annotation[] getEntityAnnotations() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Class<?> getEntityClass() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Type getEntityType() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+    
+    @Override
+    public OutputStream getEntityStream() {
+        return m.get(OutputStream.class);
+    }
+
+    @Override
+    public URI getUri() {
+        String requestURI = (String)m.get(Message.REQUEST_URI);
+        return requestURI  == null ? null : URI.create(requestURI);
+    }
+
+    @Override
+    public boolean hasEntity() {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public void setEntity(Object arg0, Annotation[] arg1, MediaType arg2) {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setEntityStream(OutputStream os) {
+        m.put(OutputStream.class, os);
+
+    }
+
+    @Override
+    public void setUri(URI requestURI) {
+        m.put(Message.ENDPOINT_ADDRESS, requestURI.toString());
+        m.put(Message.REQUEST_URI, requestURI.toString());
+
+    }
+
+    @Override
+    public MultivaluedMap<String, Object> getHeaders() {
+        return null;    
+
+    }
+
+    @Override
+    public MultivaluedMap<String, String> getStringHeaders() {
+        return null;
+    }
+
+}

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

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

Added: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientResponseContextImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientResponseContextImpl.java?rev=1383478&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientResponseContextImpl.java
(added)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientResponseContextImpl.java
Tue Sep 11 16:56:58 2012
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.jaxrs.client.spec;
+
+import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
+
+import javax.ws.rs.client.ClientResponseContext;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+
+import org.apache.cxf.jaxrs.impl.AbstractResponseContextImpl;
+import org.apache.cxf.jaxrs.impl.MetadataMap;
+import org.apache.cxf.message.Message;
+
+public class ClientResponseContextImpl extends AbstractResponseContextImpl 
+    implements ClientResponseContext {
+
+    public ClientResponseContextImpl(Response r, 
+                                     Message m) {
+        super(r, m);
+    }
+    
+    public InputStream getEntityStream() {
+        return m.get(InputStream.class);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public MultivaluedMap<String, String> getHeaders() {
+        return new MetadataMap<String, String>(
+            (Map<String, List<String>>)m.get(Message.PROTOCOL_HEADERS), false,
true, true);
+    }
+
+    
+    @Override
+    public void setEntityStream(InputStream is) {
+        m.put(InputStream.class, is);
+
+    }
+}

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

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

Added: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AbstractRequestContextImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AbstractRequestContextImpl.java?rev=1383478&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AbstractRequestContextImpl.java
(added)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AbstractRequestContextImpl.java
Tue Sep 11 16:56:58 2012
@@ -0,0 +1,146 @@
+/**
+ * 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;
+
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+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.Response;
+
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.message.Message;
+
+public abstract class AbstractRequestContextImpl {
+
+    private static final String PROPERTY_KEY = "jaxrs.filter.properties";
+    
+    protected HttpHeaders h;
+    protected Message m;
+    private Map<String, Object> props;
+    private boolean responseContext;
+    public AbstractRequestContextImpl(Message message, boolean responseContext) {
+        this.m = message;
+        this.props = CastUtils.cast((Map<?, ?>)message.get(PROPERTY_KEY));
+        this.h = new HttpHeadersImpl(message);
+        this.responseContext = responseContext;
+    }
+    
+    public void abortWith(Response response) {
+        checkContext();
+        m.getExchange().put(Response.class, response);
+    }
+
+    public List<Locale> getAcceptableLanguages() {
+        return getHttpHeaders().getAcceptableLanguages();
+    }
+
+    public List<MediaType> getAcceptableMediaTypes() {
+        return getHttpHeaders().getAcceptableMediaTypes();
+    }
+
+    public Map<String, Cookie> getCookies() {
+        return getHttpHeaders().getCookies();
+    }
+
+    public Date getDate() {
+        return getHttpHeaders().getDate();
+    }
+
+    public String getHeaderString(String name) {
+        return getHttpHeaders().getHeaderString(name);
+    }
+
+    public Locale getLanguage() {
+        return getHttpHeaders().getLanguage();
+    }
+
+    public int getLength() {
+        return getHttpHeaders().getLength();
+    }
+
+    public MediaType getMediaType() {
+        return getHttpHeaders().getMediaType();
+    }
+
+    public String getMethod() {
+        return (String)getProperty(Message.HTTP_REQUEST_METHOD);
+    }
+
+    public Object getProperty(String name) {
+        return props == null ? null : props.get(name);
+    }
+
+    public Enumeration<String> getPropertyNames() {
+        final Iterator<String> it = props.keySet().iterator();
+        return new Enumeration<String>() {
+
+            @Override
+            public boolean hasMoreElements() {
+                return it.hasNext();
+            }
+
+            @Override
+            public String nextElement() {
+                return it.next();
+            }
+            
+        };
+    }
+
+
+    public void removeProperty(String name) {
+        if (props != null) {
+            props.remove(name);    
+        }
+    }
+
+
+    public void setMethod(String method) throws IllegalStateException {
+        checkContext();
+        m.put(Message.HTTP_REQUEST_METHOD, method);
+
+    }
+
+    public void setProperty(String name, Object value) {
+        if (props == null) {
+            props = new HashMap<String, Object>();
+            m.put(PROPERTY_KEY, props);
+        }    
+        props.put(name, value);    
+        
+    }
+
+    protected HttpHeaders getHttpHeaders() {
+        return h != null ? h : new HttpHeadersImpl(m);
+    }
+    
+    protected void checkContext() {
+        if (responseContext) {
+            throw new IllegalStateException();
+        }
+    }
+}

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

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

Added: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AbstractResponseContextImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AbstractResponseContextImpl.java?rev=1383478&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AbstractResponseContextImpl.java
(added)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AbstractResponseContextImpl.java
Tue Sep 11 16:56:58 2012
@@ -0,0 +1,144 @@
+/**
+ * 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;
+
+import java.lang.annotation.Annotation;
+import java.net.URI;
+import java.util.Date;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+import javax.ws.rs.core.EntityTag;
+import javax.ws.rs.core.Link;
+import javax.ws.rs.core.Link.Builder;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.NewCookie;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.StatusType;
+
+import org.apache.cxf.message.Message;
+
+public abstract class AbstractResponseContextImpl {
+
+    protected Message m;
+    protected Response r;
+    public AbstractResponseContextImpl(Response r, Message m) {
+        this.m = m;
+        this.r = r;
+    }
+    
+    public Set<String> getAllowedMethods() {
+        return r.getAllowedMethods();
+    }
+
+    public Map<String, NewCookie> getCookies() {
+        return r.getCookies();
+    }
+
+    public Date getDate() {
+        return r.getDate();
+    }
+
+    public Object getEntity() {
+        return r.getEntity();
+    }
+
+       
+    public EntityTag getEntityTag() {
+        return r.getEntityTag();
+    }
+
+    public String getHeaderString(String name) {
+        return r.getHeaderString(name);
+    }
+
+    public Locale getLanguage() {
+        return r.getLanguage();
+    }
+
+    public Date getLastModified() {
+        return r.getLastModified();
+    }
+
+    public int getLength() {
+        return r.getLength();
+    }
+
+    public Link getLink(String rel) {
+        return r.getLink(rel);
+    }
+
+    public Builder getLinkBuilder(String rel) {
+        return r.getLinkBuilder(rel);
+    }
+
+    public Set<Link> getLinks() {
+        return r.getLinks();
+    }
+
+    public URI getLocation() {
+        return r.getLocation();
+    }
+
+    public MediaType getMediaType() {
+        return r.getMediaType();
+    }
+
+    public int getStatus() {
+        return r.getStatus();
+    }
+
+    public StatusType getStatusInfo() {
+        return r.getStatusInfo();
+    }
+
+    public MultivaluedMap<String, String> getStringHeaders() {
+        //TODO: right now this view is not modifiable
+        return r.getStringHeaders();
+    }
+
+    public boolean hasEntity() {
+        return r.hasEntity();
+    }
+
+    public boolean hasLink(String rel) {
+        return r.hasLink(rel);
+    }
+
+    public void setEntity(Object entity, Annotation[] anns, MediaType mt) {
+        ((ResponseImpl)r).setEntity(entity);
+        updateMessageResponse();
+        //TODO: review this code after API gets finalized
+    }
+    
+    public void setStatus(int status) {
+        ((ResponseImpl)r).setStatus(status);
+        updateMessageResponse();
+    }
+
+    public void setStatusInfo(StatusType status) {
+        setStatus(status.getStatusCode());
+    }
+
+    private void updateMessageResponse() {
+        m.put(Response.class, r);
+    }
+}

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

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

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerRequestContextImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerRequestContextImpl.java?rev=1383478&r1=1383477&r2=1383478&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerRequestContextImpl.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerRequestContextImpl.java
Tue Sep 11 16:56:58 2012
@@ -20,70 +20,27 @@ package org.apache.cxf.jaxrs.impl;
 
 import java.io.InputStream;
 import java.net.URI;
-import java.util.Date;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
-import java.util.Locale;
 import java.util.Map;
 
 import javax.ws.rs.container.ContainerRequestContext;
-import javax.ws.rs.core.Cookie;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Request;
-import javax.ws.rs.core.Response;
 import javax.ws.rs.core.SecurityContext;
 import javax.ws.rs.core.UriInfo;
 
-import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.jaxrs.utils.HttpUtils;
 import org.apache.cxf.message.Message;
 
-public class ContainerRequestContextImpl implements ContainerRequestContext {
+public class ContainerRequestContextImpl extends AbstractRequestContextImpl 
+    implements ContainerRequestContext {
 
-    private static final String PROPERTY_KEY = "jaxrs.filter.properties";
     private static final String ENDPOINT_ADDRESS_PROPERTY = "org.apache.cxf.transport.endpoint.address";
     
-    private HttpHeaders h;
-    private Message m;
-    private Map<String, Object> props;
     private boolean preMatch;
-    private boolean responseContext;
     public ContainerRequestContextImpl(Message message, boolean preMatch, boolean responseContext)
{
-        this.m = message;
-        this.props = CastUtils.cast((Map<?, ?>)message.get(PROPERTY_KEY));
-        this.h = new HttpHeadersImpl(message);
+        super(message, responseContext);
         this.preMatch = preMatch;
-        this.responseContext = responseContext;
-    }
-    
-    @Override
-    public void abortWith(Response response) {
-        checkContext();
-        m.getExchange().put(Response.class, response);
-    }
-
-    @Override
-    public List<Locale> getAcceptableLanguages() {
-        return getHttpHeaders().getAcceptableLanguages();
-    }
-
-    @Override
-    public List<MediaType> getAcceptableMediaTypes() {
-        return getHttpHeaders().getAcceptableMediaTypes();
-    }
-
-    @Override
-    public Map<String, Cookie> getCookies() {
-        return getHttpHeaders().getCookies();
-    }
-
-    @Override
-    public Date getDate() {
-        return getHttpHeaders().getDate();
     }
 
     @Override
@@ -91,61 +48,6 @@ public class ContainerRequestContextImpl
         return m.get(InputStream.class);
     }
 
-    @Override
-    public String getHeaderString(String name) {
-        return getHttpHeaders().getHeaderString(name);
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public MultivaluedMap<String, String> getHeaders() {
-        h = null;
-        return new MetadataMap<String, String>(
-            (Map<String, List<String>>)m.get(Message.PROTOCOL_HEADERS), false,
true, true);
-    }
-
-    @Override
-    public Locale getLanguage() {
-        return getHttpHeaders().getLanguage();
-    }
-
-    @Override
-    public int getLength() {
-        return getHttpHeaders().getLength();
-    }
-
-    @Override
-    public MediaType getMediaType() {
-        return getHttpHeaders().getMediaType();
-    }
-
-    @Override
-    public String getMethod() {
-        return (String)getProperty(Message.HTTP_REQUEST_METHOD);
-    }
-
-    @Override
-    public Object getProperty(String name) {
-        return props == null ? null : props.get(name);
-    }
-
-    @Override
-    public Enumeration<String> getPropertyNames() {
-        final Iterator<String> it = props.keySet().iterator();
-        return new Enumeration<String>() {
-
-            @Override
-            public boolean hasMoreElements() {
-                return it.hasNext();
-            }
-
-            @Override
-            public String nextElement() {
-                return it.next();
-            }
-            
-        };
-    }
 
     @Override
     public Request getRequest() {
@@ -168,34 +70,18 @@ public class ContainerRequestContextImpl
     }
 
     @Override
-    public void removeProperty(String name) {
-        if (props != null) {
-            props.remove(name);    
-        }
-    }
-
-    @Override
     public void setEntityStream(InputStream is) {
         checkContext();
         m.put(InputStream.class, is);
     }
 
-    @Override
-    public void setMethod(String method) throws IllegalStateException {
-        checkContext();
-        m.put(Message.HTTP_REQUEST_METHOD, method);
-
+    @SuppressWarnings("unchecked")
+    public MultivaluedMap<String, String> getHeaders() {
+        h = null;
+        return new MetadataMap<String, String>(
+            (Map<String, List<String>>)m.get(Message.PROTOCOL_HEADERS), false,
true, true);
     }
 
-    @Override
-    public void setProperty(String name, Object value) {
-        if (props == null) {
-            props = new HashMap<String, Object>();
-            m.put(PROPERTY_KEY, props);
-        }    
-        props.put(name, value);    
-        
-    }
 
     @Override
     public void setRequestUri(URI requestUri) throws IllegalStateException {
@@ -220,13 +106,4 @@ public class ContainerRequestContextImpl
         m.put(SecurityContext.class, sc);
     }
 
-    private HttpHeaders getHttpHeaders() {
-        return h != null ? h : new HttpHeadersImpl(m);
-    }
-    
-    private void checkContext() {
-        if (responseContext) {
-            throw new IllegalStateException();
-        }
-    }
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerResponseContextImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerResponseContextImpl.java?rev=1383478&r1=1383477&r2=1383478&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerResponseContextImpl.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerResponseContextImpl.java
Tue Sep 11 16:56:58 2012
@@ -22,59 +22,26 @@ import java.io.OutputStream;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 import java.lang.reflect.Type;
-import java.net.URI;
-import java.util.Date;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
 
 import javax.ws.rs.container.ContainerResponseContext;
-import javax.ws.rs.core.EntityTag;
-import javax.ws.rs.core.Link;
-import javax.ws.rs.core.Link.Builder;
-import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.NewCookie;
 import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.StatusType;
 
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
 import org.apache.cxf.message.Message;
 
-public class ContainerResponseContextImpl implements ContainerResponseContext {
+public class ContainerResponseContextImpl extends AbstractResponseContextImpl 
+    implements ContainerResponseContext {
 
-    private Message m;
-    private Response r;
     private OperationResourceInfo ori;
     public ContainerResponseContextImpl(Response r, 
                                         Message m,
                                         OperationResourceInfo ori) {
-        this.m = m;
-        this.r = r;
+        super(r, m);
         this.ori = ori;
     }
     
     @Override
-    public Set<String> getAllowedMethods() {
-        return r.getAllowedMethods();
-    }
-
-    @Override
-    public Map<String, NewCookie> getCookies() {
-        return r.getCookies();
-    }
-
-    @Override
-    public Date getDate() {
-        return r.getDate();
-    }
-
-    @Override
-    public Object getEntity() {
-        return r.getEntity();
-    }
-
-    @Override
     public Annotation[] getEntityAnnotations() {
         Method method = ori == null ? null : ori.getAnnotatedMethod();
         return method == null ? null : method.getAnnotations();
@@ -91,89 +58,13 @@ public class ContainerResponseContextImp
     }
     
     @Override
-    public OutputStream getEntityStream() {
-        return m.get(OutputStream.class);
-    }
-
-    @Override
-    public EntityTag getEntityTag() {
-        return r.getEntityTag();
-    }
-
-    @Override
-    public String getHeaderString(String name) {
-        return r.getHeaderString(name);
-    }
-
-    @Override
     public MultivaluedMap<String, Object> getHeaders() {
         return r.getMetadata();
     }
-
-    @Override
-    public Locale getLanguage() {
-        return r.getLanguage();
-    }
-
-    @Override
-    public Date getLastModified() {
-        return r.getLastModified();
-    }
-
-    @Override
-    public int getLength() {
-        return r.getLength();
-    }
-
-    @Override
-    public Link getLink(String rel) {
-        return r.getLink(rel);
-    }
-
-    @Override
-    public Builder getLinkBuilder(String rel) {
-        return r.getLinkBuilder(rel);
-    }
-
-    @Override
-    public Set<Link> getLinks() {
-        return r.getLinks();
-    }
-
-    @Override
-    public URI getLocation() {
-        return r.getLocation();
-    }
-
-    @Override
-    public MediaType getMediaType() {
-        return r.getMediaType();
-    }
-
-    @Override
-    public int getStatus() {
-        return r.getStatus();
-    }
-
-    @Override
-    public StatusType getStatusInfo() {
-        return r.getStatusInfo();
-    }
-
-    @Override
-    public MultivaluedMap<String, String> getStringHeaders() {
-        //TODO: right now this view is not modifiable
-        return r.getStringHeaders();
-    }
-
-    @Override
-    public boolean hasEntity() {
-        return r.hasEntity();
-    }
-
+    
     @Override
-    public boolean hasLink(String rel) {
-        return r.hasLink(rel);
+    public OutputStream getEntityStream() {
+        return m.get(OutputStream.class);
     }
 
     @Override
@@ -182,25 +73,5 @@ public class ContainerResponseContextImp
 
     }
 
-    @Override
-    public void setEntity(Object entity, Annotation[] anns, MediaType mt) {
-        ((ResponseImpl)r).setEntity(entity);
-        updateMessageResponse();
-        //TODO: review this code after API gets finalized
-    }
-    
-    @Override
-    public void setStatus(int status) {
-        ((ResponseImpl)r).setStatus(status);
-        updateMessageResponse();
-    }
 
-    @Override
-    public void setStatusInfo(StatusType status) {
-        setStatus(status.getStatusCode());
-    }
-
-    private void updateMessageResponse() {
-        m.put(Response.class, r);
-    }
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java?rev=1383478&r1=1383477&r2=1383478&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
Tue Sep 11 16:56:58 2012
@@ -38,6 +38,8 @@ import java.util.logging.Logger;
 
 import javax.ws.rs.Produces;
 import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.client.ClientRequestFilter;
+import javax.ws.rs.client.ClientResponseFilter;
 import javax.ws.rs.container.ContainerRequestFilter;
 import javax.ws.rs.container.ContainerResponseFilter;
 import javax.ws.rs.container.PreMatching;
@@ -103,6 +105,7 @@ public final class ProviderFactory {
         new ArrayList<ProviderInfo<ContextProvider<?>>>(1);
     private List<ProviderInfo<ExceptionMapper<?>>> exceptionMappers = 
         new ArrayList<ProviderInfo<ExceptionMapper<?>>>(1);
+    
     // RequestHandler & ResponseHandler will have to be deprecated for 2.7.0
     private List<ProviderInfo<RequestHandler>> requestHandlers = 
         new ArrayList<ProviderInfo<RequestHandler>>(1);
@@ -128,8 +131,6 @@ public final class ProviderFactory {
     private List<ProviderInfo<ParameterHandler<?>>> paramHandlers = 
         new ArrayList<ProviderInfo<ParameterHandler<?>>>(1);
     
-    private List<ProviderInfo<ResponseExceptionMapper<?>>> responseExceptionMappers
= 
-        new ArrayList<ProviderInfo<ResponseExceptionMapper<?>>>(1);
     private RequestPreprocessor requestPreprocessor;
     private ProviderInfo<Application> application;
     
@@ -143,6 +144,14 @@ public final class ProviderFactory {
     
     private Bus bus;
     
+    // Client-only providers, consider introducing ClientProviderFactory
+    private List<ProviderInfo<ClientRequestFilter>> clientRequestFilters = 
+        new ArrayList<ProviderInfo<ClientRequestFilter>>(1);
+    private List<ProviderInfo<ClientResponseFilter>> clientResponseFilters =

+        new ArrayList<ProviderInfo<ClientResponseFilter>>(1);
+    private List<ProviderInfo<ResponseExceptionMapper<?>>> responseExceptionMappers
= 
+        new ArrayList<ProviderInfo<ResponseExceptionMapper<?>>>(1);
+    
     private ProviderFactory(Bus bus) {
         this.bus = bus;
         initJaxbProviders();
@@ -486,6 +495,14 @@ public final class ProviderFactory {
                                             names);
     }
     
+    public List<ProviderInfo<ClientRequestFilter>> getClientRequestFilters()
{
+        return Collections.unmodifiableList(clientRequestFilters);
+    }
+    
+    public List<ProviderInfo<ClientResponseFilter>> getClientResponseFilters()
{
+        return Collections.unmodifiableList(clientResponseFilters);
+    }
+    
     private static <T> List<ProviderInfo<T>> getPostMatchContainerFilters(List<ProviderInfo<T>>
globalFilters,
                                                                          Map<String, ProviderInfo<T>>
boundFilters,
                                                                          List<String>
names) {
@@ -612,6 +629,16 @@ public final class ProviderFactory {
                    new ProviderInfo<ContainerResponseFilter>((ContainerResponseFilter)o,
bus)); 
             }
             
+            if (ClientRequestFilter.class.isAssignableFrom(oClass)) {
+                clientRequestFilters.add(
+                   new ProviderInfo<ClientRequestFilter>((ClientRequestFilter)o, bus));
+            }
+            
+            if (ClientResponseFilter.class.isAssignableFrom(oClass)) {
+                clientResponseFilters.add(
+                   new ProviderInfo<ClientResponseFilter>((ClientResponseFilter)o,
bus));
+            }
+            
             if (ExceptionMapper.class.isAssignableFrom(oClass)) {
                 exceptionMappers.add(new ProviderInfo<ExceptionMapper<?>>((ExceptionMapper<?>)o,
bus)); 
             }
@@ -632,7 +659,8 @@ public final class ProviderFactory {
         injectContextProxies(messageReaders, messageWriters, contextResolvers, 
             requestHandlers, responseHandlers, exceptionMappers,
             boundContainerRequestFilters.values(), globalPreContainerRequestFilters, globalContainerRequestFilters,
-            boundContainerResponseFilters.values(), globalPreContainerResponseFilters, globalContainerResponseFilters);
+            boundContainerResponseFilters.values(), globalPreContainerResponseFilters, globalContainerResponseFilters,
+            responseExceptionMappers, clientRequestFilters, clientResponseFilters);
     }
 //CHECKSTYLE:ON
     
@@ -961,6 +989,8 @@ public final class ProviderFactory {
         globalPreContainerResponseFilters.clear();
         paramHandlers.clear();
         responseExceptionMappers.clear();
+        clientRequestFilters.clear();
+        clientResponseFilters.clear();
     }
     
     public void setBus(Bus bus) {

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java?rev=1383478&r1=1383477&r2=1383478&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java Tue
Sep 11 16:56:58 2012
@@ -1376,6 +1376,7 @@ public final class JAXRSUtils {
                 new ContainerResponseContextImpl(r, m, ori);
             for (ProviderInfo<ContainerResponseFilter> filter : containerFilters) {
                 try {
+                    InjectionUtils.injectContexts(filter.getProvider(), filter, m);
                     filter.getProvider().filter(requestContext, responseContext);
                 } catch (IOException ex) {
                     throw new WebApplicationException(ex);



Mime
View raw message