cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject [1/2] git commit: Trying to prototype some BP code for mapping between jaxrs and jaxrs-client
Date Thu, 10 Jul 2014 15:13:44 GMT
Repository: cxf
Updated Branches:
  refs/heads/master c36a2388f -> 82d49c140


Trying to prototype some BP code for mapping between jaxrs and jaxrs-client


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/5934b2e8
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/5934b2e8
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/5934b2e8

Branch: refs/heads/master
Commit: 5934b2e83315c1ccfe1f26d21e3f62d190bab380
Parents: 22dbf10
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Thu Jul 10 16:13:08 2014 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Thu Jul 10 16:13:08 2014 +0100

----------------------------------------------------------------------
 .../blueprint/JAXRSBPNamespaceHandler.java      | 30 ++++++++++++++++++--
 1 file changed, 27 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/5934b2e8/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/JAXRSBPNamespaceHandler.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/JAXRSBPNamespaceHandler.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/JAXRSBPNamespaceHandler.java
index d42a415..7834228 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/JAXRSBPNamespaceHandler.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/JAXRSBPNamespaceHandler.java
@@ -20,13 +20,20 @@
 package org.apache.cxf.jaxrs.blueprint;
 
 import java.net.URL;
+import java.util.Collections;
+import java.util.Map;
 import java.util.Set;
 
+import javax.xml.stream.XMLStreamException;
+
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
 import org.apache.aries.blueprint.NamespaceHandler;
 import org.apache.aries.blueprint.ParserContext;
+import org.apache.cxf.staxutils.StaxUtils;
+import org.apache.cxf.staxutils.W3CDOMStreamWriter;
+import org.apache.cxf.staxutils.transform.OutTransformWriter;
 import org.osgi.service.blueprint.container.BlueprintContainer;
 import org.osgi.service.blueprint.reflect.ComponentMetadata;
 import org.osgi.service.blueprint.reflect.Metadata;
@@ -49,8 +56,11 @@ public class JAXRSBPNamespaceHandler implements NamespaceHandler {
         String s = element.getLocalName();
         if ("server".equals(s)) {
             return new JAXRSServerFactoryBeanDefinitionParser().parse(element, context);
-        } 
-        return null;
+        } else if ("client".equals(s)) {
+            return context.parseElement(Metadata.class, null, transformElement(element));
+        } else {
+            return null;
+        }
     }
 
     @SuppressWarnings("rawtypes")
@@ -61,7 +71,21 @@ public class JAXRSBPNamespaceHandler implements NamespaceHandler {
         return null;
     }
     
-
+    private Element transformElement(Element element) {
+        final Map<String, String> transformMap = 
+            Collections.singletonMap("{" + element.getNamespaceURI() + "}*", 
+                                     "{http://cxf.apache.org/blueprint/jaxrs-client}*");
+        
+        
+        W3CDOMStreamWriter domWriter = new W3CDOMStreamWriter();
+        OutTransformWriter transformWriter = new OutTransformWriter(domWriter, transformMap);
+        try {
+            StaxUtils.copy(element, transformWriter);
+        } catch (XMLStreamException e) {
+            throw new RuntimeException(e);
+        }
+        return domWriter.getDocument().getDocumentElement();
+    }
     public BlueprintContainer getBlueprintContainer() {
         return blueprintContainer;
     }


Mime
View raw message