Skip to content

Commit 76e900d

Browse files
Copilotlaeubi
andauthored
Replace internal REFERENCE_NAME_SATISFYING_CONDITION with OSGi spec constant (#8)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: laeubi <1331477+laeubi@users.noreply.github.com>
1 parent 1c0619a commit 76e900d

File tree

4 files changed

+8
-13
lines changed

4 files changed

+8
-13
lines changed

scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2516,7 +2516,7 @@ private ServiceReference<T> getTrueConditionRef()
25162516
{
25172517
return null;
25182518
}
2519-
if (ReferenceMetadata.REFERENCE_NAME_SATISFYING_CONDITION.equals(
2519+
if (ComponentConstants.REFERENCE_NAME_SATISFYING_CONDITION.equals(
25202520
m_dependencyMetadata.getName()) == false)
25212521
{
25222522
return null;

scr/src/main/java/org/apache/felix/scr/impl/metadata/ReferenceMetadata.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
import org.apache.felix.scr.impl.metadata.MetadataStoreHelper.MetaDataReader;
3030
import org.apache.felix.scr.impl.metadata.MetadataStoreHelper.MetaDataWriter;
31+
import org.osgi.service.component.ComponentConstants;
3132

3233
/**
3334
* Information associated to a dependency
@@ -101,13 +102,6 @@ public enum ReferenceScope {bundle, prototype, prototype_required}
101102

102103
public static final String CONDITION_TRUE_FILTER = "(osgi.condition.id=true)";
103104

104-
/**
105-
* The reference name for the implicit satisfying condition as defined in the
106-
* OSGi R8 Declarative Services specification (see https://github.com/osgi/osgi/pull/875).
107-
* This reference is automatically added to components when a true condition service is available.
108-
*/
109-
public static final String REFERENCE_NAME_SATISFYING_CONDITION = "osgi.ds.satisfying.condition";
110-
111105
// Name for the reference (required)
112106
private String m_name;
113107

scr/src/main/java/org/apache/felix/scr/impl/xml/XmlHandler.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.apache.felix.scr.impl.metadata.ServiceMetadata;
3636
import org.osgi.framework.Bundle;
3737
import org.osgi.framework.ServiceReference;
38+
import org.osgi.service.component.ComponentConstants;
3839
import org.xml.sax.Attributes;
3940
import org.xml.sax.SAXException;
4041
import org.xml.sax.helpers.DefaultHandler;
@@ -493,7 +494,7 @@ else if ( localName.equals( XmlConstants.EL_FACTORY_PROPERTY ) && m_pendingFacto
493494
boolean missingSatisfyingConditionRef = true;
494495
for (ReferenceMetadata ref : m_currentComponent.getDependencies())
495496
{
496-
if (ReferenceMetadata.REFERENCE_NAME_SATISFYING_CONDITION.equals(
497+
if (ComponentConstants.REFERENCE_NAME_SATISFYING_CONDITION.equals(
497498
ref.getName()))
498499
{
499500
missingSatisfyingConditionRef = false;
@@ -504,7 +505,7 @@ else if ( localName.equals( XmlConstants.EL_FACTORY_PROPERTY ) && m_pendingFacto
504505
{
505506
ReferenceMetadata trueReference = new ReferenceMetadata();
506507
trueReference.setName(
507-
ReferenceMetadata.REFERENCE_NAME_SATISFYING_CONDITION);
508+
ComponentConstants.REFERENCE_NAME_SATISFYING_CONDITION);
508509
trueReference.setTarget(ReferenceMetadata.CONDITION_TRUE_FILTER);
509510
trueReference.setInterface(ReferenceMetadata.CONDITION_SERVICE_CLASS);
510511
trueReference.setPolicy(ReferenceMetadata.POLICY_DYNAMIC);
@@ -515,7 +516,7 @@ else if ( localName.equals( XmlConstants.EL_FACTORY_PROPERTY ) && m_pendingFacto
515516
// condition targets via the osgi.ds.satisfying.condition.target property.
516517
PropertyMetadata prop = new PropertyMetadata(true);
517518
prop.setName(
518-
ReferenceMetadata.REFERENCE_NAME_SATISFYING_CONDITION + ".target");
519+
ComponentConstants.REFERENCE_NAME_SATISFYING_CONDITION + ".target");
519520
prop.setValue(ReferenceMetadata.CONDITION_TRUE_FILTER);
520521
m_currentComponent.addProperty(prop);
521522
}

scr/src/test/java/org/apache/felix/scr/integration/components/SatisfyingConditionComponentClass.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
package org.apache.felix.scr.integration.components;
2020

21-
import org.apache.felix.scr.impl.metadata.ReferenceMetadata;
21+
import org.osgi.service.component.ComponentConstants;
2222
import org.osgi.service.component.ComponentContext;
2323

2424
public class SatisfyingConditionComponentClass
@@ -27,7 +27,7 @@ public class SatisfyingConditionComponentClass
2727
void activate(ComponentContext cc)
2828
{
2929
Object trueCondition = cc.locateService(
30-
ReferenceMetadata.REFERENCE_NAME_SATISFYING_CONDITION);
30+
ComponentConstants.REFERENCE_NAME_SATISFYING_CONDITION);
3131
System.out.println("Found condition: " + trueCondition);
3232
}
3333

0 commit comments

Comments
 (0)