Package org.jboss.errai.codegen.meta

Examples of org.jboss.errai.codegen.meta.MetaParameter


      // assemble parameters for private method invoker (first param is the widget instance)
      PrivateAccessUtil.addPrivateAccessStubs("jsni", pageImplBuilder, metaMethod, new Modifier[] {});

      if (optionalParamType != null) {
        for (int i = 1; i < paramValues.length; i++) {
          MetaParameter paramSpec = metaMethod.getParameters()[i - 1];
          if (paramSpec.getType().equals(MetaClassFactory.get(optionalParamType))) {
            paramValues[i] = Stmt.loadVariable(optionalParamName);
          }
          else {
            throw new UnsupportedOperationException(
                     createAnnotionName(annotation) + " method " +
                          metaMethod.getDeclaringClass().getFullyQualifiedName() + "." + metaMethod.getName() +
                         " has an illegal parameter of type " + paramSpec.getType().getFullyQualifiedName());
          }
        }

      }
      else {
View Full Code Here


        pType = type.getParameterizedType();
        break;

      case Parameter:
        final MetaParameter parm = injectableInstance.getParm();
        type = parm.getType();

        pType = type.getParameterizedType();
        break;

      default:
View Full Code Here

      // assemble parameters for private method invoker (first param is the widget instance)
      PrivateAccessUtil.addPrivateAccessStubs("jsni", pageImplBuilder, metaMethod, new Modifier[] {});

      if (methodCanTakeParameters) {
        for (int i = 1; i < paramValues.length; i++) {
          MetaParameter paramSpec = metaMethod.getParameters()[i - 1];
          if (paramSpec.getType().equals(MetaClassFactory.get(HistoryToken.class))) {
            paramValues[i] = Stmt.loadVariable("state");
          }
          else {
            throw new UnsupportedOperationException(
                     createAnnotionName(annotation) + " method " +
                          metaMethod.getDeclaringClass().getFullyQualifiedName() + "." + metaMethod.getName() +
                         " has an illegal parameter of type " + paramSpec.getType().getFullyQualifiedName());
          }
        }

      }
      else {
View Full Code Here

    final Statement[] parmValues = new Statement[parmTypes.length];

    for (int i = 0; i < parmTypes.length; i++) {
      final Statement stmt;
      final MetaClass parmType = parmTypes[i];
      final MetaParameter metaParameter = parms[i];
      try {
        final QualifyingMetadata qualifyingMetadata = ctx.getProcessingContext().getQualifyingMetadataFactory().createFrom(
            parms[i].getAnnotations()
        );
View Full Code Here

        pType = type.getParameterizedType();
        break;

      case Parameter:
        final MetaParameter parm = injectableInstance.getParm();
        type = parm.getType();

        pType = type.getParameterizedType();
        break;

      default:
View Full Code Here

        pType = type.getParameterizedType();
        break;

      case Parameter:
        final MetaParameter parm = injectableInstance.getParm();
        type = parm.getType();

        pType = type.getParameterizedType();
        break;

      default:
View Full Code Here

  @Override
  public List<? extends Statement> generateDecorator(final InjectableInstance<Observes> instance) {
    final Context ctx = instance.getInjectionContext().getProcessingContext().getContext();
    final MetaMethod method = instance.getMethod();
    final MetaParameter parm = instance.getParm();

    if (!method.isPublic()) {
      instance.ensureMemberExposed(PrivateAccessType.Write);
    }

    final String parmClassName = parm.getType().getFullyQualifiedName();
    final List<Annotation> annotations = InjectUtil.extractQualifiers(instance);
    final Annotation[] qualifiers = annotations.toArray(new Annotation[annotations.size()]);
    final Set<String> qualifierNames = new HashSet<String>(CDI.getQualifiersPart(qualifiers));

    if (qualifierNames.contains(Any.class.getName())) {
      qualifierNames.remove(Any.class.getName());
    }

    MetaClass callBackType = parameterizedAs(AbstractCDIEventCallback.class, typeParametersOf(parm.getType()));

    AnonymousClassStructureBuilder callBack = Stmt.newObject(callBackType).extend();

    BlockBuilder<AnonymousClassStructureBuilder> callBackBlock;

    if (!qualifierNames.isEmpty()) {
      callBackBlock = callBack.initialize();
      for (String qualifierName : qualifierNames) {
        callBackBlock.append(Stmt.loadClassMember("qualifierSet").invoke("add", qualifierName));
      }
      callBack = callBackBlock.finish();
    }


    callBackBlock = callBack.publicOverridesMethod("fireEvent", Parameter.finalOf(parm, "event"))
        ._(instance.callOrBind(Refs.get("event")))
        .finish()
        .publicOverridesMethod("toString")
        ._(Stmt.load("Observer: " + parmClassName + " " + Arrays.toString(qualifiers)).returnValue());

    final List<Statement> statements = new ArrayList<Statement>();

    // create the destruction callback to deregister the service when the bean is destroyed.
    final String subscrVar = InjectUtil.getUniqueVarName();


    final Statement subscribeStatement =
        Stmt.declareVariable(Subscription.class).asFinal().named(subscrVar)
            .initializeWith(Stmt.create(ctx).invokeStatic(CDI.class, "subscribe", parmClassName,
                callBackBlock.finish().finish()));

    statements.add(subscribeStatement);

    // create the destruction callback to deregister the service when the bean is destroyed.

    final MetaClass destructionCallbackType =
        parameterizedAs(DestructionCallback.class, typeParametersOf(instance.getEnclosingType()));

    final BlockBuilder<AnonymousClassStructureBuilder> destroyMeth
        = ObjectBuilder.newInstanceOf(destructionCallbackType).extend()
        .publicOverridesMethod("destroy", Parameter.finalOf(instance.getEnclosingType(), "obj"))
        .append(Stmt.loadVariable(subscrVar).invoke("remove"));


    for (Class<?> cls : EnvUtil.getAllPortableConcreteSubtypes(parm.getType().asClass())) {
      final String subscrHandle = InjectUtil.getUniqueVarName();
      statements.add(Stmt.declareVariable(Subscription.class).asFinal().named(subscrHandle)
          .initializeWith(Stmt.invokeStatic(ErraiBus.class, "get").invoke("subscribe",
              CDI.getSubjectNameByType(cls.getName()),
              Stmt.loadStatic(CDI.class, "ROUTING_CALLBACK"))));
View Full Code Here

        pType = type.getParameterizedType();
        break;

      case Parameter:
        MetaParameter parm = injectableInstance.getParm();
        type = parm.getType();

        pType = type.getParameterizedType();
        break;
    }
View Full Code Here

    final Statement[] parmValues = new Statement[parmTypes.length];

    for (int i = 0; i < parmTypes.length; i++) {
      final Statement stmt;
      final MetaClass parmType = parmTypes[i];
      final MetaParameter metaParameter = parms[i];
      try {
        final QualifyingMetadata qualifyingMetadata = ctx.getProcessingContext().getQualifyingMetadataFactory().createFrom(
            parms[i].getAnnotations()
        );
View Full Code Here

        pType = type.getParameterizedType();
        break;

      case Parameter:
        final MetaParameter parm = injectableInstance.getParm();
        type = parm.getType();

        pType = type.getParameterizedType();
        break;

      default:
View Full Code Here

TOP

Related Classes of org.jboss.errai.codegen.meta.MetaParameter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.