You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@etch.apache.org by sc...@apache.org on 2009/02/22 06:25:48 UTC

svn commit: r746638 [3/5] - in /incubator/etch/branches/router/services: ./ router/ router/src/ router/src/main/ router/src/main/etch/ router/src/main/java/ router/src/main/java/cisco/ router/src/main/java/cisco/uc/ router/src/main/java/cisco/uc/cuae/ ...

Added: incubator/etch/branches/router/services/router/src/main/java/cisco/uc/cuae/etchrouter/utils/XmlBindingData.java
URL: http://svn.apache.org/viewvc/incubator/etch/branches/router/services/router/src/main/java/cisco/uc/cuae/etchrouter/utils/XmlBindingData.java?rev=746638&view=auto
==============================================================================
--- incubator/etch/branches/router/services/router/src/main/java/cisco/uc/cuae/etchrouter/utils/XmlBindingData.java (added)
+++ incubator/etch/branches/router/services/router/src/main/java/cisco/uc/cuae/etchrouter/utils/XmlBindingData.java Sun Feb 22 05:25:46 2009
@@ -0,0 +1,179 @@
+/* $Id$
+ *
+ * Copyright 2009-2010 Cisco Systems Inc.
+ *
+ * Licensed 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 cisco.uc.cuae.etchrouter.utils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+
+import cisco.uc.cuae.etchrouter.xml.Exception;
+import cisco.uc.cuae.etchrouter.xml.Module;
+
+/**
+ * Utility class to parse an Etch-compiled XML binding file and return
+ * the parsed result in a data object
+ * 
+ * @author Wei Wang (weiwa@cisco.com)
+ *
+ */
+public class XmlBindingData
+{
+	private static JAXBContext _jaxbContext = null;
+
+	/**
+	 * Factory method to get the parsed result object from an etch XML binding file
+	 * 
+	 * @param xmlFile
+	 * @return
+	 * @throws JAXBException
+	 * @throws IOException
+	 */
+	public static XmlBindingData loadXmlBindingFile(File xmlFile) throws JAXBException, IOException 
+	{
+		if (_jaxbContext==null)
+			_jaxbContext = JAXBContext.newInstance( "cisco.uc.cuae.etchrouter.xml" );
+        Unmarshaller u = _jaxbContext.createUnmarshaller();
+        Module mod = (Module)(u.unmarshal( new FileInputStream( xmlFile ) ));
+        return new XmlBindingData(mod);
+	}
+	
+	private List<Module.Service.Enums.Enum> _enums;
+    protected List<Module.Service.Structs.Struct> _structs;
+    protected List<cisco.uc.cuae.etchrouter.xml.Exception> _exceptions;
+    protected List<Module.Service.Methods.Method> _methods;
+    protected List<Module.Service.Externs.Extern> _externs;
+    
+    /**
+     * Getter
+     * 
+     * @return
+     */
+	public List<Module.Service.Enums.Enum> getEnums()
+	{
+		return _enums;
+	}
+
+	/**
+	 * getter
+	 * 
+	 * @return
+	 */
+	public List<Module.Service.Structs.Struct> getStructs()
+	{
+		return _structs;
+	}
+
+	/**
+	 * getter
+	 * 
+	 * @return
+	 */
+	public List<cisco.uc.cuae.etchrouter.xml.Exception> getExceptions()
+	{
+		return _exceptions;
+	}
+
+	/**
+	 * getter
+	 * 
+	 * @return
+	 */
+	public List<Module.Service.Methods.Method> getMethods()
+	{
+		return _methods;
+	}
+	
+	public List<Module.Service.Externs.Extern> getExterns()
+	{
+		return _externs;
+	}
+
+	private XmlBindingData(Module mod)
+	{
+		_enums = new ArrayList<Module.Service.Enums.Enum>();
+		_structs = new ArrayList<Module.Service.Structs.Struct>();
+		_exceptions = new ArrayList<cisco.uc.cuae.etchrouter.xml.Exception>();
+		_methods = new ArrayList<Module.Service.Methods.Method>();
+		_externs = new ArrayList<Module.Service.Externs.Extern>();
+		parseModule(mod);
+	}
+	
+	private void parseModule(Module mod)
+	{
+		List<Module.Service> svcList = mod.getService();
+		if (svcList==null) return;
+		for (Module.Service svc : svcList)
+		{
+			parseService(svc);
+		}
+	}
+	
+	private void parseService(Module.Service svc)
+	{
+		List<Module.Service.Enums> enums = svc.getEnums();
+		if (enums!=null)
+		{
+			for (Module.Service.Enums myenum : enums)
+			{
+				List<Module.Service.Enums.Enum> enumL = myenum.getEnum();
+				if (enumL!=null) _enums.addAll( enumL );
+			}
+		}
+		List<Module.Service.Structs> structs = svc.getStructs();
+		if (structs!=null)
+		{
+			for (Module.Service.Structs mystructs : structs)
+			{
+				List<Module.Service.Structs.Struct> structL = mystructs.getStruct();
+				if (structL!=null) _structs.addAll( structL );
+			}
+		}
+		List<Module.Service.Exceptions> exps = svc.getExceptions();
+		if (exps!=null)
+		{
+			for (Module.Service.Exceptions myexps : exps)
+			{
+				List<Exception> expL = myexps.getException();
+				if (expL!=null) _exceptions.addAll( expL );
+			}
+		}
+		List<Module.Service.Methods> methods = svc.getMethods();
+		if (methods!=null)
+		{
+			for (Module.Service.Methods mymethods : methods)
+			{
+				List<Module.Service.Methods.Method> methodL = mymethods.getMethod();
+				if (methodL!=null) _methods.addAll( methodL );
+			}
+		}
+		List<Module.Service.Externs> externs = svc.getExterns();
+		if (externs!=null)
+		{
+			for (Module.Service.Externs anExterns : externs)
+			{
+				List<Module.Service.Externs.Extern> externL = anExterns.getExtern();
+				if (externL!=null) _externs.addAll( externL );
+			}
+		}
+	}
+}

