Package org.codehaus.enunciate

Examples of org.codehaus.enunciate.EnunciateException


  public EnunciateAnnotationProcessor(Enunciate enunciate, String... additionalApiClasses) throws EnunciateException {
    super(null);

    if (enunciate == null) {
      throw new EnunciateException("An enunciate mechanism must be specified.");
    }
    else if (enunciate.getConfig() == null) {
      throw new EnunciateException("An enunciate mechanism must have a configuration (even if its the default configuration).");
    }

    this.enunciate = enunciate;
    this.additionalApiClasses = additionalApiClasses;
  }
View Full Code Here


      StringWriter stackTrace = new StringWriter();
      e.printStackTrace(new PrintWriter(stackTrace));
      messager.printError(stackTrace.toString());
    }

    this.ee = new EnunciateException(e);
  }
View Full Code Here

  protected final void doGenerate() throws EnunciateException, IOException {
    try {
      doFreemarkerGenerate();
    }
    catch (TemplateException e) {
      throw new EnunciateException(e);
    }
  }
View Full Code Here

      out.flush();
      bytes.flush();
      return bytes.toString("utf-8");
    }
    catch (TemplateException e) {
      throw new EnunciateException(e);
    }
  }
View Full Code Here

  public void init(Enunciate enunciate) throws EnunciateException {
    super.init(enunciate);

    if (!isDisabled()) {
      if (rpcModuleName == null) {
        throw new EnunciateException("You must specify a \"rpcModuleName\" for the GWT module.");
      }
      if (rpcModuleNamespace == null) {
        throw new EnunciateException("You must specify a \"rpcModuleNamespace\" for the GWT module.");
      }

      gwtClasspathHandler = new GWTModuleClasspathHandler(enunciate);
      enunciate.addClasspathHandler(gwtClasspathHandler);

      if (gwtApps.size() > 0) {
        if (this.gwtHome == null) {
          throw new EnunciateException("To compile a GWT app you must specify the GWT home directory, either in configuration, by setting the GWT_HOME environment variable, or setting the 'gwt.home' system property.");
        }

        for (GWTApp gwtApp : gwtApps) {
          String srcPath = gwtApp.getSrcDir();

          if (srcPath == null) {
            throw new EnunciateException("A source directory for the GWT app "
              + ("".equals(gwtApp.getName()) ? "" : "'" + gwtApp.getName() + "' ")
              + "must be supplied with the 'srcDir' attribute.");
          }

          File srcDir = enunciate.resolvePath(srcPath);
          if (!srcDir.exists()) {
            throw new EnunciateException("Source directory '" + srcDir.getAbsolutePath() + "' doesn't exist for the GWT app"
              + ("".equals(gwtApp.getName()) ? "." : " '" + gwtApp.getName() + "'."));
          }
        }
      }

      if (this.gwtVersion == null) {
        int[] gwtVersion = null; //default to 1.5
        if (this.gwtHome != null) {
          File about = new File(gwtHome, "about.txt");
          if (about.exists()) {
            try {
              BufferedReader reader = new BufferedReader(new FileReader(about));
              String line = reader.readLine();
              if (line != null) {
                Matcher matcher = Pattern.compile("[\\d\\.]+").matcher(line);
                if (matcher.find()) {
                  String gwtVersionStr = matcher.group();
                  if (getEnunciate().isDebug()) {
                    getEnunciate().debug("Targeting GWT version %s according to %s.", gwtVersionStr, (this.gwtHome + File.separatorChar + "about.txt"));
                  }

                  try {
                    gwtVersion = parseGwtVersion(gwtVersionStr);
                  }
                  catch (NumberFormatException e) {
                    getEnunciate().warn("Invalid GWT version %s according to %s.", gwtVersionStr, (this.gwtHome + File.separatorChar + "about.txt"));
                  }
                }
                else {
                  getEnunciate().warn("Unable to determine GWT version from %s.", (this.gwtHome + File.separatorChar + "about.txt"));
                }
              }
              reader.close();
            }
            catch (IOException e) {
              //fall through...
            }
          }
        }

        if (gwtVersion == null) {
          gwtVersion = new int[]{1, 5};
        }

        this.gwtVersion = gwtVersion;
      }

      if (this.gwtVersion.length < 2) {
        throw new IllegalStateException("Illegal GWT version.");
      }

      if (!gwtVersionGreaterThan(1, 4)) {
        throw new EnunciateException(String.format("As of version 1.15, Enunciate no longer supports versions of GWT less than 1.5. " +
          "It appears GWT %s.%s is being used, according to %s. If this is an invalid assessment, you can get around this error by " +
          "setting the correct version with the 'gwtVersion' attribute of the Enunciate GWT module configuration.",
                                                   this.gwtVersion[0],
                                                   this.gwtVersion[1],
                                                   (this.gwtHome + File.separatorChar + "about.txt")));
View Full Code Here

  /**
   * Invokes GWTCompile on the apps specified in the configuration file.
   */
  protected void doGWTCompile() throws EnunciateException, IOException {
    if (this.gwtHome == null) {
      throw new EnunciateException("To compile a GWT app you must specify the GWT home directory, either in configuration, by setting the GWT_HOME environment variable, or setting the 'gwt.home' system property.");
    }

    File gwtHomeDir = new File(this.gwtHome);
    if (!gwtHomeDir.exists()) {
      throw new EnunciateException("GWT home not found ('" + gwtHomeDir.getAbsolutePath() + "').");
    }

    File gwtUserJar = new File(gwtHomeDir, "gwt-user.jar");
    if (!gwtUserJar.exists()) {
      warn("Unable to find %s. You may be GWT compile errors.", gwtUserJar.getAbsolutePath());
    }

    //now we have to find gwt-dev.jar.
    //start by assuming linux...
    File gwtDevJar = new File(gwtHomeDir, "gwt-dev.jar");
    if (!gwtDevJar.exists()) {
      File linuxDevJar = new File(gwtHomeDir, "gwt-dev-linux.jar");
      gwtDevJar = linuxDevJar;

      if (!gwtDevJar.exists()) {
        //linux not found. try mac...
        File macDevJar = new File(gwtHomeDir, "gwt-dev-mac.jar");
        gwtDevJar = macDevJar;

        if (!gwtDevJar.exists()) {
          //okay, we'll try windows if we have to...
          File windowsDevJar = new File(gwtHomeDir, "gwt-dev-windows.jar");
          gwtDevJar = windowsDevJar;

          if (!gwtDevJar.exists()) {
            throw new EnunciateException(String.format("Unable to find GWT dev jar. Looked for %s, %s, and %s.", linuxDevJar.getAbsolutePath(), macDevJar.getAbsolutePath(), windowsDevJar.getAbsolutePath()));
          }
        }
      }
    }

    boolean windows = false;
    File javaBinDir = new File(System.getProperty("java.home"), "bin");
    File javaExecutable = new File(javaBinDir, "java");
    if (!javaExecutable.exists()) {
      //append the "exe" for windows users.
      javaExecutable = new File(javaBinDir, "java.exe");
      windows = true;
    }

    String javaCommand = javaExecutable.getAbsolutePath();
    if (!javaExecutable.exists()) {
      warn("No java executable found in %s.  We'll just hope the environment is set up to execute 'java'...", javaBinDir.getAbsolutePath());
      javaCommand = "java";
    }

    StringBuilder classpath = new StringBuilder(enunciate.getEnunciateRuntimeClasspath());
    //append the client-side gwt directory.
    classpath.append(File.pathSeparatorChar).append(getClientSideGenerateDir().getAbsolutePath());
    //append the gwt-user jar.
    classpath.append(File.pathSeparatorChar).append(gwtUserJar.getAbsolutePath());
    //append the gwt-dev jar.
    classpath.append(File.pathSeparatorChar).append(gwtDevJar.getAbsolutePath());

    //so here's the GWT compile command:
    //java [extra jvm args] -cp [classpath] [compilerClass] -gen [gwt-gen-dir] -style [style] -out [out] [moduleName]
    List<String> jvmargs = getGwtCompileJVMArgs();
    List<String> compilerArgs = getGwtCompilerArgs();
    List<String> gwtcCommand = new ArrayList<String>(jvmargs.size() + compilerArgs.size() + 11);
    int argIndex = 0;
    gwtcCommand.add(argIndex++, javaCommand);
    for (String arg : jvmargs) {
      gwtcCommand.add(argIndex++, arg);
    }
    gwtcCommand.add(argIndex++, "-cp");
    int classpathArgIndex = argIndex; //app-specific arg.
    gwtcCommand.add(argIndex++, null);
    int compileClassIndex = argIndex;
    gwtcCommand.add(argIndex++, getGwtCompilerClass());
    gwtcCommand.add(argIndex++, "-gen");
    gwtcCommand.add(argIndex++, getGwtGenDir().getAbsolutePath());
    gwtcCommand.add(argIndex++, "-style");
    int styleArgIndex = argIndex;
    gwtcCommand.add(argIndex++, null); //app-specific arg.
    gwtcCommand.add(argIndex++, gwtVersionGreaterThan(1, 5) ? "-war" : "-out");
    int outArgIndex = argIndex;
    gwtcCommand.add(argIndex++, null); //app-specific arg.
    for (String arg : compilerArgs) {
      gwtcCommand.add(argIndex++, arg);
    }
    int moduleNameIndex = argIndex;
    gwtcCommand.add(argIndex, null); //module-specific arg.

    for (GWTApp gwtApp : gwtApps) {
      String appName = gwtApp.getName();
      File appSource = enunciate.resolvePath(gwtApp.getSrcDir());
      String style = gwtApp.getJavascriptStyle().toString();
      File appDir = getAppGenerateDir(appName);

      gwtcCommand.set(classpathArgIndex, classpath.toString() + File.pathSeparatorChar + appSource.getAbsolutePath());
      gwtcCommand.set(styleArgIndex, style);
      gwtcCommand.set(outArgIndex, appDir.getAbsolutePath());

      boolean upToDate = enunciate.isUpToDate(getClientSideGenerateDir(), appDir) && enunciate.isUpToDate(appSource, appDir);
      if (!upToDate) {
        for (GWTAppModule appModule : gwtApp.getModules()) {
          String moduleName = appModule.getName();

          gwtcCommand.set(moduleNameIndex, moduleName);
          debug("Executing GWTCompile for module '%s'...", moduleName);
          if (enunciate.isDebug()) {
            StringBuilder command = new StringBuilder();
            for (String commandPiece : gwtcCommand) {
              command.append(' ').append(commandPiece);
            }
            debug("Executing GWTCompile for module %s with the command: %s", moduleName, command);
          }
          ProcessBuilder processBuilder = new ProcessBuilder(gwtcCommand);
          processBuilder.directory(getGenerateDir());
          processBuilder.redirectErrorStream(true);
          Process process = processBuilder.start();
          BufferedReader procReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
          String line = procReader.readLine();
          while (line != null) {
            line = URLDecoder.decode(line, "utf-8").replaceAll("%", "%%").trim(); //GWT URL-encodes spaces and other weird Windows characters.
            info(line);
            line = procReader.readLine();
          }
          int procCode;
          try {
            procCode = process.waitFor();
          }
          catch (InterruptedException e1) {
            throw new EnunciateException("Unexpected inturruption of the GWT compile process.");
          }

          if (procCode != 0) {
            throw new EnunciateException("GWT compile failed for module " + moduleName);
          }

          if (!gwtVersionGreaterThan(1, 5)) {
            File moduleOutputDir = appDir;
            String outputPath = appModule.getOutputPath();
View Full Code Here

      out.flush();
      bytes.flush();
      return bytes.toString("utf-8");
    }
    catch (TemplateException e) {
      throw new EnunciateException(e);
    }
  }
View Full Code Here

  public void init(Enunciate enunciate) throws EnunciateException {
    super.init(enunciate);

    if (!isDisabled()) {
      if (!enunciate.isModuleEnabled("jaxws-support")) {
        throw new EnunciateException("The JAX-WS RI module requires an enabled JAX-WS Support module.");
      }

      this.springModuleEnabled = enunciate.isModuleEnabled("spring-app");

      if (forceSpringEnabled && forceSpringDisabled) {
        throw new EnunciateException("jaxws-ri module must not be configured to force spring to be both enabled and disabled.");
      }
    }
  }
View Full Code Here

  public void init(Enunciate enunciate) throws EnunciateException {
    super.init(enunciate);

    if (!isDisabled()) {
      if (!enunciate.isModuleEnabled("spring-app")) {
        throw new EnunciateException("The CXF module requires the spring-app module to be enabled.");
      }
      else {
        List<DeploymentModule> enabledModules = enunciate.getConfig().getEnabledModules();
        for (DeploymentModule enabledModule : enabledModules) {
          if (enabledModule instanceof SpringAppDeploymentModule) {
View Full Code Here

        Transformer transformer = TransformerFactory.newInstance().newTransformer(source);
        debug("Transforming %s to %s.", src, dest);
        transformer.transform(new StreamSource(new FileReader(src)), new StreamResult(dest));
      }
      catch (TransformerException e) {
        throw new EnunciateException("Error during transformation of the web.xml (stylesheet " + transform + ", file " + src + ")", e);
      }
      finally {
        transformStream.close();
      }
    }
View Full Code Here

TOP

Related Classes of org.codehaus.enunciate.EnunciateException

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.