.finish(); loadProxies.append(Stmt.invokeStatic(RemoteServiceProxyFactory.class, "addRemoteProxy", remote, proxyProvider));
public Statement createGlobalActionCheck(String resourceType, String resourceAction, String onGranted, String onDenied) { return buildCheckStatement(Stmt.invokeStatic(AuthorizationManagerHelper.class, "authorize", resourceType, resourceAction), onGranted, onDenied); } }
private Statement generateRequest(ClassStructureBuilder<?> classBuilder, MetaMethod method, Statement methodParams, boolean intercepted) { final Statement sendable = Stmt .invokeStatic(MessageBuilder.class, "createCall") .invoke("call", remote.getFullyQualifiedName()) .invoke("endpoint", ProxyUtil.createCallSignature(method), Stmt.loadClassMember("qualifiers"), methodParams) .invoke("respondTo", method.getReturnType().asBoxed(), Stmt.loadVariable("remoteCallback")) .invoke("errorsHandledBy", Stmt.loadVariable("errorCallback")); final BlockStatement requestBlock = new BlockStatement(); requestBlock.addStatement(Stmt.declareVariable("sendable", RemoteCallSendable.class, sendable)); requestBlock.addStatement(Stmt.loadStatic(classBuilder.getClassDefinition(), "this") .invoke("sendRequest", Variable.get("bus"), Variable.get("sendable"))); return requestBlock; } }
public static Statement annotationLiteral(final Annotation qual) { if (qual.annotationType().equals(Any.class)) { return loadStatic(QualifierUtil.class, "ANY_ANNOTATION"); } else if (qual.annotationType().equals(Default.class)) { return loadStatic(QualifierUtil.class, "DEFAULT_ANNOTATION"); } else if (qual.annotationType().equals(Named.class)) { return invokeStatic(QualifierUtil.class, "createNamed", ((Named) qual).value()); } else { return LiteralFactory.getLiteral(qual); } }
/** * This should only be called for non-public constructors. This method forces a * private accessor to be generated for the constructor. * * @param constructor * A non-public constructor. * @return A statement for invoking the given constructor. */ public ContextualStatementBuilder exposedConstructorStmt(final MetaConstructor constructor, final Statement... params) { addExposedConstructor(constructor); return invokeStatic(factory, getPrivateMethodName(constructor), (Object[]) params); }
public Statement createResourceActionCheck(String resourceName, String resourceAction, String onGranted, String onDenied) { return buildCheckStatement(Stmt.invokeStatic(AuthorizationManagerHelper.class, "authorize", Stmt.loadVariable(resourceName), resourceAction), onGranted, onDenied); }
private ContextualStatementBuilder createConstraintViolation() { return invokeStatic(ConstraintViolationImpl.class, "builder").invoke("setInvalidValue", loadVariable("value")) .invoke("setMessage", Stmt.invokeStatic(DynamicValidatorUtil.class, "interpolateMessage", Refs.get("parameters"), Refs.get("message"))) .invoke("build"); }
private static void addCleanup(final Decorable decorable, final FactoryController controller, final List<Statement> destructionStmts) { final DataBindingUtil.DataBinderRef dataBinder = DataBindingUtil.lookupDataBinderRef(decorable, controller); if (!controller.hasAttribute(STYLE_BINDING_HOUSEKEEPING_ATTR)) { destructionStmts.add( Stmt.invokeStatic(StyleBindingsRegistry.class, "get").invoke("cleanAllForBean", Refs.get("instance"))); if (dataBinder != null) { destructionStmts.add(controller.getReferenceStmt("styleBindingChangeHandlerUnsub", PropertyChangeUnsubscribeHandle.class).invoke("unsubscribe")); } controller.setAttribute(STYLE_BINDING_HOUSEKEEPING_ATTR, Boolean.TRUE); } }
private static void addCleanup(final Decorable decorable, final FactoryController controller, final List<Statement> destructionStmts) { final DataBindingUtil.DataBinderRef dataBinder = DataBindingUtil.lookupDataBinderRef(decorable, controller); if (!controller.hasAttribute(STYLE_BINDING_HOUSEKEEPING_ATTR)) { destructionStmts.add( Stmt.invokeStatic(StyleBindingsRegistry.class, "get").invoke("cleanAllForBean", Refs.get("instance"))); if (dataBinder != null) { destructionStmts.add(controller.getReferenceStmt("styleBindingChangeHandlerUnsub", PropertyChangeUnsubscribeHandle.class).invoke("unsubscribe")); } controller.setAttribute(STYLE_BINDING_HOUSEKEEPING_ATTR, Boolean.TRUE); } }
@Override protected List<Statement> generateCreateInstanceStatements(final ClassStructureBuilder<?> bodyBlockBuilder, final Injectable injectable, final DependencyGraph graph, final InjectionContext injectionContext) { return Collections.<Statement> singletonList( Stmt.castTo(injectable.getInjectedType(), invokeStatic(WindowInjectionContextStorage.class, "createOrGet") .invoke("getBean", injectable.getInjectedType().getFullyQualifiedName())).returnValue()); }
@SuppressWarnings("unchecked") private void declareStaticLogger(final IOCProcessingContext processingContext) { processingContext.getBootstrapBuilder() .privateField("logger", Logger.class) .modifiers(Modifier.Static, Modifier.Final) .initializesWith(invokeStatic(LoggerFactory.class, "getLogger", Bootstrapper.class)) .finish(); }
@SuppressWarnings("unchecked") private void declareAsyncBeanManagerSetupField(final IOCProcessingContext processingContext) { processingContext.getBootstrapBuilder() .privateField("asyncBeanManagerSetup", AsyncBeanManagerSetup.class) .initializesWith(castTo(AsyncBeanManagerSetup.class, invokeStatic(IOC.class, "getAsyncBeanManager"))) .finish(); }
private static Statement hashArith(final MetaMethod method) { return Arith.expr( Arith.expr(31, ArithmeticOperator.Multiplication, Refs.get("hash")), ArithmeticOperator.Addition, Stmt.invokeStatic(QualifierUtil.class, "hashValueFor", Stmt.loadVariable("a1").invoke(method)) ); } }
private Statement generateFactoryLoader(final Injectable injectable, final MetaClass factoryClass) { final Statement runAsyncCallback = ObjectBuilder.newInstanceOf(DefaultRunAsyncCallback.class).extend() .publicOverridesMethod("onSuccess").append(loadVariable("callback").invoke("callback", castTo(Factory.class, invokeStatic(GWT.class, "create", loadLiteral(factoryClass))))) .finish().finish(); final Class<?> fragmentId = getAsyncFragmentId(injectable); final Object[] runAsyncParams = (fragmentId.equals(LoadAsync.NO_FRAGMENT.class) ? new Object[] { runAsyncCallback } : new Object[] { fragmentId, runAsyncCallback }); return ObjectBuilder.newInstanceOf(FactoryLoader.class).extend() .publicOverridesMethod("call", finalOf(FactoryLoaderCallback.class, "callback")) .append(invokeStatic(GWT.class, "runAsync", runAsyncParams)).finish().finish(); }
private ContextualStatementBuilder proxyHelperInvocation(final MetaMethod method, final BuildMetaClass factoryClass) { if (method.isPublic()) { return loadVariable("proxiedInstance").invoke(method.getName(), getParametersForInvocation(method)); } else { controller.addExposedMethod(method); return invokeStatic(factoryClass, getPrivateMethodName(method), getParametersForInvocation(method, loadVariable("proxiedInstance"))); } }
public static String initCachedMethod(final ClassStructureBuilder<?> classBuilder, final MetaConstructor c) { createJavaReflectionConstructorInitializerUtilMethod(classBuilder); final String fieldName = PrivateAccessUtil.getPrivateMethodName(c) + "_meth"; classBuilder.privateField(fieldName, Constructor.class).modifiers(Modifier.Static) .initializesWith(Stmt.invokeStatic(classBuilder.getClassDefinition(), JAVA_REFL_CONSTRUCTOR_UTIL_METH, c.getDeclaringClass(), MetaClassFactory.asClassArray(c.getParameters()))).finish(); return fieldName; }
public static String initCachedField(final ClassStructureBuilder<?> classBuilder, final MetaField f) { createJavaReflectionFieldInitializerUtilMethod(classBuilder); final String fieldName = PrivateAccessUtil.getPrivateFieldAccessorName(f) + "_fld"; if (classBuilder.getClassDefinition().getField(fieldName) != null) { return fieldName; } classBuilder.privateField(fieldName, Field.class).modifiers(Modifier.Static) .initializesWith(Stmt.invokeStatic(classBuilder.getClassDefinition(), JAVA_REFL_FLD_UTIL_METH, f.getDeclaringClass(), f.getName())).finish(); return fieldName; }
public static String initCachedMethod(final ClassStructureBuilder<?> classBuilder, final MetaMethod m) { createJavaReflectionMethodInitializerUtilMethod(classBuilder); final String fieldName = PrivateAccessUtil.getPrivateMethodName(m) + "_meth"; classBuilder.privateField(fieldName, Method.class).modifiers(Modifier.Static) .initializesWith(Stmt.invokeStatic(classBuilder.getClassDefinition(), JAVA_REFL_METH_UTIL_METH, m.getDeclaringClass(), m.getName(), MetaClassFactory.asClassArray(m.getParameters()))).finish(); return fieldName; }
public static String initCachedField(final ClassStructureBuilder<?> classBuilder, final MetaField f) { createJavaReflectionFieldInitializerUtilMethod(classBuilder); final String fieldName = PrivateAccessUtil.getPrivateFieldAccessorName(f) + "_fld"; if (classBuilder.getClassDefinition().getField(fieldName) != null) { return fieldName; } classBuilder.privateField(fieldName, Field.class).modifiers(Modifier.Static) .initializesWith(Stmt.invokeStatic(classBuilder.getClassDefinition(), JAVA_REFL_FLD_UTIL_METH, f.getDeclaringClass(), f.getName())).finish(); return fieldName; }
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(); }