/** * Generates the code that will create the interceptor and then invoke the callback when done. If * IOC is available *and* the interceptor is a managed bean, then the IOC bean manager will be * used to load the interceptor. * * @param context * @param interceptor */ private static Statement generateAsyncInterceptorCreation(final GeneratorContext context, final Class<?> interceptor) { if (RebindUtils.isModuleInherited(context, IOC_MODULE_NAME) && isManagedBean(interceptor)) { // Note: for the IOC path, generate the code via StringStatement because we // need to make sure that IOC is an optional dependency. This should probably // be replaced with some sort of pluggable model instead (where a Statement can // be provided by some Provider in the IOC module itself maybe). final StringBuilder builder = new StringBuilder(); builder.append("org.jboss.errai.ioc.client.container.IOC.getAsyncBeanManager().lookupBeans(") .append(interceptor.getSimpleName()) .append(".class).iterator().next().getInstance(icc)"); return new StringStatement(builder.toString()); } else { return Stmt.invokeStatic(AsyncBeanFactory.class, "createBean", Stmt.newObject(interceptor), Variable.get("icc")); } }
/** * Generates the code that will create the interceptor and then invoke the callback when done. If * IOC is available *and* the interceptor is a managed bean, then the IOC bean manager will be * used to load the interceptor. * * @param context * @param interceptor */ private static Statement generateAsyncInterceptorCreation(final GeneratorContext context, final Class<?> interceptor) { if (RebindUtils.isModuleInherited(context, IOC_MODULE_NAME) && isManagedBean(interceptor)) { // Note: for the IOC path, generate the code via StringStatement because we // need to make sure that IOC is an optional dependency. This should probably // be replaced with some sort of pluggable model instead (where a Statement can // be provided by some Provider in the IOC module itself maybe). final StringBuilder builder = new StringBuilder(); builder.append("org.jboss.errai.ioc.client.container.IOC.getAsyncBeanManager().lookupBeans(") .append(interceptor.getSimpleName()) .append(".class).iterator().next().getInstance(icc)"); return new StringStatement(builder.toString()); } else { return Stmt.invokeStatic(AsyncBeanFactory.class, "createBean", Stmt.newObject(interceptor), Variable.get("icc")); } }