BUG-113: allow for per-object subobject registries 22/1922/2
authorRobert Varga <rovarga@cisco.com>
Wed, 16 Oct 2013 09:02:35 +0000 (11:02 +0200)
committerRobert Varga <rovarga@cisco.com>
Wed, 16 Oct 2013 09:09:33 +0000 (11:09 +0200)
Change-Id: I19c0576e57cfc7b9a9f8aa4359bf9d23a9105770
Signed-off-by: Robert Varga <rovarga@cisco.com>
26 files changed:
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPImplActivator.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/SingletonPCEPProviderContext.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/AbstractObjectWithSubobjectsParser.java [moved from pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/AbstractObjectParser.java with 59% similarity]
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/AbstractObjectWithTlvsParser.java [new file with mode: 0644]
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/PCEPProviderContext.java

index 08bed1071c54dada044d359613a228f1786e2faf..3e78d319198f97c8721dde2df2625382b229d182 100644 (file)
@@ -99,9 +99,9 @@ public final class PCEPImplActivator implements PCEPProviderActivator {
                Preconditions.checkState(registrations == null);
                final List<AutoCloseable> regs = new ArrayList<>();
 
-               final SubobjectHandlerRegistry subReg = context.getSubobjectHandlerRegistry();
-               subReg.registerSubobjectParser(EROAsNumberSubobjectParser.TYPE, new EROAsNumberSubobjectParser());
-               subReg.registerSubobjectSerializer(AsNumberSubobject.class, new EROAsNumberSubobjectParser());
+               final SubobjectHandlerRegistry eroSubReg = context.getEROSubobjectHandlerRegistry();
+               eroSubReg.registerSubobjectParser(EROAsNumberSubobjectParser.TYPE, new EROAsNumberSubobjectParser());
+               eroSubReg.registerSubobjectSerializer(AsNumberSubobject.class, new EROAsNumberSubobjectParser());
 
                final TlvHandlerRegistry tlvReg = context.getTlvHandlerRegistry();
                tlvReg.registerTlvParser(NoPathVectorTlvParser.TYPE, new NoPathVectorTlvParser());
@@ -132,61 +132,61 @@ public final class PCEPImplActivator implements PCEPProviderActivator {
                tlvReg.registerTlvSerializer(PredundancyGroupIdTlv.class, new PredundancyGroupTlvParser());
 
                final ObjectHandlerRegistry objReg = context.getObjectHandlerRegistry();
-               objReg.registerObjectParser(PCEPOpenObjectParser.CLASS, PCEPOpenObjectParser.TYPE, new PCEPOpenObjectParser(subReg, tlvReg));
+               objReg.registerObjectParser(PCEPOpenObjectParser.CLASS, PCEPOpenObjectParser.TYPE, new PCEPOpenObjectParser(tlvReg));
                objReg.registerObjectParser(PCEPRequestParameterObjectParser.CLASS, PCEPRequestParameterObjectParser.TYPE,
-                               new PCEPRequestParameterObjectParser(subReg, tlvReg));
-               objReg.registerObjectParser(PCEPNoPathObjectParser.CLASS, PCEPNoPathObjectParser.TYPE, new PCEPNoPathObjectParser(subReg, tlvReg));
-               objReg.registerObjectParser(PCEPEndPointsObjectParser.CLASS, PCEPEndPointsObjectParser.TYPE, new PCEPEndPointsObjectParser(subReg, tlvReg));
-               objReg.registerObjectParser(PCEPEndPointsObjectParser.CLASS_6, PCEPEndPointsObjectParser.TYPE_6, new PCEPEndPointsObjectParser(subReg, tlvReg));
-               objReg.registerObjectParser(PCEPBandwidthObjectParser.CLASS, PCEPBandwidthObjectParser.TYPE, new PCEPBandwidthObjectParser(subReg, tlvReg));
-               objReg.registerObjectParser(PCEPBandwidthObjectParser.E_CLASS, PCEPBandwidthObjectParser.E_TYPE, new PCEPBandwidthObjectParser(subReg, tlvReg));
-               objReg.registerObjectParser(PCEPMetricObjectParser.CLASS, PCEPMetricObjectParser.TYPE, new PCEPMetricObjectParser(subReg, tlvReg));
+                               new PCEPRequestParameterObjectParser(tlvReg));
+               objReg.registerObjectParser(PCEPNoPathObjectParser.CLASS, PCEPNoPathObjectParser.TYPE, new PCEPNoPathObjectParser(tlvReg));
+               objReg.registerObjectParser(PCEPEndPointsObjectParser.CLASS, PCEPEndPointsObjectParser.TYPE, new PCEPEndPointsObjectParser(tlvReg));
+               objReg.registerObjectParser(PCEPEndPointsObjectParser.CLASS_6, PCEPEndPointsObjectParser.TYPE_6, new PCEPEndPointsObjectParser(tlvReg));
+               objReg.registerObjectParser(PCEPBandwidthObjectParser.CLASS, PCEPBandwidthObjectParser.TYPE, new PCEPBandwidthObjectParser(tlvReg));
+               objReg.registerObjectParser(PCEPBandwidthObjectParser.E_CLASS, PCEPBandwidthObjectParser.E_TYPE, new PCEPBandwidthObjectParser(tlvReg));
+               objReg.registerObjectParser(PCEPMetricObjectParser.CLASS, PCEPMetricObjectParser.TYPE, new PCEPMetricObjectParser(tlvReg));
                objReg.registerObjectParser(PCEPExplicitRouteObjectParser.CLASS, PCEPExplicitRouteObjectParser.TYPE,
-                               new PCEPExplicitRouteObjectParser(subReg, tlvReg));
+                               new PCEPExplicitRouteObjectParser(context.getEROSubobjectHandlerRegistry()));
                objReg.registerObjectParser(PCEPReportedRouteObjectParser.CLASS, PCEPReportedRouteObjectParser.TYPE,
-                               new PCEPReportedRouteObjectParser(subReg, tlvReg));
-               objReg.registerObjectParser(PCEPLspaObjectParser.CLASS, PCEPLspaObjectParser.TYPE, new PCEPLspaObjectParser(subReg, tlvReg));
+                               new PCEPReportedRouteObjectParser(context.getRROSubobjectHandlerRegistry()));
+               objReg.registerObjectParser(PCEPLspaObjectParser.CLASS, PCEPLspaObjectParser.TYPE, new PCEPLspaObjectParser( tlvReg));
                objReg.registerObjectParser(PCEPIncludeRouteObjectParser.CLASS, PCEPIncludeRouteObjectParser.TYPE,
-                               new PCEPIncludeRouteObjectParser(subReg, tlvReg));
-               objReg.registerObjectParser(PCEPSvecObjectParser.CLASS, PCEPSvecObjectParser.TYPE, new PCEPSvecObjectParser(subReg, tlvReg));
+                               new PCEPIncludeRouteObjectParser(context.getEROSubobjectHandlerRegistry()));
+               objReg.registerObjectParser(PCEPSvecObjectParser.CLASS, PCEPSvecObjectParser.TYPE, new PCEPSvecObjectParser(tlvReg));
                objReg.registerObjectParser(PCEPNotificationObjectParser.CLASS, PCEPNotificationObjectParser.TYPE,
-                               new PCEPNotificationObjectParser(subReg, tlvReg));
-               objReg.registerObjectParser(PCEPErrorObjectParser.CLASS, PCEPErrorObjectParser.TYPE, new PCEPErrorObjectParser(subReg, tlvReg));
+                               new PCEPNotificationObjectParser(tlvReg));
+               objReg.registerObjectParser(PCEPErrorObjectParser.CLASS, PCEPErrorObjectParser.TYPE, new PCEPErrorObjectParser(tlvReg));
                objReg.registerObjectParser(PCEPLoadBalancingObjectParser.CLASS, PCEPLoadBalancingObjectParser.TYPE,
-                               new PCEPLoadBalancingObjectParser(subReg, tlvReg));
-               objReg.registerObjectParser(PCEPCloseObjectParser.CLASS, PCEPCloseObjectParser.TYPE, new PCEPCloseObjectParser(subReg, tlvReg));
-               objReg.registerObjectParser(PCEPPathKeyObjectParser.CLASS, PCEPPathKeyObjectParser.TYPE, new PCEPPathKeyObjectParser(subReg, tlvReg));
+                               new PCEPLoadBalancingObjectParser(tlvReg));
+               objReg.registerObjectParser(PCEPCloseObjectParser.CLASS, PCEPCloseObjectParser.TYPE, new PCEPCloseObjectParser(tlvReg));
+               objReg.registerObjectParser(PCEPPathKeyObjectParser.CLASS, PCEPPathKeyObjectParser.TYPE, new PCEPPathKeyObjectParser(tlvReg));
                objReg.registerObjectParser(PCEPObjectiveFunctionObjectParser.CLASS, PCEPObjectiveFunctionObjectParser.TYPE,
-                               new PCEPObjectiveFunctionObjectParser(subReg, tlvReg));
-               objReg.registerObjectParser(PCEPClassTypeObjectParser.CLASS, PCEPClassTypeObjectParser.TYPE, new PCEPClassTypeObjectParser(subReg, tlvReg));
+                               new PCEPObjectiveFunctionObjectParser(tlvReg));
+               objReg.registerObjectParser(PCEPClassTypeObjectParser.CLASS, PCEPClassTypeObjectParser.TYPE, new PCEPClassTypeObjectParser(tlvReg));
                objReg.registerObjectParser(PCEPGlobalConstraintsObjectParser.CLASS, PCEPGlobalConstraintsObjectParser.TYPE,
-                               new PCEPGlobalConstraintsObjectParser(subReg, tlvReg));
-               objReg.registerObjectParser(PCEPLspObjectParser.CLASS, PCEPLspObjectParser.TYPE, new PCEPLspObjectParser(subReg, tlvReg));
-               objReg.registerObjectParser(PCEPSrpObjectParser.CLASS, PCEPSrpObjectParser.TYPE, new PCEPSrpObjectParser(subReg, tlvReg));
+                               new PCEPGlobalConstraintsObjectParser(tlvReg));
+               objReg.registerObjectParser(PCEPLspObjectParser.CLASS, PCEPLspObjectParser.TYPE, new PCEPLspObjectParser(tlvReg));
+               objReg.registerObjectParser(PCEPSrpObjectParser.CLASS, PCEPSrpObjectParser.TYPE, new PCEPSrpObjectParser(tlvReg));
                // objReg.registerObjectParser(PCEPExcludeRouteObjectParser.CLASS, PCEPExcludeRouteObjectParser.TYPE, new
