diff --git a/publisher-api/src/main/java/org/iplantc/de/publish/mechanism/api/annotations/PublicationDriver.java b/publisher-api/src/main/java/org/iplantc/de/publish/mechanism/api/annotations/PublicationDriver.java index df4fba2..2dab9c9 100644 --- a/publisher-api/src/main/java/org/iplantc/de/publish/mechanism/api/annotations/PublicationDriver.java +++ b/publisher-api/src/main/java/org/iplantc/de/publish/mechanism/api/annotations/PublicationDriver.java @@ -4,6 +4,8 @@ package org.iplantc.de.publish.mechanism.api.annotations; import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; /** * Annotation that marks up a publish mechanism for discovery @@ -12,6 +14,7 @@ * */ @Documented +@Retention(RetentionPolicy.RUNTIME) public @interface PublicationDriver { /** * Author of the publisher plugin diff --git a/publisher-sandbox/src/main/java/org/iplantc/de/publish/sandbox/PublisherDescription.java b/publisher-sandbox/src/main/java/org/iplantc/de/publish/sandbox/PublisherDescription.java new file mode 100644 index 0000000..b9860d8 --- /dev/null +++ b/publisher-sandbox/src/main/java/org/iplantc/de/publish/sandbox/PublisherDescription.java @@ -0,0 +1,147 @@ +/** + * + */ +package org.iplantc.de.publish.sandbox; + +/** + * Describes publishers discovered in the sandbox + * + * @author Mike Conway - DICE + * + */ +public class PublisherDescription { + + private Class publisherClass; + private String publisherName; + private String description; + private boolean asynch; + private String author; + private String version; + + /** + * + */ + public PublisherDescription() { + } + + /** + * @return the publisherClass + */ + public Class getPublisherClass() { + return publisherClass; + } + + /** + * @param publisherClass + * the publisherClass to set + */ + public void setPublisherClass(Class publisherClass) { + this.publisherClass = publisherClass; + } + + /** + * @return the publisherName + */ + public String getPublisherName() { + return publisherName; + } + + /** + * @param publisherName + * the publisherName to set + */ + public void setPublisherName(String publisherName) { + this.publisherName = publisherName; + } + + /** + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * @param description + * the description to set + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * @return the asynch + */ + public boolean isAsynch() { + return asynch; + } + + /** + * @param asynch + * the asynch to set + */ + public void setAsynch(boolean asynch) { + this.asynch = asynch; + } + + /** + * @return the author + */ + public String getAuthor() { + return author; + } + + /** + * @param author + * the author to set + */ + public void setAuthor(String author) { + this.author = author; + } + + /** + * @return the version + */ + public String getVersion() { + return version; + } + + /** + * @param version + * the version to set + */ + public void setVersion(String version) { + this.version = version; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("PublisherDescription ["); + if (publisherClass != null) { + builder.append("publisherClass=").append(publisherClass) + .append(", "); + } + if (publisherName != null) { + builder.append("publisherName=").append(publisherName).append(", "); + } + if (description != null) { + builder.append("description=").append(description).append(", "); + } + builder.append("asynch=").append(asynch).append(", "); + if (author != null) { + builder.append("author=").append(author).append(", "); + } + if (version != null) { + builder.append("version=").append(version); + } + builder.append("]"); + return builder.toString(); + } + +} diff --git a/publisher-sandbox/src/main/java/org/iplantc/de/publish/sandbox/PublisherEmulator.java b/publisher-sandbox/src/main/java/org/iplantc/de/publish/sandbox/PublisherEmulator.java index 778ba73..dcb209e 100644 --- a/publisher-sandbox/src/main/java/org/iplantc/de/publish/sandbox/PublisherEmulator.java +++ b/publisher-sandbox/src/main/java/org/iplantc/de/publish/sandbox/PublisherEmulator.java @@ -4,6 +4,7 @@ package org.iplantc.de.publish.sandbox; import java.io.File; +import java.lang.annotation.Annotation; import java.net.MalformedURLException; import java.net.URI; import java.net.URL; @@ -47,7 +48,28 @@ public PublisherEmulator() { } - public Set> listPublishers() { + public List listPublisherDescriptions() { + log.info("listPublisherDescriptions()"); + Set> classes = listPublisherClasses(); + + for (Class clazz : classes) { + log.info("processing class:{}", clazz); + for (Annotation annotation : clazz.getDeclaredAnnotations()) { + log.info("...annotation:{}", annotation.toString()); + } + } + + return null; + + } + + /** + * Method returns the classes for all registered publishers. Good for + * debugging and testing purposes + * + * @return Set of all of the annotated publisher classes + */ + public Set> listPublisherClasses() { /* * see: https://github.com/ronmamo/reflections diff --git a/publisher-sandbox/src/test/java/org/iplantc/de/publish/sandbox/PublisherEmulatorTest.java b/publisher-sandbox/src/test/java/org/iplantc/de/publish/sandbox/PublisherEmulatorTest.java index d1f1c06..d417263 100644 --- a/publisher-sandbox/src/test/java/org/iplantc/de/publish/sandbox/PublisherEmulatorTest.java +++ b/publisher-sandbox/src/test/java/org/iplantc/de/publish/sandbox/PublisherEmulatorTest.java @@ -3,6 +3,7 @@ */ package org.iplantc.de.publish.sandbox; +import java.util.List; import java.util.Properties; import java.util.Set; @@ -58,9 +59,24 @@ public void testListPublishers() throws PublicationException { PublisherEmulator emulator = new PublisherEmulator(); emulator.setSandboxConfiguration(sandboxConfiguration); emulator.init(); - Set> mechanisms = emulator.listPublishers(); + Set> mechanisms = emulator.listPublisherClasses(); Assert.assertFalse("no mechanisms returned", mechanisms.isEmpty()); } + @Test + public void testListPublicationDescriptions() throws PublicationException { + SandboxConfiguration sandboxConfiguration = new SandboxConfiguration(); + sandboxConfiguration + .setJarFilePluginDir(testingProperties + .getProperty(PublisherTestingProperties.TEST_PUBLISHER_DIR_PROPERTY)); + PublisherEmulator emulator = new PublisherEmulator(); + emulator.setSandboxConfiguration(sandboxConfiguration); + emulator.init(); + List descriptions = emulator + .listPublisherDescriptions(); + Assert.assertNotNull("null descriptions found:{}", descriptions); + + } + }