private Predicate<Injectable> reachabilityRootPredicate(final ReachabilityStrategy strategy) { switch (strategy) { case All: return inj -> true; case Annotated: return inj -> !inj.getWiringElementTypes().contains(WiringElementType.Simpleton); case Aggressive: return inj -> EntryPoint.class.equals(inj.getScope()) || inj.getWiringElementTypes().contains(WiringElementType.JsType); default: throw new RuntimeException("Unrecognized reachability strategy, " + strategy.toString()); } }
private void registerFactoryWithContext(final Injectable injectable, final MetaClass factoryClass, final Map<Class<? extends Annotation>, MetaClass> scopeContexts, @SuppressWarnings("rawtypes") final BlockBuilder registerFactoriesBody) { final Class<? extends Annotation> scope = injectable.getScope(); final MetaClass injectedType = injectable.getInjectedType(); final MetaClass scopeContextImpl = Assert.notNull("No scope context for " + scope.getSimpleName(), scopeContexts.get(scope)); final String contextVarName = getContextVarName(scopeContextImpl); registerFactoriesBody.append(loadVariable(contextVarName).invoke("registerFactory", Stmt.castTo(parameterizedAs(Factory.class, typeParametersOf(injectedType)), invokeStatic(GWT.class, "create", factoryClass)))); }
protected Statement generateFactoryHandleStatement(final Injectable injectable) { final Statement newObject; if (injectable.getInjectedType().isAnnotationPresent(ActivatedBy.class)) { final Class<? extends BeanActivator> activatorType = injectable.getInjectedType().getAnnotation(ActivatedBy.class).value(); newObject = newObject(FactoryHandleImpl.class, loadLiteral(injectable.getInjectedType()), injectable.getFactoryName(), injectable.getScope(), isEager(injectable.getInjectedType()), injectable.getBeanName(), !injectable.isContextual(), loadLiteral(activatorType)); } else { newObject = newObject(FactoryHandleImpl.class, loadLiteral(injectable.getInjectedType()), injectable.getFactoryName(), injectable.getScope(), isEager(injectable.getInjectedType()), injectable.getBeanName(), !injectable.isContextual()); } return newObject; }
@Override protected Statement generateFactoryHandleStatement(final Injectable injectable) { final Object[] args; if (injectable.getInjectedType().isAnnotationPresent(ActivatedBy.class)) { final Class<? extends BeanActivator> activatorType = injectable.getInjectedType().getAnnotation(ActivatedBy.class).value(); args = new Object[] { loadLiteral(injectable.getInjectedType()), injectable.getFactoryName(), injectable.getScope(), isEager(injectable.getInjectedType()), injectable.getBeanName(), loadLiteral(false), loadLiteral(activatorType) }; } else { args = new Object[] { loadLiteral(injectable.getInjectedType()), injectable.getFactoryName(), injectable.getScope(), isEager(injectable.getInjectedType()), injectable.getBeanName(), loadLiteral(false) }; } return newObject(FactoryHandleImpl.class, args); }
private Statement generateFactoryHandle(final Injectable injectable, @SuppressWarnings("rawtypes") final BlockBuilder curMethod) { final String handleVarName = "handleFor" + injectable.getFactoryName(); curMethod.append(declareFinalVariable(handleVarName, FactoryHandleImpl.class, ObjectBuilder.newInstanceOf(FactoryHandleImpl.class) .withParameters(loadLiteral(injectable.getInjectedType()), loadLiteral(injectable.getFactoryName()), loadLiteral(injectable.getScope()), loadLiteral(false), loadLiteral(injectable.getBeanName()), loadLiteral(!injectable.isContextual())))); curMethod.append(loadVariable(handleVarName).invoke("setAssignableTypes", getAssignableTypesArrayStmt(injectable))); if (!injectable.getQualifier().isDefaultQualifier()) { curMethod.append(loadVariable(handleVarName).invoke("setQualifiers", getAnnotationArrayStmt(injectable.getQualifier()))); } return loadVariable(handleVarName); }