From 07a050986f66249954844da0bc5306b4b6feac80 Mon Sep 17 00:00:00 2001 From: Fabio Boldrini Date: Mon, 5 Nov 2018 17:42:09 +0100 Subject: [PATCH] added support for property --- .../ear/GenerateApplicationXmlMojo.java | 6 ++- .../apache/maven/plugins/ear/ResourceRef.java | 38 ++++++++++++++++++- ...s-for-the-generated-application-xml.apt.vm | 5 +++ .../expected-META-INF/application.xml | 5 +++ .../resources/projects/project-087/pom.xml | 5 +++ 5 files changed, 57 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/ear/GenerateApplicationXmlMojo.java b/src/main/java/org/apache/maven/plugins/ear/GenerateApplicationXmlMojo.java index 9d3565e0..e39a88e6 100644 --- a/src/main/java/org/apache/maven/plugins/ear/GenerateApplicationXmlMojo.java +++ b/src/main/java/org/apache/maven/plugins/ear/GenerateApplicationXmlMojo.java @@ -480,11 +480,15 @@ private List buildResourceRefs() interpolate( ssi, resEntry.getChild( ResourceRef.RESOURCE_TYPE ).getValue() ); final String childResRefAuth = interpolate( ssi, resEntry.getChild( ResourceRef.RESOURCE_AUTH ).getValue() ); + final String childResRefLookupName = + interpolate( ssi, resEntry.getChild( ResourceRef.LOOKUP_NAME ).getValue() ); // CHECKSTYLE_ON: LineLength try { - result.add( new ResourceRef( childResRefName, childResType, childResRefAuth ) ); + // CHECKSTYLE_OFF: LineLength + result.add( new ResourceRef( childResRefName, childResType, childResRefAuth, childResRefLookupName ) ); + // CHECKSTYLE_ON: LineLength } catch ( IllegalArgumentException e ) { diff --git a/src/main/java/org/apache/maven/plugins/ear/ResourceRef.java b/src/main/java/org/apache/maven/plugins/ear/ResourceRef.java index 5f3d905e..89ac1e40 100644 --- a/src/main/java/org/apache/maven/plugins/ear/ResourceRef.java +++ b/src/main/java/org/apache/maven/plugins/ear/ResourceRef.java @@ -32,6 +32,14 @@ * <res-auth>Container</res-auth> * </resource-ref> * + * or + *
+ * <resource-ref>
+ *   <res-ref-name>jdbc/myDs</res-ref-name>
+ *   <res-type>javax.sql.DataSource</res-type>
+ *   <lookup-name>jdbc/lookup/myDs</lookup-name>
+ * </resource-ref>
+ * 
* * @author Karl Heinz Marbaise * @since 3.0.0 @@ -46,18 +54,23 @@ public class ResourceRef static final String RESOURCE_AUTH = "res-auth"; + static final String LOOKUP_NAME = "lookup-name"; + private String name; private String type; private String auth; + private String lookupName; + /** * @param name The res-ref-name. * @param type The res-type * @param auth The res-auth. + * @param lookupName The lookup-name. */ - public ResourceRef( String name, String type, String auth ) + public ResourceRef( String name, String type, String auth, String lookupName ) { if ( StringUtils.isEmpty( name ) ) { @@ -73,6 +86,7 @@ else if ( StringUtils.isEmpty( type ) && StringUtils.isEmpty( auth ) ) this.name = name; this.type = type; this.auth = auth; + this.lookupName = lookupName; } @@ -100,6 +114,12 @@ public void appendResourceRefEntry( XMLWriter writer ) doWriteElement( writer, RESOURCE_AUTH, getAuth() ); } + // lookup-name + if ( getLookupName() != null ) + { + doWriteElement( writer, LOOKUP_NAME, getLookupName() ); + } + // end of ejb-ref writer.endElement(); } @@ -158,5 +178,21 @@ public void setAuth( String auth ) { this.auth = auth; } + + /** + * @return {@link #LookupName} + */ + public String getLookupName() + { + return lookupName; + } + + /** + * @param auth {@link #LookupName} + */ + public void setLookupName( String lookupName ) + { + this.lookupName = lookupName; + } } diff --git a/src/site/apt/examples/specifying-resource-ref-entries-for-the-generated-application-xml.apt.vm b/src/site/apt/examples/specifying-resource-ref-entries-for-the-generated-application-xml.apt.vm index 393ddadf..3646aad1 100644 --- a/src/site/apt/examples/specifying-resource-ref-entries-for-the-generated-application-xml.apt.vm +++ b/src/site/apt/examples/specifying-resource-ref-entries-for-the-generated-application-xml.apt.vm @@ -49,6 +49,11 @@ Specifying Resource Ref entries For The Generated application.xml javax.sql.DataSource Container
+ + jdbc/myDs3 + javax.sql.DataSource + jdbc/lookup/myDs3 + diff --git a/src/test/resources/projects/project-087/expected-META-INF/application.xml b/src/test/resources/projects/project-087/expected-META-INF/application.xml index d1ab0f72..e54da281 100644 --- a/src/test/resources/projects/project-087/expected-META-INF/application.xml +++ b/src/test/resources/projects/project-087/expected-META-INF/application.xml @@ -50,4 +50,9 @@ under the License. javax.sql.DataSource Container
+ + jdbc/myDs3 + javax.sql.DataSource + jdbc/lookup/myDs3 + diff --git a/src/test/resources/projects/project-087/pom.xml b/src/test/resources/projects/project-087/pom.xml index 804e903b..76d6e1d0 100644 --- a/src/test/resources/projects/project-087/pom.xml +++ b/src/test/resources/projects/project-087/pom.xml @@ -59,6 +59,11 @@ under the License. javax.sql.DataSource Container + + jdbc/myDs3 + javax.sql.DataSource + jdbc/lookup/myDs3 +