Package org.codehaus.enunciate.apt

Examples of org.codehaus.enunciate.apt.EnunciateFreemarkerModel


      return "maven-export";
    }

    @Override
    protected void doGenerate() throws EnunciateException, IOException {
      EnunciateFreemarkerModel model = (EnunciateFreemarkerModel) FreemarkerModel.get();

      Set<String> exportedClasses = new HashSet<String>();
      for (SchemaInfo schemaInfo : model.getNamespacesToSchemas().values()) {
        for (TypeDefinition typeDefinition : schemaInfo.getTypeDefinitions()) {
          exportedClasses.add(typeDefinition.getQualifiedName());
        }

        for (RootElementDeclaration rootElementDeclaration : schemaInfo.getGlobalElements()) {
          exportedClasses.add(rootElementDeclaration.getQualifiedName());
        }

        for (Registry registry : schemaInfo.getRegistries()) {
          exportedClasses.add(registry.getQualifiedName());
        }
      }

      for (JsonSchemaInfo jsonSchemaInfo : model.getIdsToJsonSchemas().values()) {
        for (JsonTypeDefinition jsonTypeDefinition : jsonSchemaInfo.getTypes()) {
          exportedClasses.add(jsonTypeDefinition.getQualifiedName());
        }
      }

      for (WsdlInfo wsdlInfo : model.getNamespacesToWSDLs().values()) {
        for (EndpointInterface ei : wsdlInfo.getEndpointInterfaces()) {
          exportedClasses.add(ei.getQualifiedName());

          for (EndpointImplementation implementation : ei.getEndpointImplementations()) {
            exportedClasses.add(implementation.getQualifiedName());
          }
        }
      }

      for (RootResource rootResource : model.getRootResources()) {
        exportedClasses.add(rootResource.getQualifiedName());
      }

      for (TypeDeclaration jaxrsProvider : model.getJAXRSProviders()) {
        exportedClasses.add(jaxrsProvider.getQualifiedName());
      }

      File apiExportsFile = new File(classesDirectory, "META-INF/enunciate/api-exports");
      apiExportsFile.getParentFile().mkdirs();
View Full Code Here


  /**
   * tests doing the freemarker generate.
   */
  public void testDoFreemarkerGenerate() throws Exception {
    Enunciate enunciate = new Enunciate(new String[0]);
    final EnunciateFreemarkerModel model = new EnunciateFreemarkerModel();
    model.add(new EndpointInterface(getDeclaration("org.codehaus.enunciate.samples.jaxws.AnotherEndpointInterface")));
    model.add(new EndpointInterface(getDeclaration("org.codehaus.enunciate.samples.jaxws.BasicEndpointInterface")));
    FreemarkerModel.set(model);

    final HashMap<URL, Integer> counts = new HashMap<URL, Integer>();

    JAXWSSupportDeploymentModule module = new JAXWSSupportDeploymentModule() {
View Full Code Here

      protected EnunciateFreemarkerModel getModelInternal() {
        return (EnunciateFreemarkerModel) FreemarkerModel.get();
      }
    };
    module.init(enunciate);
    EnunciateFreemarkerModel model = module.getModel();
    model.put("file", new SpecifiedOutputDirectoryFileTransform(genDir));
    model.put("message", message);
    model.put("Introspector", BeansWrapper.getDefaultInstance().getStaticModels().get("java.beans.Introspector"));
    module.processTemplate(templateURL, model);

    Collection<String> srcFiles = enunciate.getJavaFiles(genDir);
    assertEquals("The wrapper bean should have been generated.", 1, srcFiles.size());
    srcFiles.addAll(getAllJavaFiles(getSamplesDir()));
View Full Code Here

  @Override
  public void doFreemarkerGenerate() throws IOException, TemplateException {
    File genDir = getGenerateDir();
    if (!enunciate.isUpToDateWithSources(genDir)) {
      EnunciateFreemarkerModel model = getModel();
      ClientPackageForMethod namespaceFor = new ClientPackageForMethod(this.packageToNamespaceConversions);
      namespaceFor.setUseClientNameConversions(true);
      model.put("namespaceFor", namespaceFor);
      model.put("findRootElement", new FindRootElementMethod());
      model.put("requestDocumentQName", new RequestDocumentQNameMethod());
      model.put("responseDocumentQName", new ResponseDocumentQNameMethod());
      ClientClassnameForMethod classnameFor = new ClientClassnameForMethod(this.packageToNamespaceConversions);
      classnameFor.setUseClientNameConversions(true);
      model.put("classnameFor", classnameFor);
      model.put("listsAsArraysClassnameFor", new ListsAsArraysClientClassnameForMethod(this.packageToNamespaceConversions));
      model.put("simpleNameFor", new SimpleNameWithParamsMethod(classnameFor));
      model.put("csFileName", getSourceFileName());
      model.put("accessorOverridesAnother", new AccessorOverridesAnotherMethod());

      debug("Generating the C# client classes...");
      URL apiTemplate = isSingleFilePerClass() ? getTemplateURL("api-multiple-files.fmt") : getTemplateURL("api.fmt");
      processTemplate(apiTemplate, model);
    }
View Full Code Here

  @Override
  public void doFreemarkerGenerate() throws IOException, TemplateException, EnunciateException {
    File genDir = getGenerateDir();
    if (!enunciate.isUpToDateWithSources(genDir)) {
      EnunciateFreemarkerModel model = getModel();
      List<TypeDefinition> schemaTypes = new ArrayList<TypeDefinition>();
      ExtensionDepthComparator comparator = new ExtensionDepthComparator();
      for (SchemaInfo schemaInfo : model.getNamespacesToSchemas().values()) {
        for (TypeDefinition typeDefinition : schemaInfo.getTypeDefinitions()) {
          int position = Collections.binarySearch(schemaTypes, typeDefinition, comparator);
          if (position < 0) {
            position = -position - 1;
          }
          schemaTypes.add(position, typeDefinition);
        }
      }
      model.put("schemaTypes", schemaTypes);
      model.put("packages2modules", this.packageToModuleConversions);
      ClientPackageForMethod moduleFor = new ClientPackageForMethod(this.packageToModuleConversions);
      moduleFor.setUseClientNameConversions(true);
      model.put("moduleFor", moduleFor);
      ClientClassnameForMethod classnameFor = new ClientClassnameForMethod(this.packageToModuleConversions);
      classnameFor.setUseClientNameConversions(true);
      model.put("classnameFor", classnameFor);
      TypeNameForMethod typeNameFor = new TypeNameForMethod(this.packageToModuleConversions);
      typeNameFor.setUseClientNameConversions(true);
      model.put("typeNameFor", typeNameFor);
      SimpleNameWithParamsMethod simpleNameFor = new SimpleNameWithParamsMethod(classnameFor);
      model.put("simpleNameFor", simpleNameFor);
      model.put("phpFileName", getSourceFileName());
      model.put("findRootElement", new FindRootElementMethod());
      model.put("referencedNamespaces", new ReferencedNamespacesMethod());
      model.put("prefix", new PrefixMethod());

      debug("Generating the PHP data classes...");
      URL apiTemplate = isSingleFilePerClass() ? getTemplateURL("api-multiple-files.fmt") : getTemplateURL("api.fmt");
      processTemplate(apiTemplate, model);
    }
View Full Code Here

  public void testBasicTypeDefinition() throws Exception {
    ClassDeclaration elementBeanOneDecl = (ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.ElementBeanOne");
    ComplexTypeDefinition elementBeanOneType = new ComplexTypeDefinition(elementBeanOneDecl);
    RootElementDeclaration elementBeanOne = new RootElementDeclaration(elementBeanOneDecl, elementBeanOneType);

    EnunciateFreemarkerModel model = new EnunciateFreemarkerModel();
    FreemarkerModel.set(model);
    model.add(elementBeanOneType);
    model.add(elementBeanOne);

    TypeDefinition typeDef = new MockTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.FullTypeDefBeanOne"));
    assertEquals(1, typeDef.getAttributes().size());
    assertEquals("property1", typeDef.getAttributes().iterator().next().getSimpleName());
View Full Code Here

  public void testExtendedTypeDefinition() throws Exception {
    ClassDeclaration elementBeanOneDecl = (ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.ElementBeanOne");
    ComplexTypeDefinition elementBeanOneType = new ComplexTypeDefinition(elementBeanOneDecl);
    RootElementDeclaration elementBeanOne = new RootElementDeclaration(elementBeanOneDecl, elementBeanOneType);

    EnunciateFreemarkerModel model = new EnunciateFreemarkerModel();
    FreemarkerModel.set(model);
    model.add(elementBeanOneType);
    model.add(elementBeanOne);

    TypeDefinition typeDef = new MockTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.ExtendedFullTypeDefBeanOne"));
    assertEquals(XmlAccessType.PROPERTY, typeDef.getAccessType());
  }
View Full Code Here

  @Override
  public void doFreemarkerGenerate() throws IOException, TemplateException, EnunciateException {
    File genDir = getGenerateDir();
    if (!enunciate.isUpToDateWithSources(genDir)) {
      EnunciateFreemarkerModel model = getModel();
      List<TypeDefinition> schemaTypes = new ArrayList<TypeDefinition>();
      ExtensionDepthComparator comparator = new ExtensionDepthComparator();
      for (SchemaInfo schemaInfo : model.getNamespacesToSchemas().values()) {
        for (TypeDefinition typeDefinition : schemaInfo.getTypeDefinitions()) {
          int position = Collections.binarySearch(schemaTypes, typeDefinition, comparator);
          if (position < 0) {
            position = -position - 1;
          }
          schemaTypes.add(position, typeDefinition);
        }
      }
      model.put("schemaTypes", schemaTypes);
      model.put("packages2modules", this.packageToModuleConversions);
      ClientPackageForMethod moduleFor = new ClientPackageForMethod(this.packageToModuleConversions);
      moduleFor.setUseClientNameConversions(true);
      model.put("moduleFor", moduleFor);
      ClientClassnameForMethod classnameFor = new ClientClassnameForMethod(this.packageToModuleConversions);
      classnameFor.setUseClientNameConversions(true);
      model.put("classnameFor", classnameFor);
      SimpleNameWithParamsMethod simpleNameFor = new SimpleNameWithParamsMethod(classnameFor);
      model.put("simpleNameFor", simpleNameFor);
      model.put("rubyFileName", getSourceFileName());

      debug("Generating the Ruby data classes...");
      URL apiTemplate = getTemplateURL("api.fmt");
      processTemplate(apiTemplate, model);
    }
View Full Code Here

  /**
   * test validating a complex type.
   */
  public void testValidateComplexType() throws Exception {
    EnunciateFreemarkerModel model = new EnunciateFreemarkerModel();
    FreemarkerModel.set(model);

    final Counter typeDefCounter = new Counter();
    DefaultValidator validator = new DefaultValidator() {
      @Override
      public ValidationResult validateTypeDefinition(TypeDefinition typeDef) {
        typeDefCounter.increment();
        return new ValidationResult();
      }
    };

    ComplexTypeDefinition complexType = new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.SimpleTypeComplexContentBean"));
    model.add(complexType);

    complexType = new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.ComplexTypeWithValueAndElements"));
    assertTrue("A complex type definition should not be valid if it has both elements and a value.", validator.validateComplexType(complexType).hasErrors());
    assertEquals(1, typeDefCounter.getCount());
  }
View Full Code Here

  /**
   * tests validating wrapped lists of element refs.
   */
  public void testValidateWrappedElementRefs() throws Exception {
    EnunciateFreemarkerModel model = new EnunciateFreemarkerModel();
    FreemarkerModel.set(model);
    ComplexTypeDefinition complexType = new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.WrappedElementRefBean"));
    model.add(complexType);
    DefaultValidator validator = new DefaultValidator();
    assertFalse("Shouldn't be errors on wrapped list of element refs.", validator.validateComplexType(complexType).hasErrors());
  }
View Full Code Here

TOP

Related Classes of org.codehaus.enunciate.apt.EnunciateFreemarkerModel

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.