You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by bi...@apache.org on 2007/12/28 23:52:48 UTC

svn commit: r607352 [1/2] - in /incubator/cxf/trunk/rt/databinding/aegis/src: main/java/org/apache/cxf/aegis/ main/java/org/apache/cxf/aegis/databinding/ main/java/org/apache/cxf/aegis/type/ main/java/org/apache/cxf/aegis/type/basic/ main/java/org/apac...

Author: bimargulies
Date: Fri Dec 28 14:52:46 2007
New Revision: 607352

URL: http://svn.apache.org/viewvc?rev=607352&view=rev
Log:
Restructure some of Aegis to clarify.

Added:
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/Messages.properties   (with props)
Modified:
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/Context.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/ElementDataWriter.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataReader.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataWriter.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMappingRegistry.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeMappingRegistry.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeUtil.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ArrayType.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/Base64Type.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/MapType.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/MarshalRegistry.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapArrayType.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapRefRegistry.java
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/inheritance/ExceptionInheritanceTest.java
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/inheritance/InheritancePOJOTest.java
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/inheritance/intf/InterfaceInheritanceTest.java
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/WrappedTest.java
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/NamespaceConfusionTest.java
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/proxy/ProxyTest.java
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/base64/BinaryDataTest.java
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayTest.java
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/ByteDataTest.java
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/DynamicProxyTest.java
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/AbstractEncodedTest.java
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/SoapArrayTypeTest.java
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/StructTypeTest.java
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/AnnotatedTypeTest.java
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionTest.java
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/EnumTypeTest.java
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/MapTest.java

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java?rev=607352&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java Fri Dec 28 14:52:46 2007
@@ -0,0 +1,246 @@
+/**
+ * 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.aegis;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.aegis.type.Configuration;
+import org.apache.cxf.aegis.type.DefaultTypeMappingRegistry;
+import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.type.TypeMapping;
+import org.apache.cxf.aegis.type.TypeMappingRegistry;
+import org.apache.cxf.aegis.type.TypeUtil;
+import org.apache.cxf.aegis.type.basic.BeanType;
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.common.util.SOAPConstants;
+
+/**
+ * The Aegis Databinding context object. This object coordinates the data binding process: reading
+ * and writing XML.
+ * 
+ * By default, this object will use the DefaultTypeMapping registry and set up two type mappings:
+ * the default set, plus an empty one that will be used for classes mapped here. Applications
+ * may replace the type mapping registry and/or the mappings, though there are currently no examples
+ * that show how to do this or how it would be useful.
+ * 
+ * This class has no API that maps from a Class or QName to a Type or visa versa. Our goal is to allow
+ * Aegis-sans-CXF, but the marshal/unmarshal-level APIs aren't sorted out yet.
+ * 
+ */
+public class AegisContext {
+    private static final String DUMMY_ENCODING_STYLE_URI = "urn:aegis.cxf.apache.org:defaultEncoding";
+    private boolean writeXsiTypes;
+    private boolean readXsiTypes = true;
+    private String mappingNamespaceURI = DUMMY_ENCODING_STYLE_URI;
+
+    private TypeMappingRegistry typeMappingRegistry;
+    private Set<String> overrideTypes;
+    private Set<Class<?>> overrideClasses;
+    private Set<QName> overrideQNames;
+    // this type mapping is the front of the chain of delegating type mappings.
+    private TypeMapping typeMapping;
+    private Set<Type> additionalTypes;
+    private Map<Class<?>, String> beanImplementationMap;
+    private Configuration configuration;
+    
+    /**
+     * Construct a context.
+     */
+    public AegisContext() {
+        beanImplementationMap = new HashMap<Class<?>, String>();
+        overrideClasses = new HashSet<Class<?>>();
+        overrideQNames = new HashSet<QName>();
+    }
+
+    /**
+     * Initialize the context. The encodingStyleURI allows .aegis.xml files to have multiple mappings 
+     * for, say, SOAP 1.1 versus SOAP 1.2. Passing null uses a default URI. 
+     * @param mappingNamespaceURI URI to select mappings based on the encoding.
+     */
+    public void initialize() {
+        if (typeMappingRegistry == null) {
+            typeMappingRegistry = new DefaultTypeMappingRegistry(true);
+        } 
+        if (configuration != null) {
+            typeMappingRegistry.setConfiguration(configuration);
+        }
+        // The use of the XSD URI in the mapping is, MAGIC.
+        typeMapping  = typeMappingRegistry.createTypeMapping(SOAPConstants.XSD, true);
+        typeMappingRegistry.register(mappingNamespaceURI, typeMapping);
+        processOverrideTypes();
+    }
+    
+    /**
+     * Retrieve the type mapping registry object.
+     * @return the registry.
+     */
+    public TypeMappingRegistry getTypeMappingRegistry() {
+        return typeMappingRegistry;
+    }
+
+    /**
+     * Set the type mapping registry. Call this after construction and before 'initialize'.
+     * @param typeMappingRegistry
+     */
+    public void setTypeMappingRegistry(TypeMappingRegistry typeMappingRegistry) {
+        this.typeMappingRegistry = typeMappingRegistry;
+    }
+    
+    /**
+     * If a class was provided as part of the 'override' list, retrieve it's Type by
+     * Class.
+     * @param clazz
+     * @return
+     */
+    public Type getOverrideType(Class clazz) {
+        if (overrideClasses.contains(clazz)) {
+            return typeMapping.getType(clazz);
+        } else {
+            return null;
+        }
+    }
+    
+    /**
+     * If a class was provided as part of the override list, retrieve it's Type by schema
+     * type QName.
+     * @param schemaTypeName
+     * @return
+     */
+    public Type getOverrideType(QName schemaTypeName) {
+        if (overrideQNames.contains(schemaTypeName)) {
+            return typeMapping.getType(schemaTypeName);
+        } else {
+            return null;
+        }
+    }
+    
+    /**
+     * Examine a list of override classes, and register all of them.
+     * @param tm      type manager for this binding
+     * @param classes list of class names
+     */
+    private void processOverrideTypes() {
+        additionalTypes = new HashSet<Type>();
+        overrideClasses = new HashSet<Class<?>>();
+        overrideQNames = new HashSet<QName>();
+        if (this.overrideTypes != null) {
+            for (String typeName : overrideTypes) {
+                Class c = null;
+                try {
+                    c = ClassLoaderUtils.loadClass(typeName, TypeUtil.class);
+                } catch (ClassNotFoundException e) {
+                    throw new DatabindingException("Could not find override type class: " + typeName, e);
+                }
+                
+                overrideClasses.add(c);
+                
+                Type t = typeMapping.getType(c);
+                if (t == null) {
+                    t = typeMapping.getTypeCreator().createType(c);
+                    typeMapping.register(t);
+                }
+                overrideQNames.add(t.getSchemaType());
+                if (t instanceof BeanType) {
+                    BeanType bt = (BeanType)t;
+                    bt.getTypeInfo().setExtension(true);
+                    additionalTypes.add(bt);
+                }
+            }
+        }
+    }
+
+    public Set<String> getOverrideTypes() {
+        return overrideTypes;
+    }
+    
+    public void setOverrideTypes(Set<String> typeNames) {
+        overrideTypes = typeNames;
+    }
+
+    /** 
+     * Return the type mapping configuration associated with this context.
+     * The configuration is retrieved from the type mapping registry.
+     * @return Returns the configuration.
+     */
+    public Configuration getConfiguration() {
+        if (typeMappingRegistry != null) {
+            return typeMappingRegistry.getConfiguration();
+        } else {
+            return configuration;
+        }
+            
+    }
+
+    /**
+     * Set the configuration for this databinding object.
+     * @param configuration The configuration to set.
+     */
+    public void setConfiguration(Configuration newConfiguration) {
+        this.configuration = newConfiguration;
+        if (typeMappingRegistry != null) {
+            typeMappingRegistry.setConfiguration(configuration);
+        }
+    }
+
+    public boolean isWriteXsiTypes() {
+        return writeXsiTypes;
+    }
+
+    public boolean isReadXsiTypes() {
+        return readXsiTypes;
+    }
+
+    public void setWriteXsiTypes(boolean flag) {
+        this.writeXsiTypes = flag;
+    }
+
+    public void setReadXsiTypes(boolean flag) {
+        this.readXsiTypes = flag;
+    }
+
+    public TypeMapping getTypeMapping() {
+        return typeMapping;
+    }
+
+    public void setTypeMapping(TypeMapping typeMapping) {
+        this.typeMapping = typeMapping;
+    }
+
+    public Set<Type> getAdditionalTypes() {
+        return additionalTypes;
+    }
+    
+    public Map<Class<?>, String> getBeanImplementationMap() {
+        return beanImplementationMap;
+    }
+
+    public void setBeanImplementationMap(Map<Class<?>, String> beanImplementationMap) {
+        this.beanImplementationMap = beanImplementationMap;
+    }
+
+    public void setMappingNamespaceURI(String uri) {
+        this.mappingNamespaceURI = uri;
+    }
+
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/Context.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/Context.java?rev=607352&r1=607351&r2=607352&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/Context.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/Context.java Fri Dec 28 14:52:46 2007
@@ -21,48 +21,32 @@
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.Set;
 
-import org.apache.cxf.aegis.databinding.AegisDatabinding;
 import org.apache.cxf.aegis.type.TypeMapping;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.Attachment;
 
 /**
- * Holds information about the message request and response.
+ * Holds information about the message request and response. Applications should not need to 
+ * work with this class.
  * 
  * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
  * @since Feb 13, 2004
  */
-public class Context implements Map<String, Object> {
-    private AegisDatabinding databinding;
-    private TypeMapping typeMapping;
+public class Context {
+    private AegisContext globalContext;
     private Collection<Attachment> attachments;
     private Fault fault;
-    private Map<String, Object> properties;
+    private boolean mtomEnabled;
+    private Map<Class<?>, Object> properties;
     
-    public Context(AegisDatabinding databinding) {
-       this(databinding, new HashMap<String, Object>());
-    }
-
-    public Context(AegisDatabinding databinding, boolean initializeProps) {
-        this.databinding = databinding;
-        if (initializeProps) {
-            properties = new HashMap<String, Object>();
-        }
-    }
-
-    public Context(AegisDatabinding databinding, Map<String, Object> properties) {
-        this.databinding = databinding;
-        this.properties = properties;
+    public Context(AegisContext aegisContext) {
+        this.globalContext = aegisContext;
+        this.properties = new HashMap<Class<?>, Object>();
     }
 
     public TypeMapping getTypeMapping() {
-        return typeMapping;
-    }
-
-    public void setTypeMapping(TypeMapping typeMapping) {
-        this.typeMapping = typeMapping;
+        return globalContext.getTypeMapping();
     }
 
     public Collection<Attachment> getAttachments() {
@@ -74,11 +58,11 @@
     }
 
     public boolean isWriteXsiTypes() {
-        return databinding.isWriteXsiTypes();
+        return globalContext.isWriteXsiTypes();
     }
 
     public boolean isReadXsiTypes() {
-        return databinding.isReadXsiTypes();
+        return globalContext.isReadXsiTypes();
     }
 
     public void setFault(Fault fault) {
@@ -89,60 +73,25 @@
         return fault;
     }
 
-    public void clear() {
-    }
-
-    public boolean containsKey(Object key) {
-        return false;
+    public AegisContext getGlobalContext() {
+        return globalContext;
     }
 
-    public boolean containsValue(Object value) {
-        return false;
+    public boolean isMtomEnabled() {
+        return mtomEnabled;
     }
 
-    public Set<java.util.Map.Entry<String, Object>> entrySet() {
-        return null;
+    public void setMtomEnabled(boolean isMtomEnabled) {
+        this.mtomEnabled = isMtomEnabled;
     }
-
-    public Object get(Object key) {
-        return properties.get(key);
-    }
-
-    public boolean isEmpty() {
-        return properties.isEmpty();
-    }
-
-    public Set<String> keySet() {
-        return properties.keySet();
-    }
-
-    public Object put(String key, Object value) {
-        return properties.put(key, value);
-    }
-
-    public void putAll(Map<? extends String, ? extends Object> t) {
-        properties.putAll(t);
-    }
-
-    public Object remove(Object key) {
-        return properties.remove(key);
-    }
-
-    public int size() {
-        return properties.size();
-    }
-
-    public Collection<Object> values() {
-        return properties.values();
+    
+    // bus-style properties for internal state management.
+    public <T> T getProperty(Class<T> key) {
+        return key.cast(properties.get(key));
     }
-
-    public void setDelegateProperties(Map<String, Object> p) {
-        this.properties = p;
+    
+    public void setProperty(Object value) {
+        properties.put(value.getClass(), value);
     }
 
-    public AegisDatabinding getDataBinding() {
-        return databinding;
-    }
-    
-    
 }

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java?rev=607352&r1=607351&r2=607352&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java Fri Dec 28 14:52:46 2007
@@ -19,11 +19,10 @@
 package org.apache.cxf.aegis.databinding;
 
 import java.lang.reflect.Method;
-import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -33,17 +32,13 @@
 
 import org.w3c.dom.Node;
 
+import org.apache.cxf.aegis.AegisContext;
 import org.apache.cxf.aegis.DatabindingException;
 import org.apache.cxf.aegis.type.AbstractTypeCreator.TypeClassInfo;
 import org.apache.cxf.aegis.type.Configuration;
-import org.apache.cxf.aegis.type.DefaultTypeMappingRegistry;
 import org.apache.cxf.aegis.type.Type;
 import org.apache.cxf.aegis.type.TypeCreator;
 import org.apache.cxf.aegis.type.TypeMapping;
-import org.apache.cxf.aegis.type.TypeMappingRegistry;
-import org.apache.cxf.aegis.type.TypeUtil;
-import org.apache.cxf.aegis.type.basic.BeanType;
-import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.util.SOAPConstants;
 import org.apache.cxf.common.xmlschema.SchemaCollection;
 import org.apache.cxf.databinding.DataBinding;
@@ -71,62 +66,49 @@
 import org.jdom.output.DOMOutputter;
 
 /**
- * Handles DataBinding functions for Aegis.
- * <p>
- * NOTE: There is an assumed 1:1 mapping between an AegisDatabinding and a Service;
- * the code in here gets and puts properties on the service. This looks as if it's leftover
- * from some idea of sharing a databinding amongst services, which I (bimargulies) didn't
- * think was especially valid. Why not just keep these items right here in the data binding?
- * 
+ * CXF databinding object for Aegis. 
  */
 public class AegisDatabinding extends AbstractDataBinding implements DataBinding {
     
-    public static final String WRITE_XSI_TYPE_KEY = "org.apache.cxf.databinding.aegis.writeXsiType";
-    public static final String READ_XSI_TYPE_KEY = "org.apache.cxf.databinding.aegis.readXsiType";
-    public static final String OVERRIDE_TYPES_KEY = "org.apache.cxf.databinding.aegis.overrideTypesList";
-
     protected static final int IN_PARAM = 0;
     protected static final int OUT_PARAM = 1;
     protected static final int FAULT_PARAM = 2;
-    
-    static final String OLD_WRITE_XSI_TYPE_KEY = "writeXsiType";
-    static final String OLD_OVERRIDE_TYPES_KEY = "overrideTypesList";
-    static final String OLD_READ_XSI_TYPE_KEY = "readXsiType";
-    private boolean writeXsiTypes;
-    private boolean readXsiTypes = true;
 
-    private TypeMappingRegistry typeMappingRegistry;
+    private AegisContext aegisContext;
     private Map<MessagePartInfo, Type> part2Type;
-    private Set<String> overrideTypes;
-    private Set<Class<?>> overrideClasses;
-    private Set<QName> overrideQNames;
     private Service service;
-    // There's a split personality in here. Much of the code of Aegis assumes that 
-    // types get registered based an 'encoding style' URL, presumably either Soap 1.1 or 1.2.
-    // However, the override types, and apparently some others, end up registered against
-    // an extra type mapping object created for the service's namespace. This is odd insofar
-    // as the XML mapping for for the service could have a mapping uri in it.
-    // Until this is better understood, we keep this extra one around.
-    private TypeMapping serviceTypeMapping;
     private boolean isInitialized;
-    
+    private Set<String> overrideTypes;
+    private Configuration configuration;
+
     public AegisDatabinding() {
         super();
-        this.typeMappingRegistry = new DefaultTypeMappingRegistry(true);
         part2Type = new HashMap<MessagePartInfo, Type>();
     }
     
-    public static boolean isOverrideTypesKey(String key) {
-        return OVERRIDE_TYPES_KEY.equals(key)
-            || OLD_OVERRIDE_TYPES_KEY.equals(key);
-    }
-    
+    /**
+     * The Databinding API has initialize(Service). However, this object should be usable even if that
+     * API is never called.
+     */
     private void ensureInitialized() {
         if (!isInitialized) {
-            initializeWithoutService();
+            if (aegisContext == null) {
+                aegisContext = new AegisContext();
+                if (overrideTypes != null) {
+                    aegisContext.setOverrideTypes(overrideTypes);
+                }
+                if (configuration != null) {
+                    aegisContext.setConfiguration(configuration);
+                }
+                aegisContext.initialize();
+            }
+            isInitialized = true;
         }
     }
-
+    
+    /**
+     * {@inheritDoc}
+     */
     @SuppressWarnings("unchecked")
     public <T> DataReader<T> createReader(Class<T> cls) {
         ensureInitialized();
@@ -139,6 +121,9 @@
         }
     }
 
+    /**
+     * {@inheritDoc}
+     */
     @SuppressWarnings("unchecked")
     public <T> DataWriter<T> createWriter(Class<T> cls) {
         ensureInitialized();
@@ -151,97 +136,52 @@
         }
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public Class<?>[] getSupportedReaderFormats() {
         return new Class[] {XMLStreamReader.class, Node.class};
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public Class<?>[] getSupportedWriterFormats() {
         return new Class[] {XMLStreamWriter.class, Node.class};
     }
 
-    public TypeMappingRegistry getTypeMappingRegistry() {
-        return typeMappingRegistry;
-    }
-
-    public void setTypeMappingRegistry(TypeMappingRegistry typeMappingRegistry) {
-        this.typeMappingRegistry = typeMappingRegistry;
-    }
-    
-    /**
-     * This is the central point of override processing on the write side.
-     * @param clazz
-     * @return
-     */
-    public Type getOverrideType(Class clazz) {
-        ensureInitialized();
-        if (overrideClasses.contains(clazz)) {
-            return serviceTypeMapping.getType(clazz);
-        } else {
-            return null;
-        }
-    }
-    
     /**
-     * This is the central point of override processing on the read side.
-     * @param schemaTypeName
-     * @return
+     * {@inheritDoc}
      */
-    public Type getOverrideType(QName schemaTypeName) {
-        ensureInitialized();
-        if (overrideQNames.contains(schemaTypeName)) {
-            return serviceTypeMapping.getType(schemaTypeName);
-        } else {
-            return null;
-        }
-    }
-    
-    private void initializeWithoutService() {
-        isInitialized = true;
-        serviceTypeMapping  = typeMappingRegistry.createTypeMapping(SOAPConstants.XSD, true);
-        typeMappingRegistry.register("urn:dummyService", serviceTypeMapping);
-        processOverrideTypes();
-    }
-
     public void initialize(Service s) {
-        isInitialized = true;
-        this.service = s;
-        
-        QName serviceName = s.getServiceInfos().get(0).getName();
-        serviceTypeMapping = typeMappingRegistry.createTypeMapping(SOAPConstants.XSD, true);
-        typeMappingRegistry.register(serviceName.getNamespaceURI(), serviceTypeMapping);
-        
-        Object val = s.get(AegisDatabinding.READ_XSI_TYPE_KEY);
         
-        if (val == null) {
-            val = s.get(AegisDatabinding.OLD_READ_XSI_TYPE_KEY);
-        }
-        if ("false".equals(val) || Boolean.FALSE.equals(val)) {
-            readXsiTypes = false;
+        if (aegisContext == null) {
+            aegisContext = new AegisContext();
+            if (overrideTypes != null) {
+                aegisContext.setOverrideTypes(overrideTypes);
+            }
+            if (configuration != null) {
+                aegisContext.setConfiguration(configuration);
+            }
         }
-
-        val = s.get(AegisDatabinding.WRITE_XSI_TYPE_KEY);
+        aegisContext.setMappingNamespaceURI(s.getServiceInfos().get(0).getName().getNamespaceURI());
+        aegisContext.initialize();
+        this.service = s;
         
-        if (val == null) {
-            val = s.get(AegisDatabinding.OLD_WRITE_XSI_TYPE_KEY);
-        }
-        if ("true".equals(val) || Boolean.TRUE.equals(val)) {
-            writeXsiTypes = true;
-        }
-
-
         Set<Type> deps = new HashSet<Type>();
 
         for (ServiceInfo info : s.getServiceInfos()) {
             for (OperationInfo opInfo : info.getInterface().getOperations()) {
                 if (opInfo.isUnwrappedCapable()) {
-                    initializeOperation(s, serviceTypeMapping, opInfo.getUnwrappedOperation(), deps);
+                    initializeOperation(s, aegisContext.getTypeMapping(), 
+                                        opInfo.getUnwrappedOperation(), deps);
                 } else {
-                    initializeOperation(s, serviceTypeMapping, opInfo, deps);
+                    initializeOperation(s, aegisContext.getTypeMapping(), opInfo, deps);
                 }
             }
         }
 
-        List<Type> additional = getAdditionalTypes(s);
+        Collection<Type> additional = aegisContext.getAdditionalTypes();
 
         if (additional != null) {
             for (Type t : additional) {
@@ -263,64 +203,6 @@
         }
     }
 
-    private List<Type> getAdditionalTypes(Service s) {
-        List classes = (List)s.get(OVERRIDE_TYPES_KEY);
-        if (classes == null) {
-            classes = (List)s.get(OLD_OVERRIDE_TYPES_KEY);
-        } 
-        if (classes != null) {
-            if (this.overrideTypes == null) {
-                this.overrideTypes = new HashSet<String>();
-            }
-            
-            for (Object classNameObject : classes) {
-                String className = (String) classNameObject;
-                this.overrideTypes.add(className);
-            }
-        }
-
-        return processOverrideTypes();
-    }
-
-    /**
-     * Examine a list of override classes, and register all of them.
-     * @param tm      type manager for this binding
-     * @param classes list of class names
-     * @return        list of Types.
-     */
-    private List<Type> processOverrideTypes() {
-        overrideClasses = new HashSet<Class<?>>();
-        overrideQNames = new HashSet<QName>();
-        if (this.overrideTypes != null) {
-            List<Type> types = new ArrayList<Type>();
-            for (String typeName : overrideTypes) {
-                Class c = null;
-                try {
-                    c = ClassLoaderUtils.loadClass(typeName, TypeUtil.class);
-                } catch (ClassNotFoundException e) {
-                    throw new DatabindingException("Could not find override type class: " + typeName, e);
-                }
-                
-                overrideClasses.add(c);
-                
-                Type t = serviceTypeMapping.getType(c);
-                if (t == null) {
-                    t = serviceTypeMapping.getTypeCreator().createType(c);
-                    serviceTypeMapping.register(t);
-                }
-                overrideQNames.add(t.getSchemaType());
-                if (t instanceof BeanType) {
-                    BeanType bt = (BeanType)t;
-                    bt.getTypeInfo().setExtension(true);
-                    types.add(bt);
-                }
-            }
-            return types;
-        } else {
-            return null;
-        }
-    }
-
     private void initializeOperation(Service s, TypeMapping serviceTM, OperationInfo opInfo,
                                      Set<Type> deps) {
         try {
@@ -584,52 +466,24 @@
         return part2Type.get(part);
     }
 
-    public Set<String> getOverrideTypes() {
-        return overrideTypes;
-    }
-    
-    public void setOverrideTypes(Set<String> typeNames) {
-        overrideTypes = typeNames;
-    }
-
     public Service getService() {
         return service;
     }
 
-    /** 
-     * Return the type mapping configuration associated with this databinding object.
-     * The configuration is retrieved from the type mapping registry.
-     * @return Returns the configuration.
-     */
-    public Configuration getConfiguration() {
-        return typeMappingRegistry.getConfiguration();
-    }
-
-    /**
-     * Set the configuration for this databinding object.
-     * @param configuration The configuration to set.
-     */
-    public void setConfiguration(Configuration configuration) {
-        typeMappingRegistry.setConfiguration(configuration);
-    }
-
-    public boolean isWriteXsiTypes() {
-        return writeXsiTypes;
-    }
-
-    public boolean isReadXsiTypes() {
-        return readXsiTypes;
+    public AegisContext getAegisContext() {
+        ensureInitialized();
+        return aegisContext;
     }
 
-    public void setWriteXsiTypes(boolean flag) {
-        this.writeXsiTypes = flag;
+    public void setAegisContext(AegisContext aegisContext) {
+        this.aegisContext = aegisContext;
     }
 
-    public void setReadXsiTypes(boolean flag) {
-        this.readXsiTypes = flag;
+    public void setOverrideTypes(Set<String> types) {
+        overrideTypes = types;
     }
-
-    public TypeMapping getServiceTypeMapping() {
-        return serviceTypeMapping;
+    
+    public void setConfiguration(Configuration configuration) {
+        this.configuration = configuration;
     }
 }

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/ElementDataWriter.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/ElementDataWriter.java?rev=607352&r1=607351&r2=607352&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/ElementDataWriter.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/ElementDataWriter.java Fri Dec 28 14:52:46 2007
@@ -37,7 +37,6 @@
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.databinding.DataWriter;
-import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.Attachment;
 import org.apache.cxf.service.model.MessagePartInfo;
@@ -72,16 +71,10 @@
         }
 
 
-        Map<String, Object> props = (Endpoint)getProperty(ENDPOINT);
-        if (props == null) {
-            props = new HashMap<String, Object>();
-        }
-        Context context = new Context(databinding, props);
+        Context context = new Context(databinding.getAegisContext());
 
-        // I'm not sure that this is the right type mapping
-        context.setTypeMapping(type.getTypeMapping());
         context.setAttachments(attachments);
-        type = TypeUtil.getWriteType(databinding, obj, type);
+        type = TypeUtil.getWriteType(databinding.getAegisContext(), obj, type);
         try {
             W3CDOMStreamWriter domWriter = new W3CDOMStreamWriter(output);
             ElementWriter writer = new ElementWriter(domWriter);

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/Messages.properties?rev=607352&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/Messages.properties (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/Messages.properties Fri Dec 28 14:52:46 2007
@@ -0,0 +1,23 @@
+#
+#
+#    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.
+#
+#
+STREAM_BAD_POSITION= The input stream is not positioned at START_DOCUMENT or START_ELEMENT.
+STREAM_READ_ERROR= Error reading XML input stream.
+

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/Messages.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/Messages.properties
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/Messages.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataReader.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataReader.java?rev=607352&r1=607351&r2=607352&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataReader.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataReader.java Fri Dec 28 14:52:46 2007
@@ -19,8 +19,6 @@
 package org.apache.cxf.aegis.databinding;
 
 import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
 import java.util.logging.Logger;
 
 import javax.xml.namespace.QName;
@@ -36,8 +34,8 @@
 import org.apache.cxf.aegis.xml.stax.ElementReader;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.SOAPConstants;
 import org.apache.cxf.databinding.DataReader;
-import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.Attachment;
 import org.apache.cxf.service.model.MessagePartInfo;
@@ -50,32 +48,21 @@
 
     private Context context;
 
-    private Map<String, Object> properties;
-    
     public XMLStreamDataReader(AegisDatabinding databinding) {
         this.databinding = databinding;
-        // optimize by avoiding the properties until we need them.
-        this.context = new Context(databinding, false);
+        this.context = new Context(databinding.getAegisContext());
     }
 
     public Object read(MessagePartInfo part, XMLStreamReader input) {
+
         Type type = databinding.getType(part);
 
-        type = TypeUtil.getReadType(input, context, type);
+        type = TypeUtil.getReadType(input, databinding.getAegisContext(), type);
         
         if (type == null) {
             throw new Fault(new Message("NO_MESSAGE_FOR_PART", LOG));
         }
         
-        Map<String, Object> props = (Endpoint)getProperty(ENDPOINT);
-        if (props == null) {
-            props = new HashMap<String, Object>();
-        }
-        context.setDelegateProperties(props);
-        
-        context.setTypeMapping(null); // let it delegate to the databinding
-        context.setFault((Fault) getProperty(DataReader.FAULT));
-        
         ElementReader elReader = new ElementReader(input);
         if (elReader.isXsiNil()) {
             elReader.readToEnd();
@@ -89,33 +76,51 @@
         }
     }
 
-    public Object getProperty(String key) {
-        if (properties == null) {
-            return null;
-        }
-        return properties.get(key);
-    }
-
-    public Object read(QName name, XMLStreamReader input, Class type) {
-        return null;
-    }
-
-    public Object read(XMLStreamReader reader) {
-        Map<String, Object> props = new HashMap<String, Object>();
-        context.setDelegateProperties(props);
-        
-        context.setTypeMapping(null); // let it delegate to the databinding
-        context.setFault((Fault) getProperty(DataReader.FAULT));
-        // JAXB will take a start_document, so should we.
+    private void setupReaderPosition(XMLStreamReader reader) {
         if (reader.getEventType() == XMLStreamConstants.START_DOCUMENT) {
             while (XMLStreamConstants.START_ELEMENT != reader.getEventType()) {
                 try {
                     reader.nextTag();
                 } catch (XMLStreamException e) {
-                    throw new RuntimeException(e);
+                    Message message = new Message("STREAM_READ_ERROR", LOG);
+                    throw new DatabindingException(message.toString(), e);
                 }
             }
         }
+        if (reader.getEventType() != XMLStreamConstants.START_ELEMENT) {
+            Message message = new Message("STREAM_BAD_POSITION", LOG);
+            throw new DatabindingException(message.toString());
+            
+        }
+    }
+
+    public Object read(QName name, XMLStreamReader reader, Class typeClass) {
+        setupReaderPosition(reader);
+        ElementReader elReader = new ElementReader(reader);
+
+        if (elReader.isXsiNil()) {
+            elReader.readToEnd();
+            return null;
+        }
+        
+        
+        Type type = TypeUtil.getReadType(reader, context.getGlobalContext(), null);
+        
+        if (type == null) {
+            return null; // throw ?
+        }
+        
+
+        try {
+            return type.readObject(elReader, context);
+        } catch (DatabindingException e) {
+            throw new RuntimeException(e);
+        }
+
+    }
+
+    public Object read(XMLStreamReader reader) {
+        setupReaderPosition(reader);
         ElementReader elReader = new ElementReader(reader);
 
         if (elReader.isXsiNil()) {
@@ -124,7 +129,7 @@
         }
         
         
-        Type type = TypeUtil.getReadType(reader, context, null);
+        Type type = TypeUtil.getReadType(reader, context.getGlobalContext(), null);
         
         if (type == null) {
             return null; // throw ?
@@ -143,11 +148,15 @@
     }
 
     public void setProperty(String prop, Object value) {
-        if (properties == null) {
-            properties = new HashMap<String, Object>();
+        if (SOAPConstants.MTOM_ENABLED.equals(prop)) {
+            if (value instanceof String) {
+                context.setMtomEnabled(Boolean.valueOf((String)value));
+            } else if (value instanceof Boolean) {
+                context.setMtomEnabled((Boolean)value);
+            }
+        } else if (DataReader.FAULT.equals(prop)) { 
+            context.setFault((Fault)value);
         }
-        
-        properties.put(prop, value);
     }
 
     public void setSchema(Schema s) {

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataWriter.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataWriter.java?rev=607352&r1=607351&r2=607352&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataWriter.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataWriter.java Fri Dec 28 14:52:46 2007
@@ -35,7 +35,6 @@
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.databinding.DataWriter;
-import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.Attachment;
 import org.apache.cxf.service.model.MessagePartInfo;
@@ -68,17 +67,11 @@
         if (type == null) {
             throw new Fault(new Message("NO_MESSAGE_FOR_PART", LOG));
         }
-
-
-        Map<String, Object> props = (Endpoint)getProperty(ENDPOINT);
-        if (props == null) {
-            props = new HashMap<String, Object>();
-        }
-        Context context = new Context(databinding, props);
         
-        context.setTypeMapping(null);
+        Context context = new Context(databinding.getAegisContext());
+        
         context.setAttachments(attachments);
-        type = TypeUtil.getWriteType(databinding, obj, type);
+        type = TypeUtil.getWriteType(databinding.getAegisContext(), obj, type);
         
         try {
             if (obj == null) {

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMappingRegistry.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMappingRegistry.java?rev=607352&r1=607351&r2=607352&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMappingRegistry.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMappingRegistry.java Fri Dec 28 14:52:46 2007
@@ -152,12 +152,15 @@
         }
     }
 
-    public TypeMapping register(String encodingStyleURI, TypeMapping mapping) {
-        TypeMapping previous = registry.get(encodingStyleURI);
+    /**
+     * {@inheritDoc}
+     */
+    public TypeMapping register(String namespaceURI, TypeMapping mapping) {
+        TypeMapping previous = registry.get(namespaceURI);
 
-        mapping.setEncodingStyleURI(encodingStyleURI);
+        mapping.setEncodingStyleURI(namespaceURI);
 
-        registry.put(encodingStyleURI, mapping);
+        registry.put(namespaceURI, mapping);
 
         return previous;
     }

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeMappingRegistry.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeMappingRegistry.java?rev=607352&r1=607351&r2=607352&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeMappingRegistry.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeMappingRegistry.java Fri Dec 28 14:52:46 2007
@@ -25,13 +25,18 @@
  * @since Feb 18, 2004
  */
 public interface TypeMappingRegistry {
-    String ROLE = TypeMappingRegistry.class.getName();
-
     /**
+     * Register a type mapping.
+     * @param namespaceURI URI that identifies the mapping. For a mapping associated with a 
+     * service, it will be service's TNS. It is used as the URI for schema derived from the mapping.
+     * @param mapping the type mapping object.
+     * @return the previous mapping for this URI.
      */
-    TypeMapping register(String encodingStyleURI, TypeMapping mapping);
+    TypeMapping register(String namespaceURI, TypeMapping mapping);
 
     /**
+     * register this mapping as the default mapping.
+     * @param mapping
      */
     void registerDefault(TypeMapping mapping);
 
@@ -55,15 +60,15 @@
 
     /**
      * Returns the registered <code>TypeMapping</code> for the specified
-     * encodingStyle URI. If there is no registered <code>TypeMapping</code>
+     * namespace. If there is no registered <code>TypeMapping</code>
      * for the specified <code>encodingStyleURI</code>, this method returns
      * <code>null</code>.
      * 
-     * @param encodingStyleURI Encoding style specified as an URI
+     * @param namespaceURI the URI for the mapping.
      * @return TypeMapping for the specified encodingStyleURI or
      *         <code>null</code>
      */
-    TypeMapping getTypeMapping(String encodingStyleURI);
+    TypeMapping getTypeMapping(String namespaceURI);
 
     /**
      * Creates a new empty <code>TypeMapping</code> object.

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeUtil.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeUtil.java?rev=607352&r1=607351&r2=607352&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeUtil.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeUtil.java Fri Dec 28 14:52:46 2007
@@ -22,8 +22,7 @@
 import javax.xml.stream.XMLStreamReader;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.cxf.aegis.Context;
-import org.apache.cxf.aegis.databinding.AegisDatabinding;
+import org.apache.cxf.aegis.AegisContext;
 import org.apache.cxf.aegis.util.NamespaceHelper;
 import org.apache.cxf.common.util.SOAPConstants;
 
@@ -39,7 +38,7 @@
         //utility class
     }
     
-    public static Type getReadType(XMLStreamReader xsr, Context context, Type baseType) {
+    public static Type getReadType(XMLStreamReader xsr, AegisContext context, Type baseType) {
 
         if (!context.isReadXsiTypes()) {
             if (baseType == null) {
@@ -61,7 +60,7 @@
                     improvedType = tm.getType(overrideName);
                 }
                 if (improvedType == null) {
-                    improvedType = context.getDataBinding().getOverrideType(overrideName);
+                    improvedType = context.getOverrideType(overrideName);
                 }
                 if (improvedType != null) {
                     return improvedType;
@@ -87,9 +86,9 @@
         }
     }
 
-    public static Type getWriteType(AegisDatabinding databinding, Object value, Type type) {
+    public static Type getWriteType(AegisContext globalContext, Object value, Type type) {
         if (value != null && type != null && type.getTypeClass() != value.getClass()) {
-            Type overrideType = databinding.getOverrideType(value.getClass());
+            Type overrideType = globalContext.getOverrideType(value.getClass());
             if (overrideType != null) {
                 return overrideType;
             }

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ArrayType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ArrayType.java?rev=607352&r1=607351&r2=607352&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ArrayType.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ArrayType.java Fri Dec 28 14:52:46 2007
@@ -78,8 +78,8 @@
 
         while (reader.hasMoreElementReaders()) {
             MessageReader creader = reader.getNextElementReader();
-            Type compType = TypeUtil.getReadType(creader.getXMLStreamReader(), context,
-                                                             getComponentType());
+            Type compType = TypeUtil.getReadType(creader.getXMLStreamReader(), context.getGlobalContext(),
+                                                 getComponentType());
 
             if (creader.isXsiNil()) {
                 values.add(null);
@@ -241,7 +241,7 @@
 
     protected void writeValue(Object value, MessageWriter writer, Context context, Type type, String name,
                               String ns) throws DatabindingException {
-        type = TypeUtil.getWriteType(context.getDataBinding(), value, type);
+        type = TypeUtil.getWriteType(context.getGlobalContext(), value, type);
         MessageWriter cwriter;
         if (type.isWriteOuter()) {
             cwriter = writer.getElementWriter(name, ns);

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/Base64Type.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/Base64Type.java?rev=607352&r1=607351&r2=607352&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/Base64Type.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/Base64Type.java Fri Dec 28 14:52:46 2007
@@ -33,7 +33,6 @@
 import org.apache.cxf.aegis.xml.MessageWriter;
 import org.apache.cxf.common.util.Base64Exception;
 import org.apache.cxf.common.util.Base64Utility;
-import org.apache.cxf.common.util.SOAPConstants;
 
 /**
  * Converts back and forth to byte[] objects.
@@ -49,7 +48,7 @@
 
     @Override
     public Object readObject(MessageReader mreader, Context context) throws DatabindingException {
-        boolean mtomEnabled = Boolean.valueOf((String)context.get(SOAPConstants.MTOM_ENABLED)).booleanValue();
+        boolean mtomEnabled = context.isMtomEnabled();
         XMLStreamReader reader = mreader.getXMLStreamReader();
 
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
@@ -107,7 +106,7 @@
     public void writeObject(Object object,
                             MessageWriter writer,
                             Context context) throws DatabindingException {
-        boolean mtomEnabled = Boolean.valueOf((String)context.get(SOAPConstants.MTOM_ENABLED)).booleanValue();
+        boolean mtomEnabled = context.isMtomEnabled();
         if (mtomEnabled) {
             optimizedType.writeObject(object, writer, context);
             return;

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java?rev=607352&r1=607351&r2=607352&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java Fri Dec 28 14:52:46 2007
@@ -88,7 +88,7 @@
             Object target;
 
             if (isInterface) {
-                String impl = (String)context.get(clazz.getName() + ".implementation");
+                String impl = context.getGlobalContext().getBeanImplementationMap().get(clazz);
 
                 if (impl == null) {
                     InvocationHandler handler = new InterfaceInvocationHandler();
@@ -177,7 +177,7 @@
         Type type = beanTypeInfo.getType(name);
 
         // Type can be overriden with a xsi:type attribute
-        type = TypeUtil.getReadType(reader.getXMLStreamReader(), context, type);
+        type = TypeUtil.getReadType(reader.getXMLStreamReader(), context.getGlobalContext(), type);
         return type;
     }
 
@@ -322,7 +322,7 @@
             Object value = readProperty(object, name);
 
             Type defaultType = getType(inf, name);
-            Type type = TypeUtil.getWriteType(context.getDataBinding(), value, defaultType);
+            Type type = TypeUtil.getWriteType(context.getGlobalContext(), value, defaultType);
 
             // Write the value if it is not null.
             if (value != null) {

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/MapType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/MapType.java?rev=607352&r1=607351&r2=607352&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/MapType.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/MapType.java Fri Dec 28 14:52:46 2007
@@ -158,8 +158,8 @@
     private void writeEntry(MessageWriter writer, Context context,
                             Type kType, Type vType,
                             Map.Entry entry) throws DatabindingException {
-        kType = TypeUtil.getWriteType(context.getDataBinding(), entry.getKey(), kType);
-        vType = TypeUtil.getWriteType(context.getDataBinding(), entry.getValue(), vType);
+        kType = TypeUtil.getWriteType(context.getGlobalContext(), entry.getKey(), kType);
+        vType = TypeUtil.getWriteType(context.getGlobalContext(), entry.getValue(), vType);
 
         MessageWriter entryWriter = writer.getElementWriter(getEntryName());
 

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/MarshalRegistry.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/MarshalRegistry.java?rev=607352&r1=607351&r2=607352&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/MarshalRegistry.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/MarshalRegistry.java Fri Dec 28 14:52:46 2007
@@ -39,7 +39,7 @@
     private final Map<Object, String> instances = new IdentityHashMap<Object, String>();
 
     /**
-     * The objects not yet marshalled.  The is maintained as a map for debugging purpuses. It is IMPORTANT
+     * The objects not yet marshaled.  The is maintained as a map for debugging purposes. It is IMPORTANT
      * that this be a LinkedHashMap so we write the objects in the order they were discovered in the object
      * graphs (and writes them in numeric order).
      */
@@ -57,10 +57,10 @@
      * @return the SoapRefRegistry; never null
      */
     public static MarshalRegistry get(Context context) {
-        MarshalRegistry marshalRegistry = (MarshalRegistry) context.get(MarshalRegistry.class.getName());
+        MarshalRegistry marshalRegistry = context.getProperty(MarshalRegistry.class);
         if (marshalRegistry == null) {
             marshalRegistry = new MarshalRegistry();
-            context.put(MarshalRegistry.class.getName(), marshalRegistry);
+            context.setProperty(marshalRegistry);
         }
         return marshalRegistry;
     }

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapArrayType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapArrayType.java?rev=607352&r1=607351&r2=607352&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapArrayType.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapArrayType.java Fri Dec 28 14:52:46 2007
@@ -142,7 +142,8 @@
                 compType = arrayTypeInfo.getType();
             }
             // check for an xsi:type override
-            compType = TypeUtil.getReadType(creader.getXMLStreamReader(), context, compType);
+            compType = TypeUtil.getReadType(creader.getXMLStreamReader(), 
+                                            context.getGlobalContext(), compType);
 
             // wrap type with soap ref to handle hrefs
             compType = new SoapRefType(compType);
@@ -309,7 +310,7 @@
             Context context,
             Type type) throws DatabindingException {
 
-        type = TypeUtil.getWriteType(context.getDataBinding(), value, type);
+        type = TypeUtil.getWriteType(context.getGlobalContext(), value, type);
 
         MessageWriter cwriter = writer.getElementWriter(type.getSchemaType().getLocalPart(), "");
 

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapRefRegistry.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapRefRegistry.java?rev=607352&r1=607351&r2=607352&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapRefRegistry.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapRefRegistry.java Fri Dec 28 14:52:46 2007
@@ -40,7 +40,7 @@
  */
 public class SoapRefRegistry {
     /**
-     * The unmarshalled object instances by id.
+     * The unmarshaled object instances by id.
      */
     private final SortedMap<String, Object> instances = new TreeMap<String, Object>();
 
@@ -56,10 +56,10 @@
      * @return the SoapRefRegistry; never null
      */
     public static SoapRefRegistry get(Context context) {
-        SoapRefRegistry soapRefRegistry = (SoapRefRegistry) context.get(SoapRefRegistry.class.getName());
+        SoapRefRegistry soapRefRegistry = context.getProperty(SoapRefRegistry.class);
         if (soapRefRegistry == null) {
             soapRefRegistry = new SoapRefRegistry();
-            context.put(SoapRefRegistry.class.getName(), soapRefRegistry);
+            context.setProperty(soapRefRegistry);
         }
         return soapRefRegistry;
     }

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java?rev=607352&r1=607351&r2=607352&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java Fri Dec 28 14:52:46 2007
@@ -130,6 +130,17 @@
         return sf.create();
     }
     
+    protected Server createService(Class serviceClass, String address) {
+        ServerFactoryBean sf = createServiceFactory(serviceClass, null, address, null, null);
+        return sf.create();
+    }
+    
+    protected Server createService(Class serviceClass) {
+        ServerFactoryBean sf = createServiceFactory(serviceClass, null, 
+                                                    serviceClass.getSimpleName(), null, null);
+        return sf.create();
+    }
+    
     public Server createService(Class serviceClass,
                                 Object serviceBean, 
                                 String address,
@@ -137,6 +148,14 @@
         ServerFactoryBean sf = createServiceFactory(serviceClass, serviceBean, address, name, null);
         return sf.create();
     }
+    
+    public Server createService(Class serviceClass,
+                                Object serviceBean, 
+                                String address,
+                                AegisDatabinding binding) {
+        ServerFactoryBean sf = createServiceFactory(serviceClass, serviceBean, address, null, binding);
+        return sf.create();
+    }
 
     protected ServerFactoryBean createServiceFactory(Class serviceClass, 
                                                      Object serviceBean, 
@@ -200,5 +219,11 @@
         }
         WSDLWriter writer = WSDLFactory.newInstance().newWSDLWriter();
         return writer.getDocument(definition);
+    }
+    
+    protected Context getContext() {
+        AegisContext globalContext = new AegisContext();
+        globalContext.initialize();
+        return new Context(globalContext);
     }
 }

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/inheritance/ExceptionInheritanceTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/inheritance/ExceptionInheritanceTest.java?rev=607352&r1=607351&r2=607352&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/inheritance/ExceptionInheritanceTest.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/inheritance/ExceptionInheritanceTest.java Fri Dec 28 14:52:46 2007
@@ -18,14 +18,14 @@
  */
 package org.apache.cxf.aegis.inheritance;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
+import java.util.HashSet;
 import java.util.Map;
+import java.util.Set;
 
 import javax.xml.namespace.QName;
 
 import org.apache.cxf.aegis.AbstractAegisTest;
+import org.apache.cxf.aegis.AegisContext;
 import org.apache.cxf.aegis.databinding.AegisDatabinding;
 import org.apache.cxf.aegis.inheritance.ws1.WS1;
 import org.apache.cxf.aegis.inheritance.ws1.WS1ExtendedException;
@@ -44,18 +44,19 @@
     
     public void setUp() throws Exception {
         super.setUp();
+        
+        AegisContext globalContext = new AegisContext();
+        globalContext.setWriteXsiTypes(true);
 
-        props = new HashMap<String, Object>();
-        props.put(AegisDatabinding.WRITE_XSI_TYPE_KEY, "true");
-
-        List<String> l = new ArrayList<String>();
+        Set<String> l = new HashSet<String>();
         l.add(SimpleBean.class.getName());
         l.add(WS1ExtendedException.class.getName());
-
-        props.put(AegisDatabinding.OVERRIDE_TYPES_KEY, l);
+        globalContext.setOverrideTypes(l);
+        AegisDatabinding binding = new AegisDatabinding();
+        binding.setAegisContext(globalContext);
 
         ClientProxyFactoryBean pf = new ClientProxyFactoryBean();
-        setupAegis(pf.getClientFactoryBean());
+        setupAegis(pf.getClientFactoryBean(), binding);
         pf.setServiceClass(WS1.class);
         pf.getServiceFactory().setProperties(props);
         pf.setAddress("local://WS1");
@@ -63,7 +64,7 @@
         
         client = (WS1) pf.create();
 
-        Server server = createService(WS1.class, new WS1Impl(), "WS1", null);
+        Server server = createService(WS1.class, new WS1Impl(), "WS1", binding);
         new LoggingFeature().initialize(server, null);
         server.getEndpoint().getService().setInvoker(new BeanInvoker(new WS1Impl()));
     }

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/inheritance/InheritancePOJOTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/inheritance/InheritancePOJOTest.java?rev=607352&r1=607351&r2=607352&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/inheritance/InheritancePOJOTest.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/inheritance/InheritancePOJOTest.java Fri Dec 28 14:52:46 2007
@@ -18,10 +18,8 @@
  */
 package org.apache.cxf.aegis.inheritance;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.HashSet;
+import java.util.Set;
 
 import javax.xml.namespace.QName;
 
@@ -29,6 +27,7 @@
 import org.w3c.dom.Node;
 
 import org.apache.cxf.aegis.AbstractAegisTest;
+import org.apache.cxf.aegis.AegisContext;
 import org.apache.cxf.aegis.databinding.AegisDatabinding;
 import org.apache.cxf.common.util.SOAPConstants;
 import org.apache.cxf.frontend.ServerFactoryBean;
@@ -49,16 +48,16 @@
                                                     new QName("urn:xfire:inheritance",
                                                               "InheritanceService"),
                                                     null);
+        AegisContext globalContext = new AegisContext();
+        globalContext.setWriteXsiTypes(true);
 
-        Map<String, Object> props = new HashMap<String, Object>();
-        props.put(AegisDatabinding.WRITE_XSI_TYPE_KEY, "true");
-
-        List<String> l = new ArrayList<String>();
+        Set<String> l = new HashSet<String>();
         l.add(Employee.class.getName());
+        globalContext.setOverrideTypes(l);
+        AegisDatabinding binding = new AegisDatabinding();
+        binding.setAegisContext(globalContext);
 
-        props.put(AegisDatabinding.OVERRIDE_TYPES_KEY, l);
-
-        sf.getServiceFactory().setProperties(props);
+        sf.getServiceFactory().setDataBinding(binding);
         sf.create();
     }
 

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/inheritance/intf/InterfaceInheritanceTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/inheritance/intf/InterfaceInheritanceTest.java?rev=607352&r1=607351&r2=607352&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/inheritance/intf/InterfaceInheritanceTest.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/inheritance/intf/InterfaceInheritanceTest.java Fri Dec 28 14:52:46 2007
@@ -40,7 +40,7 @@
     @Before
     public void setUp() throws Exception {
         super.setUp();
-        Server server = createService(IInterfaceService.class, null);
+        Server server = createService(IInterfaceService.class);
         Service service = server.getEndpoint().getService();
         service.setInvoker(new BeanInvoker(new InterfaceService()));
     }

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/WrappedTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/WrappedTest.java?rev=607352&r1=607351&r2=607352&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/WrappedTest.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/WrappedTest.java Fri Dec 28 14:52:46 2007
@@ -40,7 +40,7 @@
     public void setUp() throws Exception {
         super.setUp();
         arrayService = new ArrayService();
-        createService(BeanService.class, null, "BeanService", null);
+        createService(BeanService.class, "BeanService");
         createService(ArrayService.class, arrayService, "Array", new QName("urn:Array", "Array"));
     }
 

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/NamespaceConfusionTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/NamespaceConfusionTest.java?rev=607352&r1=607351&r2=607352&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/NamespaceConfusionTest.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/NamespaceConfusionTest.java Fri Dec 28 14:52:46 2007
@@ -58,10 +58,10 @@
     public void setUp() throws Exception {
         super.setUp();
         
-        Server s = createService(NameServiceImpl.class, null);
+        Server s = createService(NameServiceImpl.class);
         service = s.getEndpoint().getService();
         databinding = (AegisDatabinding)service.getDataBinding();
-        tm = databinding.getServiceTypeMapping();
+        tm = databinding.getAegisContext().getTypeMapping();
     }
     
     private String getNamespaceForPrefix(Element rootElement, 

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/proxy/ProxyTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/proxy/ProxyTest.java?rev=607352&r1=607351&r2=607352&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/proxy/ProxyTest.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/proxy/ProxyTest.java Fri Dec 28 14:52:46 2007
@@ -18,10 +18,9 @@
  */
 package org.apache.cxf.aegis.proxy;
 
-import java.util.HashMap;
-import java.util.Map;
-
 import org.apache.cxf.aegis.AbstractAegisTest;
+import org.apache.cxf.aegis.AegisContext;
+import org.apache.cxf.aegis.databinding.AegisDatabinding;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.frontend.ClientProxyFactoryBean;
 import org.apache.cxf.service.invoker.BeanInvoker;
@@ -43,11 +42,12 @@
         proxyFac.setAddress("local://HelloProxyService");
         proxyFac.setServiceClass(HelloProxyService.class);
         proxyFac.setBus(getBus());
-        setupAegis(proxyFac.getClientFactoryBean());
-        Map<String, Object> props = new HashMap<String, Object>();
-        props.put(Hello.class.getName() + ".implementation", MyHello.class.getName());
-        proxyFac.setProperties(props);
+        AegisContext aegisContext = new AegisContext();
+        aegisContext.getBeanImplementationMap().put(Hello.class, MyHello.class.getName());
+        AegisDatabinding binding = new AegisDatabinding();
+        binding.setAegisContext(aegisContext);
         
+        setupAegis(proxyFac.getClientFactoryBean(), binding);
         HelloProxyService client = (HelloProxyService)proxyFac.create();
         
         Hello h = client.sayHiWithProxy();

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/base64/BinaryDataTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/base64/BinaryDataTest.java?rev=607352&r1=607351&r2=607352&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/base64/BinaryDataTest.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/base64/BinaryDataTest.java Fri Dec 28 14:52:46 2007
@@ -26,7 +26,7 @@
 public class BinaryDataTest extends AbstractAegisTest {
     @Test
     public void testBinary() throws Exception {
-        createService(BinaryDataService.class, null);
+        createService(BinaryDataService.class);
 
         runTests();
     }    

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayTest.java?rev=607352&r1=607351&r2=607352&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayTest.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayTest.java Fri Dec 28 14:52:46 2007
@@ -19,15 +19,11 @@
 
 package org.apache.cxf.aegis.type.array;
 
-import java.util.HashMap;
-import java.util.Map;
-
 import org.w3c.dom.Document;
 
 import org.apache.cxf.aegis.AbstractAegisTest;
 import org.apache.cxf.aegis.databinding.AegisDatabinding;
 import org.apache.cxf.aegis.type.Configuration;
-import org.apache.cxf.aegis.type.DefaultTypeMappingRegistry;
 import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
 import org.junit.Test;
 
@@ -40,21 +36,14 @@
         JaxWsServerFactoryBean serviceFactory = new JaxWsServerFactoryBean();
         serviceFactory.getServiceFactory().setDataBinding(binder);
 
-        DefaultTypeMappingRegistry tmr = (DefaultTypeMappingRegistry)binder.getTypeMappingRegistry();
-        Configuration configuration = tmr.getConfiguration();
+        Configuration configuration = binder.getAegisContext().getConfiguration();
         configuration.setDefaultMinOccurs(1);
         configuration.setDefaultNillable(false);
 
-        // Create a properties hashmap
-        Map<String, Object> props = new HashMap<String, Object>();
-
-        // Enable the writing of xsi:type attributes
-        props.put(AegisDatabinding.WRITE_XSI_TYPE_KEY, Boolean.TRUE);
-
+        binder.getAegisContext().setWriteXsiTypes(true);
         serviceFactory.setAddress("local://DuplicateArrayService");
         serviceFactory.setServiceBean(new DuplicateArrayServiceBean());
         serviceFactory.setServiceClass(DuplicateArrayService.class);
-        serviceFactory.setProperties(props);
         Document doc = this.getWSDLDocument(serviceFactory.create());
         this.assertValid("//wsdl:definitions/wsdl:types"
                          + "/xsd:schema[@targetNamespace='http://cxf.apache.org/arrays']"

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java?rev=607352&r1=607351&r2=607352&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java Fri Dec 28 14:52:46 2007
@@ -27,7 +27,6 @@
 
 import org.apache.cxf.aegis.AbstractAegisTest;
 import org.apache.cxf.aegis.Context;
-import org.apache.cxf.aegis.databinding.AegisDatabinding;
 import org.apache.cxf.aegis.services.SimpleBean;
 import org.apache.cxf.aegis.type.Configuration;
 import org.apache.cxf.aegis.type.DefaultTypeMappingRegistry;
@@ -47,15 +46,10 @@
 public class BeanTest extends AbstractAegisTest {
     TypeMapping mapping;
     private DefaultTypeMappingRegistry reg;
-    private AegisDatabinding databinding;
-    private Context getContext() {
-        return new Context(databinding);
-    }
 
     public void setUp() throws Exception {
         super.setUp();
-        databinding = new AegisDatabinding();
-
+    
         addNamespace("b", "urn:Bean");
         addNamespace("a", "urn:anotherns");
         addNamespace("xsi", SOAPConstants.XSI_NS);
@@ -125,9 +119,8 @@
 
         // Test reading
         ElementReader reader = new ElementReader(getResourceAsStream("bean9.xml"));
-
-        databinding.setReadXsiTypes(false);
         Context ctx = getContext();
+        ctx.getGlobalContext().setReadXsiTypes(false);
 
         SimpleBean bean = (SimpleBean)type.readObject(reader, ctx);
         assertEquals("bleh", bean.getBleh());

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/ByteDataTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/ByteDataTest.java?rev=607352&r1=607351&r2=607352&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/ByteDataTest.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/ByteDataTest.java Fri Dec 28 14:52:46 2007
@@ -33,7 +33,7 @@
 public class ByteDataTest extends AbstractAegisTest {
     public void setUp() throws Exception {
         super.setUp();
-        createService(DataService.class, null);
+        createService(DataService.class);
     }
 
     @Test

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/DynamicProxyTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/DynamicProxyTest.java?rev=607352&r1=607351&r2=607352&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/DynamicProxyTest.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/DynamicProxyTest.java Fri Dec 28 14:52:46 2007
@@ -21,8 +21,6 @@
 import javax.xml.namespace.QName;
 
 import org.apache.cxf.aegis.AbstractAegisTest;
-import org.apache.cxf.aegis.Context;
-import org.apache.cxf.aegis.databinding.AegisDatabinding;
 import org.apache.cxf.aegis.type.DefaultTypeMappingRegistry;
 import org.apache.cxf.aegis.type.TypeMapping;
 import org.apache.cxf.aegis.type.TypeMappingRegistry;
@@ -31,21 +29,14 @@
 
 public class DynamicProxyTest extends AbstractAegisTest {
     TypeMapping mapping;
-    AegisDatabinding databinding;
 
     public void setUp() throws Exception {
         super.setUp();
 
         TypeMappingRegistry reg = new DefaultTypeMappingRegistry(true);
         mapping = reg.createTypeMapping(true);
-        databinding = new AegisDatabinding();
     }
     
-    private Context getContext() {
-        return new Context(databinding);
-    }
-
-
     @Test
     public void testDynamicProxy() throws Exception {
         BeanType type = new BeanType();

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/AbstractEncodedTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/AbstractEncodedTest.java?rev=607352&r1=607351&r2=607352&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/AbstractEncodedTest.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/AbstractEncodedTest.java Fri Dec 28 14:52:46 2007
@@ -24,9 +24,9 @@
 import javax.xml.stream.XMLStreamException;
 
 import org.apache.cxf.aegis.AbstractAegisTest;
+import org.apache.cxf.aegis.AegisContext;
 import org.apache.cxf.aegis.Context;
 import org.apache.cxf.aegis.DatabindingException;
-import org.apache.cxf.aegis.databinding.AegisDatabinding;
 import org.apache.cxf.aegis.type.DefaultTypeMappingRegistry;
 import org.apache.cxf.aegis.type.Type;
 import org.apache.cxf.aegis.type.TypeMapping;
@@ -64,15 +64,15 @@
     }
     
     protected Context getContext() {
-        AegisDatabinding databinding = new AegisDatabinding();
-        databinding.setWriteXsiTypes(true);
-        return new Context(databinding);
+        AegisContext globalContext = new AegisContext();
+        globalContext.initialize();
+        globalContext.setTypeMapping(mapping);
+        return new Context(globalContext);
     }
 
     public <T> T readWriteReadRef(String file, Class<T> typeClass) throws XMLStreamException {
         Context context = getContext();
-        context.setTypeMapping(mapping);
-
+        
         Type type = mapping.getType(typeClass);
         assertNotNull("no type found for " + typeClass.getName());
 
@@ -104,7 +104,6 @@
 
     public Object readRef(ElementReader root) throws XMLStreamException {
         Context context = getContext();
-        context.setTypeMapping(mapping);
 
         // get Type based on the element qname
         MessageReader reader = root.getNextElementReader();
@@ -139,7 +138,6 @@
         new Document(element);
         JDOMWriter rootWriter = new JDOMWriter(element);
         Context context = getContext();
-        context.setTypeMapping(mapping);
 
         // get Type based on the object instance
         assertNotNull("type is null", type);
@@ -165,7 +163,6 @@
         assertNotNull("type is null", type);
 
         Context context = getContext();
-        context.setTypeMapping(mapping);
 
         ElementReader reader = new ElementReader(getClass().getResourceAsStream(resourceName));
         try {

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/SoapArrayTypeTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/SoapArrayTypeTest.java?rev=607352&r1=607351&r2=607352&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/SoapArrayTypeTest.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/SoapArrayTypeTest.java Fri Dec 28 14:52:46 2007
@@ -93,7 +93,6 @@
     @Test
     public void testSimpleArray() throws Exception {
         Context context = getContext();
-        context.setTypeMapping(mapping);
 
         // xsd:int[2]
         ElementReader reader = new ElementReader(getClass().getResourceAsStream("arraySimple.xml"));
@@ -109,7 +108,6 @@
     @Test
     public void testUrTypeArray() throws Exception {
         Context context = getContext();
-        context.setTypeMapping(mapping);
 
         // ur-type[4] nested elements have xsi:type
         ElementReader reader = new ElementReader(getClass().getResourceAsStream("arrayUrType1.xml"));
@@ -133,7 +131,6 @@
     @Test
     public void testAnyTypeArray() throws Exception {
         Context context = getContext();
-        context.setTypeMapping(mapping);
 
         // ur-type[4] nested elements have xsi:type
         ElementReader reader = new ElementReader(getClass().getResourceAsStream("arrayAnyType1.xml"));
@@ -157,7 +154,6 @@
     @Test
     public void testStructArray() throws Exception {
         Context context = getContext();
-        context.setTypeMapping(mapping);
 
         // b:address[2]
         ElementReader reader = new ElementReader(getClass().getResourceAsStream("arrayStructs.xml"));
@@ -175,7 +171,6 @@
     @Test
     public void testSquareArray() throws Exception {
         Context context = getContext();
-        context.setTypeMapping(mapping);
 
         // xsd:string[2,3,4]
         ElementReader reader = new ElementReader(getClass().getResourceAsStream("arraySquare.xml"));
@@ -191,7 +186,6 @@
     @Test
     public void testArrayOfArrays() throws Exception {
         Context context = getContext();
-        context.setTypeMapping(mapping);
 
         // xsd:string[,][2]
         ElementReader reader = new ElementReader(getClass().getResourceAsStream("arrayArrayOfArrays1.xml"));
@@ -207,7 +201,6 @@
     @Test
     public void testPartiallyTransmitted() throws Exception {
         Context context = getContext();
-        context.setTypeMapping(mapping);
 
         // xsd:int[5] offset="[2]"
         ElementReader reader = new ElementReader(
@@ -224,7 +217,6 @@
     @Test
     public void testSparseArray() throws Exception {
         Context context = getContext();
-        context.setTypeMapping(mapping);
 
         // xsd:string[2,3,4]
         ElementReader reader = new ElementReader(getClass().getResourceAsStream("arraySparse1.xml"));