Package com.google.gwt.core.ext

Examples of com.google.gwt.core.ext.UnableToCompleteException


      try {
        JClassType type = typeOracle.getType(typeName);
        SerialTypes annotation = type.getAnnotation(SerialTypes.class);
        if (annotation == null) {
          logger.log(TreeLogger.ERROR, "No SerialTypes annotation on CometSerializer type: " + typeName);
          throw new UnableToCompleteException();
        }
       
        SerializableTypeOracleBuilder typesSentToBrowserBuilder = new SerializableTypeOracleBuilder(
                        logger, context.getPropertyOracle(), context);
        SerializableTypeOracleBuilder typesSentFromBrowserBuilder = new SerializableTypeOracleBuilder(
                        logger, context.getPropertyOracle(), context);
       
        for (Class<? extends Serializable> serializable : annotation.value()) {
          int rank = 0;
          if (serializable.isArray()) {
            while(serializable.isArray()) {
              serializable = (Class<? extends Serializable>) serializable.getComponentType();
              rank++;
            }
          }
           
          JType resolvedType = typeOracle.getType(serializable.getCanonicalName());
          while (rank > 0) {
            resolvedType = typeOracle.getArrayType(resolvedType);
            rank--;
          }
         
          typesSentToBrowserBuilder.addRootType(logger, resolvedType);
                    typesSentFromBrowserBuilder.addRootType(logger, resolvedType);
        }
       
        // Create a resource file to receive all of the serialization information
        // computed by STOB and mark it as private so it does not end up in the
        // output.
        OutputStream pathInfo = context.tryCreateResource(logger, typeName + ".rpc.log");
        PrintWriter writer = new PrintWriter(new OutputStreamWriter(pathInfo));
        writer.write("====================================\n");
        writer.write("Types potentially sent from server:\n");
        writer.write("====================================\n\n");
        writer.flush();
       
        typesSentToBrowserBuilder.setLogOutputWriter(writer);
        SerializableTypeOracle typesSentToBrowser = typesSentToBrowserBuilder.build(logger);

        writer.write("===================================\n");
        writer.write("Types potentially sent from browser:\n");
        writer.write("===================================\n\n");
        writer.flush();
        typesSentFromBrowserBuilder.setLogOutputWriter(writer);
          SerializableTypeOracle typesSentFromBrowser = typesSentFromBrowserBuilder.build(logger);
       
        writer.close();
       
        if (pathInfo != null) {
          context.commitResource(logger, pathInfo).setPrivate(true);
        }
       
        // Create the serializer
                final String modifiedTypeName = typeName.replace('.', '_');
                TypeSerializerCreator tsc = new TypeSerializerCreator(logger, typesSentFromBrowser, typesSentToBrowser, context, "comet." + modifiedTypeName, modifiedTypeName);
        String realize = tsc.realize(logger);
       
        // Create the CometSerializer impl
        ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(packageName, className);
       
        composerFactory.addImport(Serializer.class.getName());
        composerFactory.addImport(SerialMode.class.getName());
       
        composerFactory.setSuperclass(typeName);
        // TODO is the SERIALIZER required for DE RPC?
        SourceWriter sourceWriter = composerFactory.createSourceWriter(context, printWriter);
        sourceWriter.print("private Serializer SERIALIZER = new " + realize + "();");
        sourceWriter.print("protected Serializer getSerializer() {return SERIALIZER;}");
        sourceWriter.print("public SerialMode getMode() {return SerialMode." + annotation.mode().name() + ";}");
                sourceWriter.print("public SerialMode getPushMode() {return SerialMode." + annotation.pushmode().name() + ";}");
        sourceWriter.commit(logger);
       
        if (annotation.mode() == SerialMode.DE_RPC) {
          RpcDataArtifact data = new RpcDataArtifact(type.getQualifiedSourceName());
          for (JType t : typesSentToBrowser.getSerializableTypes()) {
            if (!(t instanceof JClassType)) {
              continue;
            }
            JField[] serializableFields = SerializationUtils.getSerializableFields(context.getTypeOracle(), (JClassType) t);
           
            List<String> names = Lists.create();
            for (int i = 0, j = serializableFields.length; i < j; i++) {
              names = Lists.add(names, serializableFields[i].getName());
            }
           
            data.setFields(SerializationUtils.getRpcTypeName(t), names);
          }
         
          context.commitArtifact(logger, data);
        }
      }
      catch (NotFoundException e) {
        logger.log(TreeLogger.ERROR, "", e);
        throw new UnableToCompleteException();
      }
    }
   
    return new RebindResult(RebindStatus.USE_PARTIAL_CACHED, packageName + '.' + className);
  }
