Code Review
/
mdsal.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Adopt odlparent-10.0.0/yangtools-8.0.0-SNAPSHOT
[mdsal.git]
/
dom
/
mdsal-dom-broker
/
src
/
main
/
java
/
org
/
opendaylight
/
mdsal
/
dom
/
broker
/
DOMMountPointServiceImpl.java
diff --git
a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMMountPointServiceImpl.java
b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMMountPointServiceImpl.java
index b8867848a82181877c42fbd617e59209625a3361..80d0c80ee34a53e1420714bce6b476188dbb5b57 100644
(file)
--- a/
dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMMountPointServiceImpl.java
+++ b/
dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMMountPointServiceImpl.java
@@
-5,7
+5,6
@@
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.dom.broker;
import static com.google.common.base.Preconditions.checkState;
package org.opendaylight.mdsal.dom.broker;
import static com.google.common.base.Preconditions.checkState;
@@
-15,6
+14,8
@@
import com.google.common.collect.MutableClassToInstanceMap;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
+import javax.inject.Singleton;
+import org.kohsuke.MetaInfServices;
import org.opendaylight.mdsal.dom.api.DOMMountPoint;
import org.opendaylight.mdsal.dom.api.DOMMountPointListener;
import org.opendaylight.mdsal.dom.api.DOMMountPointService;
import org.opendaylight.mdsal.dom.api.DOMMountPoint;
import org.opendaylight.mdsal.dom.api.DOMMountPointListener;
import org.opendaylight.mdsal.dom.api.DOMMountPointService;
@@
-25,11
+26,16
@@
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.concepts.ObjectRegistration;
import org.opendaylight.yangtools.util.ListenerRegistry;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.concepts.ObjectRegistration;
import org.opendaylight.yangtools.util.ListenerRegistry;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class DOMMountPointServiceImpl implements DOMMountPointService {
+@Component(immediate = true)
+@MetaInfServices
+@Singleton
+public final class DOMMountPointServiceImpl implements DOMMountPointService {
private static final Logger LOG = LoggerFactory.getLogger(DOMMountPointServiceImpl.class);
private final Map<YangInstanceIdentifier, DOMMountPoint> mountPoints = new HashMap<>();
private static final Logger LOG = LoggerFactory.getLogger(DOMMountPointServiceImpl.class);
private final Map<YangInstanceIdentifier, DOMMountPoint> mountPoints = new HashMap<>();
@@
-52,6
+58,18
@@
public class DOMMountPointServiceImpl implements DOMMountPointService {
return listeners.register(listener);
}
return listeners.register(listener);
}
+ @Activate
+ @SuppressWarnings("static-method")
+ void activate() {
+ LOG.info("DOMMountPointService activated");
+ }
+
+ @Deactivate
+ @SuppressWarnings("static-method")
+ void deactivate() {
+ LOG.info("DOMMountPointService deactivated");
+ }
+
@SuppressWarnings("checkstyle:IllegalCatch")
private ObjectRegistration<DOMMountPoint> registerMountPoint(final SimpleDOMMountPoint mountPoint) {
final YangInstanceIdentifier mountPointId = mountPoint.getIdentifier();
@SuppressWarnings("checkstyle:IllegalCatch")
private ObjectRegistration<DOMMountPoint> registerMountPoint(final SimpleDOMMountPoint mountPoint) {
final YangInstanceIdentifier mountPointId = mountPoint.getIdentifier();
@@
-59,15
+77,15
@@
public class DOMMountPointServiceImpl implements DOMMountPointService {
final DOMMountPoint prev = mountPoints.putIfAbsent(mountPointId, mountPoint);
checkState(prev == null, "Mount point %s already exists as %s", mountPointId, prev);
}
final DOMMountPoint prev = mountPoints.putIfAbsent(mountPointId, mountPoint);
checkState(prev == null, "Mount point %s already exists as %s", mountPointId, prev);
}
- listeners.
getRegistration
s().forEach(listener -> {
+ listeners.
streamListener
s().forEach(listener -> {
try {
try {
- listener.
getInstance().
onMountPointCreated(mountPointId);
+ listener.onMountPointCreated(mountPointId);
} catch (final Exception ex) {
LOG.error("Listener {} failed on mount point {} created event", listener, mountPoint, ex);
}
});
} catch (final Exception ex) {
LOG.error("Listener {} failed on mount point {} created event", listener, mountPoint, ex);
}
});
- return new AbstractObjectRegistration<
DOMMountPoint
>(mountPoint) {
+ return new AbstractObjectRegistration<>(mountPoint) {
@Override
protected void removeRegistration() {
unregisterMountPoint(getInstance().getIdentifier());
@Override
protected void removeRegistration() {
unregisterMountPoint(getInstance().getIdentifier());
@@
-84,9
+102,9
@@
public class DOMMountPointServiceImpl implements DOMMountPointService {
}
}
}
}
- listeners.
getRegistration
s().forEach(listener -> {
+ listeners.
streamListener
s().forEach(listener -> {
try {
try {
- listener.
getInstance().
onMountPointRemoved(mountPointId);
+ listener.onMountPointRemoved(mountPointId);
} catch (final Exception ex) {
LOG.error("Listener {} failed on mount point {} removed event", listener, mountPointId, ex);
}
} catch (final Exception ex) {
LOG.error("Listener {} failed on mount point {} removed event", listener, mountPointId, ex);
}
@@
-97,7
+115,6
@@
public class DOMMountPointServiceImpl implements DOMMountPointService {
private final MutableClassToInstanceMap<DOMService> services = MutableClassToInstanceMap.create();
private final YangInstanceIdentifier path;
private final MutableClassToInstanceMap<DOMService> services = MutableClassToInstanceMap.create();
private final YangInstanceIdentifier path;
- private SchemaContext schemaContext;
private SimpleDOMMountPoint mountPoint;
private SimpleDOMMountPoint mountPoint;
@@
-111,16
+128,10
@@
public class DOMMountPointServiceImpl implements DOMMountPointService {
return this;
}
return this;
}
- @Override
- public DOMMountPointBuilder addInitialSchemaContext(final SchemaContext ctx) {
- schemaContext = requireNonNull(ctx);
- return this;
- }
-
@Override
public ObjectRegistration<DOMMountPoint> register() {
checkState(mountPoint == null, "Mount point is already built.");
@Override
public ObjectRegistration<DOMMountPoint> register() {
checkState(mountPoint == null, "Mount point is already built.");
- mountPoint = SimpleDOMMountPoint.create(path, services
, schemaContext
);
+ mountPoint = SimpleDOMMountPoint.create(path, services);
return registerMountPoint(mountPoint);
}
}
return registerMountPoint(mountPoint);
}
}