@SuppressWarnings("rawtypes") private BlockBuilder createRegisterFactoriesMethod(final IOCProcessingContext processingContext, final Collection<MetaClass> scopeContexts) { final Parameter[] contextParams = contextParamsDeclaration(scopeContexts); @SuppressWarnings({ "unchecked" }) final BlockBuilder methodBody = processingContext.getBootstrapBuilder().privateMethod(void.class, "registerFactories", contextParams).body(); return methodBody; }
private void implementInitProxyProperties(final ClassStructureBuilder<?> proxyImpl, final Injectable injectable) { final BlockBuilder<?> initBody = proxyImpl .publicMethod(void.class, "initProxyProperties", finalOf(injectable.getInjectedType(), "instance")).body(); for (final Entry<String, Statement> prop : controller.getProxyProperties()) { proxyImpl.privateField(prop.getKey(), prop.getValue().getType()).finish(); initBody.append(loadVariable(prop.getKey()).assignValue(prop.getValue())); } initBody.finish(); }
private void implementClearInstance(final ClassStructureBuilder<?> proxyImpl, final Injectable injectable) { proxyImpl.publicMethod(void.class, "clearInstance") .body() .append(loadVariable("proxyHelper").invoke("clearInstance")) .finish(); }
private void implementAsBeanType(final ClassStructureBuilder<?> proxyImpl, final Injectable injectable) { proxyImpl.publicMethod(injectable.getInjectedType(), "asBeanType") .body() .append(loadVariable("this").returnValue()) .finish(); }
private void implementGetContext(final ClassStructureBuilder<?> proxyImpl, final Injectable injectable) { proxyImpl.publicMethod(Context.class, "getProxyContext") .body() .append(loadVariable("proxyHelper").invoke("getProxyContext").returnValue()) .finish(); }
private void appendPageUpdateMethod(AnonymousClassStructureBuilder pageImplBuilder, MetaClass pageClass) { BlockBuilder<?> method = pageImplBuilder.publicMethod(void.class, createMethodNameFromAnnotation(PageUpdate.class), Parameter.of(pageClass, "widget"), Parameter.of(HistoryToken.class, "state")) .body(); appendPageShowMethod(method, pageImplBuilder, pageClass, PageUpdate.class, false, Parameter.of(HistoryToken.class, "state")); method.finish(); }
private void appendPageShownMethod(AnonymousClassStructureBuilder pageImplBuilder, MetaClass pageClass) { BlockBuilder<?> method = pageImplBuilder.publicMethod(void.class, createMethodNameFromAnnotation(PageShown.class), Parameter.of(pageClass, "widget"), Parameter.of(HistoryToken.class, "state")) .body(); appendPageShowMethod(method, pageImplBuilder, pageClass, PageShown.class, false, Parameter.of(HistoryToken.class, "state")); method.finish(); }
private void appendPageUpdateMethod(AnonymousClassStructureBuilder pageImplBuilder, MetaClass pageClass) { BlockBuilder<?> method = pageImplBuilder.publicMethod(void.class, createMethodNameFromAnnotation(PageUpdate.class), Parameter.of(pageClass, "widget"), Parameter.of(HistoryToken.class, "state")) .body(); appendPageShowMethod(method, pageImplBuilder, pageClass, PageUpdate.class, false, Parameter.of(HistoryToken.class, "state")); method.finish(); }
private void implementUnwrappedInstance(final ClassStructureBuilder<?> proxyImpl, final Injectable injectable) { proxyImpl.publicMethod(Object.class, "unwrap") .body() .append(loadVariable("proxyHelper").invoke("getInstance", loadVariable("this")).returnValue()) .finish(); }
private void implementSetContext(final ClassStructureBuilder<?> proxyImpl, final Injectable injectable) { proxyImpl.publicMethod(void.class, "setProxyContext", finalOf(Context.class, "context")) .body() .append(loadVariable("proxyHelper").invoke("setProxyContext", loadVariable("context"))) .finish(); }
private void appendPageShownMethod(AnonymousClassStructureBuilder pageImplBuilder, MetaClass pageClass) { BlockBuilder<?> method = pageImplBuilder.publicMethod(void.class, createMethodNameFromAnnotation(PageShown.class), Parameter.of(pageClass, "widget"), Parameter.of(HistoryToken.class, "state")) .body(); appendPageShowMethod(method, pageImplBuilder, pageClass, PageShown.class, false, Parameter.of(HistoryToken.class, "state")); method.finish(); }
/** * Appends the method that calls the {@code @PageHidden} method of the widget. * * @param pageImplBuilder * The class builder for the implementation of PageNode we are adding the method to. * @param pageClass * The "content type" (Widget subclass) of the page. This is the type the user annotated * with {@code @Page}. */ private void appendPageHiddenMethod(AnonymousClassStructureBuilder pageImplBuilder, MetaClass pageClass) { BlockBuilder<?> method = pageImplBuilder.publicMethod( void.class, createMethodNameFromAnnotation(PageHidden.class), Parameter.of(pageClass, "widget")).body(); checkMethodAndAddPrivateAccessors(pageImplBuilder, method, pageClass, PageHidden.class, Parameter.of(HistoryToken.class, "state")); method.finish(); }
/** * Appends the method that calls the {@code @PageHidden} method of the widget. * * @param pageImplBuilder * The class builder for the implementation of PageNode we are adding the method to. * @param pageClass * The "content type" (Widget subclass) of the page. This is the type the user annotated * with {@code @Page}. */ private void appendPageHiddenMethod(AnonymousClassStructureBuilder pageImplBuilder, MetaClass pageClass) { BlockBuilder<?> method = pageImplBuilder.publicMethod( void.class, createMethodNameFromAnnotation(PageHidden.class), Parameter.of(pageClass, "widget")).body(); checkMethodAndAddPrivateAccessors(pageImplBuilder, method, pageClass, PageHidden.class, Parameter.of(HistoryToken.class, "state")); method.finish(); }
private void implementSetInstance(final ClassStructureBuilder<?> proxyImpl, final Injectable injectable) { proxyImpl.publicMethod(void.class, "setInstance", finalOf(injectable.getInjectedType(), "instance")) .body() .append(loadVariable("proxyHelper").invoke("setInstance", loadVariable("instance"))) .finish(); }
/** * Appends a method that destroys the IOC bean associated with a page node if the bean is * dependent scope. * * @param pageImplBuilder * The class builder for the implementation of PageNode we are adding the method to. * @param pageClass * The "content type" (Widget subclass) of the page. This is the type the user annotated * with {@code @Page}. */ private void appendDestroyMethod(AnonymousClassStructureBuilder pageImplBuilder, MetaClass pageClass) { BlockBuilder<?> method = pageImplBuilder.publicMethod( void.class, "destroy", Parameter.of(pageClass, "widget")).body(); if (pageClass.getAnnotation(Singleton.class) == null && pageClass.getAnnotation(ApplicationScoped.class) == null && pageClass.getAnnotation(EntryPoint.class) == null) { method.append(Stmt.loadVariable("bm").invoke("destroyBean", Stmt.loadVariable("widget"))); } method.finish(); }
/** * Appends a method that destroys the IOC bean associated with a page node if the bean is * dependent scope. * * @param pageImplBuilder * The class builder for the implementation of PageNode we are adding the method to. * @param pageClass * The "content type" (Widget subclass) of the page. This is the type the user annotated * with {@code @Page}. */ private void appendDestroyMethod(AnonymousClassStructureBuilder pageImplBuilder, MetaClass pageClass) { BlockBuilder<?> method = pageImplBuilder.publicMethod( void.class, "destroy", Parameter.of(pageClass, "widget")).body(); if (pageClass.getAnnotation(Singleton.class) == null && pageClass.getAnnotation(ApplicationScoped.class) == null && pageClass.getAnnotation(EntryPoint.class) == null) { method.append(Stmt.loadVariable("bm").invoke("destroyBean", Stmt.loadVariable("widget"))); } method.finish(); }
private void implementEquals(final ClassStructureBuilder<?> proxyImpl) { proxyImpl.publicMethod(boolean.class, "equals", Parameter.of(Object.class, "obj")).body() .append(loadVariable("obj").assignValue(invokeStatic(Factory.class, "maybeUnwrapProxy", loadVariable("obj")))) .append(loadVariable("proxyHelper").invoke("getInstance", loadVariable("this")).invoke("equals", loadVariable("obj")).returnValue()) .finish(); }
private void appendPageShowingMethod(AnonymousClassStructureBuilder pageImplBuilder, MetaClass pageClass) { BlockBuilder<?> method = pageImplBuilder.publicMethod(void.class, createMethodNameFromAnnotation(PageShowing.class), Parameter.of(pageClass, "widget"), Parameter.of(HistoryToken.class, "state"), Parameter.of(NavigationControl.class, "control")) .body(); MetaMethod pageShowMethod = appendPageShowMethod(method, pageImplBuilder, pageClass, PageShowing.class, true, Parameter.of(HistoryToken.class, "state"), Parameter.of(NavigationControl.class, "control")); /* * If the user did not provide a control parameter, we must proceed for them after the method is invoked. */ if (pageShowMethod == null || pageShowMethod.getParameters().length != 2) { method.append(Stmt.loadVariable("control").invoke("proceed")); } method.finish(); }
private void appendPageShowingMethod(AnonymousClassStructureBuilder pageImplBuilder, MetaClass pageClass) { BlockBuilder<?> method = pageImplBuilder.publicMethod(void.class, createMethodNameFromAnnotation(PageShowing.class), Parameter.of(pageClass, "widget"), Parameter.of(HistoryToken.class, "state"), Parameter.of(NavigationControl.class, "control")) .body(); MetaMethod pageShowMethod = appendPageShowMethod(method, pageImplBuilder, pageClass, PageShowing.class, true, Parameter.of(HistoryToken.class, "state"), Parameter.of(NavigationControl.class, "control")); /* * If the user did not provide a control parameter, we must proceed for them after the method is invoked. */ if (pageShowMethod == null || pageShowMethod.getParameters().length != 2) { method.append(Stmt.loadVariable("control").invoke("proceed")); } method.finish(); }
/** * Appends the method that calls the {@code @PageHiding} method of the widget. * * @param pageImplBuilder * The class builder for the implementation of PageNode we are adding the method to. * @param pageClass * The "content type" (Widget subclass) of the page. This is the type the user annotated * with {@code @Page}. */ private void appendPageHidingMethod(AnonymousClassStructureBuilder pageImplBuilder, MetaClass pageClass) { BlockBuilder<?> method = pageImplBuilder.publicMethod( void.class, createMethodNameFromAnnotation(PageHiding.class), Parameter.of(pageClass, "widget"), Parameter.of(NavigationControl.class, "control")).body(); final MetaMethod pageHidingMethod = checkMethodAndAddPrivateAccessors(pageImplBuilder, method, pageClass, PageHiding.class, Parameter.of(NavigationControl.class, "control")); /* * If the user did not provide a control parameter, we must proceed for them after the method is invoked. */ if (pageHidingMethod == null || pageHidingMethod.getParameters().length != 1) { method.append(Stmt.loadVariable("control").invoke("proceed")); } method.finish(); }