2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.openflowplugin.openflow.md.core.extension;
10 import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
11 import org.opendaylight.openflowplugin.extension.api.ConverterExtensionKey;
12 import org.opendaylight.openflowplugin.extension.api.ConverterMessageToOFJava;
13 import org.opendaylight.openflowplugin.extension.api.ConvertorActionFromOFJava;
14 import org.opendaylight.openflowplugin.extension.api.ConvertorActionToOFJava;
15 import org.opendaylight.openflowplugin.extension.api.ConvertorData;
16 import org.opendaylight.openflowplugin.extension.api.ConvertorFromOFJava;
17 import org.opendaylight.openflowplugin.extension.api.ConvertorMessageFromOFJava;
18 import org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava;
19 import org.opendaylight.openflowplugin.extension.api.TypeVersionKey;
20 import org.opendaylight.openflowplugin.extension.api.path.AugmentationPath;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.experimenter.core.message.ExperimenterMessageOfChoice;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.ExtensionKey;
24 import org.opendaylight.yangtools.concepts.ObjectRegistration;
25 import org.opendaylight.yangtools.yang.binding.DataContainer;
28 * Closes converter registrations.
30 * @param <K> converter key
31 * @param <C> converter instance
33 public abstract class RegistrationCloser<K, C> implements ObjectRegistration<C> {
35 private ExtensionConverterManagerImpl registrator;
40 * Sets the registrator.
42 * @param registrator the registrator to set
44 public void setRegistrator(ExtensionConverterManagerImpl registrator) {
45 this.registrator = registrator;
51 * @param key the key to set
53 public void setKey(K key) {
60 * @param converter the converter to set
62 public void setConverter(C converter) {
63 this.converter = converter;
67 * Returns the registrator.
69 public ExtensionConverterManagerImpl getRegistrator() {
81 * Returns the converter.
83 public C getConverter() {
88 public C getInstance() {
89 return getConverter();
93 * Standalone deregistrator.
95 * @param <T> target type of wrapped convertor
97 public static class RegistrationCloserToOFJava<T extends DataContainer> extends
98 RegistrationCloser<ConverterExtensionKey<? extends ExtensionKey>, ConvertorToOFJava<T>> {
101 public void close() {
102 getRegistrator().unregister(getKey(), getConverter());
107 * Standalone deregistrator.
109 * @param <F> source type of wrapped convertor
110 * @param <P> associated augmentation path
112 public static class RegistrationCloserFromOFJava<F extends DataContainer, P extends AugmentationPath>
113 extends RegistrationCloser<MessageTypeKey<?>, ConvertorFromOFJava<F, P>> {
115 public void close() {
116 getRegistrator().unregister(getKey(), getConverter());
121 * Standalone deregistrator.
123 * @param <T> target type of wrapped convertor
125 public static class RegistrationCloserActionToOFJava<T extends DataContainer> extends
126 RegistrationCloser<TypeVersionKey<? extends Action>, ConvertorActionToOFJava<Action, T>> {
129 public void close() {
130 getRegistrator().unregister(getKey(), getConverter());
135 * Standalone deregistrator.
137 * @param <F> source type of wrapped convertor
138 * @param <P> associated augmentation path
140 public static class RegistrationCloserActionFromOFJava<F extends DataContainer, P extends AugmentationPath> extends
141 RegistrationCloser<MessageTypeKey<?>, ConvertorActionFromOFJava<F, P>> {
144 public void close() {
145 getRegistrator().unregister(getKey(), getConverter());
150 * Standalone deregistrator.
152 * @param <T> target type of wrapped convertor
154 public static class RegistrationCloserMessageToOFJava<T extends DataContainer,
155 K extends ExperimenterMessageOfChoice, D extends ConvertorData>
156 extends RegistrationCloser<TypeVersionKey<K>, ConverterMessageToOFJava<K, T, D>> {
159 public void close() {
160 getRegistrator().unregister(getKey(), getConverter());
165 * Standalone deregistrator.
167 * @param <F> source type of wrapped convertor
168 * @param <P> associated augmentation path
170 public static class RegistrationCloserMessageFromOFJava<F extends DataContainer, P extends AugmentationPath> extends
171 RegistrationCloser<MessageTypeKey<?>, ConvertorMessageFromOFJava<F, P>> {
174 public void close() {
175 getRegistrator().unregister(getKey(), getConverter());