BUG-113: split HandlerRegistry into per-class registries 88/1888/1
authorRobert Varga <rovarga@cisco.com>
Mon, 14 Oct 2013 20:16:42 +0000 (22:16 +0200)
committerRobert Varga <rovarga@cisco.com>
Mon, 14 Oct 2013 20:17:43 +0000 (22:17 +0200)
Change-Id: I2951bd1169f4c6a4eb92737ce24617e1dca7b15c
Signed-off-by: Robert Varga <rovarga@cisco.com>
47 files changed:
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/HandlerRegistryImpl.java [deleted file]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPDispatcherImpl.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPHandlerFactory.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPMessageFactory.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/SimpleMessageHandlerFactory.java [new file with mode: 0644]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/SimpleObjectHandlerRegistry.java [new file with mode: 0644]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/SimpleSubobjectHandlerFactory.java [new file with mode: 0644]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/SimpleTlvHandlerRegistry.java [new file with mode: 0644]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCCreateMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPCloseMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPErrorMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPKeepAliveMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPNotificationMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPOpenMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPReplyMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPReportMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPRequestMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPUpdateRequestMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPBandwidthObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPClassTypeObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPCloseObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPEndPointsObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPErrorObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPExplicitRouteObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPGlobalConstraintsObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPIncludeRouteObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPLoadBalancingObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPLspObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPLspaObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPMetricObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPNoPathObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPNotificationObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPObjectiveFunctionObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPOpenObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPPathKeyObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPReportedRouteObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPRequestParameterObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPSrpObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPSvecObjectParser.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/AbstractMessageParser.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/AbstractObjectParser.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/HandlerRegistry.java [deleted file]
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/MessageHandlerRegistry.java [new file with mode: 0644]
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/ObjectHandlerRegistry.java [new file with mode: 0644]
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/SubobjectHandlerRegistry.java [new file with mode: 0644]
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/TlvHandlerRegistry.java [new file with mode: 0644]
pcep/testtool/src/test/java/org/opendaylight/protocol/pcep/testtool/PCCMock.java

diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/HandlerRegistryImpl.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/HandlerRegistryImpl.java
deleted file mode 100644 (file)
index 6bb3acd..0000000
+++ /dev/null
@@ -1,445 +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.pcep.impl;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.opendaylight.protocol.concepts.AbstractRegistration;
-import org.opendaylight.protocol.pcep.impl.object.PCEPBandwidthObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPClassTypeObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPCloseObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPEndPointsObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPErrorObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPExplicitRouteObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPGlobalConstraintsObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPIncludeRouteObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPLoadBalancingObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPLspObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPLspaObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPMetricObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPNoPathObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPNotificationObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPObjectiveFunctionObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPOpenObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPPathKeyObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPReportedRouteObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPRequestParameterObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPSrpObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPSvecObjectParser;
-import org.opendaylight.protocol.pcep.impl.subobject.EROAsNumberSubobjectParser;
-import org.opendaylight.protocol.pcep.impl.tlv.LSPIdentifierIPv4TlvParser;
-import org.opendaylight.protocol.pcep.impl.tlv.LSPIdentifierIPv6TlvParser;
-import org.opendaylight.protocol.pcep.impl.tlv.LspDbVersionTlvParser;
-import org.opendaylight.protocol.pcep.impl.tlv.LspSymbolicNameTlvParser;
-import org.opendaylight.protocol.pcep.impl.tlv.LspUpdateErrorTlvParser;
-import org.opendaylight.protocol.pcep.impl.tlv.NoPathVectorTlvParser;
-import org.opendaylight.protocol.pcep.impl.tlv.OFListTlvParser;
-import org.opendaylight.protocol.pcep.impl.tlv.OrderTlvParser;
-import org.opendaylight.protocol.pcep.impl.tlv.OverloadedDurationTlvParser;
-import org.opendaylight.protocol.pcep.impl.tlv.PCEStatefulCapabilityTlvParser;
-import org.opendaylight.protocol.pcep.impl.tlv.PredundancyGroupTlvParser;
-import org.opendaylight.protocol.pcep.impl.tlv.RSVPErrorSpecTlvParser;
-import org.opendaylight.protocol.pcep.impl.tlv.ReqMissingTlvParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
-import org.opendaylight.protocol.pcep.spi.MessageParser;
-import org.opendaylight.protocol.pcep.spi.MessageSerializer;
-import org.opendaylight.protocol.pcep.spi.ObjectParser;
-import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
-import org.opendaylight.protocol.pcep.spi.SubobjectParser;
-import org.opendaylight.protocol.pcep.spi.SubobjectSerializer;
-import org.opendaylight.protocol.pcep.spi.TlvParser;
-import org.opendaylight.protocol.pcep.spi.TlvSerializer;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.BandwidthObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ClasstypeObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.CloseObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.EndpointsObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ExplicitRouteObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.GcObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.IncludeRouteObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LoadBalancingObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspDbVersionTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspErrorCodeTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspIdentifiersTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspaObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.MetricObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NoPathObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NoPathVectorTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NotificationObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OfListTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OfObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OpenObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OrderTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OverloadDurationTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PathKeyObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcepErrorObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PredundancyGroupIdTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ReportedRouteObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ReqMissingTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RpObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RsvpErrorSpecTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.SrpObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.StatefulCapabilityTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.SvecObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.SymbolicPathNameTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.AsNumberSubobject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.CSubobject;
-
-import com.google.common.base.Preconditions;
-
-public class HandlerRegistryImpl implements HandlerRegistry {
-       public static final HandlerRegistry INSTANCE;
-
-       static {
-               final HandlerRegistry reg = new HandlerRegistryImpl();
-
-               // FIXME: fill this in
-
-               // reg.registerMessageHandler(PCEPOpenMessage.class, 1, new PCEPOpenMessageParser());
-               // reg.registerMessageHandler(PCEPNotificationMessage.class, 5, new PCEPNotificationMessageParser());
-               // reg.registerMessageHandler(PCEPKeepAliveMessage.class, 2, new PCEPKeepAliveMessageParser());
-               // reg.registerMessageHandler(PCEPReplyMessage.class, 4, new PCEPReplyMessageParser());
-               // reg.registerMessageHandler(PCEPRequestMessage.class, 3, new PCEPRequestMessageParser());
-               // reg.registerMessageHandler(PCEPErrorMessage.class, 6, new PCEPErrorMessageParser());
-               // reg.registerMessageHandler(PCEPCloseMessage.class, 7, new PCEPCloseMessageParser());
-               // reg.registerMessageHandler(PCEPUpdateRequestMessage.class, 11, new PCEPUpdateRequestMessageParser());
-               // reg.registerMessageHandler(PCEPReportMessage.class, 10, new PCEPReportMessageParser());
-               // reg.registerMessageHandler(PCCreateMessage.class, 12, new PCCreateMessageParser());
-
-               reg.registerTlvParser(NoPathVectorTlvParser.TYPE, new NoPathVectorTlvParser());
-               reg.registerTlvParser(OverloadedDurationTlvParser.TYPE, new OverloadedDurationTlvParser());
-               reg.registerTlvParser(ReqMissingTlvParser.TYPE, new ReqMissingTlvParser());
-               reg.registerTlvParser(OFListTlvParser.TYPE, new OFListTlvParser());
-               reg.registerTlvParser(OrderTlvParser.TYPE, new OrderTlvParser());
-               reg.registerTlvParser(PCEStatefulCapabilityTlvParser.TYPE, new PCEStatefulCapabilityTlvParser());
-               reg.registerTlvParser(LspSymbolicNameTlvParser.TYPE, new LspSymbolicNameTlvParser());
-               reg.registerTlvParser(LSPIdentifierIPv4TlvParser.TYPE, new LSPIdentifierIPv4TlvParser());
-               reg.registerTlvParser(LSPIdentifierIPv6TlvParser.TYPE, new LSPIdentifierIPv6TlvParser());
-               reg.registerTlvParser(LspUpdateErrorTlvParser.TYPE, new LspUpdateErrorTlvParser());
-               reg.registerTlvParser(RSVPErrorSpecTlvParser.TYPE, new RSVPErrorSpecTlvParser());
-               reg.registerTlvParser(LspDbVersionTlvParser.TYPE, new LspDbVersionTlvParser());
-               reg.registerTlvParser(PredundancyGroupTlvParser.TYPE, new PredundancyGroupTlvParser());
-
-               reg.registerTlvSerializer(NoPathVectorTlv.class, new NoPathVectorTlvParser());
-               reg.registerTlvSerializer(OverloadDurationTlv.class, new OverloadedDurationTlvParser());
-               reg.registerTlvSerializer(ReqMissingTlv.class, new ReqMissingTlvParser());
-               reg.registerTlvSerializer(OfListTlv.class, new OFListTlvParser());
-               reg.registerTlvSerializer(OrderTlv.class, new OrderTlvParser());
-               reg.registerTlvSerializer(StatefulCapabilityTlv.class, new PCEStatefulCapabilityTlvParser());
-               reg.registerTlvSerializer(SymbolicPathNameTlv.class, new LspSymbolicNameTlvParser());
-               reg.registerTlvSerializer(LspIdentifiersTlv.class, new LSPIdentifierIPv4TlvParser());
-               reg.registerTlvSerializer(LspErrorCodeTlv.class, new LspUpdateErrorTlvParser());
-               reg.registerTlvSerializer(RsvpErrorSpecTlv.class, new RSVPErrorSpecTlvParser());
-               reg.registerTlvSerializer(LspDbVersionTlv.class, new LspDbVersionTlvParser());
-               reg.registerTlvSerializer(PredundancyGroupIdTlv.class, new PredundancyGroupTlvParser());
-
-               reg.registerObjectParser(PCEPOpenObjectParser.CLASS, PCEPOpenObjectParser.TYPE, new PCEPOpenObjectParser(reg));
-               reg.registerObjectParser(PCEPRequestParameterObjectParser.CLASS, PCEPRequestParameterObjectParser.TYPE,
-                               new PCEPRequestParameterObjectParser(reg));
-               reg.registerObjectParser(PCEPNoPathObjectParser.CLASS, PCEPNoPathObjectParser.TYPE, new PCEPNoPathObjectParser(reg));
-               reg.registerObjectParser(PCEPEndPointsObjectParser.CLASS, PCEPEndPointsObjectParser.TYPE, new PCEPEndPointsObjectParser(reg));
-               reg.registerObjectParser(PCEPEndPointsObjectParser.CLASS_6, PCEPEndPointsObjectParser.TYPE_6, new PCEPEndPointsObjectParser(reg));
-               reg.registerObjectParser(PCEPBandwidthObjectParser.CLASS, PCEPBandwidthObjectParser.TYPE, new PCEPBandwidthObjectParser(reg));
-               reg.registerObjectParser(PCEPBandwidthObjectParser.E_CLASS, PCEPBandwidthObjectParser.E_TYPE, new PCEPBandwidthObjectParser(reg));
-               reg.registerObjectParser(PCEPMetricObjectParser.CLASS, PCEPMetricObjectParser.TYPE, new PCEPMetricObjectParser(reg));
-               reg.registerObjectParser(PCEPExplicitRouteObjectParser.CLASS, PCEPExplicitRouteObjectParser.TYPE,
-                               new PCEPExplicitRouteObjectParser(reg));
-               reg.registerObjectParser(PCEPReportedRouteObjectParser.CLASS, PCEPReportedRouteObjectParser.TYPE,
-                               new PCEPReportedRouteObjectParser(reg));
-               reg.registerObjectParser(PCEPLspaObjectParser.CLASS, PCEPLspaObjectParser.TYPE, new PCEPLspaObjectParser(reg));
-               reg.registerObjectParser(PCEPIncludeRouteObjectParser.CLASS, PCEPIncludeRouteObjectParser.TYPE,
-                               new PCEPIncludeRouteObjectParser(reg));
-               reg.registerObjectParser(PCEPSvecObjectParser.CLASS, PCEPSvecObjectParser.TYPE, new PCEPSvecObjectParser(reg));
-               reg.registerObjectParser(PCEPNotificationObjectParser.CLASS, PCEPNotificationObjectParser.TYPE,
-                               new PCEPNotificationObjectParser(reg));
-               reg.registerObjectParser(PCEPErrorObjectParser.CLASS, PCEPErrorObjectParser.TYPE, new PCEPErrorObjectParser(reg));
-               reg.registerObjectParser(PCEPLoadBalancingObjectParser.CLASS, PCEPLoadBalancingObjectParser.TYPE,
-                               new PCEPLoadBalancingObjectParser(reg));
-               reg.registerObjectParser(PCEPCloseObjectParser.CLASS, PCEPCloseObjectParser.TYPE, new PCEPCloseObjectParser(reg));
-               reg.registerObjectParser(PCEPPathKeyObjectParser.CLASS, PCEPPathKeyObjectParser.TYPE, new PCEPPathKeyObjectParser(reg));
-               reg.registerObjectParser(PCEPObjectiveFunctionObjectParser.CLASS, PCEPObjectiveFunctionObjectParser.TYPE,
-                               new PCEPObjectiveFunctionObjectParser(reg));
-               reg.registerObjectParser(PCEPClassTypeObjectParser.CLASS, PCEPClassTypeObjectParser.TYPE, new PCEPClassTypeObjectParser(reg));
-               reg.registerObjectParser(PCEPGlobalConstraintsObjectParser.CLASS, PCEPGlobalConstraintsObjectParser.TYPE,
-                               new PCEPGlobalConstraintsObjectParser(reg));
-               reg.registerObjectParser(PCEPLspObjectParser.CLASS, PCEPLspObjectParser.TYPE, new PCEPLspObjectParser(reg));
-               reg.registerObjectParser(PCEPSrpObjectParser.CLASS, PCEPSrpObjectParser.TYPE, new PCEPSrpObjectParser(reg));
-               // reg.registerObjectParser(PCEPExcludeRouteObjectParser.CLASS, PCEPExcludeRouteObjectParser.TYPE, new
-               // PCEPExcludeRouteObjectParser(reg));
-
-               reg.registerObjectSerializer(OpenObject.class, new PCEPOpenObjectParser(reg));
-               reg.registerObjectSerializer(RpObject.class, new PCEPRequestParameterObjectParser(reg));
-               reg.registerObjectSerializer(NoPathObject.class, new PCEPNoPathObjectParser(reg));
-               reg.registerObjectSerializer(EndpointsObject.class, new PCEPEndPointsObjectParser(reg));
-               reg.registerObjectSerializer(BandwidthObject.class, new PCEPBandwidthObjectParser(reg));
-               reg.registerObjectSerializer(MetricObject.class, new PCEPMetricObjectParser(reg));
-               reg.registerObjectSerializer(ExplicitRouteObject.class, new PCEPExplicitRouteObjectParser(reg));
-               reg.registerObjectSerializer(ReportedRouteObject.class, new PCEPReportedRouteObjectParser(reg));
-               reg.registerObjectSerializer(LspaObject.class, new PCEPLspaObjectParser(reg));
-               reg.registerObjectSerializer(IncludeRouteObject.class, new PCEPIncludeRouteObjectParser(reg));
-               reg.registerObjectSerializer(SvecObject.class, new PCEPSvecObjectParser(reg));
-               reg.registerObjectSerializer(NotificationObject.class, new PCEPNotificationObjectParser(reg));
-               reg.registerObjectSerializer(PcepErrorObject.class, new PCEPErrorObjectParser(reg));
-               reg.registerObjectSerializer(LoadBalancingObject.class, new PCEPLoadBalancingObjectParser(reg));
-               reg.registerObjectSerializer(CloseObject.class, new PCEPCloseObjectParser(reg));
-               reg.registerObjectSerializer(PathKeyObject.class, new PCEPPathKeyObjectParser(reg));
-               reg.registerObjectSerializer(OfObject.class, new PCEPObjectiveFunctionObjectParser(reg));
-               reg.registerObjectSerializer(ClasstypeObject.class, new PCEPClassTypeObjectParser(reg));
-               reg.registerObjectSerializer(GcObject.class, new PCEPGlobalConstraintsObjectParser(reg));
-               reg.registerObjectSerializer(LspObject.class, new PCEPLspObjectParser(reg));
-               reg.registerObjectSerializer(SrpObject.class, new PCEPSrpObjectParser(reg));
-               // reg.registerObjectSerializer(ExcludeRouteObject.class, new PCEPExcludeRouteObjectParser(reg));
-
-               reg.registerSubobjectParser(EROAsNumberSubobjectParser.TYPE, new EROAsNumberSubobjectParser());
-
-               reg.registerSubobjectSerializer(AsNumberSubobject.class, new EROAsNumberSubobjectParser());
-
-               INSTANCE = reg;
-       }
-
-       private final Map<Integer, MessageParser> msgParsers = new ConcurrentHashMap<>();
-       private final Map<Class<? extends Message>, MessageSerializer> msgSerializers = new ConcurrentHashMap<>();
-
-       private final Map<Integer, ObjectParser> objParsers = new ConcurrentHashMap<>();
-       private final Map<Class<? extends Object>, ObjectSerializer> objSerializers = new ConcurrentHashMap<>();
-
-       private final Map<Integer, TlvParser> tlvParsers = new ConcurrentHashMap<>();
-       private final Map<Class<? extends Tlv>, TlvSerializer> tlvSerializers = new ConcurrentHashMap<>();
-
-       private final Map<Integer, SubobjectParser> subobjectParsers = new ConcurrentHashMap<>();
-       private final Map<Class<? extends CSubobject>, SubobjectSerializer> subobjectSerializers = new ConcurrentHashMap<>();
-
-       private HandlerRegistryImpl() {
-
-       }
-
-       @Override
-       public MessageParser getMessageParser(final int messageType) {
-               Preconditions.checkArgument(messageType >= 0 && messageType <= 255);
-               return this.msgParsers.get(messageType);
-       }
-
-       @Override
-       public MessageSerializer getMessageSerializer(final Message message) {
-               final Class<? extends Message> c = message.getClass();
-               for (final Map.Entry<Class<? extends Message>, MessageSerializer> s : this.msgSerializers.entrySet()) {
-                       if (s.getKey().isAssignableFrom(c)) {
-                               return s.getValue();
-                       }
-               }
-
-               return null;
-       }
-
-       @Override
-       public synchronized ObjectParser getObjectParser(final int objectClass, final int objectType) {
-               Preconditions.checkArgument(objectClass >= 0 && objectClass <= 255);
-               Preconditions.checkArgument(objectType >= 0 && objectType <= 15);
-
-               return this.objParsers.get((objectClass << 4) + objectType);
-       }
-
-       @Override
-       public ObjectSerializer getObjectSerializer(final Object object) {
-               final Class<? extends Object> c = object.getClass();
-               for (final Map.Entry<Class<? extends Object>, ObjectSerializer> s : this.objSerializers.entrySet()) {
-                       if (s.getKey().isAssignableFrom(c)) {
-                               return s.getValue();
-                       }
-               }
-
-               return null;
-       }
-
-       @Override
-       public TlvParser getTlvParser(final int tlvType) {
-               Preconditions.checkArgument(tlvType >= 0 && tlvType <= 65535);
-               return this.tlvParsers.get(tlvType);
-       }
-
-       @Override
-       public TlvSerializer getTlvSerializer(final Tlv tlv) {
-               final Class<? extends Tlv> c = tlv.getClass();
-               for (final Map.Entry<Class<? extends Tlv>, TlvSerializer> s : this.tlvSerializers.entrySet()) {
-                       if (s.getKey().isAssignableFrom(c)) {
-                               return s.getValue();
-                       }
-               }
-
-               return null;
-       }
-
-       @Override
-       public SubobjectSerializer getSubobjectSerializer(final CSubobject subobject) {
-               final Class<? extends CSubobject> c = subobject.getClass();
-               for (final Map.Entry<Class<? extends CSubobject>, SubobjectSerializer> s : this.subobjectSerializers.entrySet()) {
-                       if (s.getKey().isAssignableFrom(c)) {
-                               return s.getValue();
-                       }
-               }
-               return null;
-       }
-
-       @Override
-       public SubobjectParser getSubobjectParser(final int subobjectType) {
-               Preconditions.checkArgument(subobjectType >= 0 && subobjectType <= 65535);
-               return this.subobjectParsers.get(subobjectType);
-       }
-
-       private synchronized void unregisterMessageParser(final Integer msgType) {
-               this.msgParsers.remove(msgType);
-       }
-
-       @Override
-       public synchronized AutoCloseable registerMessageParser(final int msgType, final MessageParser parser) {
-               Preconditions.checkArgument(msgType >= 0 && msgType <= 255);
-               Preconditions.checkArgument(!this.msgParsers.containsKey(msgType), "Message type %s already registered", msgType);
-               this.msgParsers.put(msgType, parser);
-
-               return new AbstractRegistration() {
-                       @Override
-                       protected void removeRegistration() {
-                               unregisterMessageParser(msgType);
-                       }
-               };
-       }
-
-       private synchronized void unregisterMessageSerializer(final Class<? extends Message> msgClass) {
-               this.msgSerializers.remove(msgClass);
-       }
-
-       @Override
-       public synchronized AutoCloseable registerMessageSerializer(final Class<? extends Message> msgClass, final MessageSerializer serializer) {
-               Preconditions.checkArgument(!this.msgSerializers.containsKey(msgClass), "Message class %s already registered", msgClass);
-               this.msgSerializers.put(msgClass, serializer);
-
-               return new AbstractRegistration() {
-                       @Override
-                       protected void removeRegistration() {
-                               unregisterMessageSerializer(msgClass);
-                       }
-               };
-       }
-
-       private synchronized void unregisterObjectParser(final Integer key) {
-               this.objParsers.remove(key);
-       }
-
-       @Override
-       public synchronized AutoCloseable registerObjectParser(final int objectClass, final int objectType, final ObjectParser parser) {
-               Preconditions.checkArgument(objectClass >= 0 && objectClass <= 255);
-               Preconditions.checkArgument(objectType >= 0 && objectType <= 15);
-
-               final Integer key = (objectClass << 4) + objectType;
-               Preconditions.checkArgument(!this.objParsers.containsKey(key), "Object class %s type %s already registered", objectClass,
-                               objectType);
-               this.objParsers.put(key, parser);
-
-               return new AbstractRegistration() {
-                       @Override
-                       protected void removeRegistration() {
-                               unregisterObjectParser(key);
-                       }
-               };
-       }
-
-       private synchronized void unregisterObjectSerializer(final Class<? extends Object> objClass) {
-               this.objSerializers.remove(objClass);
-       }
-
-       @Override
-       public synchronized AutoCloseable registerObjectSerializer(final Class<? extends Object> objClass, final ObjectSerializer serializer) {
-               Preconditions.checkArgument(!this.objSerializers.containsKey(objClass), "Object class %s already registered", objClass);
-               this.objSerializers.put(objClass, serializer);
-
-               return new AbstractRegistration() {
-                       @Override
-                       protected void removeRegistration() {
-                               unregisterObjectSerializer(objClass);
-                       }
-               };
-       }
-
-       private synchronized void unregisterTlvParser(final int tlvType) {
-               this.tlvParsers.remove(tlvType);
-       }
-
-       @Override
-       public synchronized AutoCloseable registerTlvParser(final int tlvType, final TlvParser parser) {
-               Preconditions.checkArgument(tlvType >= 0 && tlvType <= 65535);
-               Preconditions.checkArgument(!this.tlvParsers.containsKey(tlvType), "TLV type %s already registered", tlvType);
-
-               this.tlvParsers.put(tlvType, parser);
-
-               return new AbstractRegistration() {
-                       @Override
-                       protected void removeRegistration() {
-                               unregisterTlvParser(tlvType);
-                       }
-               };
-       }
-
-       private synchronized void unregisterTlvSerializer(final Class<? extends Tlv> tlvClass) {
-               this.tlvSerializers.remove(tlvClass);
-       }
-
-       @Override
-       public synchronized AutoCloseable registerTlvSerializer(final Class<? extends Tlv> tlvClass, final TlvSerializer serializer) {
-               Preconditions.checkArgument(!this.tlvSerializers.containsKey(tlvClass), "TLV class %s already registered", tlvClass);
-               this.tlvSerializers.put(tlvClass, serializer);
-
-               return new AbstractRegistration() {
-                       @Override
-                       protected void removeRegistration() {
-                               unregisterTlvSerializer(tlvClass);
-                       }
-               };
-       }
-
-       @Override
-       public AutoCloseable registerSubobjectSerializer(final Class<? extends CSubobject> subobjectClass, final SubobjectSerializer serializer) {
-               Preconditions.checkArgument(!this.tlvSerializers.containsKey(subobjectClass), "Subobject class %s already registered",
-                               subobjectClass);
-               this.subobjectSerializers.put(subobjectClass, serializer);
-
-               return new AbstractRegistration() {
-                       @Override
-                       protected void removeRegistration() {
-                               unregisterSubobjectSerializer(subobjectClass);
-                       }
-               };
-       }
-
-       private synchronized void unregisterSubobjectSerializer(final Class<? extends CSubobject> subobjectClass) {
-               this.subobjectSerializers.remove(subobjectClass);
-       }
-
-       @Override
-       public AutoCloseable registerSubobjectParser(final int subobjectType, final SubobjectParser parser) {
-               Preconditions.checkArgument(subobjectType >= 0 && subobjectType <= 65535);
-               Preconditions.checkArgument(!this.subobjectParsers.containsKey(subobjectType), "Subobject type %s already registered",
-                               subobjectType);
-
-               this.subobjectParsers.put(subobjectType, parser);
-
-               return new AbstractRegistration() {
-                       @Override
-                       protected void removeRegistration() {
-                               unregisterSubobjectParser(subobjectType);
-                       }
-               };
-       }
-
-       private synchronized void unregisterSubobjectParser(final int subobjectType) {
-               this.subobjectParsers.remove(subobjectType);
-       }
-}
index 1fda6fe572328698e938e258c52a52ebb7f54195..4d4c0b796dbe71b57c7469870c26e283cb0b943a 100644 (file)
@@ -30,7 +30,7 @@ public class PCEPDispatcherImpl extends AbstractDispatcher<PCEPSessionImpl, PCEP
 
        private final SessionNegotiatorFactory<Message, PCEPSessionImpl, PCEPSessionListener> snf;
 
