modules/helpers/pluginAnnotations/pom.xml
| 13 +-
modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DataType.java
| 2
modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DisplayType.java
| 2
modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/MeasurementType.java
| 1
modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Metric.java
| 7 -
modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Operation.java
| 7 -
modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Parameter.java
| 3
modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Units.java
| 1
modules/helpers/pluginGen/pom.xml
| 21 ++-
modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
| 65 ++++++++--
modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
| 12 +
11 files changed, 108 insertions(+), 26 deletions(-)
New commits:
commit f5570cd91084f831a938ef7cda457907269b136c
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Nov 2 10:49:35 2011 -0400
a new 3.0.4 release of pluginAnnotations and pluginGen modules that changes the
retention policy on the annotations from RUNTIME to COMPILE
diff --git a/modules/helpers/pluginAnnotations/pom.xml
b/modules/helpers/pluginAnnotations/pom.xml
index bb2d153..e9629b8 100644
--- a/modules/helpers/pluginAnnotations/pom.xml
+++ b/modules/helpers/pluginAnnotations/pom.xml
@@ -1,17 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.rhq.helpers</groupId>
- <artifactId>rhq-helpers</artifactId>
- <version>3.0.1.GA</version>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-parent</artifactId>
+ <version>4.0.1</version>
</parent>
<groupId>org.rhq.helpers</groupId>
<artifactId>rhq-pluginAnnotations</artifactId>
<packaging>jar</packaging>
+ <version>3.0.4</version>
<name>RHQ Plugin Annotations</name>
<description>Annotations to help generate plugin
descriptors</description>
@@ -49,3 +53,4 @@
</build>
</project>
+
diff --git
a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DataType.java
b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DataType.java
index a416079..6f861c7 100644
---
a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DataType.java
+++
b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DataType.java
@@ -35,5 +35,5 @@ public enum DataType {
public String toString() {
return super.toString().toLowerCase();
}
-
}
+
diff --git
a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DisplayType.java
b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DisplayType.java
index 49551ef..7193794 100644
---
a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DisplayType.java
+++
b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DisplayType.java
@@ -35,5 +35,5 @@ public enum DisplayType {
public String toString() {
return super.toString().toLowerCase();
}
-
}
+
diff --git
a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/MeasurementType.java
b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/MeasurementType.java
index c797e81..2f31cf0 100644
---
a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/MeasurementType.java
+++
b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/MeasurementType.java
@@ -36,3 +36,4 @@ public enum MeasurementType {
return super.toString().toLowerCase();
}
}
+
diff --git
a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Metric.java
b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Metric.java
index c1482f1..40d600c 100644
---
a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Metric.java
+++
b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Metric.java
@@ -27,10 +27,10 @@ import java.lang.annotation.Target;
* Annotation to denote a metric that should be measured
*
* @author Heiko W. Rupp
- * @author Galder Zamarreo
+ * @author Galder Zamarreño
*/
-(a)Retention(RetentionPolicy.RUNTIME)
@Target( { ElementType.FIELD, ElementType.METHOD })
+(a)Retention(RetentionPolicy.CLASS)
public @interface Metric {
String property() default "";
String displayName() default "";
@@ -40,4 +40,5 @@ public @interface Metric {
DataType dataType() default DataType.MEASUREMENT;
Units units() default Units.NONE;
MeasurementType measurementType() default MeasurementType.DYNAMIC;
- }
\ No newline at end of file
+ }
+
diff --git
a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Operation.java
b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Operation.java
index ba60955..7cf5fc5 100644
---
a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Operation.java
+++
b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Operation.java
@@ -27,12 +27,13 @@ import java.lang.annotation.Target;
* Annotation that denotes an Operation that can be executed
*
* @author Heiko W. Rupp
- * @author Galder Zamarreo
+ * @author Galder Zamarreño
*/
-(a)Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
+(a)Retention(RetentionPolicy.CLASS)
public @interface Operation {
String name() default "";
String displayName() default "";
String description() default "";
-}
\ No newline at end of file
+}
+
diff --git
a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Parameter.java
b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Parameter.java
index 4b82a13..ac92c86 100644
---
a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Parameter.java
+++
b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Parameter.java
@@ -34,8 +34,9 @@ import java.lang.annotation.Target;
* @since 4.0
*/
@Target(ElementType.PARAMETER)
-(a)Retention(RetentionPolicy.RUNTIME)
+(a)Retention(RetentionPolicy.CLASS)
public @interface Parameter {
String name() default "";
String description() default "";
}
+
diff --git
a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Units.java
b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Units.java
index 0ae4011..4987a40 100644
---
a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Units.java
+++
b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Units.java
@@ -36,3 +36,4 @@ public enum Units {
return super.toString().toLowerCase();
}
}
+
diff --git a/modules/helpers/pluginGen/pom.xml b/modules/helpers/pluginGen/pom.xml
index 4c9a457..b1e4b1f 100644
--- a/modules/helpers/pluginGen/pom.xml
+++ b/modules/helpers/pluginGen/pom.xml
@@ -1,17 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.rhq.helpers</groupId>
- <artifactId>rhq-helpers</artifactId>
- <version>3.0.1.GA</version>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-parent</artifactId>
+ <version>4.0.1</version>
</parent>
<groupId>org.rhq.helpers</groupId>
<artifactId>rhq-pluginGen</artifactId>
<packaging>jar</packaging>
+ <version>3.0.4</version>
<name>RHQ plugin generator</name>
<description>Helper to generate plugin skeletons</description>
@@ -83,10 +87,19 @@
<artifactId>freemarker</artifactId>
<version>2.3.11</version>
</dependency>
+
<dependency>
<groupId>org.rhq.helpers</groupId>
<artifactId>rhq-pluginAnnotations</artifactId>
<version>${project.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ <version>3.12.1.GA</version>
+ </dependency>
</dependencies>
+
</project>
+
diff --git a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
index a657f42..93efc89 100644
--- a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
+++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -23,6 +23,8 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
+import javassist.ClassPool;
+import javassist.CtClass;
import org.rhq.helpers.pluginAnnotations.agent.DataType;
import org.rhq.helpers.pluginAnnotations.agent.DisplayType;
import org.rhq.helpers.pluginAnnotations.agent.Metric;
@@ -78,7 +80,7 @@ public class Props {
/** Depends on JMX plugin ? */
private boolean dependsOnJmxPlugin;
/** What version of RHQ should this plugin's pom use ? */
- private String rhqVersion = "1.4.0-SNAPSHOT";
+ private String rhqVersion = "3.0.0";
/** Embedded children */
private Set<Props> children = new HashSet<Props>();
@@ -91,9 +93,13 @@ public class Props {
private Set<OperationProps> operations = new
LinkedHashSet<OperationProps>();;
+ private Set<TypeKey> runsInsides = new LinkedHashSet<TypeKey>();;
+
private String pluginName;
private String pluginDescription;
+ private ClassPool classPool = ClassPool.getDefault();
+
public ResourceCategory getCategory() {
return category;
}
@@ -326,10 +332,31 @@ public class Props {
this.pluginDescription = pluginDescription;
}
+ public Set<TypeKey> getRunsInsides() {
+ return runsInsides;
+ }
+
+ public void setRunsInsides(Set<TypeKey> runsInsides) {
+ this.runsInsides = runsInsides;
+ }
+
public void populateMetrics(List<Class> classes) {
for (Class<?> clazz : classes) {
- Metric metricAnnot = clazz.getAnnotation(Metric.class);
- if (metricAnnot != null) {
+ CtClass ctClass;
+ try {
+ ctClass = classPool.get(clazz.getName());
+ } catch (Exception e) {
+ throw new RuntimeException("Could not find " + clazz +
".");
+ }
+ // TODO (ips): This is broken. 'Metric' is a method/field annotation,
not a class annotation.
+ Metric metricAnnot;
+ try {
+ metricAnnot = (Metric) ctClass.getAnnotation(Metric.class);
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException("Could not find " + Metric.class
+ + ". Make sure the rhq-pluginAnnotations jar is in the classpath
when running this tool.");
+ }
+ if (metricAnnot != null) {
MetricProps metric = new MetricProps(metricAnnot.property());
metric.setDisplayName(metricAnnot.displayName());
metric.setDisplayType(metricAnnot.displayType());
@@ -337,7 +364,6 @@ public class Props {
metric.setDescription(metricAnnot.description());
metrics.add(metric);
}
-
}
}
@@ -372,10 +398,37 @@ public class Props {
sb.append(", children=").append(children);
sb.append(", simpleProps=").append(simpleProps);
sb.append(", templates=").append(templates);
+ sb.append(", runsInsides=").append(runsInsides);
sb.append('}');
return sb.toString();
}
+ public static class TypeKey {
+ private String name;
+ private String pluginName;
+
+ public TypeKey(String name, String pluginName) {
+ this.name = name;
+ this.pluginName = pluginName;
+ }
+
+ public String getPluginName() {
+ return pluginName;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String toString() {
+ return "TypeKey{" +
+ "name='" + name + '\'' +
+ ", pluginName='" + pluginName + '\'' +
+ '}';
+ }
+ }
+
public static class SimpleProperty {
private final String name;
private String description;
@@ -431,7 +484,6 @@ public class Props {
public void setDefaultValue(String defaultValue) {
this.defaultValue = defaultValue;
}
-
}
public static class Template {
@@ -519,7 +571,6 @@ public class Props {
public String getProperty() {
return property;
}
-
}
public static class OperationProps {
diff --git a/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
b/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
index 0343787..5220375 100644
--- a/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
+++ b/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
@@ -1,7 +1,7 @@
<#--
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -24,7 +24,7 @@
platform/server/service. It is called by descriptor.ftl
-->
-name="${props.name}" <#-- TODO separate out plugin name and service name
-->
+name="${props.name}"
discovery="${props.discoveryClass}"
class="${props.componentClass}"
<#if props.singleton>singleton="true"</#if>
@@ -32,6 +32,14 @@ name="${props.name}" <#-- TODO separate out plugin name
and service name -->
<#if props.createChildren &&
props.deleteChildren>createDeletePolicy="both"<#elseif
props.createChildren &&
!props.deleteChildren>createDeletePolicy="create-only"<#elseif
!props.createChildren &&
props.deleteChildren>createDeletePolicy="delete-only"<#else > <#--
Dont mention it, as 'neither' is default --></#if>
+ <#if props.runsInsides?has_content>
+ <runs-inside>
+ <#list props.runsInsides as typeKey>
+ <parent-resource-type name="${typeKey.name}"
plugin="${typeKey.pluginName}"/>
+ </#list>
+ </runs-inside>
+ </#if>
+
<#if props.simpleProps?has_content>
<plugin-configuration>
<#list props.simpleProps as simpleProps>