Пример #1
0
 /**
  * Create a class that acts as a container for a hierarchy of static inner classes, one for each
  * resource described by the WADL file.
  *
  * @param root the resource element that corresponds to the root of the resource tree
  * @throws com.sun.codemodel.JClassAlreadyExistsException if, during code generation, the WADL
  *     processor attempts to create a duplicate class. This indicates a structural problem with
  *     the WADL file, e.g. duplicate peer resource entries.
  */
 protected void generateEndpointClass(ResourceNode root) throws JClassAlreadyExistsException {
   JDefinedClass impl = jPkg._class(JMod.PUBLIC, root.getClassName());
   javaDoc.generateClassDoc(root, impl);
   for (ResourceNode r : root.getChildResources()) {
     generateSubClass(impl, r);
   }
 }
Пример #2
0
 /**
  * Generate Java interfaces for WADL resource types
  *
  * @throws com.sun.codemodel.JClassAlreadyExistsException if the interface to be generated already
  *     exists
  */
 protected void generateResourceTypeInterfaces() throws JClassAlreadyExistsException {
   for (String id : ifaceMap.keySet()) {
     ResourceTypeNode n = ifaceMap.get(id);
     JDefinedClass iface = jPkg._class(JMod.PUBLIC, n.getClassName(), ClassType.INTERFACE);
     n.setGeneratedInterface(iface);
     javaDoc.generateClassDoc(n, iface);
     ResourceClassGenerator rcGen =
         new ResourceClassGenerator(s2jModel, codeModel, jPkg, generatedPackages, javaDoc, iface);
     // generate Java methods for each resource method
     for (MethodNode m : n.getMethods()) {
       rcGen.generateMethodDecls(m, true);
     }
     // generate bean properties for matrix parameters
     for (Param p : n.getMatrixParams()) {
       rcGen.generateBeanProperty(iface, p, true);
     }
   }
 }