cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r803174 - in /cxf/trunk: api/src/main/java/org/apache/cxf/databinding/PropertiesAwareDataBinding.java rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
Date Tue, 11 Aug 2009 15:53:45 GMT
Author: sergeyb
Date: Tue Aug 11 15:53:45 2009
New Revision: 803174

URL: http://svn.apache.org/viewvc?rev=803174&view=rev
Log:
Adding PropertiesAwareDataBinding interface

Added:
    cxf/trunk/api/src/main/java/org/apache/cxf/databinding/PropertiesAwareDataBinding.java
  (with props)
Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java

Added: cxf/trunk/api/src/main/java/org/apache/cxf/databinding/PropertiesAwareDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/databinding/PropertiesAwareDataBinding.java?rev=803174&view=auto
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/databinding/PropertiesAwareDataBinding.java
(added)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/databinding/PropertiesAwareDataBinding.java
Tue Aug 11 15:53:45 2009
@@ -0,0 +1,46 @@
+/**
+ * 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.databinding;
+
+import java.util.Map;
+
+/**
+ * Provides for alternative ways of initializing DataBindings
+ *
+ */
+public interface PropertiesAwareDataBinding extends DataBinding {
+    
+    /**
+     * Identifies org.apache.cxf.service.Service model object
+     */
+    String SERVICE_MODEL_PROPERTY = "org.apache.cxf.databinding.service";
+    
+    /**
+     * Indentifies a set of all classes which can be used to initialize a DataBinding
+     */
+    String TYPES_PROPERTY = "org.apache.cxf.databinding.types";
+    
+    /**
+     * Initialize a databinding with provided properties 
+     * @param properties properties which contain information 
+     *        like classes, Service models, etc
+     */
+    void initialize(Map<String, Object> properties);
+}

Propchange: cxf/trunk/api/src/main/java/org/apache/cxf/databinding/PropertiesAwareDataBinding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/api/src/main/java/org/apache/cxf/databinding/PropertiesAwareDataBinding.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java?rev=803174&r1=803173&r2=803174&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
Tue Aug 11 15:53:45 2009
@@ -18,11 +18,12 @@
  */
 package org.apache.cxf.jaxrs;
 
-import java.lang.reflect.Method;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.ResourceBundle;
 import java.util.Set;
 import java.util.logging.Logger;
@@ -37,6 +38,7 @@
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.databinding.DataBinding;
+import org.apache.cxf.databinding.PropertiesAwareDataBinding;
 import org.apache.cxf.endpoint.AbstractEndpointFactory;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.EndpointException;
@@ -249,12 +251,13 @@
 
     protected void setDataBindingProvider(ProviderFactory factory, Service s) {
         DataBinding db = getDataBinding();
-        try {
-            Method m = db.getClass().getMethod("setAllClasses", new Class[]{Set.class});
+        if (db instanceof PropertiesAwareDataBinding) {
             Set<Class<?>> allClasses = ResourceUtils.getAllRequestResponseTypes(
                                                          serviceFactory.getRealClassResourceInfo(),
false);
-            m.invoke(db, new Object[]{allClasses});
-        } catch (Exception ex) { 
+            Map<String, Object> props = new HashMap<String, Object>();
+            props.put(PropertiesAwareDataBinding.TYPES_PROPERTY, allClasses);
+            ((PropertiesAwareDataBinding)db).initialize(props);
+        } else { 
             db.initialize(s);
         }
         factory.setUserProviders(Collections.singletonList(new DataBindingProvider(db)));



Mime
View raw message