-               // PCEPExcludeRouteObjectParser(reg));
+               // PCEPExcludeRouteObjectParser(context.getXROSubobjectHandlerRegistry()));
 
-               objReg.registerObjectSerializer(OpenObject.class, new PCEPOpenObjectParser(subReg, tlvReg));
-               objReg.registerObjectSerializer(RpObject.class, new PCEPRequestParameterObjectParser(subReg, tlvReg));
-               objReg.registerObjectSerializer(NoPathObject.class, new PCEPNoPathObjectParser(subReg, tlvReg));
-               objReg.registerObjectSerializer(EndpointsObject.class, new PCEPEndPointsObjectParser(subReg, tlvReg));
-               objReg.registerObjectSerializer(BandwidthObject.class, new PCEPBandwidthObjectParser(subReg, tlvReg));
-               objReg.registerObjectSerializer(MetricObject.class, new PCEPMetricObjectParser(subReg, tlvReg));
-               objReg.registerObjectSerializer(ExplicitRouteObject.class, new PCEPExplicitRouteObjectParser(subReg, tlvReg));
-               objReg.registerObjectSerializer(ReportedRouteObject.class, new PCEPReportedRouteObjectParser(subReg, tlvReg));
-               objReg.registerObjectSerializer(LspaObject.class, new PCEPLspaObjectParser(subReg, tlvReg));
-               objReg.registerObjectSerializer(IncludeRouteObject.class, new PCEPIncludeRouteObjectParser(subReg, tlvReg));
-               objReg.registerObjectSerializer(SvecObject.class, new PCEPSvecObjectParser(subReg, tlvReg));
-               objReg.registerObjectSerializer(NotificationObject.class, new PCEPNotificationObjectParser(subReg, tlvReg));
-               objReg.registerObjectSerializer(PcepErrorObject.class, new PCEPErrorObjectParser(subReg, tlvReg));
-               objReg.registerObjectSerializer(LoadBalancingObject.class, new PCEPLoadBalancingObjectParser(subReg, tlvReg));
-               objReg.registerObjectSerializer(CloseObject.class, new PCEPCloseObjectParser(subReg, tlvReg));
-               objReg.registerObjectSerializer(PathKeyObject.class, new PCEPPathKeyObjectParser(subReg, tlvReg));
-               objReg.registerObjectSerializer(OfObject.class, new PCEPObjectiveFunctionObjectParser(subReg, tlvReg));
-               objReg.registerObjectSerializer(ClasstypeObject.class, new PCEPClassTypeObjectParser(subReg, tlvReg));
-               objReg.registerObjectSerializer(GcObject.class, new PCEPGlobalConstraintsObjectParser(subReg, tlvReg));
-               objReg.registerObjectSerializer(LspObject.class, new PCEPLspObjectParser(subReg, tlvReg));
-               objReg.registerObjectSerializer(SrpObject.class, new PCEPSrpObjectParser(subReg, tlvReg));
+               objReg.registerObjectSerializer(OpenObject.class, new PCEPOpenObjectParser(tlvReg));
+               objReg.registerObjectSerializer(RpObject.class, new PCEPRequestParameterObjectParser(tlvReg));
+               objReg.registerObjectSerializer(NoPathObject.class, new PCEPNoPathObjectParser(tlvReg));
+               objReg.registerObjectSerializer(EndpointsObject.class, new PCEPEndPointsObjectParser(tlvReg));
+               objReg.registerObjectSerializer(BandwidthObject.class, new PCEPBandwidthObjectParser(tlvReg));
+               objReg.registerObjectSerializer(MetricObject.class, new PCEPMetricObjectParser(tlvReg));
+               objReg.registerObjectSerializer(ExplicitRouteObject.class, new PCEPExplicitRouteObjectParser(context.getEROSubobjectHandlerRegistry()));
+               objReg.registerObjectSerializer(ReportedRouteObject.class, new PCEPReportedRouteObjectParser(context.getRROSubobjectHandlerRegistry()));
+               objReg.registerObjectSerializer(LspaObject.class, new PCEPLspaObjectParser(tlvReg));
+               objReg.registerObjectSerializer(IncludeRouteObject.class, new PCEPIncludeRouteObjectParser(context.getEROSubobjectHandlerRegistry()));
+               objReg.registerObjectSerializer(SvecObject.class, new PCEPSvecObjectParser(tlvReg));
+               objReg.registerObjectSerializer(NotificationObject.class, new PCEPNotificationObjectParser(tlvReg));
+               objReg.registerObjectSerializer(PcepErrorObject.class, new PCEPErrorObjectParser(tlvReg));
+               objReg.registerObjectSerializer(LoadBalancingObject.class, new PCEPLoadBalancingObjectParser(tlvReg));
+               objReg.registerObjectSerializer(CloseObject.class, new PCEPCloseObjectParser(tlvReg));
+               objReg.registerObjectSerializer(PathKeyObject.class, new PCEPPathKeyObjectParser(tlvReg));
+               objReg.registerObjectSerializer(OfObject.class, new PCEPObjectiveFunctionObjectParser(tlvReg));
+               objReg.registerObjectSerializer(ClasstypeObject.class, new PCEPClassTypeObjectParser(tlvReg));
+               objReg.registerObjectSerializer(GcObject.class, new PCEPGlobalConstraintsObjectParser(tlvReg));
+               objReg.registerObjectSerializer(LspObject.class, new PCEPLspObjectParser(tlvReg));
+               objReg.registerObjectSerializer(SrpObject.class, new PCEPSrpObjectParser(tlvReg));
                // reg.registerObjectSerializer(ExcludeRouteObject.class, new PCEPExcludeRouteObjectParser(reg));
 
                final MessageHandlerRegistry msgReg = context.getMessageHandlerRegistry();
