public static boolean hasExplicitBindingFor(Injector injector, Class<?> type) { Key<?> key = Key.get(type); Injector target = injector; do { if (target.getBindings().containsKey(key)) { return true; } target = target.getParent(); } while (target != null); return false; }
@Override public Set<Key<?>> getRootKeys(Injector injector) { Set<Key<?>> root = Sets.newHashSet(); for (Key<?> key : injector.getBindings().keySet()) { if (key.getTypeLiteral().getRawType().getPackage() != Guice.class.getPackage() && !loggerKey.equals(key)) { root.add(key); } } return root; }
@SuppressWarnings("unchecked") @Inject void initialize(Injector inj) { for (Key<?> k : inj.getBindings().keySet()) { if (k.getTypeLiteral().getRawType().isAssignableFrom(Operator.class)) { Key<? extends Operator<?>> key = (Key<? extends Operator<?>>) k; log.debug("registering operator " + key); // registerOperator(inj.getInstance(ko)); } if (k.getTypeLiteral().getRawType().isAssignableFrom(OperatorFactory.class)) { Key<? extends OperatorFactory> key = (Key<OperatorFactory>) k; ParameterizedType type = (ParameterizedType) key.getTypeLiteral().getType(); log.debug("got operator with {} on {}.", key, type); if (Layer.class.isAssignableFrom((Class<?>) type.getActualTypeArguments()[0])) { log.debug("registering layer operator {}.", key); layOpFac.add(inj.getInstance(key)); } if (Entity.class.isAssignableFrom((Class<?>) type.getActualTypeArguments()[0])) { log.debug("registering entity operator {}.", key); entOpFac.add(inj.getInstance(key)); } } } }