You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Thijs Metsch (JIRA)" <ji...@apache.org> on 2008/11/19 17:21:44 UTC
[jira] Updated: (FELIX-824) maven-scr-plugin does not support the
lookup strategy for services.
[ https://issues.apache.org/jira/browse/FELIX-824?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Thijs Metsch updated FELIX-824:
-------------------------------
Example file changes made to support the new strategy property - tried to do it according to the rest :-) Code might need cleanup:
Index: src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
===================================================================
--- src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java (revision 718970)
+++ src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java (working copy)
@@ -283,8 +283,11 @@
IOUtils.addAttribute(ai, "cardinality", reference.getCardinality());
IOUtils.addAttribute(ai, "policy", reference.getPolicy());
IOUtils.addAttribute(ai, "target", reference.getTarget());
- IOUtils.addAttribute(ai, "bind", reference.getBind());
- IOUtils.addAttribute(ai, "unbind", reference.getUnbind());
+
+ if (!reference.isLookupStrategy()) {
+ IOUtils.addAttribute(ai, "bind", reference.getBind());
+ IOUtils.addAttribute(ai, "unbind", reference.getUnbind());
+ }
if ( isScrPrivateFile ) {
IOUtils.addAttribute(ai, "checked", String.valueOf(reference.isChecked()));
}
@@ -420,6 +423,7 @@
ref.setTarget(attributes.getValue("target"));
ref.setBind(attributes.getValue("bind"));
ref.setUnbind(attributes.getValue("unbind"));
+ ref.setStrategy(attributes.getValue("strategy"));
if ( attributes.getValue("checked") != null ) {
ref.setChecked(Boolean.valueOf(attributes.getValue("checked")).booleanValue());
Index: src/main/java/org/apache/felix/scrplugin/om/Reference.java
===================================================================
--- src/main/java/org/apache/felix/scrplugin/om/Reference.java (revision 718970)
+++ src/main/java/org/apache/felix/scrplugin/om/Reference.java (working copy)
@@ -37,6 +37,7 @@
protected String policy;
protected String bind;
protected String unbind;
+ protected String strategy;
/** Is this reference already checked? */
protected boolean checked = false;
@@ -117,6 +118,7 @@
public void setUnbind(String unbind) {
this.unbind = unbind;
}
+
public boolean isChecked() {
return checked;
@@ -125,7 +127,23 @@
public void setChecked(boolean checked) {
this.checked = checked;
}
+
+ public String getStrategy() {
+ return strategy;
+ }
+ public void setStrategy(String strategy) {
+ this.strategy = strategy;
+ }
+
+ public boolean isLookupStrategy() {
+ if ("lookup".equals(this.strategy)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
/**
* Validate the property.
* If errors occur a message is added to the issues list,
@@ -163,24 +181,36 @@
} else if (!"static".equals(this.policy) && !"dynamic".equals(this.policy)) {
issues.add(this.getMessage("Invalid Policy specification " + this.policy));
}
+
+ // validate strategy
+ if (this.strategy == null) {
+ this.strategy = "event";
+ } else if (!"event".equals(this.strategy) && !"lookup".equals(this.strategy)) {
+ issues.add(this.getMessage("Invalid startegy type " + this.strategy));
+ }
// validate bind and unbind methods
- final String oldBind = this.bind;
- final String oldUnbind = this.unbind;
- this.bind = this.validateMethod(this.bind, issues, warnings, componentIsAbstract);
- this.unbind = this.validateMethod(this.unbind, issues, warnings, componentIsAbstract);
- if ( issues.size() == currentIssueCount ) {
- if ( this.bind != null && this.unbind != null ) {
- // no errors, so we're checked
- this.checked = true;
- } else {
- if ( this.bind == null ) {
- this.bind = oldBind;
+ if (!"lookup".equals(this.strategy)) {
+ final String oldBind = this.bind;
+ final String oldUnbind = this.unbind;
+ this.bind = this.validateMethod(this.bind, issues, warnings, componentIsAbstract);
+ this.unbind = this.validateMethod(this.unbind, issues, warnings, componentIsAbstract);
+ if ( issues.size() == currentIssueCount ) {
+ if ( this.bind != null && this.unbind != null ) {
+ // no errors, so we're checked
+ this.checked = true;
+ } else {
+ if ( this.bind == null ) {
+ this.bind = oldBind;
+ }
+ if ( this.unbind == null ) {
+ this.unbind = oldUnbind;
+ }
}
- if ( this.unbind == null ) {
- this.unbind = oldUnbind;
- }
}
+ } else {
+ this.bind = null;
+ this.unbind = null;
}
}
Index: src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
===================================================================
--- src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java (revision 718970)
+++ src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java (working copy)
@@ -570,10 +570,15 @@
if ( isChecked != null ) {
ref.setChecked(Boolean.valueOf(isChecked).booleanValue());
}
+ ref.setStrategy(reference.getNamedParameter(Constants.REFERENCE_STRATEGY));
+ if (ref.getStrategy() == null) {
+ ref.setStrategy("event");
+ }
+
// if this is a field with a single cardinality,
// we look for the bind/unbind methods
// and create them if they are not availabe
- if ( this.generateAccessors ) {
+ if ( this.generateAccessors && !ref.isLookupStrategy()) {
if ( reference.getField() != null && component.getJavaClassDescription() instanceof ModifiableJavaClassDescription ) {
if ( ref.getCardinality().equals("0..1") || ref.getCardinality().equals("1..1") ) {
boolean createBind = false;
Index: src/main/java/org/apache/felix/scrplugin/Constants.java
===================================================================
--- src/main/java/org/apache/felix/scrplugin/Constants.java (revision 718970)
+++ src/main/java/org/apache/felix/scrplugin/Constants.java (working copy)
@@ -100,6 +100,8 @@
public static final String REFERENCE_UNDBIND = "unbind";
public static final String REFERENCE_CHECKED = "checked";
+
+ public static final String REFERENCE_STRATEGY = "strategy";
public static final String ABSTRACT_DESCRIPTOR_FILENAME = "scrinfo.xml";
Index: src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaTag.java
===================================================================
--- src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaTag.java (revision 718970)
+++ src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaTag.java (working copy)
@@ -113,6 +113,7 @@
map.put(Constants.REFERENCE_TARGET, this.reference.getTarget());
map.put(Constants.REFERENCE_UNDBIND, this.reference.getUnbind());
map.put(Constants.REFERENCE_CHECKED, String.valueOf(this.reference.isChecked()));
+ map.put(Constants.REFERENCE_STRATEGY, this.reference.getStrategy());
return map;
} else if ( this.property != null ) {
final Map map = new HashMap();
> maven-scr-plugin does not support the lookup strategy for services.
> -------------------------------------------------------------------
>
> Key: FELIX-824
> URL: https://issues.apache.org/jira/browse/FELIX-824
> Project: Felix
> Issue Type: Improvement
> Components: Maven SCR Plugin
> Affects Versions: maven-scr-plugin-1.0.9
> Environment: Linux/OpenSolaris
> Reporter: Thijs Metsch
> Original Estimate: 2h
> Remaining Estimate: 2h
>
> Currently the maven-scr-plugin does not support the usage of a lookup strategy of services. Therefor a new property should be added to the scr.reference tag to allow this. The idea is: strategy = event | lookup while default is event and not lookup.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.