From 15cbdc938e9991c2067002b042af40188e3965ab Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 7 Feb 2014 23:50:42 +0100 Subject: [PATCH] Remove deprecated API elements from protocol framework The use of these concepts has been deprecated in version 0.4.0, which was released. The only in-tree user was netconf, which was refactored to not to rely on these concepts, so bump the version to 0.5.0 and purge the code. Change-Id: Ibf2195b51bf12ea99b8b21f3da322d666b103b5e Signed-off-by: Robert Varga --- opendaylight/commons/opendaylight/pom.xml | 2 +- .../commons/protocol-framework/pom.xml | 2 +- .../framework/DeserializerException.java | 37 ------------ .../framework/DocumentedException.java | 40 ------------- .../framework/ProtocolHandlerFactory.java | 36 ------------ .../framework/ProtocolMessageDecoder.java | 57 ------------------- .../framework/ProtocolMessageEncoder.java | 40 ------------- .../framework/ProtocolMessageFactory.java | 41 ------------- .../protocol/framework/ComplementaryTest.java | 24 -------- 9 files changed, 2 insertions(+), 277 deletions(-) delete mode 100644 opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/DeserializerException.java delete mode 100644 opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/DocumentedException.java delete mode 100644 opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolHandlerFactory.java delete mode 100644 opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolMessageDecoder.java delete mode 100644 opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolMessageEncoder.java delete mode 100644 opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolMessageFactory.java delete mode 100644 opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/ComplementaryTest.java diff --git a/opendaylight/commons/opendaylight/pom.xml b/opendaylight/commons/opendaylight/pom.xml index d2e9048027..73630575ed 100644 --- a/opendaylight/commons/opendaylight/pom.xml +++ b/opendaylight/commons/opendaylight/pom.xml @@ -91,7 +91,7 @@ 0.0.3-SNAPSHOT 0.1.2-SNAPSHOT 0.5.2-SNAPSHOT - 0.4.1-SNAPSHOT + 0.5.0-SNAPSHOT 4.0.10.Final 2.4 0.4.2-SNAPSHOT diff --git a/opendaylight/commons/protocol-framework/pom.xml b/opendaylight/commons/protocol-framework/pom.xml index b162b9c400..a03518235b 100644 --- a/opendaylight/commons/protocol-framework/pom.xml +++ b/opendaylight/commons/protocol-framework/pom.xml @@ -17,7 +17,7 @@ protocol-framework - 0.4.1-SNAPSHOT + 0.5.0-SNAPSHOT Common protocol framework bundle ${project.artifactId} diff --git a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/DeserializerException.java b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/DeserializerException.java deleted file mode 100644 index 608e949085..0000000000 --- a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/DeserializerException.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * 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.protocol.framework; - -/** - * Used when something occurs during parsing bytes to java objects. - * - * @deprecated This exception no longer carries any special meaning. Users - * are advised to stop using it and define their own replacement. - */ -@Deprecated -public class DeserializerException extends Exception { - - private static final long serialVersionUID = -2247000673438452870L; - - /** - * Creates a deserializer exception. - * @param err string - */ - public DeserializerException(final String err) { - super(err); - } - - /** - * Creates a deserializer exception. - * @param err string - * @param e underlying exception - */ - public DeserializerException(final String err, final Throwable e) { - super(err, e); - } -} diff --git a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/DocumentedException.java b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/DocumentedException.java deleted file mode 100644 index 5e5f29eafe..0000000000 --- a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/DocumentedException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * 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.protocol.framework; - -/** - * Documented exception occurrs when an error is thrown that is documented - * in any RFC or draft for the specific protocol. - * - * @deprecated This exception no longer carries any special meaning. Users - * are advised to stop using it and define their own replacement. - */ -@Deprecated -public class DocumentedException extends Exception { - - private static final long serialVersionUID = -3727963789710833704L; - - /** - * Creates a documented exception - * @param message string - */ - public DocumentedException(final String message) { - super(message); - } - - /** - * Creates a documented exception - * @param err string - * @param cause the cause (which is saved for later retrieval by the - * Throwable.getCause() method). (A null value is permitted, and indicates - * that the cause is nonexistent or unknown.) - */ - public DocumentedException(final String err, final Exception cause) { - super(err, cause); - } -} diff --git a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolHandlerFactory.java b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolHandlerFactory.java deleted file mode 100644 index 5c1377d9f5..0000000000 --- a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolHandlerFactory.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * 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.protocol.framework; - -import io.netty.channel.ChannelHandler; - -import com.google.common.base.Preconditions; - -/** - * @deprecated This is an adaptor class for turning ProtocolMessageFactory into - * Netty encoder/decoder. Use Netty-provided classes directly, by subclassing - * {@link io.netty.handler.codec.ByteToMessageDecoder} or similar instead. - */ -@Deprecated -public class ProtocolHandlerFactory { - private final ProtocolMessageEncoder encoder; - protected final ProtocolMessageFactory msgFactory; - - public ProtocolHandlerFactory(final ProtocolMessageFactory msgFactory) { - this.msgFactory = Preconditions.checkNotNull(msgFactory); - this.encoder = new ProtocolMessageEncoder(msgFactory); - } - - public ChannelHandler[] getEncoders() { - return new ChannelHandler[] { this.encoder }; - } - - public ChannelHandler[] getDecoders() { - return new ChannelHandler[] { new ProtocolMessageDecoder(this.msgFactory) }; - } -} diff --git a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolMessageDecoder.java b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolMessageDecoder.java deleted file mode 100644 index d8ad8b6202..0000000000 --- a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolMessageDecoder.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * 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.protocol.framework; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.ByteBufUtil; -import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.ByteToMessageDecoder; - -import java.util.List; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.Preconditions; - -/** - * @deprecated This is an adaptor class for turning ProtocolMessageFactory into Netty decoder. Use Netty-provided - * classes directly, by subclassing {@link io.netty.handler.codec.ByteToMessageDecoder} or similar instead. - */ -@Deprecated -public final class ProtocolMessageDecoder extends ByteToMessageDecoder { - - private static final Logger LOG = LoggerFactory.getLogger(ProtocolMessageDecoder.class); - - private final ProtocolMessageFactory factory; - - public ProtocolMessageDecoder(final ProtocolMessageFactory factory) { - this.factory = Preconditions.checkNotNull(factory); - } - - @Override - protected void decode(final ChannelHandlerContext ctx, final ByteBuf in, final List out) throws Exception { - if (in.readableBytes() == 0) { - LOG.debug("No more content in incoming buffer."); - return; - } - in.markReaderIndex(); - try { - LOG.trace("Received to decode: {}", ByteBufUtil.hexDump(in)); - final byte[] bytes = new byte[in.readableBytes()]; - in.readBytes(bytes); - out.add(this.factory.parse(bytes)); - } catch (DeserializerException | DocumentedException e) { - LOG.debug("Failed to decode protocol message", e); - this.exceptionCaught(ctx, e); - } - in.discardReadBytes(); - } - -} - diff --git a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolMessageEncoder.java b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolMessageEncoder.java deleted file mode 100644 index 66378e75d6..0000000000 --- a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolMessageEncoder.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * 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.protocol.framework; - -import io.netty.buffer.ByteBuf; -import io.netty.channel.ChannelHandler.Sharable; -import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.MessageToByteEncoder; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @deprecated This is an adaptor class for turning ProtocolMessageFactory into Netty encoder. Use Netty-provided - * classes directly, by subclassing {@link io.netty.handler.codec.MessageToByteDecoder} or similar instead. - */ -@Deprecated -@Sharable -public final class ProtocolMessageEncoder extends MessageToByteEncoder { - - private static final Logger LOG = LoggerFactory.getLogger(ProtocolMessageEncoder.class); - - private final ProtocolMessageFactory factory; - - public ProtocolMessageEncoder(final ProtocolMessageFactory factory) { - this.factory = factory; - } - - @Override - protected void encode(final ChannelHandlerContext ctx, final Object msg, final ByteBuf out) throws Exception { - LOG.debug("Sent to encode : {}", msg); - final byte[] bytes = this.factory.put((T) msg); - out.writeBytes(bytes); - } -} diff --git a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolMessageFactory.java b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolMessageFactory.java deleted file mode 100644 index 9b89dc3592..0000000000 --- a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolMessageFactory.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * 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.protocol.framework; - - -/** - * Interface for factory for parsing and serializing protocol specific messages. Needs to be implemented by a protocol - * specific message factory. The methods put/parse should delegate parsing to specific message parsers, e.g. - * OpenMessageParser etc. - * - * @param type of messages created by this factory - * - * @deprecated Interact with Netty 4.0 directly, by subclassing {@link io.netty.handler.codec.ByteToMessageCodec} or - * similar. - */ -@Deprecated -public interface ProtocolMessageFactory { - - /** - * Parses message from byte array. Requires specific protocol message header object to parse the header. - * - * @param bytes byte array from which the message will be parsed - * @return List of specific protocol messages - * @throws DeserializerException if some parsing error occurs - * @throws DocumentedException if some documented error occurs - */ - T parse(byte[] bytes) throws DeserializerException, DocumentedException; - - /** - * Serializes protocol specific message to byte array. - * - * @param msg message to be serialized. - * @return byte array resulting message - */ - byte[] put(T msg); -} diff --git a/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/ComplementaryTest.java b/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/ComplementaryTest.java deleted file mode 100644 index 80e6ad9cde..0000000000 --- a/opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/ComplementaryTest.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * 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.protocol.framework; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -@Deprecated -public class ComplementaryTest { - - @Test - public void testExceptions() { - final DeserializerException de = new DeserializerException("some error"); - final DocumentedException ee = new DocumentedException("some error"); - - assertEquals(de.getMessage(), ee.getMessage()); - } -} -- 2.36.6