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.ConvertorActionFromOFJava;
13 import org.opendaylight.openflowplugin.extension.api.ConvertorActionToOFJava;
14 import org.opendaylight.openflowplugin.extension.api.ConvertorFromOFJava;
15 import org.opendaylight.openflowplugin.extension.api.ConvertorMessageFromOFJava;
16 import org.opendaylight.openflowplugin.extension.api.ConvertorMessageToOFJava;
17 import org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava;
18 import org.opendaylight.openflowplugin.extension.api.TypeVersionKey;
19 import org.opendaylight.openflowplugin.extension.api.path.AugmentationPath;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.experimenter.core.message.ExperimenterMessageOfChoice;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.ExtensionKey;
23 import org.opendaylight.yangtools.concepts.ObjectRegistration;
24 import org.opendaylight.yangtools.yang.binding.DataContainer;
27 * @param <KEY> converter key
28 * @param <CONVERTER> converter instance
30 public abstract class RegistrationCloser<KEY, CONVERTER> implements ObjectRegistration<CONVERTER> {
32 private ExtensionConverterManagerImpl registrator;
34 private CONVERTER converter;
37 * @param registrator the registrator to set
39 public void setRegistrator(ExtensionConverterManagerImpl registrator) {
40 this.registrator = registrator;
43 * @param key the key to set
45 public void setKey(KEY key) {
49 * @param converter the converter to set
51 public void setConverter(CONVERTER converter) {
52 this.converter = converter;
55 * @return the registrator
57 public ExtensionConverterManagerImpl getRegistrator() {
67 * @return the converter
69 public CONVERTER getConverter() {
74 public CONVERTER getInstance() {
75 return getConverter();
79 * standalone deregistrator
80 * @param <TO> target type of wrapped convertor
82 public static class RegistrationCloserToOFJava<TO extends DataContainer> extends
83 RegistrationCloser<ConverterExtensionKey<? extends ExtensionKey>, ConvertorToOFJava<TO>> {
86 public void close() throws Exception {
87 getRegistrator().unregister(getKey(), getConverter());
92 * standalone deregistrator
93 * @param <FROM> source type of wrapped convertor
94 * @param <PATH> associated augmentation path
96 public static class RegistrationCloserFromOFJava<FROM extends DataContainer, PATH extends AugmentationPath> extends RegistrationCloser<MessageTypeKey<?>, ConvertorFromOFJava<FROM, PATH>> {
99 public void close() throws Exception {
100 getRegistrator().unregister(getKey(), getConverter());
105 * standalone deregistrator
106 * @param <TO> target type of wrapped convertor
108 public static class RegistrationCloserActionToOFJava<TO extends DataContainer> extends
109 RegistrationCloser<TypeVersionKey<? extends Action>, ConvertorActionToOFJava<Action, TO>> {
112 public void close() throws Exception {
113 getRegistrator().unregister(getKey(), getConverter());
118 * standalone deregistrator
119 * @param <FROM> source type of wrapped convertor
120 * @param <PATH> associated augmentation path
122 public static class RegistrationCloserActionFromOFJava<FROM extends DataContainer, PATH extends AugmentationPath> extends
123 RegistrationCloser<MessageTypeKey<?>, ConvertorActionFromOFJava<FROM, PATH>> {
126 public void close() throws Exception {
127 getRegistrator().unregister(getKey(), getConverter());
132 * standalone deregistrator
134 * @param <TO> target type of wrapped convertor
136 public static class RegistrationCloserMessageToOFJava<TO extends DataContainer> extends
137 RegistrationCloser<TypeVersionKey<? extends ExperimenterMessageOfChoice>, ConvertorMessageToOFJava<ExperimenterMessageOfChoice, TO>> {
140 public void close() throws Exception {
141 getRegistrator().unregister(getKey(), getConverter());
146 * standalone deregistrator
148 * @param <FROM> source type of wrapped convertor
149 * @param <PATH> associated augmentation path
151 public static class RegistrationCloserMessageFromOFJava<FROM extends DataContainer, PATH extends AugmentationPath> extends
152 RegistrationCloser<MessageTypeKey<?>, ConvertorMessageFromOFJava<FROM, PATH>> {
155 public void close() throws Exception {
156 getRegistrator().unregister(getKey(), getConverter());