import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
import org.opendaylight.mdsal.eos.dom.simple.SimpleDOMEntityOwnershipService;
-import org.opendaylight.mdsal.singleton.dom.impl.DOMClusterSingletonServiceProviderImpl;
+import org.opendaylight.mdsal.singleton.dom.impl.di.DefaultClusterSingletonServiceProvider;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.core.general.entity.rev150930.Entity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.core.general.entity.rev150930.EntityBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.core.general.entity.rev150930.EntityKey;
private static final QName ENTITY_NAME_QNAME = QName.create(ENTITY_QNAME, "name");
private AbstractBootstrapSupport support;
- private DOMClusterSingletonServiceProviderImpl css;
+ private DefaultClusterSingletonServiceProvider css;
@Before
public void before() {
support = AbstractBootstrapSupport.create();
- css = new DOMClusterSingletonServiceProviderImpl(new SimpleDOMEntityOwnershipService());
+ css = new DefaultClusterSingletonServiceProvider(new SimpleDOMEntityOwnershipService());
css.initializeProvider();
}
<packaging>bundle</packaging>
<dependencies>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-common-api</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-eos-dom-api</artifactId>
<artifactId>yang-data-api</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-model-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <groupId>org.kohsuke.metainf-services</groupId>
+ <artifactId>metainf-services</artifactId>
</dependency>
<dependency>
- <groupId>javax.inject</groupId>
+ <groupId>com.guicedee.services</groupId>
<artifactId>javax.inject</artifactId>
- <scope>provided</scope>
<optional>true</optional>
</dependency>
-
<dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-data-impl</artifactId>
- <scope>test</scope>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
</dependencies>
--- /dev/null
+/*
+ * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipService;
+import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
+import org.opendaylight.mdsal.singleton.dom.impl.DOMClusterSingletonServiceProviderImpl;
+
+module org.opendaylight.mdsal.singleton.dom.impl {
+ exports org.opendaylight.mdsal.singleton.dom.impl.di;
+
+ provides ClusterSingletonServiceProvider with DOMClusterSingletonServiceProviderImpl;
+
+ requires transitive org.opendaylight.mdsal.singleton.common.api;
+ requires transitive org.opendaylight.mdsal.eos.dom.api;
+ requires org.opendaylight.mdsal.eos.common.api;
+ requires org.opendaylight.yangtools.concepts;
+ requires org.slf4j;
+
+ uses DOMEntityOwnershipService;
+
+ // Annotations
+ requires static transitive org.eclipse.jdt.annotation;
+ requires static javax.inject;
+ requires static metainf.services;
+ requires static org.checkerframework.checker.qual;
+ requires static org.osgi.service.component.annotations;
+}
*/
package org.opendaylight.mdsal.singleton.dom.impl;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import org.opendaylight.mdsal.eos.common.api.GenericEntityOwnershipService;
+import java.util.ServiceLoader;
+import org.kohsuke.MetaInfServices;
import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipChange;
import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListener;
import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListenerRegistration;
import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipService;
+import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
/**
* Binding version of {@link AbstractClusterSingletonServiceProviderImpl}.
*/
-@Singleton
-public final class DOMClusterSingletonServiceProviderImpl extends
+@MetaInfServices(value = ClusterSingletonServiceProvider.class)
+public class DOMClusterSingletonServiceProviderImpl extends
AbstractClusterSingletonServiceProviderImpl<YangInstanceIdentifier, DOMEntity,
DOMEntityOwnershipChange,
DOMEntityOwnershipListener,
DOMEntityOwnershipListenerRegistration>
implements DOMEntityOwnershipListener {
- /**
- * Initialization all needed class internal property for {@link DOMClusterSingletonServiceProviderImpl}.
- *
- * @param entityOwnershipService - we need only {@link GenericEntityOwnershipService}
- */
- @Inject
- public DOMClusterSingletonServiceProviderImpl(final DOMEntityOwnershipService entityOwnershipService) {
+ public DOMClusterSingletonServiceProviderImpl() {
+ this(ServiceLoader.load(DOMEntityOwnershipService.class).findFirst().orElseThrow(
+ () -> new IllegalStateException("Could not find DOMEntityOwnershipService")));
+ }
+
+ protected DOMClusterSingletonServiceProviderImpl(final DOMEntityOwnershipService entityOwnershipService) {
super(entityOwnershipService);
}
--- /dev/null
+/*
+ * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * 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.mdsal.singleton.dom.impl.di;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipService;
+import org.opendaylight.mdsal.singleton.dom.impl.DOMClusterSingletonServiceProviderImpl;
+
+@Singleton
+public final class DefaultClusterSingletonServiceProvider extends DOMClusterSingletonServiceProviderImpl {
+ @Inject
+ public DefaultClusterSingletonServiceProvider(final DOMEntityOwnershipService entityOwnershipService) {
+ super(entityOwnershipService);
+ }
+}
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
import org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException;
import org.opendaylight.mdsal.eos.common.api.EntityOwnershipChangeState;
import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
}
}
- static final String SERVICE_NAME = "testServiceName";
- static final DOMEntity ENTITY = new DOMEntity(SERVICE_ENTITY_TYPE, SERVICE_NAME);
- static final DOMEntity DOUBLE_ENTITY = new DOMEntity(CLOSE_SERVICE_ENTITY_TYPE, SERVICE_NAME);
+ public static final String SERVICE_NAME = "testServiceName";
+ public static final DOMEntity ENTITY = new DOMEntity(SERVICE_ENTITY_TYPE, SERVICE_NAME);
+ public static final DOMEntity DOUBLE_ENTITY = new DOMEntity(CLOSE_SERVICE_ENTITY_TYPE, SERVICE_NAME);
@Mock
- protected DOMEntityOwnershipService mockEos;
+ public DOMEntityOwnershipService mockEos;
@Mock
- protected DOMEntityOwnershipCandidateRegistration mockEntityCandReg;
+ public DOMEntityOwnershipCandidateRegistration mockEntityCandReg;
@Mock
- protected DOMEntityOwnershipCandidateRegistration mockDoubleEntityCandReg;
+ public DOMEntityOwnershipCandidateRegistration mockDoubleEntityCandReg;
@Mock
- protected DOMEntityOwnershipListenerRegistration mockEosEntityListReg;
+ public DOMEntityOwnershipListenerRegistration mockEosEntityListReg;
@Mock
- protected DOMEntityOwnershipListenerRegistration mockEosDoubleEntityListReg;
+ public DOMEntityOwnershipListenerRegistration mockEosDoubleEntityListReg;
- protected DOMClusterSingletonServiceProviderImpl clusterSingletonServiceProvider;
- protected TestClusterSingletonService clusterSingletonService;
- protected TestClusterSingletonService clusterSingletonService2;
+ public DOMClusterSingletonServiceProviderImpl clusterSingletonServiceProvider;
+ public TestClusterSingletonService clusterSingletonService;
+ public TestClusterSingletonService clusterSingletonService2;
@Before
public void setup() throws CandidateAlreadyRegisteredException {
- MockitoAnnotations.initMocks(this);
-
doNothing().when(mockEosEntityListReg).close();
doNothing().when(mockEosDoubleEntityListReg).close();
doNothing().when(mockEntityCandReg).close();
* 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.mdsal.singleton.dom.impl;
import static org.junit.Assert.assertFalse;
import java.util.concurrent.ExecutionException;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException;
import org.opendaylight.mdsal.eos.common.api.EntityOwnershipChangeState;
import org.opendaylight.mdsal.eos.common.api.GenericEntityOwnershipCandidateRegistration;
/**
* Testing {@link ClusterSingletonServiceGroupImpl}.
*/
+@RunWith(MockitoJUnitRunner.StrictStubs.class)
public class ClusterSingletonServiceGroupImplTest {
- private static final String SERVICE_IDENTIFIER = "TestServiceIdent";
- private static final ServiceGroupIdentifier SERVICE_GROUP_IDENT = ServiceGroupIdentifier.create(SERVICE_IDENTIFIER);
+ public static final String SERVICE_IDENTIFIER = "TestServiceIdent";
+ public static final ServiceGroupIdentifier SERVICE_GROUP_IDENT = ServiceGroupIdentifier.create(SERVICE_IDENTIFIER);
- private static final TestEntity MAIN_ENTITY = new TestEntity(SERVICE_ENTITY_TYPE, SERVICE_IDENTIFIER);
- private static final TestEntity CLOSE_ENTITY = new TestEntity(CLOSE_SERVICE_ENTITY_TYPE, SERVICE_IDENTIFIER);
+ public static final TestEntity MAIN_ENTITY = new TestEntity(SERVICE_ENTITY_TYPE, SERVICE_IDENTIFIER);
+ public static final TestEntity CLOSE_ENTITY = new TestEntity(CLOSE_SERVICE_ENTITY_TYPE, SERVICE_IDENTIFIER);
@Mock
- private ClusterSingletonService mockClusterSingletonService;
+ public ClusterSingletonService mockClusterSingletonService;
@Mock
- private ClusterSingletonService mockClusterSingletonServiceSecond;
+ public ClusterSingletonService mockClusterSingletonServiceSecond;
@Mock
- private GenericEntityOwnershipCandidateRegistration<?, ?> mockEntityCandReg;
+ public GenericEntityOwnershipCandidateRegistration<?, ?> mockEntityCandReg;
@Mock
- private GenericEntityOwnershipCandidateRegistration<?, ?> mockCloseEntityCandReg;
+ public GenericEntityOwnershipCandidateRegistration<?, ?> mockCloseEntityCandReg;
@Mock
- private GenericEntityOwnershipListener<TestInstanceIdentifier,
+ public GenericEntityOwnershipListener<TestInstanceIdentifier,
GenericEntityOwnershipChange<TestInstanceIdentifier, TestEntity>> mockEosListener;
@Mock
- private GenericEntityOwnershipService<TestInstanceIdentifier,TestEntity,
+ public GenericEntityOwnershipService<TestInstanceIdentifier,TestEntity,
GenericEntityOwnershipListener<TestInstanceIdentifier,
GenericEntityOwnershipChange<TestInstanceIdentifier, TestEntity>>> mockEosService;
- private ClusterSingletonServiceGroupImpl<TestInstanceIdentifier,TestEntity,
+ public ClusterSingletonServiceGroupImpl<TestInstanceIdentifier,TestEntity,
GenericEntityOwnershipChange<TestInstanceIdentifier,TestEntity>,
GenericEntityOwnershipListener<TestInstanceIdentifier,
GenericEntityOwnershipChange<TestInstanceIdentifier, TestEntity>>,
GenericEntityOwnershipListener<TestInstanceIdentifier,
GenericEntityOwnershipChange<TestInstanceIdentifier, TestEntity>>>> singletonServiceGroup;
- private ClusterSingletonServiceRegistration firstReg;
- private ClusterSingletonServiceRegistration secondReg;
+ public ClusterSingletonServiceRegistration firstReg;
+ public ClusterSingletonServiceRegistration secondReg;
/**
* Initialization functionality for every Tests in this suite.
*/
@Before
public void setup() throws CandidateAlreadyRegisteredException {
- MockitoAnnotations.initMocks(this);
-
doReturn(mockEntityCandReg).when(mockEosService).registerCandidate(MAIN_ENTITY);
doReturn(mockCloseEntityCandReg).when(mockEosService).registerCandidate(CLOSE_ENTITY);
doNothing().when(mockEntityCandReg).close();
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
/*
* Testing {@link DOMClusterSingletonServiceProviderImpl} implementation
*/
+@RunWith(MockitoJUnitRunner.StrictStubs.class)
public final class DOMClusterSingletonServiceProviderAsyncImplTest extends AbstractDOMClusterServiceProviderTest {
/*
* Test implementation of {@link ClusterSingletonService}
*/
- static class TestClusterSingletonAsyncServiceInstance extends TestClusterSingletonService {
+ public static class TestClusterSingletonAsyncServiceInstance extends TestClusterSingletonService {
@Override
public ListenableFuture<Void> closeServiceInstance() {
super.closeServiceInstance();
}
}
- protected static final long ASYNC_TIME_DELAY_MILLIS = 100L;
- protected static Timer TIMER;
+ public static final long ASYNC_TIME_DELAY_MILLIS = 100L;
+ public static Timer TIMER;
@BeforeClass
public static void asyncInitTest() {
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
/**
* Synchronous test suite.
*/
+@RunWith(MockitoJUnitRunner.StrictStubs.class)
public class DOMClusterSingletonServiceProviderImplTest extends AbstractDOMClusterServiceProviderTest {
/**
* Initialization functionality for every Tests in this suite.