store descriptions from extension points and extensions in module and plugin descriptors

This commit is contained in:
Sebastian Sdorra
2014-07-06 16:44:10 +02:00
parent 6d7beeec99
commit 1fba76c969
8 changed files with 156 additions and 23 deletions

View File

@@ -58,10 +58,12 @@ public final class ClassElement
*
*
* @param clazz
* @param description
*/
public ClassElement(Class<?> clazz)
public ClassElement(Class<?> clazz, String description)
{
this.clazz = clazz;
this.description = description;
}
//~--- methods --------------------------------------------------------------
@@ -89,7 +91,8 @@ public final class ClassElement
final ClassElement other = (ClassElement) obj;
return Objects.equal(clazz, other.clazz);
return Objects.equal(clazz, other.clazz)
&& Objects.equal(description, other.description);
}
/**
@@ -101,7 +104,7 @@ public final class ClassElement
@Override
public int hashCode()
{
return Objects.hashCode(clazz);
return Objects.hashCode(clazz, description);
}
/**
@@ -116,6 +119,7 @@ public final class ClassElement
//J-
return Objects.toStringHelper(this)
.add("clazz", clazz)
.add("description", description)
.toString();
//J+
}
@@ -133,9 +137,23 @@ public final class ClassElement
return clazz;
}
/**
* Method description
*
*
* @return
*/
public String getDescription()
{
return description;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
@XmlElement(name = "class")
private Class<?> clazz;
/** Field description */
private String description;
}

View File

@@ -63,11 +63,14 @@ public final class ExtensionPointElement
*
*
* @param clazz
* @param description
* @param multiple
*/
public ExtensionPointElement(Class<?> clazz, boolean multiple)
public ExtensionPointElement(Class<?> clazz, String description,
boolean multiple)
{
this.clazz = clazz;
this.description = description;
this.multiple = multiple;
}
@@ -97,6 +100,7 @@ public final class ExtensionPointElement
final ExtensionPointElement other = (ExtensionPointElement) obj;
return Objects.equal(clazz, other.clazz)
&& Objects.equal(description, other.description)
&& Objects.equal(multiple, other.multiple);
}
@@ -109,7 +113,7 @@ public final class ExtensionPointElement
@Override
public int hashCode()
{
return Objects.hashCode(clazz, multiple);
return Objects.hashCode(clazz, description, multiple);
}
/**
@@ -124,6 +128,7 @@ public final class ExtensionPointElement
//J-
return Objects.toStringHelper(this)
.add("class", clazz)
.add("description", description)
.add("multiple", multiple)
.toString();
//J+
@@ -142,6 +147,17 @@ public final class ExtensionPointElement
return clazz;
}
/**
* Method description
*
*
* @return
*/
public String getDescription()
{
return description;
}
/**
* Method description
*
@@ -159,6 +175,9 @@ public final class ExtensionPointElement
@XmlElement(name = "class")
private Class<?> clazz;
/** Field description */
private String description;
/** Field description */
@XmlElement(name = "multi")
private boolean multiple = true;

View File

@@ -34,11 +34,11 @@ package sonia.scm.plugin;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Objects;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
//~--- JDK imports ------------------------------------------------------------
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@@ -64,11 +64,14 @@ public final class SubscriberElement
*
* @param subscriberClass
* @param eventClass
* @param description
*/
public SubscriberElement(Class<?> subscriberClass, Class<?> eventClass)
public SubscriberElement(Class<?> subscriberClass, Class<?> eventClass,
String description)
{
this.subscriberClass = subscriberClass;
this.eventClass = eventClass;
this.description = description;
}
//~--- methods --------------------------------------------------------------
@@ -97,7 +100,8 @@ public final class SubscriberElement
final SubscriberElement other = (SubscriberElement) obj;
return Objects.equal(eventClass, other.eventClass)
&& Objects.equal(subscriberClass, other.subscriberClass);
&& Objects.equal(subscriberClass, other.subscriberClass)
&& Objects.equal(description, other.description);
}
/**
@@ -109,7 +113,7 @@ public final class SubscriberElement
@Override
public int hashCode()
{
return Objects.hashCode(eventClass, subscriberClass);
return Objects.hashCode(eventClass, subscriberClass, description);
}
/**
@@ -125,12 +129,24 @@ public final class SubscriberElement
return Objects.toStringHelper(this)
.add("eventClass", eventClass)
.add("subscriberClass", subscriberClass)
.add("description", description)
.toString();
//J+
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public String getDescription()
{
return description;
}
/**
* Method description
*
@@ -155,6 +171,9 @@ public final class SubscriberElement
//~--- fields ---------------------------------------------------------------
/** Field description */
private String description;
/** Field description */
@XmlElement(name = "event")
private Class<?> eventClass;

View File

@@ -77,9 +77,9 @@ public class ScmModuleTest
assertThat(
module.getExtensionPoints(),
containsInAnyOrder(
new ExtensionPointElement(String.class, true),
new ExtensionPointElement(Long.class, true),
new ExtensionPointElement(Integer.class, false)
new ExtensionPointElement(String.class, "ext01", true),
new ExtensionPointElement(Long.class, "ext02", true),
new ExtensionPointElement(Integer.class, "ext03", false)
)
);
assertThat(
@@ -92,8 +92,8 @@ public class ScmModuleTest
assertThat(
module.getSubscribers(),
containsInAnyOrder(
new SubscriberElement(Long.class, Integer.class),
new SubscriberElement(Double.class, Float.class)
new SubscriberElement(Long.class, Integer.class, "sub01"),
new SubscriberElement(Double.class, Float.class, "sub02")
)
);
assertThat(

View File

@@ -5,11 +5,13 @@
<subscriber>
<class>java.lang.Long</class>
<event>java.lang.Integer</event>
<description>sub01</description>
</subscriber>
<subscriber>
<class>java.lang.Double</class>
<event>java.lang.Float</event>
<description>sub02</description>
</subscriber>
<!-- events -->
@@ -26,15 +28,18 @@
<extension-point>
<class>java.lang.String</class>
<description>ext01</description>
</extension-point>
<extension-point>
<class>java.lang.Integer</class>
<description>ext03</description>
<multi>false</multi>
</extension-point>
<extension-point>
<class>java.lang.Long</class>
<description>ext02</description>
<multi>true</multi>
</extension-point>