Propchange: incubator/etch/branches/router/services/router/src/main/java/cisco/uc/cuae/etchrouter/utils/XmlBindingData.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/etch/branches/router/services/router/src/main/java/cisco/uc/cuae/etchrouter/utils/XmlBindingData.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: incubator/etch/branches/router/services/router/src/main/java/cisco/uc/cuae/etchrouter/utils/XmlBindingDataParser.java
URL: http://svn.apache.org/viewvc/incubator/etch/branches/router/services/router/src/main/java/cisco/uc/cuae/etchrouter/utils/XmlBindingDataParser.java?rev=746638&view=auto
==============================================================================
--- incubator/etch/branches/router/services/router/src/main/java/cisco/uc/cuae/etchrouter/utils/XmlBindingDataParser.java (added)
+++ incubator/etch/branches/router/services/router/src/main/java/cisco/uc/cuae/etchrouter/utils/XmlBindingDataParser.java Sun Feb 22 05:25:46 2009
@@ -0,0 +1,617 @@
+/* $Id$
+ *
+ * Copyright 2009-2010 Cisco Systems Inc.
+ *
+ * Licensed 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 cisco.uc.cuae.etchrouter.utils;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import cisco.uc.cuae.etchrouter.xml.Module;
+import etch.bindings.java.msg.AsyncMode;
+import etch.bindings.java.msg.Direction;
+import etch.bindings.java.msg.Type;
+import etch.bindings.java.msg.Validator;
+import etch.bindings.java.support.DefaultValueFactory;
+import etch.bindings.java.support.Validator_StructValue;
+import etch.bindings.java.support.Validator_boolean;
+import etch.bindings.java.support.Validator_byte;
+import etch.bindings.java.support.Validator_custom;
+import etch.bindings.java.support.Validator_double;
+import etch.bindings.java.support.Validator_float;
+import etch.bindings.java.support.Validator_int;
+import etch.bindings.java.support.Validator_long;
+import etch.bindings.java.support.Validator_object;
+import etch.bindings.java.support.Validator_short;
+import etch.bindings.java.support.Validator_string;
+import etch.bindings.java.support.Validator_void;
+
+/**
+ * 
+ * @author Wei Wang (weiwa@cisco.com)
+ *
+ */
+public class XmlBindingDataParser
+{
+
+	private static final Logger _LOGGER = Logger.getLogger( XmlBindingDataParser.class.getName());
+	
+	private Map<String, LocalTypeImportExportHelper> _localImpExpHelperMap = null;
+	
+	private Map<String, StructValueImportExportHelper> _structValueImpExpHelperMap = null;
+	
+	private Map<Type, Module.Service.Structs.Struct> _structType2StructMap = null;
+	
+	private Map<Type, cisco.uc.cuae.etchrouter.xml.Exception> _excpType2ExcpMap = null;
+	
+	private Map<Type, Module.Service.Methods.Method> _methodType2MethodMap = null;
+	
+	private List<Type> _resultMethodTypes = null;
+	
+	private List<Type> _methodTypes = null;
+	
+	private List<Type> _enumTypes = null;
+	
+	private List<Type> _structTypes = null;
+	
+	private List<Type> _exceptionTypes = null;
+	
+	private List<Type> _externTypes = null;
+	
+	// extern name/shortName to fully qualified name map:
+	private Map<String, String> _externTypeNameMap = null;
+	
+	private StructValueImportExportHelper _structValueHelper = null;
+	
+	private Map<String, Type> _typeName2TypeMap = null;
+	
+	/**
+	 * 
+	 * @param data
+	 * @throws Exception
+	 */
+	public XmlBindingDataParser( XmlBindingData data )
+		throws Exception
+	{
+		_structValueHelper = new StructValueImportExportHelper();
+		_localImpExpHelperMap = new HashMap<String, LocalTypeImportExportHelper>();
+		_structType2StructMap = new HashMap<Type, Module.Service.Structs.Struct>();
+		_excpType2ExcpMap = new HashMap<Type, cisco.uc.cuae.etchrouter.xml.Exception>();
+		_methodType2MethodMap = new HashMap<Type, Module.Service.Methods.Method>();
+		_resultMethodTypes = new ArrayList<Type>();
+		_methodTypes = new ArrayList<Type>();
+		_enumTypes = new ArrayList<Type>();
+		_structTypes = new ArrayList<Type>();
+		_exceptionTypes = new ArrayList<Type>();
+		_typeName2TypeMap = new HashMap<String, Type>();
+		_structValueImpExpHelperMap = new HashMap<String, StructValueImportExportHelper>();
+		_externTypes = new ArrayList<Type>();
+		_externTypeNameMap = new HashMap<String, String>(); 
+		
+		parseData(data);
+	}
+	
+	private void parseData(XmlBindingData data) throws Exception
+	{
+		parseEnums(data.getEnums());
+		parseStructs(data.getStructs());
+		parseExceptions(data.getExceptions());
+		parseExterns(data.getExterns());
+		parseMethods(data.getMethods());
+		parseFields();
+	}
+	
+	private void parseExterns(List<Module.Service.Externs.Extern> externs) throws Exception
+	{
+		String name, typeName;
+		for (Module.Service.Externs.Extern extern : externs)
+		{
+			name = extern.getName();
+			typeName = extern.getTypeName();
+			_externTypeNameMap.put( name, typeName );
+			_externTypeNameMap.put( typeName, typeName );
+			Type myType = new Type(typeName);
+			_externTypes.add( myType );
+			_typeName2TypeMap.put( typeName, myType );
+			_structValueImpExpHelperMap.put( myType.getName(), _structValueHelper );
+		}
+	}
+	
+	private void parseFields() throws Exception
+	{
+		parseStructFields();
+		parseExceptionFields();
+		parseMethodFields();
+	}
+	
+	public LocalTypeImportExportHelper getLocalImportExportHelper( String typeName )
+	{
+		return _localImpExpHelperMap.get( typeName );
+	}
+	
+	public StructValueImportExportHelper getStructValueImportExportHelper( String typeName )
+	{
+		return _structValueImpExpHelperMap.get( typeName );
+	}
+	
+	public List<Type> getMethodTypes()
+	{
+		return _methodTypes;
+	}
+
+	public List<Type> getEnumTypes()
+	{
+		return _enumTypes;
+	}
+
+	public List<Type> getStructTypes()
+	{
+		return _structTypes;
+	}
+
+	public List<Type> getExceptionTypes()
+	{
+		return _exceptionTypes;
+	}
+
+	public List<Type> getExternTypes()
+	{
+		return _externTypes;
+	}
+	/**
+	 * 
+	 * @param enums
+	 * @return
+	 */
+	private void parseEnums(List<Module.Service.Enums.Enum> enums)
+		throws Exception
+	{
+		String typeName = null;
+		for (Module.Service.Enums.Enum myenum : enums)
+		{
+			typeName = myenum.getTypeName();
+			Type myType = new Type(typeName);
+			_enumTypes.add( myType );
+			_typeName2TypeMap.put( typeName, myType );
+			resolveEnumType(myenum, myType);
+		}
+	}
+	
+	private void resolveEnumType(Module.Service.Enums.Enum myenum, Type myType)
+		throws Exception
+	{
+		List<Module.Service.Enums.Enum.Entry> entries = myenum.getEntry();
+		List<String> entryValues = new ArrayList<String>(entries.size());
+		for (Module.Service.Enums.Enum.Entry entry : entries)
+		{
+			entryValues.add( entry.getValue() );
+			myType.putValidator( new etch.bindings.java.msg.Field( entry.getValue()), etch.bindings.java.support.Validator_boolean.get( 0 ) );
+		}
+		try
+		{
+			LocalEnumImportExportHelper helper = new LocalEnumImportExportHelper(myType, entryValues);
+			_LOGGER.log( Level.FINE, "The enum type \"{0}\" is locally defined", myType.getName() );
+			_localImpExpHelperMap.put( myType.getName(), helper );
+		}
+		catch (ClassNotFoundException e)
+		{
+			_LOGGER.log( Level.FINEST, String.format( "The enum type \"{0}\" is not locally defined: ", myType.getName()), e );
+			_structValueImpExpHelperMap.put( myType.getName(), _structValueHelper );
+		}	
+	}
+	
+	/**
+	 * 
+	 * @param structs
+	 * @return
+	 */
+	private void parseStructs(List<Module.Service.Structs.Struct> structs)
+		throws Exception
+	{
+		String typeName = null;
+		for (Module.Service.Structs.Struct mystruct : structs)
+		{
+			typeName = mystruct.getTypeName();
+			Type myType = new Type(typeName);
+			_structTypes.add( myType );
+			_structType2StructMap.put( myType, mystruct );
+			_typeName2TypeMap.put( typeName, myType );
+			resolveStructType(mystruct, myType);
+		}
+	}
+	
+	private void resolveStructType(Module.Service.Structs.Struct mystruct, Type myType)
+		throws Exception
+	{
+		List<cisco.uc.cuae.etchrouter.xml.Field> fields = mystruct.getField();
+		List<String> fieldNames = new ArrayList<String>(fields.size());
+		for (cisco.uc.cuae.etchrouter.xml.Field field : fields)
+		{
+			fieldNames.add( field.getName() );
+		}
+		try
+		{
+			LocalStructImportExportHelper helper = new LocalStructImportExportHelper(myType, fieldNames);
+			_LOGGER.log( Level.FINE, "The struct type \"{0}\" is locally defined: ", myType.getName() );
+			_localImpExpHelperMap.put( myType.getName(), helper );
+		}
+		catch (ClassNotFoundException e)
+		{
+			_LOGGER.log( Level.FINEST, String.format( "The struct type \"%s\" is not locally defined: ", myType.getName()), e );
+			_structValueImpExpHelperMap.put( myType.getName(), _structValueHelper );
+		}
+	}
+	
+	private void parseStructFields() throws Exception
+	{
+		for (Type structType : _structTypes)
+		{
+			Module.Service.Structs.Struct mystruct = _structType2StructMap.get( structType );
+			parseStructFields( mystruct, structType);
+		}
+	}
+	
+	private void parseStructFields( Module.Service.Structs.Struct mystruct, Type structType )
+	{
+		List<cisco.uc.cuae.etchrouter.xml.Field> myFields = mystruct.getField();
+		resolveFieldValidators( structType, myFields );
+	}
+	
+	/**
+	 * 
+	 * @param exceptions
+	 * @return
+	 */
+	private void parseExceptions(List<cisco.uc.cuae.etchrouter.xml.Exception> exceptions)
+		throws Exception
+	{
+		String typeName = null;
+		for (cisco.uc.cuae.etchrouter.xml.Exception myexp : exceptions)
+		{
+			typeName = myexp.getTypeName();
+			Type myType = new Type(typeName);
+			_exceptionTypes.add( myType );
+			_excpType2ExcpMap.put( myType, myexp );
+			_typeName2TypeMap.put( typeName, myType );
+			resolveExceptionType(myexp, myType);
+		}
+	}
+
+	private void resolveExceptionType(cisco.uc.cuae.etchrouter.xml.Exception myexp, Type myType)
+		throws Exception
+	{
+		List<cisco.uc.cuae.etchrouter.xml.Field> fields = myexp.getField();
+		List<String> fieldNames = new ArrayList<String>(fields.size());
+		for (cisco.uc.cuae.etchrouter.xml.Field field : fields)
+		{
+			fieldNames.add( field.getName() );
+		}
+		try
+		{
+			LocalStructImportExportHelper helper = new LocalStructImportExportHelper(myType, fieldNames);
+			_LOGGER.log( Level.FINE, "The exception type \"{0}\" is locally defined", myType.getName() );
+			_localImpExpHelperMap.put( myType.getName(), helper );
+		}
+		catch (ClassNotFoundException e)
+		{
+			_LOGGER.log( Level.FINEST, String.format( "The exception type \"%s\" is not locally defined: ", myType.getName()), e );
+			_structValueImpExpHelperMap.put( myType.getName(), _structValueHelper );
+		}
+	}
+	
+	private void parseExceptionFields()
+	{
+		for (Type myType : _exceptionTypes)
+		{
+			cisco.uc.cuae.etchrouter.xml.Exception myexcp = _excpType2ExcpMap.get( myType );
+			parseExceptionFields( myexcp, myType);
+		}
+	}
+	
+	private void parseExceptionFields( cisco.uc.cuae.etchrouter.xml.Exception myexcp, Type excpType)
+	{
+		List<cisco.uc.cuae.etchrouter.xml.Field> myFields = myexcp.getField();
+		resolveFieldValidators( excpType, myFields );
+	}
+	
+	/**
+	 * Note: this must be called after all enum, struct and exception types are parsed, otherwise
+	 * the import-export helpers will not be created for the validator setup
+	 * 
+	 * @param methods
+	 * @return
+	 */	
+	private void parseMethods(List<Module.Service.Methods.Method> methods)
+	{
+		Map<String, Type> types = new LinkedHashMap<String, Type>(methods.size());
+		Map<Type, Module.Service.Methods.Method.Result> type2resultMap = 
+			new HashMap<Type, Module.Service.Methods.Method.Result>(methods.size()); 
+		String typeName = null;
+		for (Module.Service.Methods.Method mymethod : methods)
+		{
+			typeName = mymethod.getTypeName();
+			Type myType = new Type(typeName);
+			_methodTypes.add( myType );
+			types.put( typeName, myType );
+			_methodType2MethodMap.put( myType, mymethod );
+			String asyncReceiverMode = mymethod.getAsyncReceiverMode();
+			//String isOneway = mymethod.getIsOneway();
+			String messageDirection = mymethod.getMessageDirection();
+			AsyncMode mode = getAsyncModeEnumByName( asyncReceiverMode );
+			if (mode==null)
+			{
+				_LOGGER.log( Level.SEVERE, "Unknown AsyncReceiverMode attribute \"{0}\" for method \"{1}\" ", new Object[]{ asyncReceiverMode, typeName } );
+			}
+			else
+			{
+				myType.setAsyncMode( mode );
+			}
+			Direction direction = getDirectionEnumByName( messageDirection );
+			if (direction==null)
+			{
+				_LOGGER.log( Level.SEVERE, "Unknown MessageDirection attribute \"{0}\" for method \"{1}\" ", new Object[]{ messageDirection, typeName } );
+			}
+			else
+			{
+				myType.setDirection( direction );
+			}
+			String timeout = mymethod.getTimeout();
+			if (timeout!=null)
+			{
+				try
+				{
+					myType.setTimeout( Integer.parseInt( timeout ) );
+				}
+				catch (Exception e)
+				{
+					_LOGGER.log( Level.SEVERE, "Unknown TimeOut attribute \"{0}\" for method \"{1}\" ", new Object[]{ timeout, typeName } );
+				}
+			}
+			//String responseField = mymethod.getResponseField();
+			List<Module.Service.Methods.Method.Result> methResults = mymethod.getResult();
+			if (methResults != null && (!methResults.isEmpty()))
+			{
+				type2resultMap.put( myType, methResults.get( 0 ) );
+			}
+		}
+		Set<Type> keys = type2resultMap.keySet();
+		for (Type myType : keys)
+		{
+			Module.Service.Methods.Method.Result result = type2resultMap.get( myType );
+			String fieldName = result.getFieldName();
+			if (fieldName != null)
+			{
+				Type resultType = types.get( fieldName );
+				if (resultType==null)
+				{
+					_LOGGER.log( Level.SEVERE, "The result field \"{0}\" is not defined for method \"{1}\" ", new Object[] { fieldName, myType.getName() } );
+				}
+				else
+				{
+					myType.setResult( resultType );
+					_resultMethodTypes.add( resultType );
+				}
+			}
+		}
+	}
+	
+	private void parseMethodFields()
+	{
+		for (Type myType : _methodTypes)
+		{
+			Module.Service.Methods.Method mymethod = _methodType2MethodMap.get( myType );
+			boolean isResultMethod = _resultMethodTypes.contains( myType );
+			parseMethodFields( mymethod, myType, isResultMethod);
+		}
+	}
+	
+	private void parseMethodFields(Module.Service.Methods.Method mymethod, Type myType, boolean isResultMethod )
+	{
+		if (isResultMethod)
+		{
+			myType.putValidator( DefaultValueFactory._mf__inReplyTo, etch.bindings.java.support.Validator_long.get( 0 ) );
+			myType.putValidator( DefaultValueFactory._mf_result, etch.bindings.java.support.Validator_RuntimeException.get() );
+		}
+		myType.putValidator( DefaultValueFactory._mf__messageId, etch.bindings.java.support.Validator_long.get( 0 ) );
+		List<cisco.uc.cuae.etchrouter.xml.Field> myfields = mymethod.getField();
+		resolveFieldValidators( myType, myfields);
+		if (isResultMethod) return;
+		Type resultType = myType.getResult();
+		if (resultType==null) return;
+		List<cisco.uc.cuae.etchrouter.xml.Exception> myexps = mymethod.getException();
+		if (myexps!=null && myexps.size()>0)
+		{
+			for (cisco.uc.cuae.etchrouter.xml.Exception exp : myexps)
+			{
+				String expTypeName = exp.getType();
+				LocalTypeImportExportHelper helper = getLocalImportExportHelper( expTypeName );
+				if (helper != null)
+				{
+					resultType.putValidator( DefaultValueFactory._mf_result, Validator_custom.get( helper.getTypeClass(), 0, true ) );
+				}
+			}
+		}
+	}
+	
+	private void resolveFieldValidators( Type myType, List<cisco.uc.cuae.etchrouter.xml.Field> myFields)
+	{
+		for (cisco.uc.cuae.etchrouter.xml.Field myfield : myFields)
+		{
+			String fieldName = myfield.getName();
+			String isArray = myfield.getIsArray();
+			String dimension = myfield.getDimension();
+			int nDims = 0;
+			if (!"false".equalsIgnoreCase( isArray ))
+			{
+				try
+				{
+					nDims = Integer.parseInt( dimension );
+				}
+				catch (Exception e)
+				{
+					_LOGGER.log( Level.SEVERE, String.format( "Invalid dimmension attribute of field \"%s\" in Type \"%s\"", fieldName, myType.getName() ), e );
+				}
+			}
+			String isPrimitive = myfield.getIsPrimitiveType();
+			String typeName = myfield.getType();
+			Validator validator = getWellknownValidator(typeName, nDims);
+			etch.bindings.java.msg.Field thisField = new etch.bindings.java.msg.Field(fieldName);
+			if (validator!=null)
+			{
+				myType.putValidator( thisField, validator );
+			}
+			else if ("true".equalsIgnoreCase( isPrimitive ))
+			{
+				_LOGGER.log( Level.SEVERE, "Unknown primitive type \"{0}\" of field \"{1}\" in Type \"{2}\"", new Object[] { typeName, fieldName, myType.getName() } );
+			}
+			else
+			{
+				LocalTypeImportExportHelper helper = getLocalImportExportHelper( typeName );
+				if (helper != null)
+				{
+					myType.putValidator( thisField, Validator_custom.get( helper.getTypeClass(), nDims, true ) );
+				}
+				else
+				{
+					StructValueImportExportHelper structHelper = getStructValueImportExportHelper( typeName );
+					boolean done = false;
+					if (structHelper!=null)
+					{
+						Type fieldType = _typeName2TypeMap.get( typeName );
+						if (fieldType!=null)
+						{
+							myType.putValidator( thisField, Validator_StructValue.get( fieldType, nDims ) );
+							done = true;
+						}
+					}
+					else
+					{
+						String externFullName = _externTypeNameMap.get( typeName );
+						if (externFullName != null)
+						{
+							structHelper = getStructValueImportExportHelper( externFullName );
+							Type fieldType = _typeName2TypeMap.get( externFullName );
+							if (structHelper!=null && fieldType!=null)
+							{
+								myType.putValidator( thisField, Validator_StructValue.get( fieldType, nDims ) );
+								done = true;
+							}
+						}
+					}
+					if (!done)
+						_LOGGER.log( Level.SEVERE, "The custom type \"{0}\" of field \"{1}\" in type \"{2}\" is not defined", new Object[] { typeName, fieldName, myType.getName() } );
+				}
+			}
+		}
+
+	}
+	
+	private AsyncMode getAsyncModeEnumByName(String name)
+	{
+		AsyncMode[] vals = AsyncMode.values();
+		for (AsyncMode val : vals)
+		{
+			if (val.name().equalsIgnoreCase( name ))
+				return val;
+		}
+		return null;
+	}
+
+	private Direction getDirectionEnumByName(String name)
+	{
+		Direction[] vals = Direction.values();
+		for (Direction val : vals)
+		{
+			if (val.name().equalsIgnoreCase( name ))
+				return val;
+		}
+		return null;	
+	}
+	
+	/**
+	 * Get non-customized type's validator by name and dimensions
+	 * 
+	 * @param typeName
+	 * @param nDims
+	 * @return
+	 */
+	public static Validator getWellknownValidator(String typeName, int nDims)
+	{
+		if ("void".equals( typeName ))
+		{
+			return Validator_void.get( nDims );
+		}
+		else if ("boolean".equals( typeName ))
+		{
+			return Validator_boolean.get(nDims);
+		}
+		else if ("byte".equals( typeName ))
+		{
+			return Validator_byte.get(nDims);
+		}
+		else if ("double".equals( typeName ))
+		{
+			return Validator_double.get(nDims);
+		}
+		else if ("float".equals( typeName ))
+		{
+			return Validator_float.get(nDims);
+		}
+		else if ("int".equals( typeName ))
+		{
+			return Validator_int.get(nDims);
+		}
+		else if ("long".equals( typeName ))
+		{
+			return Validator_long.get(nDims);
+		}
+		else if ("object".equals( typeName ))
+		{
+			return Validator_object.get(nDims);
+		}
+		else if ("short".equals( typeName ))
+		{
+			return Validator_short.get(nDims);
+		}
+		else if ("string".equals( typeName ))
+		{
+			return Validator_string.get(nDims);
+		}
+		else if ("Map".equals( typeName ))
+		{
+			return Validator_custom.get( java.util.Map.class, nDims, true );
+		}
+		else if ("Datetime".equals( typeName ))
+		{
+			return Validator_custom.get( java.util.Date.class, nDims, true );
+		}
+		else if ("List".equals( typeName ))
+		{
+			return Validator_custom.get( java.util.List.class, nDims, true );
+		}
+		else if ("Set".equals( typeName ))
+		{
+			return Validator_custom.get( java.util.Set.class, nDims, true );
+		}
+		
+		return null;
+	}
+}

