예제 #1
0
  public RestLiApiBuilder(final RestLiConfig config) {
    if (config.getResourcePackageNamesSet().isEmpty()) {
      throw new ResourceConfigException(
          "At least one package containing rest-annotated classes must be specified");
    }

    _packageNames =
        config
            .getResourcePackageNamesSet()
            .toArray(new String[config.getResourcePackageNamesSet().size()]);
  }
  @Override
  public void initialize(RestLiConfig config, Map<String, ResourceModel> rootResources) {
    final DataSchemaResolver schemaResolver = new ClassNameDataSchemaResolver();
    final ResourceSchemaCollection resourceSchemas =
        ResourceSchemaCollection.loadOrCreateResourceSchema(rootResources);
    final RestLiResourceRelationship relationships =
        new RestLiResourceRelationship(resourceSchemas, schemaResolver);

    _htmlRenderer =
        new RestLiHTMLDocumentationRenderer(
            config.getServerNodeUri(),
            relationships,
            new VelocityTemplatingEngine(),
            schemaResolver);
    _jsonRenderer = new RestLiJSONDocumentationRenderer(relationships);
  }