-       private final PCEPHandlerFactory hf = new PCEPHandlerFactory();
+       private final PCEPHandlerFactory hf = new PCEPHandlerFactory(SimpleMessageHandlerFactory.INSTANCE);
 
        /**
         * Creates an instance of PCEPDispatcherImpl, gets the default selector and opens it.
index df7a5539eb15b6a282122f1bd8fc8c9a9346207f..2485cc3a503d988c63720e5a9ef1f070b08c4fa2 100644 (file)
@@ -12,6 +12,7 @@ import io.netty.channel.ChannelHandler;
 import org.opendaylight.protocol.framework.ProtocolHandlerFactory;
 import org.opendaylight.protocol.framework.ProtocolMessageDecoder;
 import org.opendaylight.protocol.framework.ProtocolMessageEncoder;
+import org.opendaylight.protocol.pcep.spi.MessageHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 
 /**
@@ -20,8 +21,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 public class PCEPHandlerFactory extends ProtocolHandlerFactory<Message> {
        private final ProtocolMessageEncoder<Message> encoder;
 
-       public PCEPHandlerFactory() {
-               super(new PCEPMessageFactory());
+       public PCEPHandlerFactory(final MessageHandlerRegistry registry) {
+               super(new PCEPMessageFactory(registry));
                this.encoder = new ProtocolMessageEncoder<Message>(this.msgFactory);
        }
 
index d542190e8bfbb13bb048a905366761b739036398..167d1dc41ab3a0545fa4cfe9b8caa624dafe955a 100644 (file)
@@ -18,7 +18,7 @@ import org.opendaylight.protocol.framework.DocumentedException;
 import org.opendaylight.protocol.framework.ProtocolMessageFactory;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.MessageHandlerRegistry;
 import org.opendaylight.protocol.pcep.spi.MessageSerializer;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
@@ -48,8 +48,6 @@ public final class PCEPMessageFactory implements ProtocolMessageFactory<Message>
 
        private static final int VERSION_SF_LENGTH = 3;
 
-       private final HandlerRegistry registry;
-
        private static final int VER_FLAGS_MF_LENGTH = 1;
        private static final int TYPE_F_LENGTH = 1;
        private static final int LENGTH_F_LENGTH = 2;
@@ -58,8 +56,10 @@ public final class PCEPMessageFactory implements ProtocolMessageFactory<Message>
        private static final int TYPE_F_OFFSET = VER_FLAGS_MF_LENGTH + VER_FLAGS_MF_OFFSET;
        private static final int LENGTH_F_OFFSET = TYPE_F_LENGTH + TYPE_F_OFFSET;
 
-       public PCEPMessageFactory() {
-               this.registry = HandlerRegistryImpl.INSTANCE;
+       private final MessageHandlerRegistry registry;
+
+       public PCEPMessageFactory(final MessageHandlerRegistry registry) {
+               this.registry = Preconditions.checkNotNull(registry);
        }
 
        @Override
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/SimpleMessageHandlerFactory.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/SimpleMessageHandlerFactory.java
new file mode 100644 (file)
index 0000000..3c70c51
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * 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.pcep.impl;
+
+import org.opendaylight.protocol.concepts.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.MessageHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.MessageParser;
+import org.opendaylight.protocol.pcep.spi.MessageSerializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+
+import com.google.common.base.Preconditions;
+
+/**
+ *
+ */
+public final class SimpleMessageHandlerFactory implements MessageHandlerRegistry {
+       public static final MessageHandlerRegistry INSTANCE;
+
+       static {
+               final MessageHandlerRegistry reg = new SimpleMessageHandlerFactory();
+
+               // FIXME: fill this in
+               // reg.registerMessageHandler(PCEPOpenMessage.class, 1, new PCEPOpenMessageParser());
+               // reg.registerMessageHandler(PCEPNotificationMessage.class, 5, new PCEPNotificationMessageParser());
+               // reg.registerMessageHandler(PCEPKeepAliveMessage.class, 2, new PCEPKeepAliveMessageParser());
+               // reg.registerMessageHandler(PCEPReplyMessage.class, 4, new PCEPReplyMessageParser());
+               // reg.registerMessageHandler(PCEPRequestMessage.class, 3, new PCEPRequestMessageParser());
+               // reg.registerMessageHandler(PCEPErrorMessage.class, 6, new PCEPErrorMessageParser());
+               // reg.registerMessageHandler(PCEPCloseMessage.class, 7, new PCEPCloseMessageParser());
+               // reg.registerMessageHandler(PCEPUpdateRequestMessage.class, 11, new PCEPUpdateRequestMessageParser());
+               // reg.registerMessageHandler(PCEPReportMessage.class, 10, new PCEPReportMessageParser());
+               // reg.registerMessageHandler(PCCreateMessage.class, 12, new PCCreateMessageParser());
+
+               INSTANCE = reg;
+       }
+
+       private final HandlerRegistry<DataContainer, MessageParser, MessageSerializer> handlers = new HandlerRegistry<>();
+
+       @Override
+       public AutoCloseable registerMessageParser(final int messageType, final MessageParser parser) {
+               Preconditions.checkArgument(messageType >= 0 && messageType <= 255);
+               return handlers.registerParser(messageType, parser);
+       }
+
+       @Override
+       public AutoCloseable registerMessageSerializer(final Class<? extends Message> msgClass, final MessageSerializer serializer) {
+               return handlers.registerSerializer(msgClass, serializer);
+       }
+
+       @Override
+       public MessageParser getMessageParser(final int messageType) {
+               Preconditions.checkArgument(messageType >= 0 && messageType <= 255);
+               return handlers.getParser(messageType);
+       }
+
+       @Override
+       public MessageSerializer getMessageSerializer(final Message message) {
+               return handlers.getSerializer(message.getImplementedInterface());
+       }
+}
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/SimpleObjectHandlerRegistry.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/SimpleObjectHandlerRegistry.java
new file mode 100644 (file)
index 0000000..5a9a7ed
--- /dev/null
@@ -0,0 +1,164 @@
+/*
+ * 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.pcep.impl;
+
+import org.opendaylight.protocol.concepts.HandlerRegistry;
+import org.opendaylight.protocol.pcep.impl.object.PCEPBandwidthObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPClassTypeObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPCloseObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPEndPointsObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPErrorObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPExplicitRouteObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPGlobalConstraintsObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPIncludeRouteObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPLoadBalancingObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPLspObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPLspaObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPMetricObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPNoPathObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPNotificationObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPObjectiveFunctionObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPOpenObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPPathKeyObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPReportedRouteObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPRequestParameterObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPSrpObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPSvecObjectParser;
+import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.ObjectParser;
+import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.BandwidthObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ClasstypeObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.CloseObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.EndpointsObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ExplicitRouteObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.GcObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.IncludeRouteObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LoadBalancingObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspaObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.MetricObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NoPathObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NotificationObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OfObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OpenObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PathKeyObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcepErrorObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ReportedRouteObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RpObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.SrpObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.SvecObject;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+
+import com.google.common.base.Preconditions;
+
+/**
+ *
+ */
+public final class SimpleObjectHandlerRegistry implements ObjectHandlerRegistry {
+       public static final ObjectHandlerRegistry INSTANCE;
+
+       static {
+               final ObjectHandlerRegistry reg = new SimpleObjectHandlerRegistry();
+
+               final SubobjectHandlerRegistry subobjReg = SimpleSubobjectHandlerFactory.INSTANCE;
+               final TlvHandlerRegistry tlvReg = SimpleTlvHandlerRegistry.INSTANCE;
+
+               reg.registerObjectParser(PCEPOpenObjectParser.CLASS, PCEPOpenObjectParser.TYPE, new PCEPOpenObjectParser(subobjReg, tlvReg));
+               reg.registerObjectParser(PCEPRequestParameterObjectParser.CLASS, PCEPRequestParameterObjectParser.TYPE,
+                               new PCEPRequestParameterObjectParser(subobjReg, tlvReg));
+               reg.registerObjectParser(PCEPNoPathObjectParser.CLASS, PCEPNoPathObjectParser.TYPE, new PCEPNoPathObjectParser(subobjReg, tlvReg));
+               reg.registerObjectParser(PCEPEndPointsObjectParser.CLASS, PCEPEndPointsObjectParser.TYPE, new PCEPEndPointsObjectParser(subobjReg, tlvReg));
+               reg.registerObjectParser(PCEPEndPointsObjectParser.CLASS_6, PCEPEndPointsObjectParser.TYPE_6, new PCEPEndPointsObjectParser(subobjReg, tlvReg));
+               reg.registerObjectParser(PCEPBandwidthObjectParser.CLASS, PCEPBandwidthObjectParser.TYPE, new PCEPBandwidthObjectParser(subobjReg, tlvReg));
+               reg.registerObjectParser(PCEPBandwidthObjectParser.E_CLASS, PCEPBandwidthObjectParser.E_TYPE, new PCEPBandwidthObjectParser(subobjReg, tlvReg));
+               reg.registerObjectParser(PCEPMetricObjectParser.CLASS, PCEPMetricObjectParser.TYPE, new PCEPMetricObjectParser(subobjReg, tlvReg));
+               reg.registerObjectParser(PCEPExplicitRouteObjectParser.CLASS, PCEPExplicitRouteObjectParser.TYPE,
+                               new PCEPExplicitRouteObjectParser(subobjReg, tlvReg));
+               reg.registerObjectParser(PCEPReportedRouteObjectParser.CLASS, PCEPReportedRouteObjectParser.TYPE,
+                               new PCEPReportedRouteObjectParser(subobjReg, tlvReg));
+               reg.registerObjectParser(PCEPLspaObjectParser.CLASS, PCEPLspaObjectParser.TYPE, new PCEPLspaObjectParser(subobjReg, tlvReg));
+               reg.registerObjectParser(PCEPIncludeRouteObjectParser.CLASS, PCEPIncludeRouteObjectParser.TYPE,
+                               new PCEPIncludeRouteObjectParser(subobjReg, tlvReg));
+               reg.registerObjectParser(PCEPSvecObjectParser.CLASS, PCEPSvecObjectParser.TYPE, new PCEPSvecObjectParser(subobjReg, tlvReg));
+               reg.registerObjectParser(PCEPNotificationObjectParser.CLASS, PCEPNotificationObjectParser.TYPE,
+                               new PCEPNotificationObjectParser(subobjReg, tlvReg));
+               reg.registerObjectParser(PCEPErrorObjectParser.CLASS, PCEPErrorObjectParser.TYPE, new PCEPErrorObjectParser(subobjReg, tlvReg));
+               reg.registerObjectParser(PCEPLoadBalancingObjectParser.CLASS, PCEPLoadBalancingObjectParser.TYPE,
+                               new PCEPLoadBalancingObjectParser(subobjReg, tlvReg));
+               reg.registerObjectParser(PCEPCloseObjectParser.CLASS, PCEPCloseObjectParser.TYPE, new PCEPCloseObjectParser(subobjReg, tlvReg));
+               reg.registerObjectParser(PCEPPathKeyObjectParser.CLASS, PCEPPathKeyObjectParser.TYPE, new PCEPPathKeyObjectParser(subobjReg, tlvReg));
+               reg.registerObjectParser(PCEPObjectiveFunctionObjectParser.CLASS, PCEPObjectiveFunctionObjectParser.TYPE,
+                               new PCEPObjectiveFunctionObjectParser(subobjReg, tlvReg));
+               reg.registerObjectParser(PCEPClassTypeObjectParser.CLASS, PCEPClassTypeObjectParser.TYPE, new PCEPClassTypeObjectParser(subobjReg, tlvReg));
+               reg.registerObjectParser(PCEPGlobalConstraintsObjectParser.CLASS, PCEPGlobalConstraintsObjectParser.TYPE,
+                               new PCEPGlobalConstraintsObjectParser(subobjReg, tlvReg));
+               reg.registerObjectParser(PCEPLspObjectParser.CLASS, PCEPLspObjectParser.TYPE, new PCEPLspObjectParser(subobjReg, tlvReg));
+               reg.registerObjectParser(PCEPSrpObjectParser.CLASS, PCEPSrpObjectParser.TYPE, new PCEPSrpObjectParser(subobjReg, tlvReg));
+               // reg.registerObjectParser(PCEPExcludeRouteObjectParser.CLASS, PCEPExcludeRouteObjectParser.TYPE, new
+               // PCEPExcludeRouteObjectParser(reg));
+
+               reg.registerObjectSerializer(OpenObject.class, new PCEPOpenObjectParser(subobjReg, tlvReg));
+               reg.registerObjectSerializer(RpObject.class, new PCEPRequestParameterObjectParser(subobjReg, tlvReg));
+               reg.registerObjectSerializer(NoPathObject.class, new PCEPNoPathObjectParser(subobjReg, tlvReg));
+               reg.registerObjectSerializer(EndpointsObject.class, new PCEPEndPointsObjectParser(subobjReg, tlvReg));
+               reg.registerObjectSerializer(BandwidthObject.class, new PCEPBandwidthObjectParser(subobjReg, tlvReg));
+               reg.registerObjectSerializer(MetricObject.class, new PCEPMetricObjectParser(subobjReg, tlvReg));
+               reg.registerObjectSerializer(ExplicitRouteObject.class, new PCEPExplicitRouteObjectParser(subobjReg, tlvReg));
+               reg.registerObjectSerializer(ReportedRouteObject.class, new PCEPReportedRouteObjectParser(subobjReg, tlvReg));
+               reg.registerObjectSerializer(LspaObject.class, new PCEPLspaObjectParser(subobjReg, tlvReg));
+               reg.registerObjectSerializer(IncludeRouteObject.class, new PCEPIncludeRouteObjectParser(subobjReg, tlvReg));
+               reg.registerObjectSerializer(SvecObject.class, new PCEPSvecObjectParser(subobjReg, tlvReg));
+               reg.registerObjectSerializer(NotificationObject.class, new PCEPNotificationObjectParser(subobjReg, tlvReg));
+               reg.registerObjectSerializer(PcepErrorObject.class, new PCEPErrorObjectParser(subobjReg, tlvReg));
+               reg.registerObjectSerializer(LoadBalancingObject.class, new PCEPLoadBalancingObjectParser(subobjReg, tlvReg));
+               reg.registerObjectSerializer(CloseObject.class, new PCEPCloseObjectParser(subobjReg, tlvReg));
+               reg.registerObjectSerializer(PathKeyObject.class, new PCEPPathKeyObjectParser(subobjReg, tlvReg));
+               reg.registerObjectSerializer(OfObject.class, new PCEPObjectiveFunctionObjectParser(subobjReg, tlvReg));
+               reg.registerObjectSerializer(ClasstypeObject.class, new PCEPClassTypeObjectParser(subobjReg, tlvReg));
+               reg.registerObjectSerializer(GcObject.class, new PCEPGlobalConstraintsObjectParser(subobjReg, tlvReg));
+               reg.registerObjectSerializer(LspObject.class, new PCEPLspObjectParser(subobjReg, tlvReg));
+               reg.registerObjectSerializer(SrpObject.class, new PCEPSrpObjectParser(subobjReg, tlvReg));
+               // reg.registerObjectSerializer(ExcludeRouteObject.class, new PCEPExcludeRouteObjectParser(reg));
+
+               INSTANCE = reg;
+       }
+
+       private final HandlerRegistry<DataContainer, ObjectParser, ObjectSerializer> handlers = new HandlerRegistry<>();
+
+       private static final int createKey(final int objectClass, final int objectType) {
+               Preconditions.checkArgument(objectClass >= 0 && objectClass <= 255);
+               Preconditions.checkArgument(objectType >= 0 && objectType <= 15);
+               return (objectClass << 4) | objectType;
+       }
+
+       @Override
+       public AutoCloseable registerObjectParser(final int objectClass, final int objectType, final ObjectParser parser) {
+               Preconditions.checkArgument(objectClass >= 0 && objectClass <= 255);
+               Preconditions.checkArgument(objectType >= 0 && objectType <= 15);
+               return handlers.registerParser(createKey(objectClass, objectType), parser);
+       }
+
+       @Override
+       public AutoCloseable registerObjectSerializer(final Class<? extends Object> objClass, final ObjectSerializer serializer) {
+               return handlers.registerSerializer(objClass, serializer);
+       }
+
+       @Override
+       public ObjectParser getObjectParser(final int objectClass, final int objectType) {
+               return handlers.getParser(createKey(objectClass, objectType));
+       }
+
+       @Override
+       public ObjectSerializer getObjectSerializer(final Object object) {
+               return handlers.getSerializer(object.getImplementedInterface());
+       }
+}
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/SimpleSubobjectHandlerFactory.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/SimpleSubobjectHandlerFactory.java
new file mode 100644 (file)
index 0000000..c1400e3
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * 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.pcep.impl;
+
+import org.opendaylight.protocol.concepts.HandlerRegistry;
+import org.opendaylight.protocol.pcep.impl.subobject.EROAsNumberSubobjectParser;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectParser;
+import org.opendaylight.protocol.pcep.spi.SubobjectSerializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.AsNumberSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.CSubobject;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+
+import com.google.common.base.Preconditions;
+
+public final class SimpleSubobjectHandlerFactory implements SubobjectHandlerRegistry {
+       public static final SubobjectHandlerRegistry INSTANCE;
+
+       static {
+               final SubobjectHandlerRegistry reg = new SimpleSubobjectHandlerFactory();
+
+               reg.registerSubobjectParser(EROAsNumberSubobjectParser.TYPE, new EROAsNumberSubobjectParser());
+               reg.registerSubobjectSerializer(AsNumberSubobject.class, new EROAsNumberSubobjectParser());
+
+               INSTANCE = reg;
+       }
+
+       private final HandlerRegistry<DataContainer, SubobjectParser, SubobjectSerializer> handlers = new HandlerRegistry<>();
+
+       @Override
+       public AutoCloseable registerSubobjectParser(final int subobjectType, final SubobjectParser parser) {
+               Preconditions.checkArgument(subobjectType >= 0 && subobjectType <= 65535);
+               return handlers.registerParser(subobjectType, parser);
+       }
+
+       @Override
+       public SubobjectParser getSubobjectParser(final int subobjectType) {
+               Preconditions.checkArgument(subobjectType >= 0 && subobjectType <= 65535);
+               return handlers.getParser(subobjectType);
+       }
+
+       @Override
+       public AutoCloseable registerSubobjectSerializer(final Class<? extends CSubobject> subobjectClass, final SubobjectSerializer serializer) {
+               return handlers.registerSerializer(subobjectClass, serializer);
+       }
+
+       @Override
+       public SubobjectSerializer getSubobjectSerializer(final CSubobject subobject) {
+               return handlers.getSerializer(subobject.getImplementedInterface());
+       }
+}
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/SimpleTlvHandlerRegistry.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/SimpleTlvHandlerRegistry.java
new file mode 100644 (file)
index 0000000..5b15a01
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * 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.pcep.impl;
+
+import org.opendaylight.protocol.concepts.HandlerRegistry;
+import org.opendaylight.protocol.pcep.impl.tlv.LSPIdentifierIPv4TlvParser;
+import org.opendaylight.protocol.pcep.impl.tlv.LSPIdentifierIPv6TlvParser;
+import org.opendaylight.protocol.pcep.impl.tlv.LspDbVersionTlvParser;
+import org.opendaylight.protocol.pcep.impl.tlv.LspSymbolicNameTlvParser;
+import org.opendaylight.protocol.pcep.impl.tlv.LspUpdateErrorTlvParser;
+import org.opendaylight.protocol.pcep.impl.tlv.NoPathVectorTlvParser;
+import org.opendaylight.protocol.pcep.impl.tlv.OFListTlvParser;
+import org.opendaylight.protocol.pcep.impl.tlv.OrderTlvParser;
+import org.opendaylight.protocol.pcep.impl.tlv.OverloadedDurationTlvParser;
+import org.opendaylight.protocol.pcep.impl.tlv.PCEStatefulCapabilityTlvParser;
+import org.opendaylight.protocol.pcep.impl.tlv.PredundancyGroupTlvParser;
+import org.opendaylight.protocol.pcep.impl.tlv.RSVPErrorSpecTlvParser;
+import org.opendaylight.protocol.pcep.impl.tlv.ReqMissingTlvParser;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvParser;
+import org.opendaylight.protocol.pcep.spi.TlvSerializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspDbVersionTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspErrorCodeTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspIdentifiersTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NoPathVectorTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OfListTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OrderTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OverloadDurationTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PredundancyGroupIdTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ReqMissingTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RsvpErrorSpecTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.StatefulCapabilityTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.SymbolicPathNameTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+
+import com.google.common.base.Preconditions;
+
+/**
+ *
+ */
+public final class SimpleTlvHandlerRegistry implements TlvHandlerRegistry {
+       public static final TlvHandlerRegistry INSTANCE;
+
+       static {
+               final TlvHandlerRegistry reg = new SimpleTlvHandlerRegistry();
+
+               reg.registerTlvParser(NoPathVectorTlvParser.TYPE, new NoPathVectorTlvParser());
+               reg.registerTlvParser(OverloadedDurationTlvParser.TYPE, new OverloadedDurationTlvParser());
+               reg.registerTlvParser(ReqMissingTlvParser.TYPE, new ReqMissingTlvParser());
+               reg.registerTlvParser(OFListTlvParser.TYPE, new OFListTlvParser());
+               reg.registerTlvParser(OrderTlvParser.TYPE, new OrderTlvParser());
+               reg.registerTlvParser(PCEStatefulCapabilityTlvParser.TYPE, new PCEStatefulCapabilityTlvParser());
+               reg.registerTlvParser(LspSymbolicNameTlvParser.TYPE, new LspSymbolicNameTlvParser());
+               reg.registerTlvParser(LSPIdentifierIPv4TlvParser.TYPE, new LSPIdentifierIPv4TlvParser());
+               reg.registerTlvParser(LSPIdentifierIPv6TlvParser.TYPE, new LSPIdentifierIPv6TlvParser());
+               reg.registerTlvParser(LspUpdateErrorTlvParser.TYPE, new LspUpdateErrorTlvParser());
+               reg.registerTlvParser(RSVPErrorSpecTlvParser.TYPE, new RSVPErrorSpecTlvParser());
+               reg.registerTlvParser(LspDbVersionTlvParser.TYPE, new LspDbVersionTlvParser());
+               reg.registerTlvParser(PredundancyGroupTlvParser.TYPE, new PredundancyGroupTlvParser());
+
+               reg.registerTlvSerializer(NoPathVectorTlv.class, new NoPathVectorTlvParser());
+               reg.registerTlvSerializer(OverloadDurationTlv.class, new OverloadedDurationTlvParser());
+               reg.registerTlvSerializer(ReqMissingTlv.class, new ReqMissingTlvParser());
+               reg.registerTlvSerializer(OfListTlv.class, new OFListTlvParser());
+               reg.registerTlvSerializer(OrderTlv.class, new OrderTlvParser());
+               reg.registerTlvSerializer(StatefulCapabilityTlv.class, new PCEStatefulCapabilityTlvParser());
+               reg.registerTlvSerializer(SymbolicPathNameTlv.class, new LspSymbolicNameTlvParser());
+               reg.registerTlvSerializer(LspIdentifiersTlv.class, new LSPIdentifierIPv4TlvParser());
+               reg.registerTlvSerializer(LspErrorCodeTlv.class, new LspUpdateErrorTlvParser());
+               reg.registerTlvSerializer(RsvpErrorSpecTlv.class, new RSVPErrorSpecTlvParser());
+               reg.registerTlvSerializer(LspDbVersionTlv.class, new LspDbVersionTlvParser());
+               reg.registerTlvSerializer(PredundancyGroupIdTlv.class, new PredundancyGroupTlvParser());
+
+               INSTANCE = reg;
+       }
+
+       private final HandlerRegistry<DataContainer, TlvParser, TlvSerializer> handlers = new HandlerRegistry<>();
+
+       @Override
+       public AutoCloseable registerTlvParser(final int tlvType, final TlvParser parser) {
+               Preconditions.checkArgument(tlvType >= 0 && tlvType < 65535);
+               return handlers.registerParser(tlvType, parser);
+       }
+
+       @Override
+       public TlvParser getTlvParser(final int tlvType) {
+               return handlers.getParser(tlvType);
+       }
+
+       @Override
+       public AutoCloseable registerTlvSerializer(final Class<? extends Tlv> tlvClass, final TlvSerializer serializer) {
+               return handlers.registerSerializer(tlvClass, serializer);
+       }
+
+       @Override
+       public TlvSerializer getTlvSerializer(final Tlv tlv) {
+               return handlers.getSerializer(tlv.getImplementedInterface());
+       }
+}
index 1a896ee9c9466ffb33976bb6eadbcac478f4e82f..99e8577a5009d785ee0ac560da510688fb890b58 100644 (file)
@@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcinitiateMessage;
 
