[forge-issues] [JBoss JIRA] (FORGE-2075) Facet like support for .jar introspection

paolo antinori (JIRA) issues at jboss.org
Wed Oct 15 12:05:35 EDT 2014


paolo antinori created FORGE-2075:
-------------------------------------

             Summary: Facet like support for .jar introspection
                 Key: FORGE-2075
                 URL: https://issues.jboss.org/browse/FORGE-2075
             Project: Forge
          Issue Type: Feature Request
            Reporter: paolo antinori
            Priority: Minor


As part of Camel addon we are trying to add this functionality:
- offer the user the ability to add to the project a new Camel component(i.e. a .jar downloaded from Maven) taken from a predefined list
- add it as a dependency to the project
- generate various resources based on dynamic templates combined with the user choice

To address the last of that list, I have to "consume" the artifact that has been added. And since there is no static metadata, I have to discover which of the classes that are in that .jar implements a specific interface, extends a class or is annotated in a specific way.

It would be handy if there could be any helper class that behaves similarly to the {{JavaSourceFacet}} , offering facilities to inspect the classes contained in a .jar.

Anything similar to the following snippet but applied on a {{.jar}}
{code}
 project.getFacet(JavaSourceFacet.class).visitJavaSources(
 	new JavaResourceVisitor() {
 		@Override
 		public void visit(VisitContext context, JavaResource javaResource) {
 			try {
 				JavaSource<?> javaType = javaResource.getJavaType();
 				if (javaType.isClass()) {
 					JavaClassSource source = (JavaClassSource) javaType;
 					if (source.hasAnnotation(org.apache.camel.cdi.ContextName.class)
 						|| source.hasAnnotation(org.apache.camel.cdi.Uri.class)
 						) {
 						matched[0] = true;
 				}
 			}
 		} catch (FileNotFoundException e) {
 			e.printStackTrace();
 		}
 	}
 });
{code}

[~lincolnthree] pointed me to this example:

https://github.com/forge/core/blob/master/database-tools/impl/src/main/java/org/jboss/forge/addon/database/tools/connections/AbstractConnectionProfileDetailsPage.java#L227

Which is exactly what I need, but it would turn out handy having helper methods and classes to keep the code simpler and symmetric to other interaction with Forge APIs



--
This message was sent by Atlassian JIRA
(v6.3.1#6329)


More information about the forge-issues mailing list