Repository: incubator-reef Updated Branches: refs/heads/master 4b77bf57d -> 603c71491
[REEF-512] Allow alias for NamedParameter in C# Tang This PR added the alias in NamedParameter at REEF C# side. It prepares for deserializing configuration sent from Java. - Adding new properties alias and language in NamedParameter - Parse alias and language when creating class hierarchy - Added overloading method for GetNode() in IClassHierarchy and its implementations - Add new optional properties in class_hierarchy protobuffer schema and updated data contract - Added test cases JIRA: [REEF-512](https://issues.apache.org/jira/browse/REEF-512) Pull Request: This closes #454 Project: http://git-wip-us.apache.org/repos/asf/incubator-reef/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-reef/commit/603c7149 Tree: http://git-wip-us.apache.org/repos/asf/incubator-reef/tree/603c7149 Diff: http://git-wip-us.apache.org/repos/asf/incubator-reef/diff/603c7149 Branch: refs/heads/master Commit: 603c71491937691137579b1fdde22423310ef5c0 Parents: 4b77bf5 Author: Julia Wang <[email protected]> Authored: Mon Aug 31 18:52:15 2015 -0700 Committer: Markus Weimer <[email protected]> Committed: Tue Sep 8 11:17:06 2015 -0700 ---------------------------------------------------------------------- .../ClassHierarchy/TestNamedParameter.cs | 112 +++++ .../Org.Apache.REEF.Tang.Tests.csproj | 1 + .../Annotations/NamedParameter.cs | 7 +- .../ClassHierarchy/AvroClassHierarchy.cs | 67 ++- .../ClassHierarchy/ClassHierarchyImpl.cs | 83 +++- .../ClassHierarchy/NamedParameterNodeImpl.cs | 24 +- .../ClassHierarchy/NodeFactory.cs | 2 +- .../Interface/IClassHierarchy.cs | 13 + .../Protobuf/ProtocolBufferClassHierarchy.cs | 98 +++- .../Protobuf/class_hierarchy.cs | 475 ++++++++++--------- .../Types/INamedParameterNode.cs | 18 +- .../tang/src/main/proto/class_hierarchy.proto | 8 + 12 files changed, 661 insertions(+), 247 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/603c7149/lang/cs/Org.Apache.REEF.Tang.Tests/ClassHierarchy/TestNamedParameter.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Tang.Tests/ClassHierarchy/TestNamedParameter.cs b/lang/cs/Org.Apache.REEF.Tang.Tests/ClassHierarchy/TestNamedParameter.cs new file mode 100644 index 0000000..d555278 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Tang.Tests/ClassHierarchy/TestNamedParameter.cs @@ -0,0 +1,112 @@ +/** + * 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. + */ + +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Org.Apache.REEF.Tang.Annotations; +using Org.Apache.REEF.Tang.Formats; +using Org.Apache.REEF.Tang.Implementations.Tang; +using Org.Apache.REEF.Tang.Protobuf; +using Org.Apache.REEF.Tang.Types; +using Org.Apache.REEF.Tang.Util; + +namespace Org.Apache.REEF.Tang.Tests.ClassHierarchy +{ + [TestClass] + public class TestNamedParameter + { + [TestMethod] + public void TestNamedParameterWithDefaultValues() + { + var ns = TangFactory.GetTang().GetDefaultClassHierarchy(); + INamedParameterNode cls = (INamedParameterNode)ns.GetNode(typeof(NamedParameterWithDefaultValues).AssemblyQualifiedName); + Assert.IsTrue(cls.GetDocumentation().Equals("NamedParameterWithDefaultValues")); + Assert.IsTrue(cls.GetShortName().Equals("NamedParameterWithDefaultValues")); + Assert.IsTrue(cls.GetAlias().Equals("org.apache.REEF.tang.tests.classHierarchy.NamedParameterWithDefaultValues")); + Assert.IsTrue(cls.GetAliasLanguage().Equals(AvroConfigurationSerializer.Java)); + } + + [TestMethod] + public void TestNamedParameterWithAlias() + { + var ns = TangFactory.GetTang().GetDefaultClassHierarchy(); + INamedParameterNode cls = (INamedParameterNode)ns.GetNode(typeof(NamedParameterWithAlias).AssemblyQualifiedName); + Assert.IsTrue(cls.GetAlias().Equals("org.apache.REEF.tang.tests.classHierarchy.NamedParameterWithAlias")); + Assert.IsTrue(cls.GetAliasLanguage().Equals(AvroConfigurationSerializer.Java)); + } + + [TestMethod] + public void TestNamedParameterWithAliasRoundTrip() + { + var ns = TangFactory.GetTang().GetDefaultClassHierarchy(); + INamedParameterNode node1 = (INamedParameterNode)ns.GetNode(typeof(NamedParameterWithAlias).AssemblyQualifiedName); + + var ns1 = new ProtocolBufferClassHierarchy(ProtocolBufferClassHierarchy.Serialize(ns)); + var node2 = ns1.GetNode(typeof(NamedParameterWithAlias).AssemblyQualifiedName); + + Assert.IsTrue(node2 is INamedParameterNode); + Assert.IsTrue(((INamedParameterNode)node2).GetAliasLanguage().Equals(AvroConfigurationSerializer.Java)); + Assert.IsTrue(((INamedParameterNode)node2).GetFullName().Equals(typeof(NamedParameterWithAlias).AssemblyQualifiedName)); + Assert.IsTrue(((INamedParameterNode)node2).GetAlias().Equals("org.apache.REEF.tang.tests.classHierarchy.NamedParameterWithAlias")); + } + + [TestMethod] + public void TestGetNamedparameterValue() + { + var b = TangFactory.GetTang().NewConfigurationBuilder() + .BindNamedParameter<NamedParameterWithAlias, string>(GenericType<NamedParameterWithAlias>.Class, "test") + .Build(); + + var c = b.GetClassHierarchy(); + var i = TangFactory.GetTang().NewInjector(b); + var o = i.GetInstance<ClassWithNamedParameterWithAlias>(); + var no = i.GetNamedInstance<NamedParameterWithAlias, string>(); + Assert.IsTrue(o.Value.Equals("test")); + } + } + + [NamedParameter(Documentation = "NamedParameterWithDefaultValues", + ShortName = "NamedParameterWithDefaultValues", + DefaultValue = "default", + DefaultClass = null, + DefaultValues = null, + DefaultClasses = null, + Alias = "org.apache.REEF.tang.tests.classHierarchy.NamedParameterWithDefaultValues", + AliasLanguage = AvroConfigurationSerializer.Java + )] + + public class NamedParameterWithDefaultValues : Name<string> + { + } + + [NamedParameter(alias: "org.apache.REEF.tang.tests.classHierarchy.NamedParameterWithAlias", aliasLanguage: AvroConfigurationSerializer.Java)] + public class NamedParameterWithAlias : Name<string> + { + } + + public class ClassWithNamedParameterWithAlias + { + public string Value; + + [Inject] + private ClassWithNamedParameterWithAlias([Parameter(typeof(NamedParameterWithAlias))] string abc) + { + Value = abc; + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/603c7149/lang/cs/Org.Apache.REEF.Tang.Tests/Org.Apache.REEF.Tang.Tests.csproj ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Tang.Tests/Org.Apache.REEF.Tang.Tests.csproj b/lang/cs/Org.Apache.REEF.Tang.Tests/Org.Apache.REEF.Tang.Tests.csproj index 0c74c2d..c57131b 100644 --- a/lang/cs/Org.Apache.REEF.Tang.Tests/Org.Apache.REEF.Tang.Tests.csproj +++ b/lang/cs/Org.Apache.REEF.Tang.Tests/Org.Apache.REEF.Tang.Tests.csproj @@ -52,6 +52,7 @@ under the License. <Compile Include="ClassHierarchy\TestClassHierarchy.cs" /> <Compile Include="ClassHierarchy\TestGeneric.cs" /> <Compile Include="ClassHierarchy\TestMultipleInterface.cs" /> + <Compile Include="ClassHierarchy\TestNamedParameter.cs" /> <Compile Include="ClassHierarchy\TestParameterParser.cs" /> <Compile Include="ClassHierarchy\TestSerilization.cs" /> <Compile Include="Configuration\TestAvroConfiguration.cs" /> http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/603c7149/lang/cs/Org.Apache.REEF.Tang/Annotations/NamedParameter.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Tang/Annotations/NamedParameter.cs b/lang/cs/Org.Apache.REEF.Tang/Annotations/NamedParameter.cs index 0d3170c..51af58a 100644 --- a/lang/cs/Org.Apache.REEF.Tang/Annotations/NamedParameter.cs +++ b/lang/cs/Org.Apache.REEF.Tang/Annotations/NamedParameter.cs @@ -18,6 +18,7 @@ */ using System; +using Org.Apache.REEF.Tang.Formats; namespace Org.Apache.REEF.Tang.Annotations { @@ -30,9 +31,11 @@ namespace Org.Apache.REEF.Tang.Annotations public Type DefaultClass { get; set; } public string[] DefaultValues { get; set; } public Type[] DefaultClasses { get; set; } + public string Alias { get; set; } + public string AliasLanguage { get; set; } public NamedParameterAttribute(string documentation = "", string shortName = "", - string defaultValue = "", Type defaultClass = null, string[] defaultValues = null, Type[] defaultClasses = null) + string defaultValue = "", Type defaultClass = null, string[] defaultValues = null, Type[] defaultClasses = null, string alias = null, string aliasLanguage = AvroConfigurationSerializer.Java) { this.Documentation = documentation; this.ShortName = shortName; @@ -40,6 +43,8 @@ namespace Org.Apache.REEF.Tang.Annotations this.DefaultClass = defaultClass; this.DefaultValues = defaultValues; this.DefaultClasses = defaultClasses; + this.Alias = alias; + this.AliasLanguage = aliasLanguage; } } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/603c7149/lang/cs/Org.Apache.REEF.Tang/Implementations/ClassHierarchy/AvroClassHierarchy.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Tang/Implementations/ClassHierarchy/AvroClassHierarchy.cs b/lang/cs/Org.Apache.REEF.Tang/Implementations/ClassHierarchy/AvroClassHierarchy.cs index f245c13..0364115 100644 --- a/lang/cs/Org.Apache.REEF.Tang/Implementations/ClassHierarchy/AvroClassHierarchy.cs +++ b/lang/cs/Org.Apache.REEF.Tang/Implementations/ClassHierarchy/AvroClassHierarchy.cs @@ -19,7 +19,9 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; +using System.Runtime.Remoting.Messaging; using Org.Apache.REEF.Tang.Exceptions; using Org.Apache.REEF.Tang.Implementations.ClassHierarchy.AvroDataContract; using Org.Apache.REEF.Tang.Interface; @@ -37,6 +39,7 @@ namespace Org.Apache.REEF.Tang.Implementations.ClassHierarchy private readonly IPackageNode _rootNode; private readonly IDictionary<string, INode> _lookupTable = new Dictionary<string, INode>(); + private readonly IDictionary<string, IDictionary<string, string>> _aliasLookupTable = new Dictionary<string, IDictionary<string, string>>(); /// <summary> /// create a AvroClassHierarchy with empty nodes and lookup table. It can be used to merge other class hierarchy to it @@ -177,7 +180,7 @@ namespace Org.Apache.REEF.Tang.Implementations.ClassHierarchy } /// <summary> - /// Build hashtable to index the node + /// Build hash table to index the node /// </summary> /// <param name="n"></param> public void BuildHashTable(INode n) @@ -185,10 +188,38 @@ namespace Org.Apache.REEF.Tang.Implementations.ClassHierarchy foreach (INode child in n.GetChildren()) { _lookupTable.Add(child.GetFullName(), child); + if (child is INamedParameterNode) + { + AddAlias((INamedParameterNode)child); + } BuildHashTable(child); } } + private void AddAlias(INamedParameterNode np) + { + if (np.GetAlias() != null && !np.GetAlias().Equals("")) + { + IDictionary<string, string> mapping = null; + _aliasLookupTable.TryGetValue(np.GetAliasLanguage(), out mapping); + if (mapping == null) + { + mapping = new Dictionary<string, string>(); + _aliasLookupTable.Add(np.GetAliasLanguage(), mapping); + } + + try + { + mapping.Add(np.GetAlias(), np.GetFullName()); + } + catch (Exception) + { + var e = new ApplicationException(string.Format(CultureInfo.CurrentCulture, "Duplicated alias {0} on named parameter {1}.", np.GetAlias(), np.GetFullName())); + Utilities.Diagnostics.Exceptions.Throw(e, LOGGER); + } + } + } + /// <summary> /// Get a Node from the class hierarchy /// </summary> @@ -207,6 +238,40 @@ namespace Org.Apache.REEF.Tang.Implementations.ClassHierarchy } /// <summary> + /// This method get INode from deSerialized class hierarchy by fullName. + /// If the name is not found, it will found alias for aliasLanguage. If alias is found, + /// it will use the alias to do look up again. + /// </summary> + /// <param name="fullName"></param> + /// <param name="aliasLanguage"></param> + /// <returns></returns> + public INode GetNode(string fullName, string aliasLanguage) + { + INode ret = null; + _lookupTable.TryGetValue(fullName, out ret); + if (ret == null) + { + IDictionary<string, string> mapping = null; + string assemblyName = null; + _aliasLookupTable.TryGetValue(aliasLanguage, out mapping); + if (mapping != null) + { + mapping.TryGetValue(fullName, out assemblyName); + if (assemblyName != null) + { + _lookupTable.TryGetValue(assemblyName, out ret); + } + } + if (mapping == null || assemblyName == null || ret == null) + { + var ex = new NameResolutionException(fullName, "Cannot resolve the name from the class hierarchy during de-serialization: " + fullName); + Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); + } + } + return ret; + } + + /// <summary> /// return root node /// </summary> /// <returns></returns> http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/603c7149/lang/cs/Org.Apache.REEF.Tang/Implementations/ClassHierarchy/ClassHierarchyImpl.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Tang/Implementations/ClassHierarchy/ClassHierarchyImpl.cs b/lang/cs/Org.Apache.REEF.Tang/Implementations/ClassHierarchy/ClassHierarchyImpl.cs index 1f320dc..5164b4a 100644 --- a/lang/cs/Org.Apache.REEF.Tang/Implementations/ClassHierarchy/ClassHierarchyImpl.cs +++ b/lang/cs/Org.Apache.REEF.Tang/Implementations/ClassHierarchy/ClassHierarchyImpl.cs @@ -19,6 +19,7 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Reflection; using System.Text; @@ -42,6 +43,10 @@ namespace Org.Apache.REEF.Tang.Implementations.ClassHierarchy private object _mergeLock = new object(); private object _implLock = new object(); + //alias is indexed by language, for each language, a mapping between alias and corresponding name kept in a Dictionary + private readonly IDictionary<string, IDictionary<string, string>> _aliasLookupTable = new Dictionary<string, IDictionary<string, string>>(); + + public ParameterParser Parameterparser = new ParameterParser(); public ClassHierarchyImpl(string file) : this(new string[] { file }, new Type[0]) @@ -246,6 +251,26 @@ namespace Org.Apache.REEF.Tang.Implementations.ClassHierarchy } } + if (!string.IsNullOrEmpty(np.GetAlias())) + { + IDictionary<string, string> mapping = null; + _aliasLookupTable.TryGetValue(np.GetAliasLanguage(), out mapping); + if (null == mapping) + { + mapping= new Dictionary<string, string>(); + _aliasLookupTable.Add(np.GetAliasLanguage(), mapping); + } + try + { + mapping.Add(np.GetAlias(), np.GetFullName()); + } + catch (Exception) + { + var e = new ApplicationException(string.Format(CultureInfo.CurrentCulture, "Duplicated alias {0} on named parameter {1}.", np.GetAlias(), np.GetFullName())); + Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER); + } + } + string shortName = np.GetShortName(); if (shortName != null && !shortName.Equals("")) { @@ -363,6 +388,52 @@ namespace Org.Apache.REEF.Tang.Implementations.ClassHierarchy return this.GetNode(t); } + /// <summary> + /// This method get INode from the class hierarchy by fullName. + /// If the Type for the name is not found in assemblies, it will found alias for aliasLanguage. + /// If alias is found, it will get the Type for the alias then call GetNode(Type). + /// </summary> + /// <param name="fullName"></param> + /// <param name="aliasLanguage"></param> + /// <returns></returns> + public INode GetNode(string fullName, string aliasLanguage) + { + Type t = null; + try + { + t = loader.GetType(fullName); + } + catch (ApplicationException) + { + IDictionary<string, string> mapping = null; + _aliasLookupTable.TryGetValue(aliasLanguage, out mapping); + if (mapping != null) + { + string assemblyName; + mapping.TryGetValue(fullName, out assemblyName); + if (assemblyName != null) + { + t = loader.GetType(assemblyName); + } + else + { + t = null; + } + } + else + { + t = null; + } + } + + if (t == null) + { + Utilities.Diagnostics.Exceptions.Throw(new NameResolutionException(fullName, fullName), LOGGER); + } + + return this.GetNode(t); + } + public INode GetNode(Type type) { lock (_nodeLock) @@ -391,7 +462,7 @@ namespace Org.Apache.REEF.Tang.Implementations.ClassHierarchy if (!(ch is ClassHierarchyImpl)) { - Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(new NotSupportedException("Can't merge java and non-java class hierarchies yet!"), LOGGER); + Utilities.Diagnostics.Exceptions.Throw(new NotSupportedException("Can't merge java and non-java class hierarchies yet!"), LOGGER); } if(this.assemblies.Count == 0) @@ -428,9 +499,9 @@ namespace Org.Apache.REEF.Tang.Implementations.ClassHierarchy } catch(NameResolutionException e) { - Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER); + Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER); var ex = new IllegalStateException("Could not parse validated named parameter argument type. NamedParameter is " + np.GetFullName() + " argument type is " + np.GetFullArgName(), e); - Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); + Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); } Type clazz; string fullName; @@ -472,16 +543,16 @@ namespace Org.Apache.REEF.Tang.Implementations.ClassHierarchy new ParseException( "Name<" + iface.GetFullName() + "> " + np.GetFullName() + " cannot take non-subclass " + impl.GetFullName()); - Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); + Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); } catch (NameResolutionException ec) { - Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Caught(ec, Level.Error, LOGGER); + Utilities.Diagnostics.Exceptions.Caught(ec, Level.Error, LOGGER); var ex = new ParseException( "Name<" + iface.GetFullName() + "> " + np.GetFullName() + " cannot take non-class " + value, ec); - Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); + Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); } } return result; http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/603c7149/lang/cs/Org.Apache.REEF.Tang/Implementations/ClassHierarchy/NamedParameterNodeImpl.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Tang/Implementations/ClassHierarchy/NamedParameterNodeImpl.cs b/lang/cs/Org.Apache.REEF.Tang/Implementations/ClassHierarchy/NamedParameterNodeImpl.cs index d2a52ec..76b10d2 100644 --- a/lang/cs/Org.Apache.REEF.Tang/Implementations/ClassHierarchy/NamedParameterNodeImpl.cs +++ b/lang/cs/Org.Apache.REEF.Tang/Implementations/ClassHierarchy/NamedParameterNodeImpl.cs @@ -18,6 +18,7 @@ */ using System; +using Org.Apache.REEF.Tang.Annotations; using Org.Apache.REEF.Tang.Types; namespace Org.Apache.REEF.Tang.Implementations.ClassHierarchy @@ -31,10 +32,12 @@ namespace Org.Apache.REEF.Tang.Implementations.ClassHierarchy private readonly String[] defaultInstanceAsStrings; private readonly bool isSet; private readonly bool isList; + private readonly string alias; + private readonly string aliasLanguage; public NamedParameterNodeImpl(INode parent, String simpleName, String fullName, String fullArgName, String simpleArgName, bool isSet, bool isList, - String documentation, String shortName, String[] defaultInstanceAsStrings) + String documentation, String shortName, String[] defaultInstanceAsStrings, string alias, string aliasLanguage) : base(parent, simpleName, fullName) { this.fullArgName = fullArgName; @@ -44,6 +47,15 @@ namespace Org.Apache.REEF.Tang.Implementations.ClassHierarchy this.documentation = documentation; this.shortName = shortName; this.defaultInstanceAsStrings = defaultInstanceAsStrings; + this.alias = alias; + this.aliasLanguage = aliasLanguage; + } + + public NamedParameterNodeImpl(INode parent, String simpleName, + String fullName, String fullArgName, String simpleArgName, bool isSet, bool isList, + String documentation, String shortName, String[] defaultInstanceAsStrings) + : this(parent, simpleName, fullName, simpleArgName, simpleArgName, isSet, isList, documentation, shortName, defaultInstanceAsStrings, null, null) + { } public override String ToString() @@ -85,5 +97,15 @@ namespace Org.Apache.REEF.Tang.Implementations.ClassHierarchy { return isList; } + + public string GetAlias() + { + return alias; + } + + public string GetAliasLanguage() + { + return aliasLanguage; + } } } http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/603c7149/lang/cs/Org.Apache.REEF.Tang/Implementations/ClassHierarchy/NodeFactory.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Tang/Implementations/ClassHierarchy/NodeFactory.cs b/lang/cs/Org.Apache.REEF.Tang/Implementations/ClassHierarchy/NodeFactory.cs index 012eed9..5d0b661 100644 --- a/lang/cs/Org.Apache.REEF.Tang/Implementations/ClassHierarchy/NodeFactory.cs +++ b/lang/cs/Org.Apache.REEF.Tang/Implementations/ClassHierarchy/NodeFactory.cs @@ -291,7 +291,7 @@ namespace Org.Apache.REEF.Tang.Implementations.ClassHierarchy } return new NamedParameterNodeImpl(parent, simpleName, fullName, - fullArgName, simpleArgName, isSet, isList, documentation, shortName, defaultInstanceAsStrings); + fullArgName, simpleArgName, isSet, isList, documentation, shortName, defaultInstanceAsStrings, namedParameter.Alias, namedParameter.AliasLanguage); } // private static void assertIsSubclassOf(Class<?> named_parameter, Class<?> default_class, Type argClass) { http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/603c7149/lang/cs/Org.Apache.REEF.Tang/Interface/IClassHierarchy.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Tang/Interface/IClassHierarchy.cs b/lang/cs/Org.Apache.REEF.Tang/Interface/IClassHierarchy.cs index 9eca4f1..f43363c 100644 --- a/lang/cs/Org.Apache.REEF.Tang/Interface/IClassHierarchy.cs +++ b/lang/cs/Org.Apache.REEF.Tang/Interface/IClassHierarchy.cs @@ -17,6 +17,8 @@ * under the License. */ +using System; +using System.Runtime.Remoting.Channels; using Org.Apache.REEF.Tang.Types; namespace Org.Apache.REEF.Tang.Interface @@ -24,6 +26,17 @@ namespace Org.Apache.REEF.Tang.Interface public interface IClassHierarchy { INode GetNode(string fullName); + + /// <summary> + /// This method gets INode from the class hierarchy by fullName. + /// If the name is not found, it will found alias for aliasLanguage. If alias is found, + /// it will use the alias to find Node again. + /// </summary> + /// <param name="fullName"></param> + /// <param name="aliasLanguage"></param> + /// <returns></returns> + INode GetNode(string fullName, string aliasLanguage); + INode GetNamespace(); bool IsImplementation(IClassNode inter, IClassNode impl); IClassHierarchy Merge(IClassHierarchy ch); http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/603c7149/lang/cs/Org.Apache.REEF.Tang/Protobuf/ProtocolBufferClassHierarchy.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Tang/Protobuf/ProtocolBufferClassHierarchy.cs b/lang/cs/Org.Apache.REEF.Tang/Protobuf/ProtocolBufferClassHierarchy.cs index 07acd8f..2c688f5 100644 --- a/lang/cs/Org.Apache.REEF.Tang/Protobuf/ProtocolBufferClassHierarchy.cs +++ b/lang/cs/Org.Apache.REEF.Tang/Protobuf/ProtocolBufferClassHierarchy.cs @@ -19,6 +19,7 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Linq; using Org.Apache.REEF.Tang.Exceptions; @@ -36,6 +37,8 @@ namespace Org.Apache.REEF.Tang.Protobuf private readonly IPackageNode rootNode; private readonly IDictionary<string, INode> lookupTable = new Dictionary<string, INode>(); + private readonly IDictionary<string, IDictionary<string, string>> _aliasLookupTable = new Dictionary<string, IDictionary<string, string>>(); + public static void Serialize(string fileName, IClassHierarchy classHierarchy) { @@ -100,7 +103,7 @@ namespace Org.Apache.REEF.Tang.Protobuf INamedParameterNode np = (INamedParameterNode)n; return NewNamedParameterNode(np.GetName(), np.GetFullName(), np.GetSimpleArgName(), np.GetFullArgName(), np.IsSet(), np.IsList(), np.GetDocumentation(), - np.GetShortName(), np.GetDefaultInstanceAsStrings(), children); + np.GetShortName(), np.GetDefaultInstanceAsStrings(), children, np.GetAlias(), np.GetAliasLanguage()); } if (n is IPackageNode) { @@ -184,7 +187,8 @@ namespace Org.Apache.REEF.Tang.Protobuf bool isSet, bool isList, string documentation, // can be null string shortName, // can be null string[] instanceDefault, // can be null - IList<Org.Apache.REEF.Tang.Protobuf.Node> children) + IList<Org.Apache.REEF.Tang.Protobuf.Node> children, + string alias, string aliasLanguage) { Org.Apache.REEF.Tang.Protobuf.NamedParameterNode namedParameterNode = new Org.Apache.REEF.Tang.Protobuf.NamedParameterNode(); namedParameterNode.simple_arg_class_name = simpleArgClassName; @@ -202,6 +206,16 @@ namespace Org.Apache.REEF.Tang.Protobuf namedParameterNode.short_name = shortName; } + if (alias != null) + { + namedParameterNode.alias_name = alias; + } + + if (aliasLanguage != null) + { + namedParameterNode.alias_language = aliasLanguage; + } + foreach (var id in instanceDefault) { namedParameterNode.instance_default.Add(id); @@ -280,10 +294,37 @@ namespace Org.Apache.REEF.Tang.Protobuf foreach (INode child in n.GetChildren()) { lookupTable.Add(child.GetFullName(), child); + if (child is INamedParameterNode) + { + AddAlias((INamedParameterNode)child); + } BuildHashTable(child); } } + private void AddAlias(INamedParameterNode np) + { + if (np.GetAlias() != null && !np.GetAlias().Equals("")) + { + IDictionary<string, string> mapping = null; + _aliasLookupTable.TryGetValue(np.GetAliasLanguage(), out mapping); + if (mapping == null) + { + mapping = new Dictionary<string, string>(); + _aliasLookupTable.Add(np.GetAliasLanguage(), mapping); + } + try + { + mapping.Add(np.GetAlias(), np.GetFullName()); + } + catch (Exception) + { + var e = new ApplicationException(string.Format(CultureInfo.CurrentCulture, "Duplicated alias {0} on named parameter {1}.", np.GetAlias(), np.GetFullName())); + Utilities.Diagnostics.Exceptions.Throw(e, LOGGER); + } + } + } + private static void ParseSubHierarchy(INode parent, Org.Apache.REEF.Tang.Protobuf.Node n) { INode parsed = null; @@ -294,10 +335,21 @@ namespace Org.Apache.REEF.Tang.Protobuf else if (n.named_parameter_node != null) { Org.Apache.REEF.Tang.Protobuf.NamedParameterNode np = n.named_parameter_node; - parsed = new NamedParameterNodeImpl(parent, n.name, - n.full_name, np.full_arg_class_name, np.simple_arg_class_name, - np.is_set, np.is_list, np.documentation, np.short_name, - np.instance_default.ToArray()); + + if (np.alias_name != null && np.alias_language != null) + { + parsed = new NamedParameterNodeImpl(parent, n.name, + n.full_name, np.full_arg_class_name, np.simple_arg_class_name, + np.is_set, np.is_list, np.documentation, np.short_name, + np.instance_default.ToArray(), np.alias_name, np.alias_language); + } + else + { + parsed = new NamedParameterNodeImpl(parent, n.name, + n.full_name, np.full_arg_class_name, np.simple_arg_class_name, + np.is_set, np.is_list, np.documentation, np.short_name, + np.instance_default.ToArray()); + } } else if (n.class_node != null) { @@ -411,6 +463,40 @@ namespace Org.Apache.REEF.Tang.Protobuf return ret; } + /// <summary> + /// This method get INode from deSerialized class hierarchy by fullName. + /// If the name is not found, it will found alias for aliasLanguage. If alias is found, + /// it will use the alias to do look up again. + /// </summary> + /// <param name="fullName"></param> + /// <param name="aliasLanguage"></param> + /// <returns></returns> + public INode GetNode(string fullName, string aliasLanguage) + { + INode ret = null; + lookupTable.TryGetValue(fullName, out ret); + if (ret == null) + { + IDictionary<string, string> mapping = null; + string assemblyName = null; + _aliasLookupTable.TryGetValue(aliasLanguage, out mapping); + if (mapping != null) + { + mapping.TryGetValue(fullName, out assemblyName); + if (assemblyName != null) + { + lookupTable.TryGetValue(assemblyName, out ret); + } + } + if (mapping == null || assemblyName == null || ret == null) + { + var ex = new NameResolutionException(fullName, "Cannot resolve the name from the class hierarchy during de-serialization: " + fullName); + Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); + } + } + return ret; + } + public INode GetNamespace() { return rootNode; http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/603c7149/lang/cs/Org.Apache.REEF.Tang/Protobuf/class_hierarchy.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Tang/Protobuf/class_hierarchy.cs b/lang/cs/Org.Apache.REEF.Tang/Protobuf/class_hierarchy.cs index adf9982..0e5a33b 100644 --- a/lang/cs/Org.Apache.REEF.Tang/Protobuf/class_hierarchy.cs +++ b/lang/cs/Org.Apache.REEF.Tang/Protobuf/class_hierarchy.cs @@ -29,246 +29,261 @@ // Generated from: class_hierarchy.proto namespace Org.Apache.REEF.Tang.Protobuf { - [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"Node")] - public partial class Node : global::ProtoBuf.IExtensible - { - public Node() {} - - private string _name; - [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"name", DataFormat = global::ProtoBuf.DataFormat.Default)] - public string name + [global::System.Serializable, global::ProtoBuf.ProtoContract(Name = @"Node")] + public partial class Node : global::ProtoBuf.IExtensible { - get { return _name; } - set { _name = value; } - } - private string _full_name; - [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"full_name", DataFormat = global::ProtoBuf.DataFormat.Default)] - public string full_name - { - get { return _full_name; } - set { _full_name = value; } - } - private ClassNode _class_node = null; - [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"class_node", DataFormat = global::ProtoBuf.DataFormat.Default)] - [global::System.ComponentModel.DefaultValue(null)] - public ClassNode class_node - { - get { return _class_node; } - set { _class_node = value; } - } - private NamedParameterNode _named_parameter_node = null; - [global::ProtoBuf.ProtoMember(4, IsRequired = false, Name=@"named_parameter_node", DataFormat = global::ProtoBuf.DataFormat.Default)] - [global::System.ComponentModel.DefaultValue(null)] - public NamedParameterNode named_parameter_node - { - get { return _named_parameter_node; } - set { _named_parameter_node = value; } - } - private PackageNode _package_node = null; - [global::ProtoBuf.ProtoMember(5, IsRequired = false, Name=@"package_node", DataFormat = global::ProtoBuf.DataFormat.Default)] - [global::System.ComponentModel.DefaultValue(null)] - public PackageNode package_node - { - get { return _package_node; } - set { _package_node = value; } - } - private readonly global::System.Collections.Generic.List<Node> _children = new global::System.Collections.Generic.List<Node>(); - [global::ProtoBuf.ProtoMember(6, Name=@"children", DataFormat = global::ProtoBuf.DataFormat.Default)] - public global::System.Collections.Generic.List<Node> children - { - get { return _children; } - } - - private global::ProtoBuf.IExtension extensionObject; - global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) - { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } - } - - [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ClassNode")] - public partial class ClassNode : global::ProtoBuf.IExtensible - { - public ClassNode() {} - - private bool _is_injection_candidate; - [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"is_injection_candidate", DataFormat = global::ProtoBuf.DataFormat.Default)] - public bool is_injection_candidate - { - get { return _is_injection_candidate; } - set { _is_injection_candidate = value; } - } - private bool _is_external_constructor; - [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"is_external_constructor", DataFormat = global::ProtoBuf.DataFormat.Default)] - public bool is_external_constructor - { - get { return _is_external_constructor; } - set { _is_external_constructor = value; } - } - private bool _is_unit; - [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"is_unit", DataFormat = global::ProtoBuf.DataFormat.Default)] - public bool is_unit - { - get { return _is_unit; } - set { _is_unit = value; } - } - private readonly global::System.Collections.Generic.List<ConstructorDef> _InjectableConstructors = new global::System.Collections.Generic.List<ConstructorDef>(); - [global::ProtoBuf.ProtoMember(4, Name=@"InjectableConstructors", DataFormat = global::ProtoBuf.DataFormat.Default)] - public global::System.Collections.Generic.List<ConstructorDef> InjectableConstructors - { - get { return _InjectableConstructors; } - } - - private readonly global::System.Collections.Generic.List<ConstructorDef> _OtherConstructors = new global::System.Collections.Generic.List<ConstructorDef>(); - [global::ProtoBuf.ProtoMember(5, Name=@"OtherConstructors", DataFormat = global::ProtoBuf.DataFormat.Default)] - public global::System.Collections.Generic.List<ConstructorDef> OtherConstructors - { - get { return _OtherConstructors; } - } - - private readonly global::System.Collections.Generic.List<string> _impl_full_names = new global::System.Collections.Generic.List<string>(); - [global::ProtoBuf.ProtoMember(6, Name=@"impl_full_names", DataFormat = global::ProtoBuf.DataFormat.Default)] - public global::System.Collections.Generic.List<string> impl_full_names - { - get { return _impl_full_names; } - } - - private string _default_implementation = ""; - [global::ProtoBuf.ProtoMember(7, IsRequired = false, Name=@"default_implementation", DataFormat = global::ProtoBuf.DataFormat.Default)] - [global::System.ComponentModel.DefaultValue("")] - public string default_implementation - { - get { return _default_implementation; } - set { _default_implementation = value; } - } - private global::ProtoBuf.IExtension extensionObject; - global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) - { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } - } - - [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"NamedParameterNode")] - public partial class NamedParameterNode : global::ProtoBuf.IExtensible - { - public NamedParameterNode() {} - - private string _simple_arg_class_name; - [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"simple_arg_class_name", DataFormat = global::ProtoBuf.DataFormat.Default)] - public string simple_arg_class_name - { - get { return _simple_arg_class_name; } - set { _simple_arg_class_name = value; } - } - private string _full_arg_class_name; - [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"full_arg_class_name", DataFormat = global::ProtoBuf.DataFormat.Default)] - public string full_arg_class_name - { - get { return _full_arg_class_name; } - set { _full_arg_class_name = value; } - } - private bool _is_set; - [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"is_set", DataFormat = global::ProtoBuf.DataFormat.Default)] - public bool is_set - { - get { return _is_set; } - set { _is_set = value; } - } - private bool _is_list; - [global::ProtoBuf.ProtoMember(4, IsRequired = true, Name=@"is_list", DataFormat = global::ProtoBuf.DataFormat.Default)] - public bool is_list - { - get { return _is_list; } - set { _is_list = value; } - } - private string _documentation = ""; - [global::ProtoBuf.ProtoMember(5, IsRequired = false, Name=@"documentation", DataFormat = global::ProtoBuf.DataFormat.Default)] - [global::System.ComponentModel.DefaultValue("")] - public string documentation - { - get { return _documentation; } - set { _documentation = value; } - } - private string _short_name = ""; - [global::ProtoBuf.ProtoMember(6, IsRequired = false, Name=@"short_name", DataFormat = global::ProtoBuf.DataFormat.Default)] - [global::System.ComponentModel.DefaultValue("")] - public string short_name - { - get { return _short_name; } - set { _short_name = value; } - } - private readonly global::System.Collections.Generic.List<string> _instance_default = new global::System.Collections.Generic.List<string>(); - [global::ProtoBuf.ProtoMember(7, Name=@"instance_default", DataFormat = global::ProtoBuf.DataFormat.Default)] - public global::System.Collections.Generic.List<string> instance_default - { - get { return _instance_default; } + public Node() { } + + private string _name; + [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name = @"name", DataFormat = global::ProtoBuf.DataFormat.Default)] + public string name + { + get { return _name; } + set { _name = value; } + } + private string _full_name; + [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name = @"full_name", DataFormat = global::ProtoBuf.DataFormat.Default)] + public string full_name + { + get { return _full_name; } + set { _full_name = value; } + } + private ClassNode _class_node = null; + [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name = @"class_node", DataFormat = global::ProtoBuf.DataFormat.Default)] + [global::System.ComponentModel.DefaultValue(null)] + public ClassNode class_node + { + get { return _class_node; } + set { _class_node = value; } + } + private NamedParameterNode _named_parameter_node = null; + [global::ProtoBuf.ProtoMember(4, IsRequired = false, Name = @"named_parameter_node", DataFormat = global::ProtoBuf.DataFormat.Default)] + [global::System.ComponentModel.DefaultValue(null)] + public NamedParameterNode named_parameter_node + { + get { return _named_parameter_node; } + set { _named_parameter_node = value; } + } + private PackageNode _package_node = null; + [global::ProtoBuf.ProtoMember(5, IsRequired = false, Name = @"package_node", DataFormat = global::ProtoBuf.DataFormat.Default)] + [global::System.ComponentModel.DefaultValue(null)] + public PackageNode package_node + { + get { return _package_node; } + set { _package_node = value; } + } + private readonly global::System.Collections.Generic.List<Node> _children = new global::System.Collections.Generic.List<Node>(); + [global::ProtoBuf.ProtoMember(6, Name = @"children", DataFormat = global::ProtoBuf.DataFormat.Default)] + public global::System.Collections.Generic.List<Node> children + { + get { return _children; } + } + + private global::ProtoBuf.IExtension extensionObject; + global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) + { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } } - - private global::ProtoBuf.IExtension extensionObject; - global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) - { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } - } - - [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"PackageNode")] - public partial class PackageNode : global::ProtoBuf.IExtensible - { - public PackageNode() {} - - private global::ProtoBuf.IExtension extensionObject; - global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) - { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } - } - - [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ConstructorDef")] - public partial class ConstructorDef : global::ProtoBuf.IExtensible - { - public ConstructorDef() {} - - private string _full_class_name; - [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"full_class_name", DataFormat = global::ProtoBuf.DataFormat.Default)] - public string full_class_name + + [global::System.Serializable, global::ProtoBuf.ProtoContract(Name = @"ClassNode")] + public partial class ClassNode : global::ProtoBuf.IExtensible { - get { return _full_class_name; } - set { _full_class_name = value; } + public ClassNode() { } + + private bool _is_injection_candidate; + [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name = @"is_injection_candidate", DataFormat = global::ProtoBuf.DataFormat.Default)] + public bool is_injection_candidate + { + get { return _is_injection_candidate; } + set { _is_injection_candidate = value; } + } + private bool _is_external_constructor; + [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name = @"is_external_constructor", DataFormat = global::ProtoBuf.DataFormat.Default)] + public bool is_external_constructor + { + get { return _is_external_constructor; } + set { _is_external_constructor = value; } + } + private bool _is_unit; + [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name = @"is_unit", DataFormat = global::ProtoBuf.DataFormat.Default)] + public bool is_unit + { + get { return _is_unit; } + set { _is_unit = value; } + } + private readonly global::System.Collections.Generic.List<ConstructorDef> _InjectableConstructors = new global::System.Collections.Generic.List<ConstructorDef>(); + [global::ProtoBuf.ProtoMember(4, Name = @"InjectableConstructors", DataFormat = global::ProtoBuf.DataFormat.Default)] + public global::System.Collections.Generic.List<ConstructorDef> InjectableConstructors + { + get { return _InjectableConstructors; } + } + + private readonly global::System.Collections.Generic.List<ConstructorDef> _OtherConstructors = new global::System.Collections.Generic.List<ConstructorDef>(); + [global::ProtoBuf.ProtoMember(5, Name = @"OtherConstructors", DataFormat = global::ProtoBuf.DataFormat.Default)] + public global::System.Collections.Generic.List<ConstructorDef> OtherConstructors + { + get { return _OtherConstructors; } + } + + private readonly global::System.Collections.Generic.List<string> _impl_full_names = new global::System.Collections.Generic.List<string>(); + [global::ProtoBuf.ProtoMember(6, Name = @"impl_full_names", DataFormat = global::ProtoBuf.DataFormat.Default)] + public global::System.Collections.Generic.List<string> impl_full_names + { + get { return _impl_full_names; } + } + + private string _default_implementation = ""; + [global::ProtoBuf.ProtoMember(7, IsRequired = false, Name = @"default_implementation", DataFormat = global::ProtoBuf.DataFormat.Default)] + [global::System.ComponentModel.DefaultValue("")] + public string default_implementation + { + get { return _default_implementation; } + set { _default_implementation = value; } + } + private global::ProtoBuf.IExtension extensionObject; + global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) + { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } } - private readonly global::System.Collections.Generic.List<ConstructorArg> _args = new global::System.Collections.Generic.List<ConstructorArg>(); - [global::ProtoBuf.ProtoMember(2, Name=@"args", DataFormat = global::ProtoBuf.DataFormat.Default)] - public global::System.Collections.Generic.List<ConstructorArg> args + + [global::System.Serializable, global::ProtoBuf.ProtoContract(Name = @"NamedParameterNode")] + public partial class NamedParameterNode : global::ProtoBuf.IExtensible { - get { return _args; } + public NamedParameterNode() { } + + private string _simple_arg_class_name; + [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name = @"simple_arg_class_name", DataFormat = global::ProtoBuf.DataFormat.Default)] + public string simple_arg_class_name + { + get { return _simple_arg_class_name; } + set { _simple_arg_class_name = value; } + } + private string _full_arg_class_name; + [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name = @"full_arg_class_name", DataFormat = global::ProtoBuf.DataFormat.Default)] + public string full_arg_class_name + { + get { return _full_arg_class_name; } + set { _full_arg_class_name = value; } + } + private bool _is_set; + [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name = @"is_set", DataFormat = global::ProtoBuf.DataFormat.Default)] + public bool is_set + { + get { return _is_set; } + set { _is_set = value; } + } + private bool _is_list; + [global::ProtoBuf.ProtoMember(4, IsRequired = true, Name = @"is_list", DataFormat = global::ProtoBuf.DataFormat.Default)] + public bool is_list + { + get { return _is_list; } + set { _is_list = value; } + } + private string _documentation = ""; + [global::ProtoBuf.ProtoMember(5, IsRequired = false, Name = @"documentation", DataFormat = global::ProtoBuf.DataFormat.Default)] + [global::System.ComponentModel.DefaultValue("")] + public string documentation + { + get { return _documentation; } + set { _documentation = value; } + } + private string _short_name = ""; + [global::ProtoBuf.ProtoMember(6, IsRequired = false, Name = @"short_name", DataFormat = global::ProtoBuf.DataFormat.Default)] + [global::System.ComponentModel.DefaultValue("")] + public string short_name + { + get { return _short_name; } + set { _short_name = value; } + } + private readonly global::System.Collections.Generic.List<string> _instance_default = new global::System.Collections.Generic.List<string>(); + [global::ProtoBuf.ProtoMember(7, Name = @"instance_default", DataFormat = global::ProtoBuf.DataFormat.Default)] + public global::System.Collections.Generic.List<string> instance_default + { + get { return _instance_default; } + } + + private string _alias_name = ""; + [global::ProtoBuf.ProtoMember(8, IsRequired = false, Name = @"alias_name", DataFormat = global::ProtoBuf.DataFormat.Default)] + [global::System.ComponentModel.DefaultValue("")] + public string alias_name + { + get { return _alias_name; } + set { _alias_name = value; } + } + private string _alias_language = ""; + [global::ProtoBuf.ProtoMember(9, IsRequired = false, Name = @"alias_language", DataFormat = global::ProtoBuf.DataFormat.Default)] + [global::System.ComponentModel.DefaultValue("")] + public string alias_language + { + get { return _alias_language; } + set { _alias_language = value; } + } + private global::ProtoBuf.IExtension extensionObject; + global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) + { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } } - - private global::ProtoBuf.IExtension extensionObject; - global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) - { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } - } - - [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ConstructorArg")] - public partial class ConstructorArg : global::ProtoBuf.IExtensible - { - public ConstructorArg() {} - - private string _full_arg_class_name; - [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"full_arg_class_name", DataFormat = global::ProtoBuf.DataFormat.Default)] - public string full_arg_class_name + + [global::System.Serializable, global::ProtoBuf.ProtoContract(Name = @"PackageNode")] + public partial class PackageNode : global::ProtoBuf.IExtensible { - get { return _full_arg_class_name; } - set { _full_arg_class_name = value; } + public PackageNode() { } + + private global::ProtoBuf.IExtension extensionObject; + global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) + { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } } - private string _named_parameter_name = ""; - [global::ProtoBuf.ProtoMember(2, IsRequired = false, Name=@"named_parameter_name", DataFormat = global::ProtoBuf.DataFormat.Default)] - [global::System.ComponentModel.DefaultValue("")] - public string named_parameter_name + + [global::System.Serializable, global::ProtoBuf.ProtoContract(Name = @"ConstructorDef")] + public partial class ConstructorDef : global::ProtoBuf.IExtensible { - get { return _named_parameter_name; } - set { _named_parameter_name = value; } + public ConstructorDef() { } + + private string _full_class_name; + [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name = @"full_class_name", DataFormat = global::ProtoBuf.DataFormat.Default)] + public string full_class_name + { + get { return _full_class_name; } + set { _full_class_name = value; } + } + private readonly global::System.Collections.Generic.List<ConstructorArg> _args = new global::System.Collections.Generic.List<ConstructorArg>(); + [global::ProtoBuf.ProtoMember(2, Name = @"args", DataFormat = global::ProtoBuf.DataFormat.Default)] + public global::System.Collections.Generic.List<ConstructorArg> args + { + get { return _args; } + } + + private global::ProtoBuf.IExtension extensionObject; + global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) + { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } } - private bool _is_injection_future; - [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"is_injection_future", DataFormat = global::ProtoBuf.DataFormat.Default)] - public bool is_injection_future + + [global::System.Serializable, global::ProtoBuf.ProtoContract(Name = @"ConstructorArg")] + public partial class ConstructorArg : global::ProtoBuf.IExtensible { - get { return _is_injection_future; } - set { _is_injection_future = value; } + public ConstructorArg() { } + + private string _full_arg_class_name; + [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name = @"full_arg_class_name", DataFormat = global::ProtoBuf.DataFormat.Default)] + public string full_arg_class_name + { + get { return _full_arg_class_name; } + set { _full_arg_class_name = value; } + } + private string _named_parameter_name = ""; + [global::ProtoBuf.ProtoMember(2, IsRequired = false, Name = @"named_parameter_name", DataFormat = global::ProtoBuf.DataFormat.Default)] + [global::System.ComponentModel.DefaultValue("")] + public string named_parameter_name + { + get { return _named_parameter_name; } + set { _named_parameter_name = value; } + } + private bool _is_injection_future; + [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name = @"is_injection_future", DataFormat = global::ProtoBuf.DataFormat.Default)] + public bool is_injection_future + { + get { return _is_injection_future; } + set { _is_injection_future = value; } + } + private global::ProtoBuf.IExtension extensionObject; + global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) + { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } } - private global::ProtoBuf.IExtension extensionObject; - global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) - { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } - } - } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/603c7149/lang/cs/Org.Apache.REEF.Tang/Types/INamedParameterNode.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Tang/Types/INamedParameterNode.cs b/lang/cs/Org.Apache.REEF.Tang/Types/INamedParameterNode.cs index cf4aa02..442fd6c 100644 --- a/lang/cs/Org.Apache.REEF.Tang/Types/INamedParameterNode.cs +++ b/lang/cs/Org.Apache.REEF.Tang/Types/INamedParameterNode.cs @@ -16,7 +16,9 @@ * specific language governing permissions and limitations * under the License. */ - + +using Org.Apache.REEF.Tang.Annotations; + namespace Org.Apache.REEF.Tang.Types { public interface INamedParameterNode : INode @@ -34,5 +36,19 @@ namespace Org.Apache.REEF.Tang.Types bool IsSet(); bool IsList(); + + /// <summary> + /// It returns an alias of the NamedParameter + /// The alias is defined as an attribute of the NamedParameter + /// </summary> + /// <returns></returns> + string GetAlias(); + + /// <summary> + /// It returns the programming language for the alias + /// Examples are "Java", "Cs" + /// </summary> + /// <returns></returns> + string GetAliasLanguage(); } } http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/603c7149/lang/java/reef-tang/tang/src/main/proto/class_hierarchy.proto ---------------------------------------------------------------------- diff --git a/lang/java/reef-tang/tang/src/main/proto/class_hierarchy.proto b/lang/java/reef-tang/tang/src/main/proto/class_hierarchy.proto index dc6a9e9..0bcb1cf 100644 --- a/lang/java/reef-tang/tang/src/main/proto/class_hierarchy.proto +++ b/lang/java/reef-tang/tang/src/main/proto/class_hierarchy.proto @@ -137,6 +137,14 @@ message NamedParameterNode { */ // calling this "default_instance" breaks protoc. repeated string instance_default = 7; + /* + An alias of the named parameter + */ + optional string alias_name = 8; + /* + An alias language of the named parameter + */ + optional string alias_language = 9; } message PackageNode {
