public ConfigurationBuilderImpl(ConfigurationBuilderImpl t) { this.ClassHierarchy = t.GetClassHierarchy(); try { AddConfiguration(t.GetClassHierarchy(), t); } catch (BindException e) { Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER); Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException("Could not copy builder", e), LOGGER); } }
public ConfigurationImpl(ConfigurationBuilderImpl builder) { Builder = builder; }
private void AddConfiguration(IClassHierarchy ns, ConfigurationBuilderImpl builder) { this.ClassHierarchy = this.ClassHierarchy.Merge(ns); if (ClassHierarchy is ClassHierarchyImpl || builder.ClassHierarchy is ClassHierarchyImpl) { if (ClassHierarchy is ClassHierarchyImpl && builder.ClassHierarchy is ClassHierarchyImpl) { ((ClassHierarchyImpl)ClassHierarchy).Parameterparser.MergeIn(((ClassHierarchyImpl)builder.ClassHierarchy).Parameterparser); } else { Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(new ArgumentException("Attempt to merge Java and non-Java class hierarchy! Not supported."), LOGGER); } } foreach (IClassNode cn in builder.BoundImpls.Keys) { IClassNode n = null; builder.BoundImpls.TryGetValue(cn, out n); if (n != null) { Bind(cn.GetFullName(), n.GetFullName()); } } foreach (IClassNode cn in builder.BoundConstructors.Keys) { IClassNode n = null; builder.BoundConstructors.TryGetValue(cn, out n); if (n != null) { Bind(cn.GetFullName(), n.GetFullName()); } } // The namedParameters set contains the strings that can be used to // instantiate new // named parameter instances. Create new ones where we can. foreach (INamedParameterNode np in builder.NamedParameters.Keys) { string v = null; builder.NamedParameters.TryGetValue(np, out v); Bind(np.GetFullName(), v); } foreach (IClassNode cn in builder.LegacyConstructors.Keys) { IConstructorDef cd = null; builder.LegacyConstructors.TryGetValue(cn, out cd); RegisterLegacyConstructor(cn, cd.GetArgs()); } foreach (KeyValuePair<INamedParameterNode, object> e in builder.BoundSetEntries) { string name = ((INamedParameterNode)e.Key).GetFullName(); if (e.Value is INode) { BindSetEntry(name, (INode)e.Value); } else if (e.Value is string) { BindSetEntry(name, (string)e.Value); } else { var ex = new IllegalStateException(string.Format(CultureInfo.CurrentCulture, "The value {0} set to the named parameter {1} is illegel.", e.Value, name)); Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); } } foreach (var p in builder.BoundLists) { BoundLists.Add(p.Key, p.Value); } }
private void AddConfiguration(IClassHierarchy ns, ConfigurationBuilderImpl builder) { this.ClassHierarchy = this.ClassHierarchy.Merge(ns); if (ClassHierarchy is ClassHierarchyImpl || builder.ClassHierarchy is ClassHierarchyImpl) { if (ClassHierarchy is ClassHierarchyImpl && builder.ClassHierarchy is ClassHierarchyImpl) { ((ClassHierarchyImpl)ClassHierarchy).Parameterparser.MergeIn(((ClassHierarchyImpl)builder.ClassHierarchy).Parameterparser); } else { Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(new ArgumentException("Attempt to merge Java and non-Java class hierarchy! Not supported."), LOGGER); } } foreach (IClassNode cn in builder.BoundImpls.Keys) { IClassNode n = null; builder.BoundImpls.TryGetValue(cn, out n); if (n != null) { Bind(cn.GetFullName(), n.GetFullName()); } } foreach (IClassNode cn in builder.BoundConstructors.Keys) { IClassNode n = null; builder.BoundConstructors.TryGetValue(cn, out n); if (n != null) { Bind(cn.GetFullName(), n.GetFullName()); } } // The namedParameters set contains the strings that can be used to // instantiate new // named parameter instances. Create new ones where we can. foreach (INamedParameterNode np in builder.NamedParameters.Keys) { string v = null; builder.NamedParameters.TryGetValue(np, out v); Bind(np.GetFullName(), v); } foreach (IClassNode cn in builder.LegacyConstructors.Keys) { IConstructorDef cd = null; builder.LegacyConstructors.TryGetValue(cn, out cd); RegisterLegacyConstructor(cn, cd.GetArgs()); } foreach (KeyValuePair <INamedParameterNode, object> e in builder.BoundSetEntries) { string name = ((INamedParameterNode)e.Key).GetFullName(); if (e.Value is INode) { BindSetEntry(name, (INode)e.Value); } else if (e.Value is string) { BindSetEntry(name, (string)e.Value); } else { var ex = new IllegalStateException(string.Format(CultureInfo.CurrentCulture, "The value {0} set to the named parameter {1} is illegel.", e.Value, name)); Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); } } foreach (var p in builder.BoundLists) { BoundLists.Add(p.Key, p.Value); } }