Search in sources :

Example 1 with UriEndpoint

use of org.apache.camel.spi.UriEndpoint in project camel by apache.

the class EndpointAnnotationProcessor method processEndpointClass.

private void processEndpointClass(final RoundEnvironment roundEnv, final TypeElement classElement) {
    final UriEndpoint uriEndpoint = classElement.getAnnotation(UriEndpoint.class);
    if (uriEndpoint != null) {
        String scheme = uriEndpoint.scheme();
        String extendsScheme = uriEndpoint.extendsScheme();
        String title = uriEndpoint.title();
        final String label = uriEndpoint.label();
        if (!isNullOrEmpty(scheme)) {
            // support multiple schemes separated by comma, which maps to the exact same component
            // for example camel-mail has a bunch of component schema names that does that
            String[] schemes = scheme.split(",");
            String[] titles = title.split(",");
            String[] extendsSchemes = extendsScheme.split(",");
            for (int i = 0; i < schemes.length; i++) {
                final String alias = schemes[i];
                final String extendsAlias = i < extendsSchemes.length ? extendsSchemes[i] : extendsSchemes[0];
                String aTitle = i < titles.length ? titles[i] : titles[0];
                // some components offer a secure alternative which we need to amend the title accordingly
                if (secureAlias(schemes[0], alias)) {
                    aTitle += " (Secure)";
                }
                final String aliasTitle = aTitle;
                // write json schema
                String name = canonicalClassName(classElement.getQualifiedName().toString());
                String packageName = name.substring(0, name.lastIndexOf("."));
                String fileName = alias + ".json";
                Func1<PrintWriter, Void> handler = new Func1<PrintWriter, Void>() {

                    @Override
                    public Void call(PrintWriter writer) {
                        writeJSonSchemeDocumentation(writer, roundEnv, classElement, uriEndpoint, aliasTitle, alias, extendsAlias, label, schemes);
                        return null;
                    }
                };
                processFile(processingEnv, packageName, fileName, handler);
            }
        }
    }
}
Also used : UriEndpoint(org.apache.camel.spi.UriEndpoint) UriEndpoint(org.apache.camel.spi.UriEndpoint) PrintWriter(java.io.PrintWriter)

Aggregations

PrintWriter (java.io.PrintWriter)1 UriEndpoint (org.apache.camel.spi.UriEndpoint)1