Propchange: incubator/etch/branches/router/services/router/src/main/java/cisco/uc/cuae/etchrouter/utils/XmlBindingDataParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/etch/branches/router/services/router/src/main/java/cisco/uc/cuae/etchrouter/utils/XmlBindingDataParser.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: incubator/etch/branches/router/services/router/src/main/java/cisco/uc/cuae/etchrouter/xml/Exception.java
URL: http://svn.apache.org/viewvc/incubator/etch/branches/router/services/router/src/main/java/cisco/uc/cuae/etchrouter/xml/Exception.java?rev=746638&view=auto
==============================================================================
--- incubator/etch/branches/router/services/router/src/main/java/cisco/uc/cuae/etchrouter/xml/Exception.java (added)
+++ incubator/etch/branches/router/services/router/src/main/java/cisco/uc/cuae/etchrouter/xml/Exception.java Sun Feb 22 05:25:46 2009
@@ -0,0 +1,283 @@
+/* $Id$
+ *
+ * Copyright 2009-2010 Cisco Systems Inc.
+ *
+ * Licensed 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.
+ */
+
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-661 
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
+// Any modifications to this file will be lost upon recompilation of the source schema. 
+// Generated on: 2008.12.02 at 02:28:29 PM CST 
+//
+
+
+package cisco.uc.cuae.etchrouter.xml;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for anonymous complex type.
+ * 
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * 
+ * <pre>
+ * &lt;complexType>
+ *   &lt;complexContent>
+ *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       &lt;sequence>
+ *         &lt;element name="description" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         &lt;element ref="{}field" maxOccurs="unbounded" minOccurs="0"/>
+ *       &lt;/sequence>
+ *       &lt;attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       &lt;attribute name="isUnchecked" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       &lt;attribute name="typeId" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       &lt;attribute name="typeName" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       &lt;attribute name="baseType" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       &lt;attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     &lt;/restriction>
+ *   &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ * 
+ * 
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {
+    "description",
+    "field"
+})
+@XmlRootElement(name = "exception")
+public class Exception {
+
+    protected String description;
+    protected List<Field> field;
+    @XmlAttribute
+    protected String name;
+    @XmlAttribute
+    protected String isUnchecked;
+    @XmlAttribute
+    protected String typeId;
+    @XmlAttribute
+    protected String typeName;
+    @XmlAttribute
+    protected String baseType;
+    @XmlAttribute
+    protected String type;
+
+    /**
+     * Gets the value of the description property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getDescription() {
+        return description;
+    }
+
+    /**
+     * Sets the value of the description property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setDescription(String value) {
+        this.description = value;
+    }
+
+    /**
+     * Gets the value of the field property.
+     * 
+     * <p>
+     * This accessor method returns a reference to the live list,
+     * not a snapshot. Therefore any modification you make to the
+     * returned list will be present inside the JAXB object.
+     * This is why there is not a <CODE>set</CODE> method for the field property.
+     * 
+     * <p>
+     * For example, to add a new item, do as follows:
+     * <pre>
+     *    getField().add(newItem);
+     * </pre>
+     * 
+     * 
+     * <p>
+     * Objects of the following type(s) are allowed in the list
+     * {@link Field }
+     * 
+     * 
+     */
+    public List<Field> getField() {
+        if (field == null) {
+            field = new ArrayList<Field>();
+        }
+        return this.field;
+    }
+
+    /**
+     * Gets the value of the name property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Sets the value of the name property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setName(String value) {
+        this.name = value;
+    }
+
+    /**
+     * Gets the value of the isUnchecked property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getIsUnchecked() {
+        return isUnchecked;
+    }
+
+    /**
+     * Sets the value of the isUnchecked property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setIsUnchecked(String value) {
+        this.isUnchecked = value;
+    }
+
+    /**
+     * Gets the value of the typeId property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getTypeId() {
+        return typeId;
+    }
+
+    /**
+     * Sets the value of the typeId property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setTypeId(String value) {
+        this.typeId = value;
+    }
+
+    /**
+     * Gets the value of the typeName property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getTypeName() {
+        return typeName;
+    }
+
+    /**
+     * Sets the value of the typeName property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setTypeName(String value) {
+        this.typeName = value;
+    }
+
+    /**
+     * Gets the value of the baseType property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getBaseType() {
+        return baseType;
+    }
+
+    /**
+     * Sets the value of the baseType property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setBaseType(String value) {
+        this.baseType = value;
+    }
+
+    /**
+     * Gets the value of the type property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getType() {
+        return type;
+    }
+
+    /**
+     * Sets the value of the type property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setType(String value) {
+        this.type = value;
+    }
+
+}

Propchange: incubator/etch/branches/router/services/router/src/main/java/cisco/uc/cuae/etchrouter/xml/Exception.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/etch/branches/router/services/router/src/main/java/cisco/uc/cuae/etchrouter/xml/Exception.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: incubator/etch/branches/router/services/router/src/main/java/cisco/uc/cuae/etchrouter/xml/Field.java
URL: http://svn.apache.org/viewvc/incubator/etch/branches/router/services/router/src/main/java/cisco/uc/cuae/etchrouter/xml/Field.java?rev=746638&view=auto
==============================================================================
--- incubator/etch/branches/router/services/router/src/main/java/cisco/uc/cuae/etchrouter/xml/Field.java (added)
+++ incubator/etch/branches/router/services/router/src/main/java/cisco/uc/cuae/etchrouter/xml/Field.java Sun Feb 22 05:25:46 2009
@@ -0,0 +1,276 @@
+/* $Id$
+ *
+ * Copyright 2009-2010 Cisco Systems Inc.
+ *
+ * Licensed 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.
+ */
+
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-661 
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
+// Any modifications to this file will be lost upon recompilation of the source schema. 
+// Generated on: 2008.12.02 at 02:28:29 PM CST 
+//
+
+
+package cisco.uc.cuae.etchrouter.xml;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for anonymous complex type.
+ * 
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * 
+ * <pre>
+ * &lt;complexType>
+ *   &lt;complexContent>
+ *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       &lt;sequence>
+ *         &lt;element name="description" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       &lt;/sequence>
+ *       &lt;attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       &lt;attribute name="fieldId" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       &lt;attribute name="fieldName" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       &lt;attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       &lt;attribute name="isPrimitiveType" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       &lt;attribute name="isArray" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       &lt;attribute name="dimension" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     &lt;/restriction>
+ *   &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ * 
+ * 
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {
+    "description"
+})
+@XmlRootElement(name = "field")
+public class Field {
+
+    protected String description;
+    @XmlAttribute
+    protected String name;
+    @XmlAttribute
+    protected String fieldId;
+    @XmlAttribute
+    protected String fieldName;
+    @XmlAttribute
+    protected String type;
+    @XmlAttribute
+    protected String isPrimitiveType;
+    @XmlAttribute
+    protected String isArray;
+    @XmlAttribute
+    protected String dimension;
+
+    /**
+     * Gets the value of the description property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getDescription() {
+        return description;
+    }
+
+    /**
+     * Sets the value of the description property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setDescription(String value) {
+        this.description = value;
+    }
+
+    /**
+     * Gets the value of the name property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Sets the value of the name property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setName(String value) {
+        this.name = value;
+    }
+
+    /**
+     * Gets the value of the fieldId property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getFieldId() {
+        return fieldId;
+    }
+
+    /**
+     * Sets the value of the fieldId property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setFieldId(String value) {
+        this.fieldId = value;
+    }
+
+    /**
+     * Gets the value of the fieldName property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getFieldName() {
+        return fieldName;
+    }
+
+    /**
+     * Sets the value of the fieldName property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setFieldName(String value) {
+        this.fieldName = value;
+    }
+
+    /**
+     * Gets the value of the type property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getType() {
+        return type;
+    }
+
+    /**
+     * Sets the value of the type property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setType(String value) {
+        this.type = value;
+    }
+
+    /**
+     * Gets the value of the isPrimitiveType property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getIsPrimitiveType() {
+        return isPrimitiveType;
+    }
+
+    /**
+     * Sets the value of the isPrimitiveType property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setIsPrimitiveType(String value) {
+        this.isPrimitiveType = value;
+    }
+
+    /**
+     * Gets the value of the isArray property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getIsArray() {
+        return isArray;
+    }
+
+    /**
+     * Sets the value of the isArray property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setIsArray(String value) {
+        this.isArray = value;
+    }
+
+    /**
+     * Gets the value of the dimension property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getDimension() {
+        return dimension;
+    }
+
+    /**
+     * Sets the value of the dimension property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setDimension(String value) {
+        this.dimension = value;
+    }
+
+}

Propchange: incubator/etch/branches/router/services/router/src/main/java/cisco/uc/cuae/etchrouter/xml/Field.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/etch/branches/router/services/router/src/main/java/cisco/uc/cuae/etchrouter/xml/Field.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"