index 3f99f4961c61181dad61fd3d4284ce234d496369..fcded2e917483c9f86b289a4b0eeacfdb289baa9 100644 (file)
@@ -34,7 +34,9 @@ public final class SingletonPCEPProviderContext implements PCEPProviderContext {
        private final LabelHandlerRegistry labelReg = new SimpleLabelHandlerRegistry();
        private final MessageHandlerRegistry msgReg = new SimpleMessageHandlerRegistry();
        private final ObjectHandlerRegistry objReg = new SimpleObjectHandlerRegistry();
-       private final SubobjectHandlerRegistry subobjReg =  new SimpleSubobjectHandlerFactory();
+       private final SubobjectHandlerRegistry eroSubReg =  new SimpleSubobjectHandlerFactory();
+       private final SubobjectHandlerRegistry rroSubReg =  new SimpleSubobjectHandlerFactory();
+       private final SubobjectHandlerRegistry xroSubReg =  new SimpleSubobjectHandlerFactory();
        private final TlvHandlerRegistry tlvReg = new SimpleTlvHandlerRegistry();
 
        private SingletonPCEPProviderContext() {
@@ -61,8 +63,18 @@ public final class SingletonPCEPProviderContext implements PCEPProviderContext {
        }
 
        @Override
-       public SubobjectHandlerRegistry getSubobjectHandlerRegistry() {
-               return subobjReg;
+       public SubobjectHandlerRegistry getEROSubobjectHandlerRegistry() {
+               return eroSubReg;
+       }
+
+       @Override
+       public SubobjectHandlerRegistry getRROSubobjectHandlerRegistry() {
+               return rroSubReg;
+       }
+
+       @Override
+       public SubobjectHandlerRegistry getXROSubobjectHandlerRegistry() {
+               return xroSubReg;
        }
 
        @Override
index aad6c6409ad3c2627c9837349fa975ef782c96a4..5d0eda91b47c0534e5661d774ce3db4e8c588f09 100644 (file)
@@ -9,8 +9,7 @@ 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.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
 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;
@@ -22,7 +21,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 /**
  * Parser for {@link BandwidthObject}
  */
-public class PCEPBandwidthObjectParser extends AbstractObjectParser<BandwidthBuilder> {
+public class PCEPBandwidthObjectParser extends AbstractObjectWithTlvsParser<BandwidthBuilder> {
 
        public static final int E_CLASS = 5;
 
@@ -34,8 +33,8 @@ public class PCEPBandwidthObjectParser extends AbstractObjectParser<BandwidthBui
 
        private static final int BANDWIDTH_F_LENGTH = 4;
 
-       public PCEPBandwidthObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
-               super(subobjReg, tlvReg);
+       public PCEPBandwidthObjectParser(final TlvHandlerRegistry tlvReg) {
+               super(tlvReg);
        }
 
        @Override
index 75abed44f765a94dc33c7d0e589c794b542d3756..088dfd027de53d5f6dfa58402d9beff0d41b72cd 100644 (file)
@@ -10,8 +10,7 @@ package org.opendaylight.protocol.pcep.impl.object;
 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.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
 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;
@@ -23,7 +22,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 /**
  * Parser for {@link org.opendaylight.protocol.pcep.object.PCEPClassTypeObject PCEPClassTypeObject}
  */
-public class PCEPClassTypeObjectParser extends AbstractObjectParser<ClassTypeBuilder> {
+public class PCEPClassTypeObjectParser extends AbstractObjectWithTlvsParser<ClassTypeBuilder> {
 
        public static final int CLASS = 22;
 
@@ -44,8 +43,8 @@ public class PCEPClassTypeObjectParser extends AbstractObjectParser<ClassTypeBui
         */
        public static final int SIZE = (RESERVED + CT_F_LENGTH) / 8;
 
-       public PCEPClassTypeObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
-               super(subobjReg, tlvReg);
+       public PCEPClassTypeObjectParser(final TlvHandlerRegistry tlvReg) {
+               super(tlvReg);
        }
 
        @Override
index 7ba58f2c230e3bed4475f46c1cb1c9d480717d09..6eac2708da6336347be79ca0b6603dd9beeddf59 100644 (file)
@@ -10,8 +10,7 @@ package org.opendaylight.protocol.pcep.impl.object;
 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.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
 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;
@@ -25,7 +24,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 /**
  * Parser for {@link org.opendaylight.protocol.pcep.object.PCEPCloseObject PCEPCloseObject}
  */
-public class PCEPCloseObjectParser extends AbstractObjectParser<CCloseBuilder> {
+public class PCEPCloseObjectParser extends AbstractObjectWithTlvsParser<CCloseBuilder> {
 
        public static final int CLASS = 15;
 
@@ -48,8 +47,8 @@ public class PCEPCloseObjectParser extends AbstractObjectParser<CCloseBuilder> {
         */
        public static final int TLVS_OFFSET = REASON_F_OFFSET + REASON_F_LENGTH;
 
-       public PCEPCloseObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
-               super(subobjReg, tlvReg);
+       public PCEPCloseObjectParser(final TlvHandlerRegistry tlvReg) {
+               super(tlvReg);
        }
 
        @Override
index 3f0b78f4f52cb578015537b3c918e297a327d7e7..59ecbd4802e96e7a4c13515c1e5ad61f91fe9ffc 100644 (file)
@@ -12,8 +12,7 @@ import org.opendaylight.protocol.concepts.Ipv6Util;
 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.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
 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;
@@ -30,7 +29,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 /**
  * Parser for IPv4 {@link EndpointsObject}
  */
-public class PCEPEndPointsObjectParser extends AbstractObjectParser<EndpointsBuilder> {
+public class PCEPEndPointsObjectParser extends AbstractObjectWithTlvsParser<EndpointsBuilder> {
 
        public static final int CLASS = 4;
 
@@ -55,8 +54,8 @@ 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 SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
-               super(subobjReg, tlvReg);
+       public PCEPEndPointsObjectParser(final TlvHandlerRegistry tlvReg) {
+               super(tlvReg);
        }
 
        @Override
index 5273204fbb2fec8977a540c805853eb261f80cf3..5612f81f9045cdae4a699c62e2f0366dbfc71b60 100644 (file)
@@ -10,8 +10,7 @@ package org.opendaylight.protocol.pcep.impl.object;
 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.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
 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;
@@ -28,7 +27,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 /**
  * Parser for {@link org.opendaylight.protocol.pcep.object.PCEPErrorObject PCEPErrorObject}
  */
-public class PCEPErrorObjectParser extends AbstractObjectParser<ErrorsBuilder> {
+public class PCEPErrorObjectParser extends AbstractObjectWithTlvsParser<ErrorsBuilder> {
 
        public static final int CLASS = 13;
 
@@ -43,8 +42,8 @@ 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 SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
-               super(subobjReg, tlvReg);
+       public PCEPErrorObjectParser(final TlvHandlerRegistry tlvReg) {
+               super(tlvReg);
        }
 
        @Override
index 1f3c87b3ab98deb0d0c050b4f0280cbf2d779fb3..dc8e3362c2f09e1a7d91bbde1e3d441c2e45b79b 100644 (file)
@@ -11,13 +11,11 @@ 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.AbstractObjectWithSubobjectsParser;
 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;
-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.pcep.types.rev131005.explicit.route.object.Subobjects;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.definition.ExplicitRouteBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.CSubobject;
@@ -27,14 +25,14 @@ import com.google.common.collect.Maps;
 /**
  * Parser for {@link ExplicitRouteObject}
  */
-public class PCEPExplicitRouteObjectParser extends AbstractObjectParser<ExplicitRouteBuilder> {
+public class PCEPExplicitRouteObjectParser extends AbstractObjectWithSubobjectsParser<ExplicitRouteBuilder> {
 
        public static final int CLASS = 7;
 
        public static final int TYPE = 1;
 
-       public PCEPExplicitRouteObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
-               super(subobjReg, tlvReg);
+       public PCEPExplicitRouteObjectParser(final SubobjectHandlerRegistry subobjReg) {
+               super(subobjReg);
        }
 
        @Override
@@ -53,11 +51,6 @@ public class PCEPExplicitRouteObjectParser extends AbstractObjectParser<Explicit
                return builder.build();
        }
 
-       @Override
-       public void addTlv(final ExplicitRouteBuilder builder, final Tlv tlv) {
-               // No tlvs defined
-       }
-
        @Override
        public byte[] serializeObject(final Object object) {
                if (!(object instanceof ExplicitRouteObject)) {
index a381f7e63664f5dce319f82059eda08f9dfac9d6..c088927df2a09f24697b636159dc3968bd954cd3 100644 (file)
@@ -9,8 +9,7 @@ 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.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
 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;
@@ -22,7 +21,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 /**
  * Parser for {@link GcObject}
  */
-public class PCEPGlobalConstraintsObjectParser extends AbstractObjectParser<GcBuilder> {
+public class PCEPGlobalConstraintsObjectParser extends AbstractObjectWithTlvsParser<GcBuilder> {
 
        public static final int CLASS = 24;
 
@@ -40,8 +39,8 @@ 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 SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
-               super(subobjReg, tlvReg);
+       public PCEPGlobalConstraintsObjectParser(final TlvHandlerRegistry tlvReg) {
+               super(tlvReg);
        }
 
        @Override
index c5b0fe431930288b43d7d4f5e1c27fb185864982..77e994c3b014f160bac4539937fa1c87e576b69d 100644 (file)
@@ -9,26 +9,24 @@ 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.AbstractObjectWithSubobjectsParser;
 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;
-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.pcep.types.rev131005.lsp.attributes.IncludeRouteBuilder;
 
 /**
  * Parser for {@link IncludeRouteObject}
  */
-public class PCEPIncludeRouteObjectParser extends AbstractObjectParser<IncludeRouteBuilder> {
+public class PCEPIncludeRouteObjectParser extends AbstractObjectWithSubobjectsParser<IncludeRouteBuilder> {
 
        public static final int CLASS = 10;
 
        public static final int TYPE = 1;
 
-       public PCEPIncludeRouteObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
-               super(subobjReg, tlvReg);
+       public PCEPIncludeRouteObjectParser(final SubobjectHandlerRegistry subobjReg) {
+               super(subobjReg);
        }
 
        @Override
@@ -46,11 +44,6 @@ public class PCEPIncludeRouteObjectParser extends AbstractObjectParser<IncludeRo
                return builder.build();
        }
 
-       @Override
-       public void addTlv(final IncludeRouteBuilder builder, final Tlv tlv) {
-               // No tlvs defined
-       }
-
        @Override
        public byte[] serializeObject(final Object object) {
                if (!(object instanceof IncludeRouteObject)) {
index f3be5e7348de3ac5f378461bc6805182327a9249..2508adae57c4b965b00e2b74b515f01868b1efd1 100644 (file)
@@ -9,8 +9,7 @@ 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.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
 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;
@@ -23,7 +22,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 /**
  * Parser for {@link org.opendaylight.protocol.pcep.object.PCEPLoadBalancingObject PCEPLoadBalancingObject}
  */
-public class PCEPLoadBalancingObjectParser extends AbstractObjectParser<LoadBalancingBuilder> {
+public class PCEPLoadBalancingObjectParser extends AbstractObjectWithTlvsParser<LoadBalancingBuilder> {
 
        public static final int CLASS = 14;
 
@@ -39,8 +38,8 @@ public class PCEPLoadBalancingObjectParser extends AbstractObjectParser<LoadBala
 
        public static final int SIZE = MIN_BAND_F_OFFSET + MIN_BAND_F_LENGTH;
 
-       public PCEPLoadBalancingObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
-               super(subobjReg, tlvReg);
+       public PCEPLoadBalancingObjectParser(final TlvHandlerRegistry tlvReg) {
+               super(tlvReg);
        }
 
        @Override
index 623340ccb927725ca3d1d35b6fed239a1d1af4fb..0a236ff104fd66c8e40562584bf79c605af8038f 100644 (file)
@@ -11,8 +11,7 @@ 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.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
 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;
@@ -24,7 +23,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 /**
  * Parser for {@link org.opendaylight.protocol.pcep.object.PCEPLspObject PCEPLspObject}
  */
-public class PCEPLspObjectParser extends AbstractObjectParser<LspBuilder> {
+public class PCEPLspObjectParser extends AbstractObjectWithTlvsParser<LspBuilder> {
 
        public static final int CLASS = 32;
 
@@ -44,8 +43,8 @@ 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 SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
-               super(subobjReg, tlvReg);
+       public PCEPLspObjectParser(final TlvHandlerRegistry tlvReg) {
+               super(tlvReg);
        }
 
        @Override
index dd4064caeef8e9ecf5eec6c3d3cf65a89e20d0c7..1a0edc317186ab3ba9effb5c7b08f6dd89ad223a 100644 (file)
@@ -11,8 +11,7 @@ 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.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
 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;
@@ -25,7 +24,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev
 /**
  * Parser for {@link LspaObject}
  */
-public class PCEPLspaObjectParser extends AbstractObjectParser<LspaBuilder> {
+public class PCEPLspaObjectParser extends AbstractObjectWithTlvsParser<LspaBuilder> {
 
        public static final int CLASS = 9;
 
@@ -58,8 +57,8 @@ 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 SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
-               super(subobjReg, tlvReg);
+       public PCEPLspaObjectParser(final TlvHandlerRegistry tlvReg) {
+               super(tlvReg);
        }
 
        @Override
index f1a5f40675171b2952219ad28bc85c70af1239ae..21d534877183424f17e8f8c61aed3b08031c474b 100644 (file)
@@ -11,8 +11,7 @@ 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.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
 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;
@@ -26,7 +25,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 /**
  * Parser for {@link org.opendaylight.protocol.pcep.object.PCEPMetricObject PCEPMetricObject}
  */
-public class PCEPMetricObjectParser extends AbstractObjectParser<MetricBuilder> {
+public class PCEPMetricObjectParser extends AbstractObjectWithTlvsParser<MetricBuilder> {
 
        public static final int CLASS = 6;
 
@@ -54,8 +53,8 @@ public class PCEPMetricObjectParser extends AbstractObjectParser<MetricBuilder>
 
        public static final int SIZE = METRIC_VALUE_F_OFFSET + METRIC_VALUE_F_LENGTH;
 
-       public PCEPMetricObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
-               super(subobjReg, tlvReg);
+       public PCEPMetricObjectParser(final TlvHandlerRegistry tlvReg) {
+               super(tlvReg);
        }
 
        @Override
index bbf06a8adccc43ea225991c9bda5f061e35b4f36..a565b635205976dc9bd87fa616315e95936418d4 100644 (file)
@@ -12,8 +12,7 @@ import java.util.BitSet;
 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.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
 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;
@@ -27,7 +26,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 /**
  * Parser for {@link NoPathObject}
  */
-public class PCEPNoPathObjectParser extends AbstractObjectParser<NoPathBuilder> {
+public class PCEPNoPathObjectParser extends AbstractObjectWithTlvsParser<NoPathBuilder> {
 
        public static final int CLASS = 3;
 
@@ -55,8 +54,8 @@ public class PCEPNoPathObjectParser extends AbstractObjectParser<NoPathBuilder>
 
        public static final int C_FLAG_OFFSET = 0;
 
-       public PCEPNoPathObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
-               super(subobjReg, tlvReg);
+       public PCEPNoPathObjectParser(final TlvHandlerRegistry tlvReg) {
+               super(tlvReg);
        }
 
        @Override
index da652bf855196c7d44ae785c2bf137e74ac6a34b..cfe395b28b642d7c478542128437f2133908070f 100644 (file)
@@ -10,8 +10,7 @@ package org.opendaylight.protocol.pcep.impl.object;
 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.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
 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;
@@ -27,7 +26,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 /**
  * Parser for {@link NotificationObject}
  */
-public class PCEPNotificationObjectParser extends AbstractObjectParser<NotificationsBuilder> {
+public class PCEPNotificationObjectParser extends AbstractObjectWithTlvsParser<NotificationsBuilder> {
 
        public static final int CLASS = 12;
 
@@ -48,8 +47,8 @@ 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 SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
-               super(subobjReg, tlvReg);
+       public PCEPNotificationObjectParser(final TlvHandlerRegistry tlvReg) {
+               super(tlvReg);
        }
 
        @Override
index 9e2ffa3091a75941e5f9aeced7f6a4053c537147..0d9f03324f63a8095b4b06c136f7ec1db392ca0d 100644 (file)
@@ -9,8 +9,7 @@ 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.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
 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;
@@ -23,7 +22,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 /**
  * Parser for {@link OfObject}
  */
-public class PCEPObjectiveFunctionObjectParser extends AbstractObjectParser<OfBuilder> {
+public class PCEPObjectiveFunctionObjectParser extends AbstractObjectWithTlvsParser<OfBuilder> {
 
        public static final int CLASS = 21;
 
@@ -39,8 +38,8 @@ 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 SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
-               super(subobjReg, tlvReg);
+       public PCEPObjectiveFunctionObjectParser(final TlvHandlerRegistry tlvReg) {
+               super(tlvReg);
        }
 
        @Override
index 9adf9d2c643698b3feef7156479fc09ce4c400be..8c2e063368028089b111b421a5872b7dcbfc59d2 100644 (file)
@@ -12,8 +12,7 @@ import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 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.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
 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;
@@ -39,7 +38,7 @@ import com.google.common.primitives.UnsignedBytes;
  * Parser for {@link OpenObject}
  */
 
-public class PCEPOpenObjectParser extends AbstractObjectParser<OpenBuilder> {
+public class PCEPOpenObjectParser extends AbstractObjectWithTlvsParser<OpenBuilder> {
 
        public static final int CLASS = 1;
 
@@ -78,8 +77,8 @@ public class PCEPOpenObjectParser extends AbstractObjectParser<OpenBuilder> {
 
        private static final int PCEP_VERSION = 1;
 
-       public PCEPOpenObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
-               super(subobjReg, tlvReg);
+       public PCEPOpenObjectParser(final TlvHandlerRegistry tlvReg) {
+               super(tlvReg);
        }
 
        @Override
index a865e9f5780c919ed4dca66c83eb1c7e24c6788c..d47b78bb537be3463c40a10c9127505217280908 100644 (file)
@@ -9,8 +9,7 @@ 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.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
 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;
@@ -21,14 +20,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 /**
  * Parser for {@link PathKeyObject}
  */
-public class PCEPPathKeyObjectParser extends AbstractObjectParser<PathKeyBuilder> {
+public class PCEPPathKeyObjectParser extends AbstractObjectWithTlvsParser<PathKeyBuilder> {
 
        public static final int CLASS = 16;
 
        public static final int TYPE = 1;
 
-       public PCEPPathKeyObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
-               super(subobjReg, tlvReg);
+       public PCEPPathKeyObjectParser(final TlvHandlerRegistry tlvReg) {
+               super(tlvReg);
        }
 
        @Override
index 4b0408dd4df569e1c33fb259beeee3765c1c175f..a9bcb769d91df984515648898b139df97fbc3843 100644 (file)
@@ -9,26 +9,24 @@ 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.AbstractObjectWithSubobjectsParser;
 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;
-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.pcep.types.rev131005.pcreq.message.pcreq.message.requests.segment.computation.p2p.ReportedRouteBuilder;
 
 /**
  * Parser for {@link ReportedRouteObject}
  */
-public class PCEPReportedRouteObjectParser extends AbstractObjectParser<ReportedRouteBuilder> {
+public class PCEPReportedRouteObjectParser extends AbstractObjectWithSubobjectsParser<ReportedRouteBuilder> {
 
        public static final int CLASS = 8;
 
        public static final int TYPE = 1;
 
-       public PCEPReportedRouteObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
-               super(subobjReg, tlvReg);
+       public PCEPReportedRouteObjectParser(final SubobjectHandlerRegistry subobjReg) {
+               super(subobjReg);
        }
 
        @Override
@@ -46,11 +44,6 @@ public class PCEPReportedRouteObjectParser extends AbstractObjectParser<Reported
                return builder.build();
        }
 
-       @Override
-       public void addTlv(final ReportedRouteBuilder builder, final Tlv tlv) {
-               // No tlvs defined
-       }
-
        @Override
        public byte[] serializeObject(final Object object) {
                if (!(object instanceof ReportedRouteObject)) {
index 7e177131769d458b9ea71d7696f10f903d405727..acc5b1eecde4ea8f37b204dae0a7ef073331d4c4 100644 (file)
@@ -14,8 +14,7 @@ import java.util.BitSet;
 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.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
 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;
@@ -33,7 +32,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
  * Parser for {@link RpObject}
  */
 
-public class PCEPRequestParameterObjectParser extends AbstractObjectParser<RpBuilder> {
+public class PCEPRequestParameterObjectParser extends AbstractObjectWithTlvsParser<RpBuilder> {
 
        public static final int CLASS = 2;
 
@@ -95,8 +94,8 @@ public class PCEPRequestParameterObjectParser extends AbstractObjectParser<RpBui
 
        private static int E_FLAG_OFFSET = 20;
 
-       public PCEPRequestParameterObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
-               super(subobjReg, tlvReg);
+       public PCEPRequestParameterObjectParser(final TlvHandlerRegistry tlvReg) {
+               super(tlvReg);
        }
 
        @Override
index d8087f36a128adb510adb56cafe9df23168ba57a..a606587aac3f4bdb6d0a6755f8ce83de37ad69c3 100644 (file)
@@ -9,8 +9,7 @@ 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.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
 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;
@@ -18,14 +17,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 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.pcep.types.rev131005.pcinitiate.message.pcinitiate.message.requests.SrpBuilder;
 
-public final class PCEPSrpObjectParser extends AbstractObjectParser<SrpBuilder> {
+public final class PCEPSrpObjectParser extends AbstractObjectWithTlvsParser<SrpBuilder> {
 
        public static final int CLASS = 33;
 
        public static final int TYPE = 1;
 
-       public PCEPSrpObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
-               super(subobjReg, tlvReg);
+       public PCEPSrpObjectParser(final TlvHandlerRegistry tlvReg) {
+               super(tlvReg);
        }
 
        @Override
index b5079bd8543265ccc4373fe1c8042c444957482e..2dfd0dd8abb359126c7a91dcd819785cdc06074d 100644 (file)
@@ -12,8 +12,7 @@ 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.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
 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;
@@ -28,7 +27,7 @@ import com.google.common.collect.Lists;
 /**
  * Parser for {@link SvecObject}
  */
-public class PCEPSvecObjectParser extends AbstractObjectParser<SvecBuilder> {
+public class PCEPSvecObjectParser extends AbstractObjectWithTlvsParser<SvecBuilder> {
 
        public static final int CLASS = 11;
 
@@ -58,8 +57,8 @@ public class PCEPSvecObjectParser extends AbstractObjectParser<SvecBuilder> {
         */
        public static final int MIN_SIZE = FLAGS_F_LENGTH + FLAGS_F_OFFSET;
 
-       public PCEPSvecObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
-               super(subobjReg, tlvReg);
+       public PCEPSvecObjectParser(final TlvHandlerRegistry tlvReg) {
+               super(tlvReg);
        }
 
        @Override
similarity index 59%
rename from pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/AbstractObjectParser.java
rename to pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/AbstractObjectWithSubobjectsParser.java
index ca2fe202da2a4a42a317b1549d645846e5439916..7daaf988dd1c6779eb9573bec6fb8f1d013748a9 100644 (file)
@@ -13,7 +13,6 @@ import java.util.Map.Entry;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.util.ByteArray;
-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;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -22,13 +21,9 @@ import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 
-public abstract class AbstractObjectParser<BUILDER> implements ObjectParser, ObjectSerializer {
+public abstract class AbstractObjectWithSubobjectsParser<BUILDER> implements ObjectParser, ObjectSerializer {
 
-       private static final Logger logger = LoggerFactory.getLogger(AbstractObjectParser.class);
-
-       private static final int TLV_TYPE_F_LENGTH = 2;
-       private static final int TLV_LENGTH_F_LENGTH = 2;
-       private static final int TLV_HEADER_LENGTH = TLV_LENGTH_F_LENGTH + TLV_TYPE_F_LENGTH;
+       private static final Logger logger = LoggerFactory.getLogger(AbstractObjectWithSubobjectsParser.class);
 
        private static final int SUB_TYPE_FLAG_F_LENGTH = 1;
        private static final int SUB_LENGTH_F_LENGTH = 1;
@@ -41,62 +36,9 @@ public abstract class AbstractObjectParser<BUILDER> implements ObjectParser, Obj
        protected static final int PADDED_TO = 4;
 
        private final SubobjectHandlerRegistry subobjReg;
-       private final TlvHandlerRegistry tlvReg;
 
-       protected AbstractObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+       protected AbstractObjectWithSubobjectsParser(final SubobjectHandlerRegistry subobjReg) {
                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) {
-                       throw new IllegalArgumentException("Byte array is mandatory.");
-               }
-
-               int length;
-               int byteOffset = 0;
-               int type = 0;
-
-               while (byteOffset < bytes.length) {
-                       type = ByteArray.bytesToInt(ByteArray.subByte(bytes, byteOffset, TLV_TYPE_F_LENGTH));
-                       byteOffset += TLV_TYPE_F_LENGTH;
-                       length = ByteArray.bytesToInt(ByteArray.subByte(bytes, byteOffset, TLV_LENGTH_F_LENGTH));
-                       byteOffset += TLV_LENGTH_F_LENGTH;
-
-                       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.tlvReg.getTlvParser(type).parseTlv(tlvBytes);
-                       logger.trace("Tlv was parsed. {}", tlv);
-
-                       addTlv(builder, tlv);
-
-                       byteOffset += length + getPadding(TLV_HEADER_LENGTH + length, PADDED_TO);
-               }
-       }
-
-       protected final byte[] serializeTlv(final Tlv tlv) {
-
-               final TlvSerializer serializer = this.tlvReg.getTlvSerializer(tlv);
-
-               final byte[] typeBytes = (ByteArray.cutBytes(ByteArray.intToBytes(serializer.getType()), (Integer.SIZE / 8) - TLV_TYPE_F_LENGTH));
-
-               final byte[] valueBytes = serializer.serializeTlv(tlv);
-
-               final byte[] lengthBytes = ByteArray.cutBytes(ByteArray.intToBytes(valueBytes.length), (Integer.SIZE / 8) - TLV_LENGTH_F_LENGTH);
-
-               final byte[] bytes = new byte[TLV_HEADER_LENGTH + valueBytes.length + getPadding(TLV_HEADER_LENGTH + valueBytes.length, PADDED_TO)];
-
-               int byteOffset = 0;
-               System.arraycopy(typeBytes, 0, bytes, byteOffset, TLV_TYPE_F_LENGTH);
-               System.arraycopy(lengthBytes, 0, bytes, byteOffset += TLV_TYPE_F_LENGTH, TLV_LENGTH_F_LENGTH);
-               System.arraycopy(valueBytes, 0, bytes, byteOffset += TLV_LENGTH_F_LENGTH, valueBytes.length);
-               return bytes;
        }
 
        protected final void parseSubobjects(final BUILDER builder, final byte[] bytes) throws PCEPDeserializerException {
@@ -178,9 +120,4 @@ public abstract class AbstractObjectParser<BUILDER> implements ObjectParser, Obj
 
        // public abstract void addSubobject(final BUILDER builder, final Map<CSubobject, Boolean> subobjects);
 
-       public abstract void addTlv(final BUILDER builder, final Tlv tlv);
-
-       private static int getPadding(final int length, final int padding) {
-               return (padding - (length % padding)) % padding;
-       }
 }
diff --git a/pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/AbstractObjectWithTlvsParser.java b/pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/AbstractObjectWithTlvsParser.java
new file mode 100644 (file)
index 0000000..b4ec3f7
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * 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.protocol.pcep.PCEPDeserializerException;
+import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Preconditions;
+
+public abstract class AbstractObjectWithTlvsParser<BUILDER> implements ObjectParser, ObjectSerializer {
+
+       private static final Logger logger = LoggerFactory.getLogger(AbstractObjectWithTlvsParser.class);
+
+       private static final int TLV_TYPE_F_LENGTH = 2;
+       private static final int TLV_LENGTH_F_LENGTH = 2;
+       private static final int TLV_HEADER_LENGTH = TLV_LENGTH_F_LENGTH + TLV_TYPE_F_LENGTH;
+
+       protected static final int PADDED_TO = 4;
+
+       private final TlvHandlerRegistry tlvReg;
+
+       protected AbstractObjectWithTlvsParser(final TlvHandlerRegistry tlvReg) {
+               this.tlvReg = Preconditions.checkNotNull(tlvReg);
+       }
+
+       protected final void parseTlvs(final BUILDER builder, final byte[] bytes) throws PCEPDeserializerException {
+               if (bytes == null) {
+                       throw new IllegalArgumentException("Byte array is mandatory.");
+               }
+
+               int length;
+               int byteOffset = 0;
+               int type = 0;
+
+               while (byteOffset < bytes.length) {
+                       type = ByteArray.bytesToInt(ByteArray.subByte(bytes, byteOffset, TLV_TYPE_F_LENGTH));
+                       byteOffset += TLV_TYPE_F_LENGTH;
+                       length = ByteArray.bytesToInt(ByteArray.subByte(bytes, byteOffset, TLV_LENGTH_F_LENGTH));
+                       byteOffset += TLV_LENGTH_F_LENGTH;
+
+                       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.tlvReg.getTlvParser(type).parseTlv(tlvBytes);
+                       logger.trace("Tlv was parsed. {}", tlv);
+
+                       addTlv(builder, tlv);
+
+                       byteOffset += length + getPadding(TLV_HEADER_LENGTH + length, PADDED_TO);
+               }
+       }
+
+       protected final byte[] serializeTlv(final Tlv tlv) {
+
+               final TlvSerializer serializer = this.tlvReg.getTlvSerializer(tlv);
+
+               final byte[] typeBytes = (ByteArray.cutBytes(ByteArray.intToBytes(serializer.getType()), (Integer.SIZE / 8) - TLV_TYPE_F_LENGTH));
+
+               final byte[] valueBytes = serializer.serializeTlv(tlv);
+
+               final byte[] lengthBytes = ByteArray.cutBytes(ByteArray.intToBytes(valueBytes.length), (Integer.SIZE / 8) - TLV_LENGTH_F_LENGTH);
+
+               final byte[] bytes = new byte[TLV_HEADER_LENGTH + valueBytes.length + getPadding(TLV_HEADER_LENGTH + valueBytes.length, PADDED_TO)];
+
+               int byteOffset = 0;
+               System.arraycopy(typeBytes, 0, bytes, byteOffset, TLV_TYPE_F_LENGTH);
+               System.arraycopy(lengthBytes, 0, bytes, byteOffset += TLV_TYPE_F_LENGTH, TLV_LENGTH_F_LENGTH);
+               System.arraycopy(valueBytes, 0, bytes, byteOffset += TLV_LENGTH_F_LENGTH, valueBytes.length);
+               return bytes;
+       }
+
+       public abstract void addTlv(final BUILDER builder, final Tlv tlv);
+
+       private static int getPadding(final int length, final int padding) {
+               return (padding - (length % padding)) % padding;
+       }
+}
index 58ae54f41ac22c41dd7f6b4cd49abe2d8a2f3cfe..a15204760f9cd240a18df3a40a46741e60a0f5e8 100644 (file)
@@ -14,6 +14,8 @@ public interface PCEPProviderContext {
        public LabelHandlerRegistry getHandlerRegistry();
        public MessageHandlerRegistry getMessageHandlerRegistry();
        public ObjectHandlerRegistry getObjectHandlerRegistry();
-       public SubobjectHandlerRegistry getSubobjectHandlerRegistry();
+       public SubobjectHandlerRegistry getEROSubobjectHandlerRegistry();
+       public SubobjectHandlerRegistry getRROSubobjectHandlerRegistry();
+       public SubobjectHandlerRegistry getXROSubobjectHandlerRegistry();
        public TlvHandlerRegistry getTlvHandlerRegistry();
 }