public ConfigurationModuleBuilder BindImplementation <T>(GenericType <T> iface, string impl) { ConfigurationModuleBuilder c = DeepCopy(); c.lateBindClazz.Add(typeof(T), impl); return(c); }
public ConfigurationModuleBuilder BindList <U, T>(GenericType <U> iface, IImpl <IList <T> > opt) where U : Name <IList <T> > { ConfigurationModuleBuilder c = DeepCopy(); Type ifaceType = typeof(U); c.ProcessUse(opt); c.FreeImpls.Add(ifaceType, opt); return(c); }
public ConfigurationModuleBuilder BindImplementation <U, T>(GenericType <T> iface, IImpl <U> opt) where U : T { ConfigurationModuleBuilder c = DeepCopy(); c.ProcessUse(opt); Type ifaceType = typeof(T); c.FreeImpls.Add(ifaceType, opt); return(c); }
public ConfigurationModuleBuilder BindNamedParameter <U, T>(GenericType <U> name, IParam <T> opt) where U : Name <T> { ConfigurationModuleBuilder c = DeepCopy(); c.ProcessUse(opt); Type nameType = typeof(U); c.FreeParams.Add(nameType, opt); return(c); }
// public final <T> ConfigurationModuleBuilder bindNamedParameter(Class<? extends Name<T>> iface, Impl<? extends T> opt) // if ValueType is T, you would better to use public ConfigurationModuleBuilder BindNamedParameter<U, T>(GenericType<U> iface, IImpl<T> opt) public ConfigurationModuleBuilder BindNamedParameter <U, V, T>(GenericType <U> iface, IImpl <V> opt) where U : Name <T> where V : T { ConfigurationModuleBuilder c = DeepCopy(); c.ProcessUse(opt); Type ifaceType = typeof(U); c.FreeImpls.Add(ifaceType, opt); return(c); }
public ConfigurationModuleBuilder BindConstructor <T, U>(GenericType <T> cons, IImpl <U> v) where U : IExternalConstructor <T> { ConfigurationModuleBuilder c = DeepCopy(); c.ProcessUse(v); Type consType = typeof(T); var i = (IImpl <object>)v; c.FreeImpls.Add(consType, i); return(c); }
public ConfigurationModuleBuilder BindSetEntry <U, T>(GenericType <U> iface, IParam <T> opt) where U : Name <ISet <T> > { ConfigurationModuleBuilder c = DeepCopy(); Type ifaceType = typeof(U); c.ProcessUse(opt); c.FreeParams.Add(ifaceType, opt); if (!SetOpts.Contains(opt)) { c.SetOpts.Add(opt); } return(c); }
public ConfigurationModuleBuilder BindImplementation <U, T>(GenericType <U> iface, GenericType <T> impl) where T : U { ConfigurationModuleBuilder c = DeepCopy(); try { c.B.BindImplementation(iface, impl); } catch (BindException e) { Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER); Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(new ClassHierarchyException("Error in BindImplementation: ", e), LOGGER); } return(c); }
public ConfigurationModuleBuilder BindList <U, T>(GenericType <U> iface, IList <string> impl) where U : Name <IList <T> > { ConfigurationModuleBuilder c = DeepCopy(); try { ICsInternalConfigurationBuilder b = (ICsInternalConfigurationBuilder)c.B; b.BindList(typeof(U), impl); } catch (BindException ex) { Utilities.Diagnostics.Exceptions.CaughtAndThrow(new ClassHierarchyException("Error in BindList: " + ex), Level.Error, LOGGER); } return(c); }
public ConfigurationModuleBuilder BindNamedParameter <U, T>(GenericType <U> iface, GenericType <T> impl) where U : Name <T> { ConfigurationModuleBuilder c = DeepCopy(); try { c.B.BindNamedParameter <U, T, T>(iface, impl); } catch (BindException e) { Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER); Utilities.Diagnostics.Exceptions.Throw(new ClassHierarchyException("Error in BindNamedParameter: ", e), LOGGER); } return(c); }
public ConfigurationModuleBuilder BindConstructor <T, U>(GenericType <T> clazz, GenericType <U> constructor) where U : IExternalConstructor <T> { ConfigurationModuleBuilder c = DeepCopy(); try { c.B.BindConstructor <T, U>(clazz, constructor); } catch (BindException e) { Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER); Utilities.Diagnostics.Exceptions.Throw(new ClassHierarchyException("Error in BindConstructor: ", e), LOGGER); } return(c); }
public ConfigurationModuleBuilder BindNamedParameter <U, T>(GenericType <U> name, string value) where U : Name <T> { ConfigurationModuleBuilder c = DeepCopy(); try { c.B.BindNamedParameter <U, T>(name, value); } catch (BindException e) { Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER); Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(new ClassHierarchyException("Error in BindNamedParameter: ", e), LOGGER); } return(c); }
public ConfigurationModule Build() { ConfigurationModuleBuilder c = DeepCopy(); if (!(c.reqUsed.ContainsAll(c.ReqDecl) && c.optUsed.ContainsAll(c.OptDecl))) { ISet <FieldInfo> fset = new MonotonicHashSet <FieldInfo>(); foreach (FieldInfo f in c.ReqDecl) { if (!c.reqUsed.Contains(f)) { fset.Add(f); } } foreach (FieldInfo f in c.OptDecl) { if (!c.optUsed.Contains(f)) { fset.Add(f); } } var e = new ClassHierarchyException( "Found declared options that were not used in binds: " + ToString(fset)); Utilities.Diagnostics.Exceptions.Throw(e, LOGGER); } foreach (Type clz in c.lateBindClazz.Keys) { try { c.B.Bind(ReflectionUtilities.GetAssemblyQualifiedName(clz), c.lateBindClazz.Get(clz)); } catch (NameResolutionException e) { Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER); var ex = new ClassHierarchyException("ConfigurationModule refers to unknown class: " + c.lateBindClazz.Get(clz), e); Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); } catch (BindException e) { Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER); var ex = new ClassHierarchyException("bind failed while initializing ConfigurationModuleBuilder", e); Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); } } return(new ConfigurationModule(c)); }
public ConfigurationModuleBuilder BindSetEntry <U, T>(GenericType <U> iface, string impl) where U : Name <ISet <T> > { ConfigurationModuleBuilder c = DeepCopy(); try { ICsInternalConfigurationBuilder b = (ICsInternalConfigurationBuilder)c.B; b.BindSetEntry(typeof(U), impl); } catch (BindException ex) { Utilities.Diagnostics.Exceptions.Caught(ex, Level.Error, LOGGER); var e = new ClassHierarchyException("Error in BindSetEntry: " + ex); Utilities.Diagnostics.Exceptions.Throw(e, LOGGER); } return(c); }
public ConfigurationModuleBuilder BindSetEntry <U, V, T>(GenericType <U> iface, GenericType <V> impl) where U : Name <ISet <T> > where V : T { ConfigurationModuleBuilder c = DeepCopy(); try { c.B.BindSetEntry <U, V, T>(iface, impl); } catch (BindException ex) { Utilities.Diagnostics.Exceptions.Caught(ex, Level.Error, LOGGER); var e = new ClassHierarchyException("Error in BindSetEntry: " + ex); Utilities.Diagnostics.Exceptions.Throw(e, LOGGER); } return(c); }
public ConfigurationModuleBuilder Merge(ConfigurationModule d) { if (d == null) { var e = new NullReferenceException("If merge() was passed a static final field that is initialized to non-null, then this is almost certainly caused by a circular class dependency."); Utilities.Diagnostics.Exceptions.Throw(e, LOGGER); } try { d.AssertStaticClean(); } catch (ClassHierarchyException ex) { Utilities.Diagnostics.Exceptions.Caught(ex, Level.Error, LOGGER); var e = new ClassHierarchyException(ReflectionUtilities.GetAssemblyQualifiedName(GetType()) + ": detected attempt to merge with ConfigurationModule that has had set() called on it", ex); Utilities.Diagnostics.Exceptions.Throw(e, LOGGER); } ConfigurationModuleBuilder c = DeepCopy(); try { c.B.AddConfiguration(d.Builder.B.Build()); } catch (BindException ex) { Utilities.Diagnostics.Exceptions.Caught(ex, Level.Error, LOGGER); var e = new ClassHierarchyException("Error in AddConfiguration in Merge: " + ex); Utilities.Diagnostics.Exceptions.Throw(e, LOGGER); } c.ReqDecl.AddAll(d.Builder.ReqDecl); c.OptDecl.AddAll(d.Builder.OptDecl); c.reqUsed.AddAll(d.Builder.reqUsed); c.optUsed.AddAll(d.Builder.optUsed); c.SetOpts.AddAll(d.Builder.SetOpts); //// c.ListOpts.AddAll(d.Builder.ListOpts); c.Map.AddAll(d.Builder.Map); c.FreeImpls.AddAll(d.Builder.FreeImpls); c.FreeParams.AddAll(d.Builder.FreeParams); c.lateBindClazz.AddAll(d.Builder.lateBindClazz); return(c); }
private ConfigurationModuleBuilder(ConfigurationModuleBuilder c) { try { B.AddConfiguration(c.B.Build()); } catch (BindException e) { Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER); var ex = new ClassHierarchyException("Build error in ConfigurationModuleBuilder: " + e); Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); } ReqDecl.UnionWith(c.ReqDecl); OptDecl.UnionWith(c.OptDecl); reqUsed.UnionWith(c.reqUsed); optUsed.UnionWith(c.optUsed); SetOpts.UnionWith(c.SetOpts); Map.AddAll(c.Map); FreeImpls.AddAll(c.FreeImpls); FreeParams.AddAll(c.FreeParams); lateBindClazz.AddAll(c.lateBindClazz); }
public ConfigurationModule(ConfigurationModuleBuilder builder) { this.Builder = builder.DeepCopy(); }