View Full Code Here


    if (requestedType == null) {
      logger.log(TreeLogger.ERROR,
          "Type '" + requestedType.getQualifiedSourceName()
              + "' does not implement Exportable", null);
      throw new UnableToCompleteException();
    }

    // get the name of the Java class implementing Exporter
    String genName = requestedType.getExporterImplementationName();

    sw.indent();

    // export constructor
    sw.println("private " + ExportableTypeOracle.JSO_CLASS + " jso;");
    sw.println();
    sw.println("public " + genName + "() { export(); }");

    sw.println(
        "public " + genName + "(" + ExportableTypeOracle.JSO_CLASS + " jso) {");
    sw.indent();
    sw.println("this.jso = jso;");
    if (requestedType.isStructuralType()) {
      sw.println("___importStructuralType();");
    }
    sw.outdent();
    sw.println("}");
    sw.println();

    // export static factory method
    sw.println("public static " + genName + " makeClosure("
        + ExportableTypeOracle.JSO_CLASS + " closure) {");
    sw.indent();
    sw.println("return new " + genName + "(closure);");
    sw.outdent();
    sw.println("}");
    sw.println();

    JExportableMethod[] methods = requestedType.getExportableMethods();

    if (methods.length != 1) {
      logger.log(TreeLogger.ERROR,
          "Interface " + requestedType.getQualifiedSourceName()
              + " has more than one "
              + "declared method. @gwt.exportClosure only currently works for "
              + "single method interfaces.", null);
      throw new UnableToCompleteException();
    }

    JExportableMethod method = methods[0];
    JExportableType retType = method.getExportableReturnType();
    if (retType == null) {
      logger.log(TreeLogger.ERROR,
          "Return type of method " + method + " is not exportable.", null);
      throw new UnableToCompleteException();
    }

    if (retType.needsExport() && !exported
        .contains(retType.getQualifiedSourceName())) {
      if (exportDependentClass(retType.getQualifiedSourceName())) {
View Full Code Here

        .findExportableClassType(requestedClass);

    if (requestedType == null) {
      logger.log(TreeLogger.ERROR,
          "Type '" + requestedClass + "' does not implement Exportable", null);
      throw new UnableToCompleteException();
    }

    // add this so we don't try to recursively reexport ourselves later
    exported.add(requestedType);
    visited.add(requestedType.getQualifiedSourceName());
View Full Code Here

      if (eType == null) {
        logger.log(TreeLogger.ERROR,
            "Structural type field " + field.getMethodName() + " for class "
                + requestedType.getQualifiedSourceName()
                + " is not exportable.");
        throw new UnableToCompleteException();
      }
      if (eType instanceof JExportableClassType) {
        JExportableClassType cType = (JExportableClassType) field
            .getExportableType();
        if (cType.needsExport() && cType.isStructuralType()) {
View Full Code Here

      }
      if (!dt.addSignature(meth, meth.getExportableParameters())) {
        logger.log(TreeLogger.ERROR,
            "Ambiguous method signature " + meth.getJSNIReference()
                + " would conflict in JS with another method");
        throw new UnableToCompleteException();
      }
    }
    return dispMap;
  }
View Full Code Here

        logger.log(TreeLogger.ERROR,
            "Constructor " + conflicting + " with " + numArguments + " "
                + "arguments conflicts with " + constructor + "."
                + "Two constructors may not have identical numbers of "
                + "arguments.", null);
        throw new UnableToCompleteException();
      }
      arity.put(numArguments, constructor);
      sw.println("else if(arguments.length == " + numArguments + ") {");
      sw.indent();
View Full Code Here

    if (retType == null) {
      logger.log(TreeLogger.ERROR,
          "Return type of method " + method.toString() + " is not Exportable.",
          null);
      throw new UnableToCompleteException();
    }

    int arity = method.getExportableParameters().length;
    String name = method.getUnqualifiedExportName();
    String key = name + "_" + arity;
View Full Code Here

    }
    if (annotation.handles().length == 0 && !isAConcreteGenericEvent(eventParameter)) {
      logger.log(Type.ERROR, "Method " + method.getName()
          + " annotated with @EventHandler without event classes must have exactly "
          + "one argument of a concrete type assignable to GenericEvent");
      throw new UnableToCompleteException();
    }

    List<String> eventTypes = new ArrayList<String>();
    if (annotation.handles().length != 0) {
      for (Class<? extends GenericEvent> event : annotation.handles()) {
        String eventTypeName = event.getCanonicalName();
        JClassType eventClassType = typeOracle.findType(eventTypeName);
        if (eventClassType == null) {
          logger.log(Type.ERROR, "Can't resolve " + eventTypeName);
          throw new UnableToCompleteException();
        }
        if (eventParameter != null && !eventClassType.isAssignableTo(eventParameter)) {
          logger.log(Type.ERROR, "Event " + eventTypeName + " isn't assignable to "
              + eventParameter.getName() + " in method: " + method.getName());
          throw new UnableToCompleteException();
        }
        eventTypes.add(eventClassType.getQualifiedSourceName());
      }
    } else {
      eventTypes.add(eventParameter.getQualifiedSourceName());
View Full Code Here

        writer.commit(logger);
      }
      return getFullyQualifiedGeneratedClassName(eventBinderType);
    } catch (NotFoundException e) {
      logger.log(Type.ERROR, "Error generating " + typeName, e);
      throw new UnableToCompleteException();
    }
  }
View Full Code Here

    PreferenceGeneratorName generator = extendsPreferenceType.getAnnotation(PreferenceGeneratorName.class);

    if (generator == null) {
      logger.log(TreeLogger.ERROR, "No PreferenceGenerator defined for type "
          + extendsPreferenceType.getQualifiedSourceName(), null);
      throw new UnableToCompleteException();
    }

    try {
      String typeName = generator.value();

      Class<? extends PreferenceGenerator> clazz = Class.forName(typeName).asSubclass(
          PreferenceGenerator.class);
      return clazz.newInstance();
    } catch (ClassCastException e) {
      logger.log(TreeLogger.ERROR, "Not a PreferenceGenerator", e);
      throw new UnableToCompleteException();
    } catch (ClassNotFoundException e) {
      logger.log(TreeLogger.ERROR, "Unable to create PreferenceGenerator", e);
      throw new UnableToCompleteException();
    } catch (InstantiationException e) {
      logger.log(TreeLogger.ERROR, "Unable to create PreferenceGenerator", e);
      throw new UnableToCompleteException();
    } catch (IllegalAccessException e) {
      logger.log(TreeLogger.ERROR, "Unable to create PreferenceGenerator", e);
      throw new UnableToCompleteException();
    }
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.core.ext.UnableToCompleteException

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.