use of org.opendaylight.protocol.concepts.AbstractRegistration in project bgpcep by opendaylight.
the class SimpleNlriRegistry method registerNlriSerializer.
synchronized AutoCloseable registerNlriSerializer(final Class<? extends DataObject> nlriClass, final NlriSerializer serializer) {
final NlriSerializer prev = this.serializers.get(nlriClass);
Preconditions.checkState(prev == null, "Serializer already bound to class " + prev);
this.serializers.put(nlriClass, serializer);
final Object lock = this;
return new AbstractRegistration() {
@Override
protected void removeRegistration() {
synchronized (lock) {
SimpleNlriRegistry.this.serializers.remove(nlriClass);
}
}
};
}
use of org.opendaylight.protocol.concepts.AbstractRegistration in project bgpcep by opendaylight.
the class SimpleNlriRegistry method registerNlriParser.
synchronized AutoCloseable registerNlriParser(final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi, final NlriParser parser, final NextHopParserSerializer nextHopSerializer, final Class<? extends CNextHop> cNextHopClass, final Class<? extends CNextHop>... cNextHopClassList) {
final BgpTableType key = createKey(afi, safi);
final NlriParser prev = this.handlers.get(key);
Preconditions.checkState(prev == null, "AFI/SAFI is already bound to parser " + prev);
this.handlers.put(key, parser);
this.nextHopParsers.put(key, nextHopSerializer);
if (cNextHopClass != null) {
final Entry<Class<? extends CNextHop>, BgpTableType> nhKey = new SimpleEntry<>(cNextHopClass, key);
this.nextHopSerializers.put(nhKey, nextHopSerializer);
for (final Class<? extends CNextHop> cNextHop : cNextHopClassList) {
final Entry<Class<? extends CNextHop>, BgpTableType> nhKeys = new SimpleEntry<>(cNextHop, key);
this.nextHopSerializers.put(nhKeys, nextHopSerializer);
}
}
final Object lock = this;
return new AbstractRegistration() {
@Override
protected void removeRegistration() {
synchronized (lock) {
SimpleNlriRegistry.this.handlers.remove(key);
SimpleNlriRegistry.this.nextHopParsers.remove(key);
if (cNextHopClass != null) {
final Entry<Class<? extends CNextHop>, BgpTableType> nhKey = new SimpleEntry<>(cNextHopClass, key);
SimpleNlriRegistry.this.nextHopSerializers.remove(nhKey);
for (final Class<? extends CNextHop> cNextHop : cNextHopClassList) {
final Entry<Class<? extends CNextHop>, BgpTableType> nhKeys = new SimpleEntry<>(cNextHop, key);
SimpleNlriRegistry.this.nextHopSerializers.remove(nhKeys);
}
}
}
}
};
}
use of org.opendaylight.protocol.concepts.AbstractRegistration in project bgpcep by opendaylight.
the class SimpleAttributeRegistry method registerAttributeSerializer.
synchronized AutoCloseable registerAttributeSerializer(final Class<? extends DataObject> paramClass, final AttributeSerializer serializer) {
final AbstractRegistration reg = this.handlers.registerSerializer(paramClass, serializer);
this.serializers.put(reg, serializer);
return new AbstractRegistration() {
@Override
protected void removeRegistration() {
synchronized (SimpleAttributeRegistry.this) {
SimpleAttributeRegistry.this.serializers.remove(reg);
SimpleAttributeRegistry.this.roSerializers.set(SimpleAttributeRegistry.this.serializers.values());
}
reg.close();
}
};
}
Aggregations