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.ConvertorToOFJava;
16 import org.opendaylight.openflowplugin.extension.api.TypeVersionKey;
17 import org.opendaylight.openflowplugin.extension.api.path.AugmentationPath;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.ExtensionKey;
20 import org.opendaylight.yangtools.concepts.ObjectRegistration;
21 import org.opendaylight.yangtools.yang.binding.DataContainer;
24 * @param <KEY> converter key
25 * @param <CONVERTER> converter instance
27 public abstract class RegistrationCloser<KEY, CONVERTER> implements ObjectRegistration<CONVERTER> {
29 private ExtensionConverterManagerImpl registrator;
31 private CONVERTER converter;
34 * @param registrator the registrator to set
36 public void setRegistrator(ExtensionConverterManagerImpl registrator) {
37 this.registrator = registrator;
40 * @param key the key to set
42 public void setKey(KEY key) {
46 * @param converter the converter to set
48 public void setConverter(CONVERTER converter) {
49 this.converter = converter;
52 * @return the registrator
54 public ExtensionConverterManagerImpl getRegistrator() {
64 * @return the converter
66 public CONVERTER getConverter() {
71 public CONVERTER getInstance() {
72 return getConverter();
76 * standalone deregistrator
77 * @param <TO> target type of wrapped convertor
79 public static class RegistrationCloserToOFJava<TO extends DataContainer> extends
80 RegistrationCloser<ConverterExtensionKey<? extends ExtensionKey>, ConvertorToOFJava<TO>> {
83 public void close() throws Exception {
84 getRegistrator().unregister(getKey(), getConverter());
89 * standalone deregistrator
90 * @param <FROM> source type of wrapped convertor
91 * @param <PATH> associated augmentation path
93 public static class RegistrationCloserFromOFJava<FROM extends DataContainer, PATH extends AugmentationPath> extends RegistrationCloser<MessageTypeKey<?>, ConvertorFromOFJava<FROM, PATH>> {
96 public void close() throws Exception {
97 getRegistrator().unregister(getKey(), getConverter());
102 * standalone deregistrator
103 * @param <TO> target type of wrapped convertor
105 public static class RegistrationCloserActionToOFJava<TO extends DataContainer> extends
106 RegistrationCloser<TypeVersionKey<? extends Action>, ConvertorActionToOFJava<Action, TO>> {
109 public void close() throws Exception {
110 getRegistrator().unregister(getKey(), getConverter());
115 * standalone deregistrator
116 * @param <FROM> source type of wrapped convertor
117 * @param <PATH> associated augmentation path
119 public static class RegistrationCloserActionFromOFJava<FROM extends DataContainer, PATH extends AugmentationPath> extends RegistrationCloser<MessageTypeKey<?>, ConvertorActionFromOFJava<FROM, PATH>> {
122 public void close() throws Exception {
123 getRegistrator().unregister(getKey(), getConverter());