cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject svn commit: r465454 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/databinding/ api/src/main/java/org/apache/cxf/message/ rt/core/src/main/java/org/apache/cxf/interceptor/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/
Date Thu, 19 Oct 2006 02:52:22 GMT
Author: tli
Date: Wed Oct 18 19:52:21 2006
New Revision: 465454

URL: http://svn.apache.org/viewvc?view=rev&rev=465454
Log:
add schema setting for data binding

Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/databinding/DataReaderFactory.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/Message.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/databinding/DataReaderFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/databinding/DataReaderFactory.java?view=diff&rev=465454&r1=465453&r2=465454
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/databinding/DataReaderFactory.java
(original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/databinding/DataReaderFactory.java
Wed Oct 18 19:52:21 2006
@@ -19,11 +19,15 @@
 
 package org.apache.cxf.databinding;
 
+import javax.xml.validation.Schema;
+
 
 //REVISIT - need to move the Reader/Writer stuff, also probably 
 //need the MessageInfo/OperationInfo as a param 
 public interface DataReaderFactory {
-    Class<?>[] getSupportedFormats();
     
+    Class<?>[] getSupportedFormats();    
     <T> DataReader<T> createReader(Class<T> cls);
+    void setSchema(Schema s);
+    
 }

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/Message.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/Message.java?view=diff&rev=465454&r1=465453&r2=465454
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/Message.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/Message.java Wed Oct 18 19:52:21
2006
@@ -44,7 +44,7 @@
     String PATH_INFO = Message.class.getName() + ".PATH_INFO";
     String QUERY_STRING = Message.class.getName() + ".QUERY_STRING";
     String MTOM_ENABLED = Message.class.getName() + ".isMtomEnabled";
-
+    String SCHEMA_VALIDATION_ENABLED = Message.class.getCanonicalName() + ".schemaValidationEnabled";
 
     String getId();
     void setId(String id);

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java?view=diff&rev=465454&r1=465453&r2=465454
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
Wed Oct 18 19:52:21 2006
@@ -25,6 +25,7 @@
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamReader;
+import javax.xml.validation.Schema;
 
 import org.w3c.dom.Node;
 
@@ -41,6 +42,7 @@
 import org.apache.cxf.service.model.OperationInfo;
 import org.apache.cxf.service.model.ServiceModelUtil;
 import org.apache.cxf.staxutils.DepthXMLStreamReader;
+import org.apache.cxf.wsdl.EndpointReferenceUtils;
 
 public abstract class AbstractInDatabindingInterceptor extends AbstractPhaseInterceptor<Message>
{
 
@@ -56,7 +58,7 @@
     protected DataReader getDataReader(Message message, Class<?> input) {
         Service service = ServiceModelUtil.getService(message.getExchange());
         DataReaderFactory factory = service.getDataBinding().getDataReaderFactory();
-
+        setSchemaInMessage(service, message);
         DataReader dataReader = null;
         for (Class<?> cls : factory.getSupportedFormats()) {
             if (cls == input) {
@@ -74,7 +76,7 @@
     protected DataReader<Message> getMessageDataReader(Message message) {
         Service service = ServiceModelUtil.getService(message.getExchange());
         DataReaderFactory factory = service.getDataBinding().getDataReaderFactory();
-
+        setSchemaInMessage(service, message);
         DataReader<Message> dataReader = null;
         for (Class<?> cls : factory.getSupportedFormats()) {
             if (cls == Message.class) {
@@ -92,7 +94,7 @@
     protected DataReader<XMLStreamReader> getDataReader(Message message) {
         Service service = ServiceModelUtil.getService(message.getExchange());
         DataReaderFactory factory = service.getDataBinding().getDataReaderFactory();
-
+        setSchemaInMessage(service, message);
         DataReader<XMLStreamReader> dataReader = null;
         for (Class<?> cls : factory.getSupportedFormats()) {
             if (cls == XMLStreamReader.class) {
@@ -110,7 +112,7 @@
     protected DataReader<Node> getNodeDataReader(Message message) {
         Service service = ServiceModelUtil.getService(message.getExchange());
         DataReaderFactory factory = service.getDataBinding().getDataReaderFactory();
-
+        setSchemaInMessage(service, message);
         DataReader<Node> dataReader = null;
         for (Class<?> cls : factory.getSupportedFormats()) {
             if (cls == Node.class) {
@@ -126,6 +128,14 @@
         return dataReader;
     }
 
+    private void setSchemaInMessage(Service service, Message message) {
+        if (message.getContextualProperty(Message.SCHEMA_VALIDATION_ENABLED) != null 
+                && Boolean.TRUE.equals(message.getContextualProperty(Message.SCHEMA_VALIDATION_ENABLED)))
{
+            Schema schema = EndpointReferenceUtils.getSchema(service.getServiceInfo());
+            service.getDataBinding().getDataReaderFactory().setSchema(schema);
+        }
+    }
+    
     protected DepthXMLStreamReader getXMLStreamReader(Message message) {
         XMLStreamReader xr = message.getContent(XMLStreamReader.class);
         return new DepthXMLStreamReader(xr);

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java?view=diff&rev=465454&r1=465453&r2=465454
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
Wed Oct 18 19:52:21 2006
@@ -26,7 +26,6 @@
 
 import javax.xml.bind.JAXBException;
 import javax.xml.transform.Source;
-import javax.xml.validation.Schema;
 import javax.xml.ws.Binding;
 import javax.xml.ws.Provider;
 import javax.xml.ws.WebServiceException;
@@ -39,8 +38,6 @@
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.endpoint.ServerImpl;
 import org.apache.cxf.jaxb.JAXBDataBinding;
-import org.apache.cxf.jaxb.JAXBDataReaderFactory;
-import org.apache.cxf.jaxb.JAXBDataWriterFactory;
 import org.apache.cxf.jaxws.context.WebContextResourceResolver;
 import org.apache.cxf.jaxws.handler.AnnotationHandlerChainBuilder;
 import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
@@ -53,7 +50,6 @@
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
 import org.apache.cxf.service.factory.ServerFactoryBean;
-import org.apache.cxf.wsdl.EndpointReferenceUtils;
 
 public class EndpointImpl extends javax.xml.ws.Endpoint {
     private static final Logger LOG = LogUtils.getL7dLogger(JaxWsServiceFactoryBean.class);
@@ -102,11 +98,6 @@
         serviceFactory.setBus(bus);
         service = serviceFactory.create();
         configureObject(service);
- 
-        // revisit: should get enableSchemaValidation from configuration
-        if (false) {
-            addSchemaValidation();
-        }
         
         if (implInfo.isWebServiceProvider()) {
             service.setInvoker(new ProviderInvoker((Provider<?>)i));
@@ -234,18 +225,7 @@
             configurer.configureBean(instance);
         }
     }
-    
-    private void addSchemaValidation() {
-        Schema schema = EndpointReferenceUtils.getSchema(service.getServiceInfo());
-        
-        if (service.getDataBinding().getDataReaderFactory() instanceof JAXBDataReaderFactory)
{
-            ((JAXBDataReaderFactory)service.getDataBinding().getDataReaderFactory()).setSchema(schema);
-        }
-        
-        if (service.getDataBinding().getDataWriterFactory() instanceof JAXBDataWriterFactory)
{
-            ((JAXBDataWriterFactory)service.getDataBinding().getDataWriterFactory()).setSchema(schema);
-        }
-    }
+
 
     private synchronized void init() {
         if (doInit) {



Mime
View raw message