// TODO // public <T, U extends T> void AddParser(Class<U> clazz, Class<? extends ExternalConstructor<T>> ec) throws BindException { // public void AddParser<T, U, V>(GenericType<U> clazz, GenericType<V> ec) // where U : T // where V: IExternalConstructor<T> // { // clazz: A, ec: ACons private void AddParser(Type clazz, Type ec) { ConstructorInfo c = ec.GetConstructor(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, new Type[] { typeof(string) }, null); if (c == null) { var e = new BindException("Constructor " + ReflectionUtilities.GetAssemblyQualifiedName(ec) + "(String) does not exist!"); Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER); } // c.setAccessible(true); // set as public parsers.Add(ReflectionUtilities.GetAssemblyQualifiedName(clazz), c); }
public static void ProcessConfigData(IConfigurationBuilder conf, IList<KeyValuePair<string, string>> settings) { foreach (KeyValuePair<string, string> kv in settings) { try { conf.Bind(kv.Key, kv.Value); } catch (BindException ex) { Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Caught(ex, Level.Error, LOGGER); var e = new BindException("Failed to process configuration tuple: [" + kv.Key + "=" + kv.Value + "]", ex); Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER); } catch (ClassHierarchyException ex) { Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Caught(ex, Level.Error, LOGGER); var e = new ClassHierarchyException("Failed to process configuration tuple: [" + kv.Key + "=" + kv.Value + "]", ex); Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER); } } }
public IConstructorDef GetConstructorDef(IList<IClassNode> paramTypes) { if (!IsInjectionCandidate()) { var e = new BindException("Cannot @Inject non-static member/local class: " + GetFullName()); Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER); } foreach (IConstructorDef c in GetAllConstructors()) { if (c.TakesParameters(paramTypes)) { return c; } } Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(new BindException("Could not find requested constructor for class " + GetFullName()), LOGGER); return null; // this line would not be reached as Thrwo throws an exception }