<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-binding-api</artifactId>
</dependency>
- <dependency>
- <groupId>javax.inject</groupId>
- <artifactId>javax.inject</artifactId>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.cdi</groupId>
- <artifactId>pax-cdi-api</artifactId>
- <optional>true</optional>
- </dependency>
</dependencies>
<build>
<plugins>
- <plugin>
- <groupId>org.apache.aries.blueprint</groupId>
- <artifactId>blueprint-maven-plugin</artifactId>
- </plugin>
+ <!-- Do *NOT* use annotation based DI with the blueprint-maven-plugin here; the issue is that this
+ will cause problems in other projects having a dependency to this one (they would repeat and re-generate this project's BP XML). -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.serviceutils.upgrade.impl;
import static org.opendaylight.controller.md.sal.binding.api.WriteTransaction.CREATE_MISSING_PARENTS;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.Nonnull;
-import javax.annotation.PreDestroy;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.upgrade.rev180702.UpgradeConfig;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.ops4j.pax.cdi.api.OsgiService;
-import org.ops4j.pax.cdi.api.OsgiServiceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Singleton
-@OsgiServiceProvider(classes = UpgradeState.class)
+// Do *NOT* use annotation based DI with the blueprint-maven-plugin here; the issue is that this will cause
+// problems in other projects having a dependency to this one (they would repeat and re-generate this project's BP XML).
public class UpgradeStateListener implements ClusteredDataTreeChangeListener<UpgradeConfig>, UpgradeState {
private static final Logger LOG = LoggerFactory.getLogger(UpgradeStateListener.class);
new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(UpgradeConfig.class));
private final AtomicBoolean isUpgradeInProgress = new AtomicBoolean(false);
- @Inject
- public UpgradeStateListener(@OsgiService DataBroker dataBroker, UpgradeConfig upgradeConfig) {
+ public UpgradeStateListener(DataBroker dataBroker, UpgradeConfig upgradeConfig) {
registration = dataBroker.registerDataTreeChangeListener(treeId, UpgradeStateListener.this);
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
//TODO: DS Writes should ideally be done from one node to avoid ConflictingModExceptions
} // Possibility of OptimisticLockException?
}
- @PreDestroy
public void close() {
if (registration != null) {
registration.close();
xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
odl:use-default-for-reference-types="true">
+ <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"/>
+
<odl:clustered-app-config id="upgradeConfig"
binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.upgrade.rev180702.UpgradeConfig"
default-config-file-name="serviceutils-upgrade-config.xml"
update-strategy="none">
</odl:clustered-app-config>
+ <bean id="upgradeStateListener" class="org.opendaylight.serviceutils.upgrade.impl.UpgradeStateListener" destroy-method="close">
+ <argument ref="dataBroker"/>
+ <argument ref="upgradeConfig"/>
+ </bean>
+ <service ref="upgradeStateListener" interface="org.opendaylight.serviceutils.upgrade.UpgradeState"/>
+
</blueprint>