@@ -22,15 +22,16 @@ public class PCCreateMessageParser extends AbstractMessageParser {
 
        private final int TYPE = 12;
 
-       public PCCreateMessageParser(final HandlerRegistry registry) {
+       public PCCreateMessageParser(final ObjectHandlerRegistry registry) {
                super(registry);
        }
 
        @Override
        public void serializeMessage(final Message message, final ByteBuf buffer) {
-               if (!(message instanceof PcinitiateMessage))
+               if (!(message instanceof PcinitiateMessage)) {
                        throw new IllegalArgumentException("Wrong instance of Message. Passed instance of " + message.getClass()
                                        + ". Needed PcinitiateMessage.");
+               }
        }
 
        @Override
index 5a37f08e4af46555026ea4f73dd24f676ffe1c14..de83f4ca3e43556108eba075e7299ea7bd1dd531 100644 (file)
@@ -14,7 +14,7 @@ import java.util.List;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Close;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.CloseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.CloseMessage;
@@ -31,15 +31,16 @@ public class PCEPCloseMessageParser extends AbstractMessageParser {
 
        private final int TYPE = 7;
 
-       public PCEPCloseMessageParser(final HandlerRegistry registry) {
+       public PCEPCloseMessageParser(final ObjectHandlerRegistry registry) {
                super(registry);
        }
 
        @Override
        public void serializeMessage(final Message message, final ByteBuf buffer) {
-               if (!(message instanceof CloseMessage))
+               if (!(message instanceof CloseMessage)) {
                        throw new IllegalArgumentException("Wrong instance of Message. Passed instance of " + message.getClass()
                                        + ". Nedded CloseMessage.");
+               }
                final CCloseMessage close = ((CloseMessage) message).getCCloseMessage();
 
                if (close.getCClose() == null) {
@@ -59,18 +60,21 @@ public class PCEPCloseMessageParser extends AbstractMessageParser {
        }
 
        private Close validate(final List<Object> objects) throws PCEPDeserializerException {
-               if (objects == null)
+               if (objects == null) {
                        throw new IllegalArgumentException("Passed list can't be null.");
+               }
 
-               if (objects.isEmpty() || !(objects.get(0) instanceof CClose))
+               if (objects.isEmpty() || !(objects.get(0) instanceof CClose)) {
                        throw new PCEPDeserializerException("Close message doesn't contain CLOSE object.");
+               }
 
                final Object o = objects.get(0);
                final CCloseMessage msg = new CCloseMessageBuilder().setCClose((CClose) o).build();
                objects.remove(0);
 
-               if (!objects.isEmpty())
+               if (!objects.isEmpty()) {
                        throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
+               }
 
                return new CloseBuilder().setCCloseMessage(msg).build();
        }
index f65a99dfee67eee5e409b1ddf46e6701ac3d4e8d..01f037dddab35728dd693250b934739ea1c4e71b 100644 (file)
@@ -18,7 +18,7 @@ import org.opendaylight.protocol.pcep.PCEPErrorMapping;
 import org.opendaylight.protocol.pcep.PCEPErrors;
 import org.opendaylight.protocol.pcep.UnknownObject;
 import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcerrBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
@@ -45,19 +45,21 @@ public class PCEPErrorMessageParser extends AbstractMessageParser {
 
        public final int TYPE = 6;
 
-       public PCEPErrorMessageParser(final HandlerRegistry registry) {
+       public PCEPErrorMessageParser(final ObjectHandlerRegistry registry) {
                super(registry);
        }
 
        @Override
        public void serializeMessage(final Message message, final ByteBuf buffer) {
-               if (!(message instanceof PcerrMessage))
+               if (!(message instanceof PcerrMessage)) {
                        throw new IllegalArgumentException("Wrong instance of Message. Passed instance " + message.getClass()
                                        + ". Nedded ErrorMessage.");
+               }
                final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.PcerrMessage err = ((PcerrMessage) message).getPcerrMessage();
 
-               if (err.getErrors() == null || err.getErrors().isEmpty())
+               if (err.getErrors() == null || err.getErrors().isEmpty()) {
                        throw new IllegalArgumentException("Errors should not be empty.");
+               }
 
                if (err.getErrorType() instanceof Request) {
                        final List<Rps> rps = ((Request) err.getErrorType()).getRps();
@@ -95,8 +97,9 @@ public class PCEPErrorMessageParser extends AbstractMessageParser {
        }
 
        private PcerrMessage validate(final List<Object> objects) throws PCEPDeserializerException, PCEPDocumentedException {
-               if (objects == null)
+               if (objects == null) {
                        throw new IllegalArgumentException("Passed list can't be null.");
+               }
 
                Open openObj = null;
                final List<Rps> requestParameters = Lists.newArrayList();
@@ -108,8 +111,9 @@ public class PCEPErrorMessageParser extends AbstractMessageParser {
                while (!objects.isEmpty()) {
                        obj = objects.get(0);
 
-                       if (obj instanceof UnknownObject)
+                       if (obj instanceof UnknownObject) {
                                return new PcerrBuilder().setPcerrMessage(b.setErrors(((UnknownObject) obj).getErrors()).build()).build();
+                       }
 
                        switch (state) {
                        case 1:
@@ -132,8 +136,9 @@ public class PCEPErrorMessageParser extends AbstractMessageParser {
                                                state = 2;
                                                if (obj instanceof RpObject) {
                                                        final RpObject o = ((RpObject) obj);
-                                                       if (o.isProcessingRule())
+                                                       if (o.isProcessingRule()) {
                                                                throw new PCEPDocumentedException("Invalid setting of P flag.", PCEPErrors.P_FLAG_NOT_SET);
+                                                       }
                                                        requestParameters.add((Rps) o);
                                                        state = 1;
                                                        break;
@@ -148,8 +153,9 @@ public class PCEPErrorMessageParser extends AbstractMessageParser {
                                                state = 3;
                                        }
 
-                                       if (state == 3)
+                                       if (state == 3) {
                                                break;
+                                       }
 
                                        objects.remove(0);
                                }
@@ -165,15 +171,19 @@ public class PCEPErrorMessageParser extends AbstractMessageParser {
                        objects.remove(0);
                }
 
-               if (errorObjects.isEmpty() && errorObjects.isEmpty())
+               if (errorObjects.isEmpty() && errorObjects.isEmpty()) {
                        throw new PCEPDeserializerException("At least one PCEPErrorObject is mandatory.");
+               }
 
-               if (!objects.isEmpty())
+               if (!objects.isEmpty()) {
                        throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
-               if (requestParameters != null)
+               }
+               if (requestParameters != null) {
                        b.setErrorType(new RequestBuilder().setRps(requestParameters).build());
-               if (openObj != null)
+               }
+               if (openObj != null) {
                        b.setErrorType(new SessionBuilder().setOpen(openObj).build());
+               }
 
                return new PcerrBuilder().setPcerrMessage(b.setErrors(errorObjects).build()).build();
        }
index 0f4c5e5548ace9e804d24722d53ab30f367d9f25..5349348bce9327b61552644f4b5ece533406c002 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.protocol.pcep.impl.message;
 import io.netty.buffer.ByteBuf;
 
 import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.KeepaliveBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.KeepaliveMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
@@ -20,24 +20,25 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
  * Parser for {@link KeepaliveMessage}
  */
 public class PCEPKeepAliveMessageParser extends AbstractMessageParser {
-       
+
        private final int TYPE = 2;
 
-       public PCEPKeepAliveMessageParser(HandlerRegistry registry) {
+       public PCEPKeepAliveMessageParser(final ObjectHandlerRegistry registry) {
                super(registry);
        }
 
        @Override
-       public void serializeMessage(Message message, ByteBuf buffer) {
-               if (!(message instanceof KeepaliveMessage))
+       public void serializeMessage(final Message message, final ByteBuf buffer) {
+               if (!(message instanceof KeepaliveMessage)) {
                        throw new IllegalArgumentException("Wrong instance of Message. Passed instance of " + message.getClass()
                                        + ". Nedded KeepaliveMessage.");
+               }
 
                buffer.writeBytes(new byte[0]);
        }
 
        @Override
-       public KeepaliveMessage parseMessage(byte[] buffer) {
+       public KeepaliveMessage parseMessage(final byte[] buffer) {
                return new KeepaliveBuilder().setKeepaliveMessage(new KeepaliveMessageBuilder().build()).build();
        }
 
index c39589f07971f866dbe5c4924e21da3fc9c5f0e4..9c428783183172a49dbf9ce6f82729a9b6118263 100644 (file)
@@ -18,7 +18,7 @@ import org.opendaylight.protocol.pcep.PCEPErrorMapping;
 import org.opendaylight.protocol.pcep.PCEPErrors;
 import org.opendaylight.protocol.pcep.UnknownObject;
 import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcerrBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcntfBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
@@ -41,15 +41,16 @@ public class PCEPNotificationMessageParser extends AbstractMessageParser {
 
        private final int TYPE = 5;
 
-       public PCEPNotificationMessageParser(final HandlerRegistry registry) {
+       public PCEPNotificationMessageParser(final ObjectHandlerRegistry registry) {
                super(registry);
        }
 
        @Override
        public void serializeMessage(final Message message, final ByteBuf buffer) {
-               if (!(message instanceof PcntfMessage))
+               if (!(message instanceof PcntfMessage)) {
                        throw new IllegalArgumentException("Wrong instance of Message. Passed instance of " + message.getClass()
                                        + ". Needed PcntfMessage.");
+               }
                final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.PcntfMessage msg = ((PcntfMessage) message).getPcntfMessage();
 
                for (final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.Notifications n : msg.getNotifications()) {
@@ -79,8 +80,9 @@ public class PCEPNotificationMessageParser extends AbstractMessageParser {
        }
 
        public Message validate(final List<Object> objects) throws PCEPDeserializerException {
-               if (objects == null)
+               if (objects == null) {
                        throw new IllegalArgumentException("Passed list can't be null.");
+               }
 
                final PCEPErrorMapping maping = PCEPErrorMapping.getInstance();
 
@@ -97,17 +99,20 @@ public class PCEPNotificationMessageParser extends AbstractMessageParser {
                                return new PcerrBuilder().setPcerrMessage(b.build()).build();
                        }
 
-                       if (comObj == null)
+                       if (comObj == null) {
                                break;
+                       }
 
                        compositeNotifications.add(comObj);
                }
 
-               if (compositeNotifications.isEmpty())
+               if (compositeNotifications.isEmpty()) {
                        throw new PCEPDeserializerException("Atleast one CompositeNotifiObject is mandatory.");
+               }
 
-               if (!objects.isEmpty())
+               if (!objects.isEmpty()) {
                        throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
+               }
 
                return new PcntfBuilder().setPcntfMessage(new PcntfMessageBuilder().setNotifications(compositeNotifications).build()).build();
        }
@@ -122,16 +127,18 @@ public class PCEPNotificationMessageParser extends AbstractMessageParser {
                while (!objects.isEmpty()) {
                        obj = objects.get(0);
 
-                       if (obj instanceof UnknownObject)
+                       if (obj instanceof UnknownObject) {
                                throw new PCEPDocumentedException("Unknown object", ((UnknownObject) obj).getError());
+                       }
 
                        switch (state) {
                        case 1:
                                state = 2;
                                if (obj instanceof RpObject) {
                                        final RpObject rp = (RpObject) obj;
-                                       if (rp.isProcessingRule())
+                                       if (rp.isProcessingRule()) {
                                                throw new PCEPDocumentedException("Invalid setting of P flag.", PCEPErrors.P_FLAG_NOT_SET);
+                                       }
                                        requestParameters.add((Rps) rp);
                                        state = 1;
                                        break;
@@ -146,14 +153,16 @@ public class PCEPNotificationMessageParser extends AbstractMessageParser {
                                state = 3;
                        }
 
-                       if (state == 3)
+                       if (state == 3) {
                                break;
+                       }
 
                        objects.remove(obj);
                }
 
-               if (notifications.isEmpty())
+               if (notifications.isEmpty()) {
                        return null;
+               }
 
                return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.NotificationsBuilder().setNotifications(
                                notifications).setRps(requestParameters).build();
index 4e63577fcde2f5674d2cb846405f306c2eff35cf..e682b9df4d481e56ead270f008b524b1db196429 100644 (file)
@@ -14,7 +14,7 @@ import java.util.List;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OpenMessage;
@@ -28,14 +28,15 @@ public class PCEPOpenMessageParser extends AbstractMessageParser {
 
        private final int TYPE = 1;
 
-       public PCEPOpenMessageParser(final HandlerRegistry registry) {
+       public PCEPOpenMessageParser(final ObjectHandlerRegistry registry) {
                super(registry);
        }
 
        @Override
        public void serializeMessage(final Message message, final ByteBuf buffer) {
-               if (!(message instanceof OpenMessage))
+               if (!(message instanceof OpenMessage)) {
                        throw new IllegalArgumentException("Wrong instance of Message. Passed instance " + message.getClass() + ". Nedded OpenMessage.");
+               }
                final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.message.OpenMessage open = ((OpenMessage) message).getOpenMessage();
 
                if (open.getOpen() == null) {
@@ -58,19 +59,22 @@ public class PCEPOpenMessageParser extends AbstractMessageParser {
 
        private org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.message.OpenMessage validate(
                        final List<Object> objects) throws PCEPDeserializerException {
-               if (objects == null)
+               if (objects == null) {
                        throw new IllegalArgumentException("Passed list can't be null.");
+               }
 
-               if (objects.isEmpty() || !(objects.get(0) instanceof Open))
+               if (objects.isEmpty() || !(objects.get(0) instanceof Open)) {
                        throw new PCEPDeserializerException("Open message doesn't contain OPEN object.");
+               }
 
                final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.message.OpenMessage msg = new OpenMessageBuilder().setOpen(
                                (Open) objects.get(0)).build();
 
                objects.remove(0);
 
-               if (!objects.isEmpty())
+               if (!objects.isEmpty()) {
                        throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
+               }
 
                return msg;
        }
index ac27bcf8780601b70fec60baec570553b63fd1cd..72f9012c82cc22919aefd4d49db9af7c8836f748 100644 (file)
@@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcrepMessage;
 
@@ -20,23 +20,24 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
  */
 // FIXME: finish
 public class PCEPReplyMessageParser extends AbstractMessageParser {
-       
+
        private final int TYPE = 4;
 
-       public PCEPReplyMessageParser(HandlerRegistry registry) {
+       public PCEPReplyMessageParser(final ObjectHandlerRegistry registry) {
                super(registry);
        }
 
        @Override
-       public void serializeMessage(Message message, ByteBuf buffer) {
-               if (!(message instanceof PcrepMessage))
+       public void serializeMessage(final Message message, final ByteBuf buffer) {
+               if (!(message instanceof PcrepMessage)) {
                        throw new IllegalArgumentException("Wrong instance of Message. Passed instance of " + message.getClass()
                                        + ". Nedded PcrepMessage.");
+               }
 
        }
 
        @Override
-       public PcrepMessage parseMessage(byte[] buffer) throws PCEPDeserializerException {
+       public PcrepMessage parseMessage(final byte[] buffer) throws PCEPDeserializerException {
                return null;
        }
 
index 0d1828f7940fe8c9904586df2c28cfa474c157ce..186b6fa9f0e6e81588d258d8a2df12168ac4d077 100644 (file)
@@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcrptMessage;
 
@@ -22,20 +22,21 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 public class PCEPReportMessageParser extends AbstractMessageParser {
 
        private final int TYPE = 10;
-       
-       public PCEPReportMessageParser(HandlerRegistry registry) {
+
+       public PCEPReportMessageParser(final ObjectHandlerRegistry registry) {
                super(registry);
        }
 
        @Override
-       public void serializeMessage(Message message, ByteBuf buffer) {
-               if (!(message instanceof PcrptMessage))
+       public void serializeMessage(final Message message, final ByteBuf buffer) {
+               if (!(message instanceof PcrptMessage)) {
                        throw new IllegalArgumentException("Wrong instance of Message. Passed instance of " + message.getClass()
                                        + ". Nedded PcrptMessage.");
+               }
        }
 
        @Override
-       public PcrptMessage parseMessage(byte[] buffer) throws PCEPDeserializerException {
+       public PcrptMessage parseMessage(final byte[] buffer) throws PCEPDeserializerException {
                return null;
        }
 
index 6d590f7c875add9f39d819787be9870715427142..357bcfc26986571b263fd4d75c296dd9f4a5bdf8 100644 (file)
@@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcrepMessage;
 
@@ -20,22 +20,23 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
  */
 //FIXME finish
 public class PCEPRequestMessageParser extends AbstractMessageParser {
-       
+
        private final int TYPE = 3;
 
-       public PCEPRequestMessageParser(HandlerRegistry registry) {
+       public PCEPRequestMessageParser(final ObjectHandlerRegistry registry) {
                super(registry);
        }
 
        @Override
-       public void serializeMessage(Message message, ByteBuf buffer) {
-               if (!(message instanceof PcrepMessage))
+       public void serializeMessage(final Message message, final ByteBuf buffer) {
+               if (!(message instanceof PcrepMessage)) {
                        throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + message.getClass()
                                        + ". Needed PcrepMessage.");
+               }
        }
 
        @Override
-       public PcrepMessage parseMessage(byte[] buffer) throws PCEPDeserializerException {
+       public PcrepMessage parseMessage(final byte[] buffer) throws PCEPDeserializerException {
                // TODO Auto-generated method stub
                return null;
        }
index 73460aacace3a52d068e106ce1538eec0d59dcca..17b9ee4cb077a5aaed0e45943c212440b67d8079 100644 (file)
@@ -11,31 +11,32 @@ import io.netty.buffer.ByteBuf;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcupdMessage;
 
 /**
- * Parser for {@link PcupdMessage} 
+ * Parser for {@link PcupdMessage}
  */
 public class PCEPUpdateRequestMessageParser extends AbstractMessageParser {
-       
+
        private final int TYPE = 11;
-       
-       public PCEPUpdateRequestMessageParser(HandlerRegistry registry) {
+
+       public PCEPUpdateRequestMessageParser(final ObjectHandlerRegistry registry) {
                super(registry);
        }
 
        @Override
-       public void serializeMessage(Message message, ByteBuf buffer) {
-               if (!(message instanceof PcupdMessage))
+       public void serializeMessage(final Message message, final ByteBuf buffer) {
+               if (!(message instanceof PcupdMessage)) {
                        throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + message.getClass()
                                        + ". Nedded PcupdMessage.");
+               }
 
        }
 
        @Override
-       public PcupdMessage parseMessage(byte[] buffer) throws PCEPDeserializerException {
+       public PcupdMessage parseMessage(final byte[] buffer) throws PCEPDeserializerException {
                // TODO Auto-generated method stub
                return null;
        }
index bd7b025d5204641bef7aff33acba8cea10e71f04..aad6c6409ad3c2627c9837349fa975ef782c96a4 100644 (file)
@@ -10,7 +10,8 @@ package org.opendaylight.protocol.pcep.impl.object;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.BandwidthObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
@@ -33,18 +34,20 @@ public class PCEPBandwidthObjectParser extends AbstractObjectParser<BandwidthBui
 
        private static final int BANDWIDTH_F_LENGTH = 4;
 
-       public PCEPBandwidthObjectParser(final HandlerRegistry registry) {
-               super(registry);
+       public PCEPBandwidthObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+               super(subobjReg, tlvReg);
        }
 
        @Override
        public BandwidthObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
-                       PCEPDocumentedException {
-               if (bytes == null || bytes.length == 0)
+       PCEPDocumentedException {
+               if (bytes == null || bytes.length == 0) {
                        throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
-               if (bytes.length != BANDWIDTH_F_LENGTH)
+               }
+               if (bytes.length != BANDWIDTH_F_LENGTH) {
                        throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + bytes.length + "; Expected: "
                                        + BANDWIDTH_F_LENGTH + ".");
+               }
 
                final BandwidthBuilder builder = new BandwidthBuilder();
 
@@ -63,8 +66,9 @@ public class PCEPBandwidthObjectParser extends AbstractObjectParser<BandwidthBui
 
        @Override
        public byte[] serializeObject(final Object object) {
-               if (!(object instanceof BandwidthObject))
+               if (!(object instanceof BandwidthObject)) {
                        throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed BandwidthObject.");
+               }
 
                return ((BandwidthObject) object).getBandwidth().getValue();
        }
index cba23bdb0b91b6c579b7eea98a4f3e395b7dbb2c..75abed44f765a94dc33c7d0e589c794b542d3756 100644 (file)
@@ -11,7 +11,8 @@ import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.PCEPErrors;
 import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ClassType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ClasstypeObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
@@ -43,20 +44,23 @@ public class PCEPClassTypeObjectParser extends AbstractObjectParser<ClassTypeBui
         */
        public static final int SIZE = (RESERVED + CT_F_LENGTH) / 8;
 
-       public PCEPClassTypeObjectParser(final HandlerRegistry registry) {
-               super(registry);
+       public PCEPClassTypeObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+               super(subobjReg, tlvReg);
        }
 
        @Override
        public ClasstypeObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
-                       PCEPDocumentedException {
-               if (bytes == null)
+       PCEPDocumentedException {
+               if (bytes == null) {
                        throw new IllegalArgumentException("Byte array is mandatory.");
-               if (bytes.length != SIZE)
+               }
+               if (bytes.length != SIZE) {
                        throw new PCEPDeserializerException("Size of byte array doesn't match defined size. Expected: " + SIZE + "; Passed: "
                                        + bytes.length);
-               if (!header.isProcessingRule())
+               }
+               if (!header.isProcessingRule()) {
                        throw new PCEPDocumentedException("Processed bit not set", PCEPErrors.P_FLAG_NOT_SET);
+               }
 
                final ClassTypeBuilder builder = new ClassTypeBuilder();
 
@@ -79,8 +83,9 @@ public class PCEPClassTypeObjectParser extends AbstractObjectParser<ClassTypeBui
 
        @Override
        public byte[] serializeObject(final Object object) {
-               if (!(object instanceof ClasstypeObject))
+               if (!(object instanceof ClasstypeObject)) {
                        throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed ClasstypeObject.");
+               }
 
                final byte[] retBytes = new byte[SIZE];
                retBytes[SIZE - 1] = ((ClasstypeObject) object).getClassType().getValue().byteValue();
index b21d80f489e115dfed7e379ae7d46a7445ab9eef..7ba58f2c230e3bed4475f46c1cb1c9d480717d09 100644 (file)
@@ -11,7 +11,8 @@ import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.impl.Util;
 import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.CloseObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
@@ -47,14 +48,15 @@ public class PCEPCloseObjectParser extends AbstractObjectParser<CCloseBuilder> {
         */
        public static final int TLVS_OFFSET = REASON_F_OFFSET + REASON_F_LENGTH;
 
-       public PCEPCloseObjectParser(final HandlerRegistry registry) {
-               super(registry);
+       public PCEPCloseObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+               super(subobjReg, tlvReg);
        }
 
        @Override
        public CloseObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException, PCEPDocumentedException {
-               if (bytes == null)
+               if (bytes == null) {
                        throw new IllegalArgumentException("Byte array is mandatory.");
+               }
 
                final CCloseBuilder builder = new CCloseBuilder();
 
@@ -75,19 +77,22 @@ public class PCEPCloseObjectParser extends AbstractObjectParser<CCloseBuilder> {
 
        @Override
        public byte[] serializeObject(final Object object) {
-               if (!(object instanceof CloseObject))
+               if (!(object instanceof CloseObject)) {
                        throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed CloseObject.");
+               }
 
                final CloseObject obj = (CloseObject) object;
 
                final byte[] tlvs = serializeTlvs(obj.getTlvs());
                int tlvsLength = 0;
-               if (tlvs != null)
+               if (tlvs != null) {
                        tlvsLength = tlvs.length;
+               }
                final byte[] retBytes = new byte[TLVS_OFFSET + tlvsLength + Util.getPadding(TLVS_OFFSET + tlvs.length, PADDED_TO)];
 
-               if (tlvs != null)
+               if (tlvs != null) {
                        ByteArray.copyWhole(tlvs, retBytes, TLVS_OFFSET);
+               }
 
                final int reason = ((CClose) obj).getReason().intValue();
 
index 434e7dfa64408e60aa81f1a8c6de4e7b65280746..3f0b78f4f52cb578015537b3c918e297a327d7e7 100644 (file)
@@ -13,7 +13,8 @@ import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.PCEPErrors;
 import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.EndpointsObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
@@ -43,7 +44,7 @@ public class PCEPEndPointsObjectParser extends AbstractObjectParser<EndpointsBui
 
        public static final int SRC4_F_OFFSET = 0;
        public static final int DEST4_F_OFFSET = SRC4_F_OFFSET + SRC4_F_LENGTH;
-       
+
        public static final int CLASS_6 = 4;
 
        public static final int TYPE_6 = 2;
@@ -54,23 +55,25 @@ public class PCEPEndPointsObjectParser extends AbstractObjectParser<EndpointsBui
        public static final int SRC6_F_OFFSET = 0;
        public static final int DEST6_F_OFFSET = SRC6_F_OFFSET + SRC6_F_LENGTH;
 
-       public PCEPEndPointsObjectParser(final HandlerRegistry registry) {
-               super(registry);
+       public PCEPEndPointsObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+               super(subobjReg, tlvReg);
        }
 
        @Override
        public EndpointsObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
-                       PCEPDocumentedException {
-               if (bytes == null)
+       PCEPDocumentedException {
+               if (bytes == null) {
                        throw new IllegalArgumentException("Array of bytes is mandatory");
-               
-               if (!header.isProcessingRule())
+               }
+
+               if (!header.isProcessingRule()) {
                        throw new PCEPDocumentedException("Processed flag not set", PCEPErrors.P_FLAG_NOT_SET);
-               
+               }
+
                final EndpointsBuilder builder = new EndpointsBuilder();
                builder.setIgnore(header.isIgnore());
                builder.setProcessingRule(header.isProcessingRule());
-               
+
                if (bytes.length == SRC4_F_LENGTH + DEST4_F_LENGTH) {
                        final Ipv4Builder b = new Ipv4Builder();
                        b.setSourceIpv4Address(Ipv4Util.addressForBytes(ByteArray.subByte(bytes, SRC4_F_OFFSET, SRC4_F_LENGTH)));
@@ -81,8 +84,9 @@ public class PCEPEndPointsObjectParser extends AbstractObjectParser<EndpointsBui
                        b.setSourceIpv6Address(Ipv6Util.addressForBytes(ByteArray.subByte(bytes, SRC6_F_OFFSET, SRC6_F_LENGTH)));
                        b.setDestinationIpv6Address((Ipv6Util.addressForBytes(ByteArray.subByte(bytes, DEST6_F_OFFSET, DEST6_F_LENGTH))));
                        builder.setAddressFamily(b.build());
-               } else
+               } else {
                        throw new PCEPDeserializerException("Wrong length of array of bytes.");
+               }
                return builder.build();
        }
 
@@ -93,8 +97,9 @@ public class PCEPEndPointsObjectParser extends AbstractObjectParser<EndpointsBui
 
        @Override
        public byte[] serializeObject(final Object object) {
-               if (!(object instanceof EndpointsObject))
+               if (!(object instanceof EndpointsObject)) {
                        throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed EndpointsObject.");
+               }
 
                final EndpointsObject ePObj = (EndpointsObject) object;
 
@@ -110,8 +115,9 @@ public class PCEPEndPointsObjectParser extends AbstractObjectParser<EndpointsBui
                        ByteArray.copyWhole(Ipv6Util.bytesForAddress(((Ipv6) afi).getSourceIpv6Address()), retBytes, SRC6_F_OFFSET);
                        ByteArray.copyWhole(Ipv6Util.bytesForAddress(((Ipv6) afi).getDestinationIpv6Address()), retBytes, DEST6_F_OFFSET);
                        return retBytes;
-               } else
+               } else {
                        throw new IllegalArgumentException("Wrong instance of NetworkAddress. Passed " + afi.getClass() + ". Needed IPv4");
+               }
        }
 
        @Override
@@ -123,7 +129,7 @@ public class PCEPEndPointsObjectParser extends AbstractObjectParser<EndpointsBui
        public int getObjectClass() {
                return CLASS;
        }
-       
+
        public int get6ObjectType() {
                return TYPE_6;
        }
index dda846eca6db1b7b51881e673b1eaf87704ab627..5273204fbb2fec8977a540c805853eb261f80cf3 100644 (file)
@@ -11,7 +11,8 @@ import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.impl.Util;
 import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
@@ -42,15 +43,16 @@ public class PCEPErrorObjectParser extends AbstractObjectParser<ErrorsBuilder> {
        public static final int EV_F_OFFSET = ET_F_OFFSET + ET_F_LENGTH;
        public static final int TLVS_OFFSET = EV_F_OFFSET + EV_F_LENGTH;
 
-       public PCEPErrorObjectParser(final HandlerRegistry registry) {
-               super(registry);
+       public PCEPErrorObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+               super(subobjReg, tlvReg);
        }
 
        @Override
        public PcepErrorObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
-                       PCEPDocumentedException {
-               if (bytes == null)
+       PCEPDocumentedException {
+               if (bytes == null) {
                        throw new IllegalArgumentException("Array of bytes is mandatory.");
+               }
 
                final ErrorsBuilder builder = new ErrorsBuilder();
 
@@ -67,26 +69,30 @@ public class PCEPErrorObjectParser extends AbstractObjectParser<ErrorsBuilder> {
 
        @Override
        public void addTlv(final ErrorsBuilder builder, final Tlv tlv) {
-               if (tlv instanceof ReqMissingTlv && builder.getType() == 7)
+               if (tlv instanceof ReqMissingTlv && builder.getType() == 7) {
                        builder.setTlvs(new TlvsBuilder().setReqMissing(
                                        new ReqMissingBuilder().setRequestId(((ReqMissingTlv) tlv).getRequestId()).build()).build());
+               }
        }
 
        @Override
        public byte[] serializeObject(final Object object) {
-               if (!(object instanceof PcepErrorObject))
+               if (!(object instanceof PcepErrorObject)) {
                        throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed PcepErrorObject.");
+               }
 
                final PcepErrorObject errObj = (PcepErrorObject) object;
 
                final byte[] tlvs = serializeTlvs(((Errors) errObj).getTlvs());
                int tlvsLength = 0;
-               if (tlvs != null)
+               if (tlvs != null) {
                        tlvsLength = tlvs.length;
+               }
                final byte[] retBytes = new byte[TLVS_OFFSET + tlvsLength + Util.getPadding(TLVS_OFFSET + tlvs.length, PADDED_TO)];
 
-               if (tlvs != null)
+               if (tlvs != null) {
                        ByteArray.copyWhole(tlvs, retBytes, TLVS_OFFSET);
+               }
 
                retBytes[ET_F_OFFSET] = ByteArray.shortToBytes(errObj.getType())[1];
                retBytes[EV_F_OFFSET] = ByteArray.shortToBytes(errObj.getValue())[1];
index 46ecbaae8eb08781c72f3b75546bb31d37bcc549..1f3c87b3ab98deb0d0c050b4f0280cbf2d779fb3 100644 (file)
@@ -12,7 +12,8 @@ import java.util.Map;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ExplicitRouteObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
@@ -32,15 +33,16 @@ public class PCEPExplicitRouteObjectParser extends AbstractObjectParser<Explicit
 
        public static final int TYPE = 1;
 
-       public PCEPExplicitRouteObjectParser(final HandlerRegistry registry) {
-               super(registry);
+       public PCEPExplicitRouteObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+               super(subobjReg, tlvReg);
        }
 
        @Override
        public ExplicitRouteObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
-                       PCEPDocumentedException {
-               if (bytes == null || bytes.length == 0)
+       PCEPDocumentedException {
+               if (bytes == null || bytes.length == 0) {
                        throw new IllegalArgumentException("Byte array is mandatory. Can't be null or empty.");
+               }
 
                final ExplicitRouteBuilder builder = new ExplicitRouteBuilder();
 
@@ -58,9 +60,10 @@ public class PCEPExplicitRouteObjectParser extends AbstractObjectParser<Explicit
 
        @Override
        public byte[] serializeObject(final Object object) {
-               if (!(object instanceof ExplicitRouteObject))
+               if (!(object instanceof ExplicitRouteObject)) {
                        throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass()
                                        + ". Needed ExplicitRouteObject.");
+               }
 
                final ExplicitRouteObject ero = ((ExplicitRouteObject) object);
 
index 3836b6da396c2f5cde36c1ab6ff7f5e8cf236673..a381f7e63664f5dce319f82059eda08f9dfac9d6 100644 (file)
@@ -10,7 +10,8 @@ package org.opendaylight.protocol.pcep.impl.object;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.GcObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
@@ -39,14 +40,15 @@ public class PCEPGlobalConstraintsObjectParser extends AbstractObjectParser<GcBu
 
        private final static int TLVS_OFFSET = OVER_BOOKING_FACTOR_F_OFFSET + OVER_BOOKING_FACTOR_F_LENGTH;
 
-       public PCEPGlobalConstraintsObjectParser(final HandlerRegistry registry) {
-               super(registry);
+       public PCEPGlobalConstraintsObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+               super(subobjReg, tlvReg);
        }
 
        @Override
        public GcObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException, PCEPDocumentedException {
-               if (bytes == null || bytes.length == 0)
+               if (bytes == null || bytes.length == 0) {
                        throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
+               }
 
                final GcBuilder builder = new GcBuilder();
 
@@ -70,8 +72,9 @@ public class PCEPGlobalConstraintsObjectParser extends AbstractObjectParser<GcBu
 
        @Override
        public byte[] serializeObject(final Object object) {
-               if (!(object instanceof GcObject))
+               if (!(object instanceof GcObject)) {
                        throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed GcObject.");
+               }
 
                final GcObject specObj = (GcObject) object;
 
index 2cf506db809c26994597ac19adb34937971915d1..c5b0fe431930288b43d7d4f5e1c27fb185864982 100644 (file)
@@ -10,7 +10,8 @@ package org.opendaylight.protocol.pcep.impl.object;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.IncludeRouteObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
@@ -26,15 +27,16 @@ public class PCEPIncludeRouteObjectParser extends AbstractObjectParser<IncludeRo
 
        public static final int TYPE = 1;
 
-       public PCEPIncludeRouteObjectParser(final HandlerRegistry registry) {
-               super(registry);
+       public PCEPIncludeRouteObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+               super(subobjReg, tlvReg);
        }
 
        @Override
        public IncludeRouteObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
-                       PCEPDocumentedException {
-               if (bytes == null || bytes.length == 0)
+       PCEPDocumentedException {
+               if (bytes == null || bytes.length == 0) {
                        throw new IllegalArgumentException("Byte array is mandatory. Can't be null or empty.");
+               }
 
                final IncludeRouteBuilder builder = new IncludeRouteBuilder();
 
@@ -51,8 +53,9 @@ public class PCEPIncludeRouteObjectParser extends AbstractObjectParser<IncludeRo
 
        @Override
        public byte[] serializeObject(final Object object) {
-               if (!(object instanceof IncludeRouteObject))
+               if (!(object instanceof IncludeRouteObject)) {
                        throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed IncludeRouteObject.");
+               }
 
                assert !(((IncludeRouteObject) object).getSubobjects().isEmpty()) : "Empty Include Route Object.";
 
index 3127a55010024f4891d1bca3ce3229555f8cf91d..f3be5e7348de3ac5f378461bc6805182327a9249 100644 (file)
@@ -10,7 +10,8 @@ package org.opendaylight.protocol.pcep.impl.object;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LoadBalancingObject;
@@ -38,18 +39,20 @@ public class PCEPLoadBalancingObjectParser extends AbstractObjectParser<LoadBala
 
        public static final int SIZE = MIN_BAND_F_OFFSET + MIN_BAND_F_LENGTH;
 
-       public PCEPLoadBalancingObjectParser(final HandlerRegistry registry) {
-               super(registry);
+       public PCEPLoadBalancingObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+               super(subobjReg, tlvReg);
        }
 
        @Override
        public LoadBalancingObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
-                       PCEPDocumentedException {
-               if (bytes == null || bytes.length == 0)
+       PCEPDocumentedException {
+               if (bytes == null || bytes.length == 0) {
                        throw new IllegalArgumentException("Byte array is mandatory. Can't be null or empty.");
+               }
 
-               if (bytes.length != SIZE)
+               if (bytes.length != SIZE) {
                        throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + bytes.length + "; Expected: " + SIZE + ".");
+               }
 
                final LoadBalancingBuilder builder = new LoadBalancingBuilder();
 
@@ -69,9 +72,10 @@ public class PCEPLoadBalancingObjectParser extends AbstractObjectParser<LoadBala
 
        @Override
        public byte[] serializeObject(final Object object) {
-               if (!(object instanceof LoadBalancingObject))
+               if (!(object instanceof LoadBalancingObject)) {
                        throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass()
                                        + ". Needed LoadBalancingObject.");
+               }
 
                final LoadBalancingObject specObj = (LoadBalancingObject) object;
 
index 002201d4cc9891568b2f679f3cbbc537e237bd64..623340ccb927725ca3d1d35b6fed239a1d1af4fb 100644 (file)
@@ -12,7 +12,8 @@ import java.util.BitSet;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
@@ -43,14 +44,15 @@ public class PCEPLspObjectParser extends AbstractObjectParser<LspBuilder> {
        private static final int SYNC_FLAG_OFFSET = 14;
        private static final int REMOVE_FLAG_OFFSET = 12;
 
-       public PCEPLspObjectParser(final HandlerRegistry registry) {
-               super(registry);
+       public PCEPLspObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+               super(subobjReg, tlvReg);
        }
 
        @Override
        public LspObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException, PCEPDocumentedException {
-               if (bytes == null || bytes.length == 0)
+               if (bytes == null || bytes.length == 0) {
                        throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
+               }
 
                final BitSet flags = ByteArray.bytesToBitSet(ByteArray.subByte(bytes, 2, 2));
 
@@ -78,8 +80,9 @@ public class PCEPLspObjectParser extends AbstractObjectParser<LspBuilder> {
 
        @Override
        public byte[] serializeObject(final Object object) {
-               if (!(object instanceof LspObject))
+               if (!(object instanceof LspObject)) {
                        throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed LspObject.");
+               }
 
                final LspObject specObj = (LspObject) object;
 
@@ -91,15 +94,18 @@ public class PCEPLspObjectParser extends AbstractObjectParser<LspBuilder> {
                retBytes[0] = (byte) (lspID >> 12);
                retBytes[1] = (byte) (lspID >> 4);
                retBytes[2] = (byte) (lspID << 4);
-               if (specObj.isDelegate())
+               if (specObj.isDelegate()) {
                        retBytes[3] |= 1 << (Byte.SIZE - (DELEGATE_FLAG_OFFSET - Byte.SIZE) - 1);
+               }
                // FIXME: !!
                // if (specObj.isOperational())
                // retBytes[3] |= 1 << (Byte.SIZE - (OPERATIONAL_FLAG_OFFSET - Byte.SIZE) - 1);
-               if (specObj.isRemove())
+               if (specObj.isRemove()) {
                        retBytes[3] |= 1 << (Byte.SIZE - (REMOVE_FLAG_OFFSET - Byte.SIZE) - 1);
-               if (specObj.isSync())
+               }
+               if (specObj.isSync()) {
                        retBytes[3] |= 1 << (Byte.SIZE - (SYNC_FLAG_OFFSET - Byte.SIZE) - 1);
+               }
 
                // ByteArray.copyWhole(tlvs, retBytes, TLVS_OFFSET);
 
index 489e1a2a0448248bc1ed1a46806a39b59d397d17..dd4064caeef8e9ecf5eec6c3d3cf65a89e20d0c7 100644 (file)
@@ -12,7 +12,8 @@ import java.util.BitSet;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspaObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
@@ -57,14 +58,15 @@ public class PCEPLspaObjectParser extends AbstractObjectParser<LspaBuilder> {
        public static final int FLAGS_F_OFFSET = HOLD_PRIO_F_OFFSET + HOLD_PRIO_F_LENGTH;
        public static final int TLVS_F_OFFSET = FLAGS_F_OFFSET + FLAGS_F_LENGTH + 1; // added reserved field of length 1B
 
-       public PCEPLspaObjectParser(final HandlerRegistry registry) {
-               super(registry);
+       public PCEPLspaObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+               super(subobjReg, tlvReg);
        }
 
        @Override
        public LspaObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException, PCEPDocumentedException {
-               if (bytes == null)
+               if (bytes == null) {
                        throw new IllegalArgumentException("Bytes array is mandatory.");
+               }
 
                final BitSet flags = ByteArray.bytesToBitSet(ByteArray.subByte(bytes, FLAGS_F_OFFSET, FLAGS_F_LENGTH));
 
@@ -92,8 +94,9 @@ public class PCEPLspaObjectParser extends AbstractObjectParser<LspaBuilder> {
 
        @Override
        public byte[] serializeObject(final Object object) {
-               if (!(object instanceof LspaObject))
+               if (!(object instanceof LspaObject)) {
                        throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed LspaObject.");
+               }
 
                final LspaObject lspaObj = (LspaObject) object;
 
index 2f50386bc1b51cc18d6142e0c7b424a275b9bb3e..f1a5f40675171b2952219ad28bc85c70af1239ae 100644 (file)
@@ -12,7 +12,8 @@ import java.util.BitSet;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.MetricObject;
@@ -53,17 +54,19 @@ public class PCEPMetricObjectParser extends AbstractObjectParser<MetricBuilder>
 
        public static final int SIZE = METRIC_VALUE_F_OFFSET + METRIC_VALUE_F_LENGTH;
 
-       public PCEPMetricObjectParser(final HandlerRegistry registry) {
-               super(registry);
+       public PCEPMetricObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+               super(subobjReg, tlvReg);
        }
 
        @Override
        public MetricObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
-                       PCEPDocumentedException {
-               if (bytes == null || bytes.length == 0)
+       PCEPDocumentedException {
+               if (bytes == null || bytes.length == 0) {
                        throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
-               if (bytes.length != SIZE)
+               }
+               if (bytes.length != SIZE) {
                        throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + bytes.length + "; Expected: " + SIZE + ".");
+               }
                final byte[] flagBytes = { bytes[FLAGS_F_OFFSET] };
                final BitSet flags = ByteArray.bytesToBitSet(flagBytes);
 
@@ -87,8 +90,9 @@ public class PCEPMetricObjectParser extends AbstractObjectParser<MetricBuilder>
 
        @Override
        public byte[] serializeObject(final Object object) {
-               if (!(object instanceof MetricObject))
+               if (!(object instanceof MetricObject)) {
                        throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed MetricObject.");
+               }
 
                final MetricObject mObj = (MetricObject) object;
 
index 8d5f41a0b0b80eaf61e902affeaf8610ded703ed..bbf06a8adccc43ea225991c9bda5f061e35b4f36 100644 (file)
@@ -13,7 +13,8 @@ import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.impl.Util;
 import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.pcrep.pcrep.message.replies.result.failure.NoPath;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.pcrep.pcrep.message.replies.result.failure.no.path.Tlvs;
@@ -54,15 +55,16 @@ public class PCEPNoPathObjectParser extends AbstractObjectParser<NoPathBuilder>
 
        public static final int C_FLAG_OFFSET = 0;
 
-       public PCEPNoPathObjectParser(final HandlerRegistry registry) {
-               super(registry);
+       public PCEPNoPathObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+               super(subobjReg, tlvReg);
        }
 
        @Override
        public NoPathObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
-                       PCEPDocumentedException {
-               if (bytes == null || bytes.length == 0)
+       PCEPDocumentedException {
+               if (bytes == null || bytes.length == 0) {
                        throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
+               }
 
                final BitSet flags = ByteArray.bytesToBitSet(ByteArray.subByte(bytes, FLAGS_F_OFFSET, FLAGS_F_LENGTH));
 
@@ -86,19 +88,22 @@ public class PCEPNoPathObjectParser extends AbstractObjectParser<NoPathBuilder>
 
        @Override
        public byte[] serializeObject(final Object object) {
-               if (!(object instanceof NoPathObject))
+               if (!(object instanceof NoPathObject)) {
                        throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed NoPathObject.");
+               }
 
                final NoPathObject nPObj = (NoPathObject) object;
 
                final byte[] tlvs = serializeTlvs(((NoPath) nPObj).getTlvs());
                int tlvsLength = 0;
-               if (tlvs != null)
+               if (tlvs != null) {
                        tlvsLength = tlvs.length;
+               }
                final byte[] retBytes = new byte[TLVS_OFFSET + tlvsLength + Util.getPadding(TLVS_OFFSET + tlvs.length, PADDED_TO)];
 
-               if (tlvs != null)
+               if (tlvs != null) {
                        ByteArray.copyWhole(tlvs, retBytes, TLVS_OFFSET);
+               }
                final BitSet flags = new BitSet(FLAGS_F_LENGTH * Byte.SIZE);
                flags.set(C_FLAG_OFFSET, nPObj.isUnsatisfiedConstraints());
                retBytes[NI_F_OFFSET] = ByteArray.shortToBytes(nPObj.getNatureOfIssue())[1];
index 9c654954a61f30382a736090650155c8432e1984..da652bf855196c7d44ae785c2bf137e74ac6a34b 100644 (file)
@@ -11,7 +11,8 @@ import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.impl.Util;
 import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NotificationObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
@@ -47,15 +48,16 @@ public class PCEPNotificationObjectParser extends AbstractObjectParser<Notificat
        public static final int NV_F_OFFSET = NT_F_OFFSET + NT_F_LENGTH;
        public static final int TLVS_OFFSET = NV_F_OFFSET + NV_F_LENGTH;
 
-       public PCEPNotificationObjectParser(final HandlerRegistry registry) {
-               super(registry);
+       public PCEPNotificationObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+               super(subobjReg, tlvReg);
        }
 
        @Override
        public NotificationObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
-                       PCEPDocumentedException {
-               if (bytes == null || bytes.length == 0)
+       PCEPDocumentedException {
+               if (bytes == null || bytes.length == 0) {
                        throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
+               }
 
                final NotificationsBuilder builder = new NotificationsBuilder();
 
@@ -72,26 +74,30 @@ public class PCEPNotificationObjectParser extends AbstractObjectParser<Notificat
 
        @Override
        public void addTlv(final NotificationsBuilder builder, final Tlv tlv) {
-               if (tlv instanceof OverloadDurationTlv && builder.getType() == 2 && builder.getValue() == 1)
+               if (tlv instanceof OverloadDurationTlv && builder.getType() == 2 && builder.getValue() == 1) {
                        builder.setTlvs(new TlvsBuilder().setOverloadDuration(
                                        new OverloadDurationBuilder().setDuration(((OverloadDurationTlv) tlv).getDuration()).build()).build());
+               }
        }
 
        @Override
        public byte[] serializeObject(final Object object) {
-               if (!(object instanceof NotificationObject))
+               if (!(object instanceof NotificationObject)) {
                        throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed NotificationObject.");
+               }
 
                final NotificationObject notObj = (NotificationObject) object;
 
                final byte[] tlvs = serializeTlvs(notObj.getTlvs());
                int tlvsLength = 0;
-               if (tlvs != null)
+               if (tlvs != null) {
                        tlvsLength = tlvs.length;
+               }
                final byte[] retBytes = new byte[TLVS_OFFSET + tlvsLength + Util.getPadding(TLVS_OFFSET + tlvs.length, PADDED_TO)];
 
-               if (tlvs != null)
+               if (tlvs != null) {
                        ByteArray.copyWhole(tlvs, retBytes, TLVS_OFFSET);
+               }
 
                retBytes[NT_F_OFFSET] = ByteArray.shortToBytes(notObj.getType())[1];
                retBytes[NV_F_OFFSET] = ByteArray.shortToBytes(notObj.getValue())[1];
index b37523999128aa08e23875274849ec4227a65a18..9e2ffa3091a75941e5f9aeced7f6a4053c537147 100644 (file)
@@ -10,7 +10,8 @@ package org.opendaylight.protocol.pcep.impl.object;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
@@ -38,14 +39,15 @@ public class PCEPObjectiveFunctionObjectParser extends AbstractObjectParser<OfBu
        public static final int OF_CODE_F_OFFSET = 0;
        public static final int TLVS_OFFSET = OF_CODE_F_OFFSET + OF_CODE_F_LENGTH + 2; // added reserved field of size 2
 
-       public PCEPObjectiveFunctionObjectParser(final HandlerRegistry registry) {
-               super(registry);
+       public PCEPObjectiveFunctionObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+               super(subobjReg, tlvReg);
        }
 
        @Override
        public OfObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException, PCEPDocumentedException {
-               if (bytes == null || bytes.length == 0)
+               if (bytes == null || bytes.length == 0) {
                        throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
+               }
 
                final OfBuilder builder = new OfBuilder();
 
@@ -65,9 +67,10 @@ public class PCEPObjectiveFunctionObjectParser extends AbstractObjectParser<OfBu
 
        @Override
        public byte[] serializeObject(final Object object) {
-               if (!(object instanceof OfObject))
+               if (!(object instanceof OfObject)) {
                        throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass()
                                        + ". Needed PCEPObjectiveFunction.");
+               }
 
                final OfObject specObj = (OfObject) object;
                // FIXME
index 556d20b8cbae7d1d52167c2cd0a650a58c1b0013..9adf9d2c643698b3feef7156479fc09ce4c400be 100644 (file)
@@ -13,7 +13,8 @@ import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.PCEPErrors;
 import org.opendaylight.protocol.pcep.impl.Util;
 import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspDbVersionTlv;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
@@ -77,19 +78,21 @@ public class PCEPOpenObjectParser extends AbstractObjectParser<OpenBuilder> {
 
        private static final int PCEP_VERSION = 1;
 
-       public PCEPOpenObjectParser(final HandlerRegistry registry) {
-               super(registry);
+       public PCEPOpenObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+               super(subobjReg, tlvReg);
        }
 
        @Override
        public OpenObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException, PCEPDocumentedException {
-               if (bytes == null || bytes.length == 0)
+               if (bytes == null || bytes.length == 0) {
                        throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
+               }
 
                final int versionValue = ByteArray.copyBitsRange(bytes[VER_FLAGS_MF_OFFSET], VERSION_SF_OFFSET, VERSION_SF_LENGTH);
 
-               if (versionValue != PCEP_VERSION)
+               if (versionValue != PCEP_VERSION) {
                        throw new PCEPDocumentedException("Unsupported PCEP version " + versionValue, PCEPErrors.PCEP_VERSION_NOT_SUPPORTED);
+               }
 
                final OpenBuilder builder = new OpenBuilder();
 
@@ -107,21 +110,23 @@ public class PCEPOpenObjectParser extends AbstractObjectParser<OpenBuilder> {
        @Override
        public void addTlv(final OpenBuilder builder, final Tlv tlv) {
                final TlvsBuilder tbuilder = new TlvsBuilder();
-               if (tlv instanceof OfListTlv)
+               if (tlv instanceof OfListTlv) {
                        tbuilder.setOfList(new OfListBuilder().setCodes(((OfListTlv) tlv).getCodes()).build());
-               else if (tlv instanceof StatefulCapabilityTlv)
+               } else if (tlv instanceof StatefulCapabilityTlv) {
                        tbuilder.setStateful(new StatefulBuilder().setFlags(((StatefulCapabilityTlv) tlv).getFlags()).build());
-               else if (tlv instanceof PredundancyGroupIdTlv)
+               } else if (tlv instanceof PredundancyGroupIdTlv) {
                        tbuilder.setPredundancyGroupId(new PredundancyGroupIdBuilder().setIdentifier(((PredundancyGroupIdTlv) tlv).getIdentifier()).build());
-               else if (tlv instanceof LspDbVersionTlv)
+               } else if (tlv instanceof LspDbVersionTlv) {
                        tbuilder.setLspDbVersion(new LspDbVersionBuilder().build());
+               }
                builder.setTlvs(tbuilder.build());
        }
 
        @Override
        public byte[] serializeObject(final Object object) {
-               if (!(object instanceof OpenObject))
+               if (!(object instanceof OpenObject)) {
                        throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed OpenObject.");
+               }
                final OpenObject open = (OpenObject) object;
 
                final byte versionFlagMF = (byte) (PCEP_VERSION << (Byte.SIZE - VERSION_SF_LENGTH));
index 274f4463b34512afc47b0503f6d13d6762b37dc0..a865e9f5780c919ed4dca66c83eb1c7e24c6788c 100644 (file)
@@ -10,7 +10,8 @@ package org.opendaylight.protocol.pcep.impl.object;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PathKeyObject;
@@ -26,13 +27,13 @@ public class PCEPPathKeyObjectParser extends AbstractObjectParser<PathKeyBuilder
 
        public static final int TYPE = 1;
 
-       public PCEPPathKeyObjectParser(final HandlerRegistry registry) {
-               super(registry);
+       public PCEPPathKeyObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+               super(subobjReg, tlvReg);
        }
 
        @Override
        public PathKeyObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
-                       PCEPDocumentedException {
+       PCEPDocumentedException {
                // FIXME : finish
 
                final PathKeyBuilder builder = new PathKeyBuilder();
@@ -50,8 +51,9 @@ public class PCEPPathKeyObjectParser extends AbstractObjectParser<PathKeyBuilder
 
        @Override
        public byte[] serializeObject(final Object object) {
-               if (!(object instanceof PathKeyObject))
+               if (!(object instanceof PathKeyObject)) {
                        throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed PathKeyObject.");
+               }
 
                final PathKeyObject pkey = (PathKeyObject) object;
 
index b2b1ecc8d34683b88f6d86316359953a0a0854dd..4b0408dd4df569e1c33fb259beeee3765c1c175f 100644 (file)
@@ -10,7 +10,8 @@ package org.opendaylight.protocol.pcep.impl.object;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ReportedRouteObject;
@@ -26,15 +27,16 @@ public class PCEPReportedRouteObjectParser extends AbstractObjectParser<Reported
 
        public static final int TYPE = 1;
 
-       public PCEPReportedRouteObjectParser(final HandlerRegistry registry) {
-               super(registry);
+       public PCEPReportedRouteObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+               super(subobjReg, tlvReg);
        }
 
        @Override
        public ReportedRouteObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
-                       PCEPDocumentedException {
-               if (bytes == null || bytes.length == 0)
+       PCEPDocumentedException {
+               if (bytes == null || bytes.length == 0) {
                        throw new IllegalArgumentException("Byte array is mandatory. Can't be null or empty.");
+               }
 
                final ReportedRouteBuilder builder = new ReportedRouteBuilder();
 
@@ -51,9 +53,10 @@ public class PCEPReportedRouteObjectParser extends AbstractObjectParser<Reported
 
        @Override
        public byte[] serializeObject(final Object object) {
-               if (!(object instanceof ReportedRouteObject))
+               if (!(object instanceof ReportedRouteObject)) {
                        throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass()
                                        + ". Needed ReportedRouteObject.");
+               }
 
                assert !(((ReportedRouteObject) object).getSubobjects().isEmpty()) : "Empty Reported Route Object.";
                // FIXME add subobjects
index a7a00e318b03fc0bef94d9bf08d7ad3ad0f5eec5..7e177131769d458b9ea71d7696f10f903d405727 100644 (file)
@@ -15,7 +15,8 @@ import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.impl.Util;
 import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
@@ -94,14 +95,15 @@ public class PCEPRequestParameterObjectParser extends AbstractObjectParser<RpBui
 
        private static int E_FLAG_OFFSET = 20;
 
-       public PCEPRequestParameterObjectParser(final HandlerRegistry registry) {
-               super(registry);
+       public PCEPRequestParameterObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+               super(subobjReg, tlvReg);
        }
 
        @Override
        public RpObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException, PCEPDocumentedException {
-               if (bytes == null || bytes.length == 0)
+               if (bytes == null || bytes.length == 0) {
                        throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
+               }
 
                final BitSet flags = ByteArray.bytesToBitSet(Arrays.copyOfRange(bytes, FLAGS_PRI_MF_OFFSET, FLAGS_PRI_MF_OFFSET
                                + FLAGS_PRI_MF_LENGTH));
@@ -146,8 +148,9 @@ public class PCEPRequestParameterObjectParser extends AbstractObjectParser<RpBui
 
        @Override
        public byte[] serializeObject(final Object object) {
-               if (!(object instanceof RpObject))
+               if (!(object instanceof RpObject)) {
                        throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed RpObject.");
+               }
 
                final RpObject rPObj = (RpObject) object;
 
@@ -169,12 +172,14 @@ public class PCEPRequestParameterObjectParser extends AbstractObjectParser<RpBui
 
                final byte[] tlvs = serializeTlvs(rPObj.getTlvs());
                int tlvsLength = 0;
-               if (tlvs != null)
+               if (tlvs != null) {
                        tlvsLength = tlvs.length;
+               }
                final byte[] retBytes = new byte[TLVS_OFFSET + tlvsLength + Util.getPadding(TLVS_OFFSET + tlvs.length, PADDED_TO)];
 
-               if (tlvs != null)
+               if (tlvs != null) {
                        ByteArray.copyWhole(tlvs, retBytes, TLVS_OFFSET);
+               }
 
                ByteArray.copyWhole(ByteArray.bitSetToBytes(flags_priority, FLAGS_PRI_MF_LENGTH), retBytes, FLAGS_PRI_MF_OFFSET);
                ByteArray.copyWhole(ByteArray.subByte(ByteArray.longToBytes(rPObj.getRequestId().getValue()), (Long.SIZE / Byte.SIZE)
index 3c0cc378d15a6fb2c48e053a2f2afbb1c1594e3d..d8087f36a128adb510adb56cafe9df23168ba57a 100644 (file)
@@ -10,7 +10,8 @@ package org.opendaylight.protocol.pcep.impl.object;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.SrpObject;
@@ -23,8 +24,8 @@ public final class PCEPSrpObjectParser extends AbstractObjectParser<SrpBuilder>
 
        public static final int TYPE = 1;
 
-       public PCEPSrpObjectParser(final HandlerRegistry registry) {
-               super(registry);
+       public PCEPSrpObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+               super(subobjReg, tlvReg);
        }
 
        @Override
@@ -47,8 +48,9 @@ public final class PCEPSrpObjectParser extends AbstractObjectParser<SrpBuilder>
 
        @Override
        public byte[] serializeObject(final Object object) {
-               if (!(object instanceof SrpObject))
+               if (!(object instanceof SrpObject)) {
                        throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed SrpObject.");
+               }
 
                final SrpObject srp = (SrpObject) object;
                // FIXME: finish
index 6ae579c2ee8c3130f89cc478b1379d77f7ba3414..b5079bd8543265ccc4373fe1c8042c444957482e 100644 (file)
@@ -13,7 +13,8 @@ import java.util.List;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
@@ -57,18 +58,20 @@ public class PCEPSvecObjectParser extends AbstractObjectParser<SvecBuilder> {
         */
        public static final int MIN_SIZE = FLAGS_F_LENGTH + FLAGS_F_OFFSET;
 
-       public PCEPSvecObjectParser(final HandlerRegistry registry) {
-               super(registry);
+       public PCEPSvecObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+               super(subobjReg, tlvReg);
        }
 
        @Override
        public SvecObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException, PCEPDocumentedException {
-               if (bytes == null || bytes.length == 0)
+               if (bytes == null || bytes.length == 0) {
                        throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
+               }
 
-               if (bytes.length < MIN_SIZE)
+               if (bytes.length < MIN_SIZE) {
                        throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + bytes.length + "; Expected: >=" + MIN_SIZE
                                        + ".");
+               }
 
                final BitSet flags = ByteArray.bytesToBitSet(ByteArray.subByte(bytes, FLAGS_F_OFFSET, FLAGS_F_LENGTH));
                final List<RequestId> requestIDs = Lists.newArrayList();
@@ -77,8 +80,9 @@ public class PCEPSvecObjectParser extends AbstractObjectParser<SvecBuilder> {
                        requestIDs.add(new RequestId(ByteArray.bytesToLong(ByteArray.subByte(bytes, i, REQ_LIST_ITEM_LENGTH))));
                }
 
-               if (requestIDs.isEmpty())
+               if (requestIDs.isEmpty()) {
                        throw new PCEPDeserializerException("Empty Svec Object - no request ids.");
+               }
 
                final SvecBuilder builder = new SvecBuilder();
 
@@ -99,8 +103,9 @@ public class PCEPSvecObjectParser extends AbstractObjectParser<SvecBuilder> {
 
        @Override
        public byte[] serializeObject(final Object object) {
-               if (!(object instanceof SvecObject))
+               if (!(object instanceof SvecObject)) {
                        throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed SvecObject.");
+               }
 
                final SvecObject svecObj = (SvecObject) object;
                final byte[] retBytes = new byte[svecObj.getRequestsIds().size() * REQ_LIST_ITEM_LENGTH + REQ_ID_LIST_OFFSET];
index ba7f57596175607c2c32c050798d1507ad4d409b..bb431c72498ecc79be859df24f3357c2c11409ee 100644 (file)
@@ -12,6 +12,7 @@ import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
 
+import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
 import com.google.common.primitives.UnsignedBytes;
 
@@ -42,15 +43,16 @@ public abstract class AbstractMessageParser implements MessageParser, MessageSer
        private final static int P_FLAG_OFFSET = 6;
        private final static int I_FLAG_OFFSET = 7;
 
-       private final HandlerRegistry registry;
+       private final ObjectHandlerRegistry registry;
 
-       protected AbstractMessageParser(final HandlerRegistry registry) {
-               this.registry = registry;
+       protected AbstractMessageParser(final ObjectHandlerRegistry registry) {
+               this.registry = Preconditions.checkNotNull(registry);
        }
 
        protected byte[] serializeObject(final Object object) {
-               if (object == null)
+               if (object == null) {
                        throw new IllegalArgumentException("Null object passed.");
+               }
 
                final ObjectSerializer serializer = this.registry.getObjectSerializer(object);
 
@@ -63,10 +65,12 @@ public abstract class AbstractMessageParser implements MessageParser, MessageSer
 
                // objType_flags multi-field
                retBytes[OT_FLAGS_MF_OFFSET] = (byte) (serializer.getObjectType() << (Byte.SIZE - OT_SF_LENGTH));
-               if (object.isProcessingRule())
+               if (object.isProcessingRule()) {
                        retBytes[OT_FLAGS_MF_OFFSET] |= 1 << Byte.SIZE - (P_FLAG_OFFSET) - 1;
-               if (object.isIgnore())
+               }
+               if (object.isIgnore()) {
                        retBytes[OT_FLAGS_MF_OFFSET] |= 1 << Byte.SIZE - (I_FLAG_OFFSET) - 1;
+               }
 
                // objLength
                System.arraycopy(ByteArray.intToBytes(valueBytes.length), Integer.SIZE / Byte.SIZE - OBJ_LENGTH_F_LENGTH, retBytes,
@@ -81,9 +85,10 @@ public abstract class AbstractMessageParser implements MessageParser, MessageSer
                int offset = 0;
                final List<Object> objs = Lists.newArrayList();
                while (bytes.length - offset > 0) {
-                       if (bytes.length - offset < COMMON_OBJECT_HEADER_LENGTH)
+                       if (bytes.length - offset < COMMON_OBJECT_HEADER_LENGTH) {
                                throw new PCEPDeserializerException("Too few bytes in passed array. Passed: " + (bytes.length - offset) + " Expected: >= "
                                                + COMMON_OBJECT_HEADER_LENGTH + ".");
+                       }
 
                        final int objClass = ByteArray.bytesToInt(Arrays.copyOfRange(bytes, OC_F_OFFSET, OC_F_OFFSET + OC_F_LENGTH));
 
@@ -96,9 +101,10 @@ public abstract class AbstractMessageParser implements MessageParser, MessageSer
 
                        final BitSet flags = ByteArray.bytesToBitSet(flagsBytes);
 
-                       if (bytes.length - offset < objLength)
+                       if (bytes.length - offset < objLength) {
                                throw new PCEPDeserializerException("Too few bytes in passed array. Passed: " + (bytes.length - offset) + " Expected: >= "
                                                + objLength + ".");
+                       }
 
                        // copy bytes for deeper parsing
                        final byte[] bytesToPass = ByteArray.subByte(bytes, offset + COMMON_OBJECT_HEADER_LENGTH, objLength
@@ -116,8 +122,9 @@ public abstract class AbstractMessageParser implements MessageParser, MessageSer
                                if (e.getError() == PCEPErrors.UNRECOGNIZED_OBJ_CLASS | e.getError() == PCEPErrors.UNRECOGNIZED_OBJ_TYPE
                                                | e.getError() == PCEPErrors.NOT_SUPPORTED_OBJ_CLASS | e.getError() == PCEPErrors.NOT_SUPPORTED_OBJ_TYPE) {
                                        objs.add(new UnknownObject(e.getError()));
-                               } else
+                               } else {
                                        throw e;
+                               }
                        }
                }
                return objs;
index 045fd791d0c6e46c4ca2c5f2f2ec08043e93cd51..ca2fe202da2a4a42a317b1549d645846e5439916 100644 (file)
@@ -18,6 +18,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 
@@ -39,15 +40,18 @@ public abstract class AbstractObjectParser<BUILDER> implements ObjectParser, Obj
 
        protected static final int PADDED_TO = 4;
 
-       private final HandlerRegistry registry;
+       private final SubobjectHandlerRegistry subobjReg;
+       private final TlvHandlerRegistry tlvReg;
 
-       protected AbstractObjectParser(final HandlerRegistry registry) {
-               this.registry = registry;
+       protected AbstractObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+               this.subobjReg = Preconditions.checkNotNull(subobjReg);
+               this.tlvReg = Preconditions.checkNotNull(tlvReg);
        }
 
        protected final void parseTlvs(final BUILDER builder, final byte[] bytes) throws PCEPDeserializerException {
-               if (bytes == null)
+               if (bytes == null) {
                        throw new IllegalArgumentException("Byte array is mandatory.");
+               }
 
                int length;
                int byteOffset = 0;
@@ -59,14 +63,15 @@ public abstract class AbstractObjectParser<BUILDER> implements ObjectParser, Obj
                        length = ByteArray.bytesToInt(ByteArray.subByte(bytes, byteOffset, TLV_LENGTH_F_LENGTH));
                        byteOffset += TLV_LENGTH_F_LENGTH;
 
-                       if (TLV_HEADER_LENGTH + length > bytes.length - byteOffset)
+                       if (TLV_HEADER_LENGTH + length > bytes.length - byteOffset) {
                                throw new PCEPDeserializerException("Wrong length specified. Passed: " + (TLV_HEADER_LENGTH + length) + "; Expected: <= "
                                                + (bytes.length - byteOffset) + ".");
+                       }
 
                        final byte[] tlvBytes = ByteArray.subByte(bytes, byteOffset, length);
 
                        logger.trace("Attempt to parse tlv from bytes: {}", ByteArray.bytesToHexString(tlvBytes));
-                       final Tlv tlv = this.registry.getTlvParser(type).parseTlv(tlvBytes);
+                       final Tlv tlv = this.tlvReg.getTlvParser(type).parseTlv(tlvBytes);
                        logger.trace("Tlv was parsed. {}", tlv);
 
                        addTlv(builder, tlv);
@@ -77,7 +82,7 @@ public abstract class AbstractObjectParser<BUILDER> implements ObjectParser, Obj
 
        protected final byte[] serializeTlv(final Tlv tlv) {
 
-               final TlvSerializer serializer = this.registry.getTlvSerializer(tlv);
+               final TlvSerializer serializer = this.tlvReg.getTlvSerializer(tlv);
 
                final byte[] typeBytes = (ByteArray.cutBytes(ByteArray.intToBytes(serializer.getType()), (Integer.SIZE / 8) - TLV_TYPE_F_LENGTH));
 
@@ -95,8 +100,9 @@ public abstract class AbstractObjectParser<BUILDER> implements ObjectParser, Obj
        }
 
        protected final void parseSubobjects(final BUILDER builder, final byte[] bytes) throws PCEPDeserializerException {
-               if (bytes == null)
+               if (bytes == null) {
                        throw new IllegalArgumentException("Byte array is mandatory.");
+               }
 
                boolean loose_flag = false;
                int type;
@@ -114,15 +120,16 @@ public abstract class AbstractObjectParser<BUILDER> implements ObjectParser, Obj
 
                        type = (bytes[offset + TYPE_FLAG_F_OFFSET] & 0xff) & ~(1 << 7);
 
-                       if (length > bytes.length - offset)
+                       if (length > bytes.length - offset) {
                                throw new PCEPDeserializerException("Wrong length specified. Passed: " + length + "; Expected: <= "
                                                + (bytes.length - offset));
+                       }
 
                        soContentsBytes = new byte[length - SO_CONTENTS_OFFSET];
                        System.arraycopy(bytes, offset + SO_CONTENTS_OFFSET, soContentsBytes, 0, length - SO_CONTENTS_OFFSET);
 
                        logger.debug("Attempt to parse subobject from bytes: {}", ByteArray.bytesToHexString(soContentsBytes));
-                       final CSubobject subObj = this.registry.getSubobjectParser(type).parseSubobject(soContentsBytes);
+                       final CSubobject subObj = this.subobjReg.getSubobjectParser(type).parseSubobject(soContentsBytes);
                        logger.debug("Subobject was parsed. {}", subObj);
 
                        subs.put(subObj, loose_flag);
@@ -142,7 +149,7 @@ public abstract class AbstractObjectParser<BUILDER> implements ObjectParser, Obj
 
                        final CSubobject subobject = entry.getKey();
 
-                       final SubobjectSerializer serializer = this.registry.getSubobjectSerializer(subobject);
+                       final SubobjectSerializer serializer = this.subobjReg.getSubobjectSerializer(subobject);
 
                        final byte[] valueBytes = serializer.serializeSubobject(subobject);
 
diff --git a/pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/HandlerRegistry.java b/pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/HandlerRegistry.java
deleted file mode 100644 (file)
index fed1e4a..0000000
+++ /dev/null
@@ -1,39 +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.pcep.spi;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.CSubobject;
-
-public interface HandlerRegistry {
-       public AutoCloseable registerMessageParser(int messageType, MessageParser parser);
-       public MessageParser getMessageParser(int messageType);
-
-       public AutoCloseable registerMessageSerializer(Class<? extends Message> msgClass, MessageSerializer serializer);
-       public MessageSerializer getMessageSerializer(Message message);
-
-       public AutoCloseable registerObjectParser(int objectClass, int objectType, ObjectParser parser);
-       public ObjectParser getObjectParser(int objectClass, int objectType);
-
-       public AutoCloseable registerObjectSerializer(Class<? extends Object> objClass, ObjectSerializer serializer);
-       public ObjectSerializer getObjectSerializer(Object object);
-
-       public AutoCloseable registerTlvParser(int tlvType, TlvParser parser);
-       public TlvParser getTlvParser(int tlvType);
-
-       public AutoCloseable registerTlvSerializer(Class<? extends Tlv> tlvClass, TlvSerializer serializer);
-       public TlvSerializer getTlvSerializer(Tlv tlv);
-       
-       public AutoCloseable registerSubobjectParser(int subobjectType, SubobjectParser parser);
-       public SubobjectParser getSubobjectParser(int subobjectType);
-       
-       public AutoCloseable registerSubobjectSerializer(Class<? extends CSubobject> subobjectClass, SubobjectSerializer serializer);
-       public SubobjectSerializer getSubobjectSerializer(CSubobject subobject);
-}
diff --git a/pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/MessageHandlerRegistry.java b/pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/MessageHandlerRegistry.java
new file mode 100644 (file)
index 0000000..bd3c136
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * 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.pcep.spi;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+
+public interface MessageHandlerRegistry {
+       public AutoCloseable registerMessageParser(int messageType, MessageParser parser);
+       public AutoCloseable registerMessageSerializer(Class<? extends Message> msgClass, MessageSerializer serializer);
+
+       public MessageParser getMessageParser(int messageType);
+       public MessageSerializer getMessageSerializer(Message message);
+}
diff --git a/pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/ObjectHandlerRegistry.java b/pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/ObjectHandlerRegistry.java
new file mode 100644 (file)
index 0000000..a003177
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * 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.pcep.spi;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
+
+public interface ObjectHandlerRegistry {
+       public AutoCloseable registerObjectParser(int objectClass, int objectType, ObjectParser parser);
+       public AutoCloseable registerObjectSerializer(Class<? extends Object> objClass, ObjectSerializer serializer);
+
+       public ObjectParser getObjectParser(int objectClass, int objectType);
+       public ObjectSerializer getObjectSerializer(Object object);
+}
diff --git a/pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/SubobjectHandlerRegistry.java b/pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/SubobjectHandlerRegistry.java
new file mode 100644 (file)
index 0000000..ba50021
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * 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.pcep.spi;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.CSubobject;
+
+public interface SubobjectHandlerRegistry {
+       public AutoCloseable registerSubobjectParser(int subobjectType, SubobjectParser parser);
+       public SubobjectParser getSubobjectParser(int subobjectType);
+
+       public AutoCloseable registerSubobjectSerializer(Class<? extends CSubobject> subobjectClass, SubobjectSerializer serializer);
+       public SubobjectSerializer getSubobjectSerializer(CSubobject subobject);
+}
diff --git a/pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/TlvHandlerRegistry.java b/pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/TlvHandlerRegistry.java
new file mode 100644 (file)
index 0000000..5ad71a0
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * 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.pcep.spi;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv;
+
+public interface TlvHandlerRegistry {
+       public AutoCloseable registerTlvParser(int tlvType, TlvParser parser);
+       public TlvParser getTlvParser(int tlvType);
+
+       public AutoCloseable registerTlvSerializer(Class<? extends Tlv> tlvClass, TlvSerializer serializer);
+       public TlvSerializer getTlvSerializer(Tlv tlv);
+}
index 0f7f052050264e53467a80286d9e4cafbf25422f..1c8e47c08ab0c5ab85ace5295ae4cea04722fdbd 100644 (file)
@@ -28,6 +28,7 @@ import org.opendaylight.protocol.pcep.PCEPSessionListener;
 import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory;
 import org.opendaylight.protocol.pcep.impl.PCEPHandlerFactory;
 import org.opendaylight.protocol.pcep.impl.PCEPSessionImpl;
+import org.opendaylight.protocol.pcep.impl.SimpleMessageHandlerFactory;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.message.open.message.OpenBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.TlvsBuilder;
@@ -65,15 +66,17 @@ public class PCCMock<M, S extends ProtocolSession<M>, L extends SessionListener<
                final SessionNegotiatorFactory<Message, PCEPSessionImpl, PCEPSessionListener> snf = new DefaultPCEPSessionNegotiatorFactory(new HashedWheelTimer(), new OpenBuilder().setKeepalive(
                                (short) 30).setDeadTimer((short) 120).setSessionId((short) 0).setTlvs(builder.build()).build(), 0);
 
-               final PCCMock<Message, PCEPSessionImpl, PCEPSessionListener> pcc = new PCCMock<>(snf, new PCEPHandlerFactory(), new DefaultPromise<PCEPSessionImpl>(GlobalEventExecutor.INSTANCE));
+               final PCCMock<Message, PCEPSessionImpl, PCEPSessionListener> pcc = new PCCMock<>(snf,
+                               new PCEPHandlerFactory(SimpleMessageHandlerFactory.INSTANCE),
+                               new DefaultPromise<PCEPSessionImpl>(GlobalEventExecutor.INSTANCE));
 
                pcc.createClient(new InetSocketAddress("127.0.0.3", 12345), new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, 2000),
                                new SessionListenerFactory<PCEPSessionListener>() {
 
-                                       @Override
-                                       public PCEPSessionListener getSessionListener() {
-                                               return new SimpleSessionListener();
-                                       }
-                               }).get();
+                       @Override
+                       public PCEPSessionListener getSessionListener() {
+                               return new SimpleSessionListener();
+                       }
+               }).get();
        }
 }