Examples of Messager


Examples of com.sun.enterprise.tools.Messager

    public void write(final AnnotationProcessorEnvironment env) {
        String outDirectory = env.getOptions().get("-d");
        if (outDirectory==null) outDirectory = env.getOptions().get("-s");
        if(outDirectory==nulloutDirectory = System.getProperty("user.home");

        Messager messager = new Messager() {
          @Override
          public void printError(String msg, Exception e) {
            e.printStackTrace();
            env.getMessager().printError(msg);
          }
View Full Code Here

Examples of com.sun.mirror.apt.Messager

     * todo: should this always run all tests whenever called for any supported annotation?
     */
    @Override
    public void check(Declaration _decl) {

        Messager messager = _env.getMessager();

        try {

            // check if we've already handled this declaration
            if (handledDecls.contains(_decl)) {
                return;
            }

            // check if we're interested in declaration
            if (! (_decl instanceof TypeDeclaration)) {
                return;
            }
            WebService wsAnnotation = _decl.getAnnotation(WebService.class);
            if (null == wsAnnotation) {
                messager.printError(_decl.getPosition(), "@WebService annotation missing; unable to process: " + ((TypeDeclaration) _decl).getQualifiedName());
            }

            // store declaration so we don't handle it multiple times
            handledDecls.add((TypeDeclaration) _decl);
       
            // service implementation bean
            if (_decl instanceof ClassDeclaration) {
                ClassDeclaration classDecl = (ClassDeclaration) _decl;
                messager.printNotice("processing service implementation bean: " + classDecl.getQualifiedName());
               
                BeehiveWsTypeMetadata om = null;
                String endpointInterface = wsAnnotation.endpointInterface().trim();
               
                // start from endpoint interface
                if (null != endpointInterface && 0 < endpointInterface.length()) {

                    // get object model for service endpoint interface
                    om = getEndpointInterfaceObjectModel(endpointInterface);
                   
                    // merge abstract and concrete object models
                    om.merge(new MirrorTypeInfo(classDecl, _env));
                }
               
                // create object model from scratch
                else {
                    om = new Jsr181TypeMetadataImpl(new MirrorTypeInfo(classDecl, _env));
                }

                // check if we have an object model
                if (null == om) {
                    return;
                }

                // persist object model
                oms.store(om);
            }
           
            // service endpoint interface
            else if (_decl instanceof InterfaceDeclaration) {
                InterfaceDeclaration interfaceDecl = (InterfaceDeclaration) _decl;
               
                messager.printNotice("processing service endpoint interface: " + interfaceDecl.getQualifiedName());
               
                // create object model
                BeehiveWsTypeMetadata om = new Jsr181TypeMetadataImpl(new MirrorTypeInfo(interfaceDecl, _env));
                if (null == om) {
                    return;
                }

                // store the object model
                oms.store(om);
            }

            // @WebService annotation on unknown/unsupported type definition
            else {
                messager.printError(_decl.getPosition(), "found unsupported type of TypeDeclaration:" + _decl.getSimpleName());
            }
        }

        // if an exception or error ocurred log it and return
        catch (Throwable t) {
            messager.printError(_decl.getPosition(), t.getMessage());
        }
    }
View Full Code Here

Examples of com.sun.mirror.apt.Messager

   * @param model The model to validate.
   * @throws ModelValidationException If any validation errors are encountered.
   */
  protected void validate(EnunciateFreemarkerModel model) throws ModelValidationException {
    debug("Validating the model...");
    Messager messager = getMessager();
    ValidatorChain validator = new ValidatorChain();
    EnunciateConfiguration config = this.enunciate.getConfig();
    Set<String> disabledRules = new TreeSet<String>(config.getDisabledRules());
    if (this.enunciate.isModuleEnabled("rest")) {
      //if the REST module is enabled, disable the validation rule that
      //fails if the module is not enabled.
      disabledRules.add("disabled.rest.module");
    }

    Validator coreValidator = config.getValidator();
    if (coreValidator instanceof ConfigurableRules) {
      ((ConfigurableRules) coreValidator).disableRules(disabledRules);
    }
    validator.addValidator("core", coreValidator);
    debug("Default validator added to the chain.");
    for (DeploymentModule module : config.getEnabledModules()) {
      Validator moduleValidator = module.getValidator();
      if (moduleValidator != null) {
        if (moduleValidator instanceof ConfigurableRules) {
          ((ConfigurableRules)moduleValidator).disableRules(disabledRules);
        }
        validator.addValidator(module.getName(), moduleValidator);
        debug("Validator for module %s added to the chain.", module.getName());
      }
    }

    if (!config.isAllowEmptyNamespace()) {
      validator.addValidator("emptyns", new EmptyNamespaceValidator());
    }

    ValidationResult validationResult = validate(model, validator);

    if (validationResult.hasWarnings()) {
      warn("Validation result has warnings.");
      for (ValidationMessage warning : validationResult.getWarnings()) {
        if (!disabledRules.contains("all.warnings") && !disabledRules.contains(String.valueOf(warning.getLabel()) + ".warnings")) {
          StringBuilder text = new StringBuilder();
          if (warning.getLabel() != null) {
            text.append('[').append(warning.getLabel()).append("] ");
          }
          text.append(warning.getText());

          if (warning.getPosition() != null) {
            messager.printWarning(warning.getPosition(), text.toString());
          }
          else {
            messager.printWarning(text.toString());
          }
        }
      }
    }

    if (validationResult.hasErrors()) {
      warn("Validation result has errors.");
      for (ValidationMessage error : validationResult.getErrors()) {
        StringBuilder text = new StringBuilder();
        if (error.getLabel() != null) {
          text.append('[').append(error.getLabel()).append("] ");
        }
        text.append(error.getText());

        if (error.getPosition() != null) {
          messager.printError(error.getPosition(), text.toString());
        }
        else {
          messager.printError(text.toString());
        }
      }

      throw new ModelValidationException();
    }
View Full Code Here

Examples of com.sun.mirror.apt.Messager

  //Inherited.
  @Override
  protected void process(TemplateException e) {
    if (!(e instanceof ModelValidationException)) {
      Messager messager = getMessager();
      StringWriter stackTrace = new StringWriter();
      e.printStackTrace(new PrintWriter(stackTrace));
      messager.printError(stackTrace.toString());
    }

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

Examples of com.sun.mirror.apt.Messager

  public void testValidate() throws Exception {
    final EndpointInterface ei = new EndpointInterface(getDeclaration("org.codehaus.enunciate.samples.services.NamespacedWebService"));
    final ComplexTypeDefinition beanOne = new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.BeanOne"));
    final ComplexTypeDefinition beanTwo = new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.BeanTwo"));
    final ComplexTypeDefinition beanThree = new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.BeanThree"));
    final Messager messager = EasyMock.createNiceMock(Messager.class);
    RootElementDeclaration beanThreeElement = new RootElementDeclaration((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.BeanThree"), beanThree);

    EnunciateConfiguration config = new EnunciateConfiguration();
    final MockValidator validator = new MockValidator();
    config.setValidator(validator);
View Full Code Here

Examples of com.sun.tools.javadoc.Messager

   *            the new messager
   * @return the old messager
   */
  public static Messager replaceMessager(Object docEnvContainer,
      Messager newMessager) {
    Messager messager = null;

    // replace the messager to avoid unnecessary warnings

    try {

View Full Code Here

Examples of com.sun.tools.javadoc.Messager

   * @param root
   *            container of the current messager
   */
  public static void replaceMessageWriters(Writer newWriter, RootDoc root)
      throws Exception {
    Messager messager = replaceMessager(root, null);
    ObjectAnalyzer analyzer = new ObjectAnalyzer(messager);
    ArrayList<PrintWriter> writers = new ArrayList<PrintWriter>();
    writers.add((PrintWriter) analyzer.getPrivateField("warnWriter"));
    writers.add((PrintWriter) analyzer.getPrivateField("errWriter"));
    writers.add((PrintWriter) analyzer.getPrivateField("noticeWriter"));
View Full Code Here

Examples of com.sun.tools.javadoc.Messager

        if (!result) {
          // info: if the annotation type has an error (not found)
          // then Message.printWarning is invoked.
          // avoid the printing of these warnings by replacing the
          // messager
          Messager originalMessager = replaceMessager(annotation,
              null);
          String name = null;
          if (useOnlyName)
            name = annotation.annotationType().name();
          else
View Full Code Here

Examples of edu.isi.karma.cleaning.Messager

        }
        vtmp.add(pair);
      }
      DataPreProcessor dpp = new DataPreProcessor(vtmp);
      dpp.run();
      Messager msger = new Messager();
      while (true) {

        Vector<String[]> result = new Vector<String[]>();
        System.out.print("Enter raw value\n");
        // open up standard input
        BufferedReader br = new BufferedReader(new InputStreamReader(
            System.in));
        String raw = null;
        raw = br.readLine();
        if (raw.compareTo("end") == 0) {
          break;
        }
        System.out.print("Enter tar value\n");
        // open up standard input
        String tar = null;
        tar = br.readLine();

        // learn the program
        String[] xStrings = { "<_START>" + raw + "<_END>", tar };
        examples.add(xStrings);
        for (String[] elem : examples) {
          System.out.println("Examples inputed: "
              + Arrays.toString(elem));
        }
        String ofpath = "/Users/bowu/Research/50newdata/tmp/"
            + nf.getName();
        CSVWriter cw = new CSVWriter(new FileWriter(new File(ofpath)));
        ProgSynthesis psProgSynthesis = new ProgSynthesis();       
        psProgSynthesis.inite(examples,dpp,msger); //
        Collection<ProgramRule> ps = psProgSynthesis.run_main();
        msger.updateCM_Constr(psProgSynthesis.partiCluster
            .getConstraints());
        msger.updateWeights(psProgSynthesis.partiCluster.weights);
        ProgramRule pr = ps.iterator().next();
        System.out.println(""+psProgSynthesis.myprog.toString());
        System.out.println("" + pr.toString());
        for(String org: vtmp)
        {
View Full Code Here

Examples of edu.isi.karma.cleaning.Messager

          xHashMap.put(index + "", line);
          index++;
        }
        DataPreProcessor dpp = new DataPreProcessor(vtmp);
        dpp.run();
        Messager msger = new Messager();
        Vector<Vector<String[]>> constraints = new Vector<Vector<String[]>>();
        if (entries.size() <= 1)
          return;
        ExampleSelection expsel = new ExampleSelection();
        ExampleSelection.firsttime = true;
        expsel.inite(xHashMap, null);
        int target = Integer.parseInt(expsel.Choose());
        String[] mt = { "<_START>" + entries.get(target)[0] + "<_END>",
            entries.get(target)[1] };
        examples.add(mt);
        ExampleSelection.firsttime = false;
        // accuracy record code
        ArrayList<double[]> accArrayList = new ArrayList<double[]>();
        while (true) // repeat as no incorrect answer appears.
        {
          if (examples.size() == 8) {
            System.out.println("Hello World");
          }
          long checknumber = 1;
          long iterAfterNoFatalError = 0;
          long isvisible = 0;
          HashMap<String, Vector<String[]>> expFeData = new HashMap<String, Vector<String[]>>();
          Vector<String> resultString = new Vector<String>();
          xHashMap = new HashMap<String, String[]>();
          ProgSynthesis psProgSynthesis = new ProgSynthesis();
          HashMap<String, String> unlabeledData = new HashMap<String, String>();
          for (int i = 0; i < vtmp.size(); i++) {
            unlabeledData.put("" + i, vtmp.get(i));
          }
          psProgSynthesis.inite(examples, dpp, msger);
          Vector<ProgramRule> pls = new Vector<ProgramRule>();
          Collection<ProgramRule> ps = psProgSynthesis.run_main();
          // collect history contraints
          msger.updateCM_Constr(psProgSynthesis.partiCluster
              .getConstraints());
          msger.updateWeights(psProgSynthesis.partiCluster.weights);
          // constraints.addAll();
          if (ps != null) {
            pls.addAll(ps);
          } else {
            System.out.println("Cannot find any rule");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.