BUG-50 : adjusted Metric object.
[bgpcep.git] / pcep / impl / src / main / java / org / opendaylight / protocol / pcep / impl / Activator.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.protocol.pcep.impl;
9
10 import java.util.ArrayList;
11 import java.util.List;
12
13 import org.opendaylight.protocol.pcep.impl.message.PCCreateMessageParser;
14 import org.opendaylight.protocol.pcep.impl.message.PCEPCloseMessageParser;
15 import org.opendaylight.protocol.pcep.impl.message.PCEPErrorMessageParser;
16 import org.opendaylight.protocol.pcep.impl.message.PCEPKeepAliveMessageParser;
17 import org.opendaylight.protocol.pcep.impl.message.PCEPNotificationMessageParser;
18 import org.opendaylight.protocol.pcep.impl.message.PCEPOpenMessageParser;
19 import org.opendaylight.protocol.pcep.impl.message.PCEPReplyMessageParser;
20 import org.opendaylight.protocol.pcep.impl.message.PCEPReportMessageParser;
21 import org.opendaylight.protocol.pcep.impl.message.PCEPRequestMessageParser;
22 import org.opendaylight.protocol.pcep.impl.message.PCEPUpdateRequestMessageParser;
23 import org.opendaylight.protocol.pcep.impl.object.PCEPBandwidthObjectParser;
24 import org.opendaylight.protocol.pcep.impl.object.PCEPClassTypeObjectParser;
25 import org.opendaylight.protocol.pcep.impl.object.PCEPCloseObjectParser;
26 import org.opendaylight.protocol.pcep.impl.object.PCEPEndPointsObjectParser;
27 import org.opendaylight.protocol.pcep.impl.object.PCEPErrorObjectParser;
28 import org.opendaylight.protocol.pcep.impl.object.PCEPExcludeRouteObjectParser;
29 import org.opendaylight.protocol.pcep.impl.object.PCEPExplicitRouteObjectParser;
30 import org.opendaylight.protocol.pcep.impl.object.PCEPGlobalConstraintsObjectParser;
31 import org.opendaylight.protocol.pcep.impl.object.PCEPIncludeRouteObjectParser;
32 import org.opendaylight.protocol.pcep.impl.object.PCEPLoadBalancingObjectParser;
33 import org.opendaylight.protocol.pcep.impl.object.PCEPLspObjectParser;
34 import org.opendaylight.protocol.pcep.impl.object.PCEPLspaObjectParser;
35 import org.opendaylight.protocol.pcep.impl.object.PCEPMetricObjectParser;
36 import org.opendaylight.protocol.pcep.impl.object.PCEPNoPathObjectParser;
37 import org.opendaylight.protocol.pcep.impl.object.PCEPNotificationObjectParser;
38 import org.opendaylight.protocol.pcep.impl.object.PCEPObjectiveFunctionObjectParser;
39 import org.opendaylight.protocol.pcep.impl.object.PCEPOpenObjectParser;
40 import org.opendaylight.protocol.pcep.impl.object.PCEPPathKeyObjectParser;
41 import org.opendaylight.protocol.pcep.impl.object.PCEPReportedRouteObjectParser;
42 import org.opendaylight.protocol.pcep.impl.object.PCEPRequestParameterObjectParser;
43 import org.opendaylight.protocol.pcep.impl.object.PCEPSrpObjectParser;
44 import org.opendaylight.protocol.pcep.impl.object.PCEPSvecObjectParser;
45 import org.opendaylight.protocol.pcep.impl.subobject.EROAsNumberSubobjectParser;
46 import org.opendaylight.protocol.pcep.impl.subobject.EROIpPrefixSubobjectParser;
47 import org.opendaylight.protocol.pcep.impl.subobject.EROLabelSubobjectParser;
48 import org.opendaylight.protocol.pcep.impl.subobject.EROPathKeySubobjectParser;
49 import org.opendaylight.protocol.pcep.impl.subobject.EROUnnumberedInterfaceSubobjectParser;
50 import org.opendaylight.protocol.pcep.impl.subobject.GeneralizedLabelParser;
51 import org.opendaylight.protocol.pcep.impl.subobject.RROIpPrefixSubobjectParser;
52 import org.opendaylight.protocol.pcep.impl.subobject.RROLabelSubobjectParser;
53 import org.opendaylight.protocol.pcep.impl.subobject.RROPathKeySubobjectParser;
54 import org.opendaylight.protocol.pcep.impl.subobject.RROUnnumberedInterfaceSubobjectParser;
55 import org.opendaylight.protocol.pcep.impl.subobject.Type1LabelParser;
56 import org.opendaylight.protocol.pcep.impl.subobject.WavebandSwitchingLabelParser;
57 import org.opendaylight.protocol.pcep.impl.subobject.XROAsNumberSubobjectParser;
58 import org.opendaylight.protocol.pcep.impl.subobject.XROIpPrefixSubobjectParser;
59 import org.opendaylight.protocol.pcep.impl.subobject.XROPathKeySubobjectParser;
60 import org.opendaylight.protocol.pcep.impl.subobject.XROSRLGSubobjectParser;
61 import org.opendaylight.protocol.pcep.impl.subobject.XROUnnumberedInterfaceSubobjectParser;
62 import org.opendaylight.protocol.pcep.impl.tlv.LSPIdentifierTlvParser;
63 import org.opendaylight.protocol.pcep.impl.tlv.LspDbVersionTlvParser;
64 import org.opendaylight.protocol.pcep.impl.tlv.LspSymbolicNameTlvParser;
65 import org.opendaylight.protocol.pcep.impl.tlv.LspUpdateErrorTlvParser;
66 import org.opendaylight.protocol.pcep.impl.tlv.NoPathVectorTlvParser;
67 import org.opendaylight.protocol.pcep.impl.tlv.OFListTlvParser;
68 import org.opendaylight.protocol.pcep.impl.tlv.OrderTlvParser;
69 import org.opendaylight.protocol.pcep.impl.tlv.OverloadedDurationTlvParser;
70 import org.opendaylight.protocol.pcep.impl.tlv.PCEStatefulCapabilityTlvParser;
71 import org.opendaylight.protocol.pcep.impl.tlv.PredundancyGroupTlvParser;
72 import org.opendaylight.protocol.pcep.impl.tlv.RSVPErrorSpecTlvParser;
73 import org.opendaylight.protocol.pcep.impl.tlv.ReqMissingTlvParser;
74 import org.opendaylight.protocol.pcep.spi.EROSubobjectHandlerRegistry;
75 import org.opendaylight.protocol.pcep.spi.LabelHandlerRegistry;
76 import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
77 import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderActivator;
78 import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderContext;
79 import org.opendaylight.protocol.pcep.spi.RROSubobjectHandlerRegistry;
80 import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
81 import org.opendaylight.protocol.pcep.spi.XROSubobjectHandlerRegistry;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.CloseMessage;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.KeepaliveMessage;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NoPathObject;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OpenMessage;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcerrMessage;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcinitiateMessage;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcntfMessage;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcrepMessage;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcreqMessage;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcrptMessage;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcupdMessage;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ReportedRouteObject;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.SvecObject;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.bandwidth.object.Bandwidth;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.classtype.object.ClassType;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.object.CClose;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.object.EndpointsObj;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.Xro;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Ero;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.subobjects.subobject.type.PathKey;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.gc.object.Gc;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.include.route.object.Iro;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.load.balancing.object.LoadBalancing;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.db.version.tlv.LspDbVersion;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.error.code.tlv.LspErrorCode;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.identifiers.tlv.LspIdentifiers;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.object.Lsp;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lspa.object.Lspa;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.metric.object.Metric;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.CNotification;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.list.tlv.OfList;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.object.Of;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.order.tlv.Order;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.overload.duration.tlv.OverloadDuration;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.ErrorObject;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure.no.path.tlvs.NoPathVector;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.predundancy.group.id.tlv.PredundancyGroupId;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.req.missing.tlv.ReqMissing;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rsvp.error.spec.tlv.RsvpErrorSpec;
123 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.srp.object.Srp;
124 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.Stateful;
125 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.symbolic.path.name.tlv.SymbolicPathName;
126 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.subobject.type.AsNumber;
127 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.subobject.type.IpPrefix;
128 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.subobject.type.Label;
129 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.subobject.type.Srlg;
130 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.subobject.type.Unnumbered;
131 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.label.subobject.label.type.GeneralizedLabel;
132 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.label.subobject.label.type.Type1Label;
133 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.label.subobject.label.type.WavebandSwitchingLabel;
134 import org.slf4j.Logger;
135 import org.slf4j.LoggerFactory;
136
137 import com.google.common.base.Preconditions;
138
139 public final class Activator implements PCEPExtensionProviderActivator {
140         private static final Logger logger = LoggerFactory.getLogger(Activator.class);
141         private List<AutoCloseable> registrations;
142
143         @Override
144         public void start(final PCEPExtensionProviderContext context) {
145                 Preconditions.checkState(this.registrations == null);
146                 final List<AutoCloseable> regs = new ArrayList<>();
147
148                 final LabelHandlerRegistry labelReg = context.getLabelHandlerRegistry();
149                 context.registerLabelParser(Type1LabelParser.CTYPE, new Type1LabelParser());
150                 context.registerLabelParser(GeneralizedLabelParser.CTYPE, new GeneralizedLabelParser());
151                 context.registerLabelParser(WavebandSwitchingLabelParser.CTYPE, new WavebandSwitchingLabelParser());
152
153                 context.registerLabelSerializer(Type1Label.class, new Type1LabelParser());
154                 context.registerLabelSerializer(GeneralizedLabel.class, new GeneralizedLabelParser());
155                 context.registerLabelSerializer(WavebandSwitchingLabel.class, new WavebandSwitchingLabelParser());
156
157                 final EROSubobjectHandlerRegistry eroSubReg = context.getEROSubobjectHandlerRegistry();
158                 context.registerEROSubobjectParser(EROIpPrefixSubobjectParser.TYPE, new EROIpPrefixSubobjectParser());
159                 context.registerEROSubobjectParser(EROIpPrefixSubobjectParser.TYPE6, new EROIpPrefixSubobjectParser());
160                 context.registerEROSubobjectParser(EROAsNumberSubobjectParser.TYPE, new EROAsNumberSubobjectParser());
161                 context.registerEROSubobjectParser(EROLabelSubobjectParser.TYPE, new EROLabelSubobjectParser(labelReg));
162                 context.registerEROSubobjectParser(EROUnnumberedInterfaceSubobjectParser.TYPE, new EROUnnumberedInterfaceSubobjectParser());
163                 context.registerEROSubobjectParser(EROPathKeySubobjectParser.TYPE, new EROPathKeySubobjectParser());
164                 context.registerEROSubobjectParser(EROPathKeySubobjectParser.TYPE128, new EROPathKeySubobjectParser());
165
166                 context.registerEROSubobjectSerializer(IpPrefix.class, new EROIpPrefixSubobjectParser());
167                 context.registerEROSubobjectSerializer(AsNumber.class, new EROAsNumberSubobjectParser());
168                 context.registerEROSubobjectSerializer(Label.class, new EROLabelSubobjectParser(labelReg));
169                 context.registerEROSubobjectSerializer(Unnumbered.class, new EROUnnumberedInterfaceSubobjectParser());
170                 context.registerEROSubobjectSerializer(
171                                 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.subobjects.subobject.type.PathKey.class,
172                                 new EROPathKeySubobjectParser());
173
174                 final RROSubobjectHandlerRegistry rroSubReg = context.getRROSubobjectHandlerRegistry();
175                 context.registerRROSubobjectParser(RROIpPrefixSubobjectParser.TYPE, new RROIpPrefixSubobjectParser());
176                 context.registerRROSubobjectParser(RROIpPrefixSubobjectParser.TYPE6, new RROIpPrefixSubobjectParser());
177                 context.registerRROSubobjectParser(RROLabelSubobjectParser.TYPE, new RROLabelSubobjectParser(labelReg));
178                 context.registerRROSubobjectParser(RROUnnumberedInterfaceSubobjectParser.TYPE, new RROUnnumberedInterfaceSubobjectParser());
179                 context.registerRROSubobjectParser(RROPathKeySubobjectParser.TYPE, new RROPathKeySubobjectParser());
180                 context.registerRROSubobjectParser(RROPathKeySubobjectParser.TYPE128, new RROPathKeySubobjectParser());
181
182                 context.registerRROSubobjectSerializer(
183                                 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.record.route.subobjects.subobject.type.IpPrefix.class,
184                                 new RROIpPrefixSubobjectParser());
185                 context.registerRROSubobjectSerializer(
186                                 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.record.route.subobjects.subobject.type.Label.class,
187                                 new RROLabelSubobjectParser(labelReg));
188                 context.registerRROSubobjectSerializer(
189                                 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.record.route.subobjects.subobject.type.Unnumbered.class,
190                                 new RROUnnumberedInterfaceSubobjectParser());
191                 context.registerRROSubobjectSerializer(
192                                 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.subobjects.subobject.type.PathKey.class,
193                                 new RROPathKeySubobjectParser());
194
195                 final XROSubobjectHandlerRegistry xroSubReg = context.getXROSubobjectHandlerRegistry();
196                 context.registerXROSubobjectParser(XROIpPrefixSubobjectParser.TYPE, new XROIpPrefixSubobjectParser());
197                 context.registerXROSubobjectParser(XROIpPrefixSubobjectParser.TYPE6, new XROIpPrefixSubobjectParser());
198                 context.registerXROSubobjectParser(XROAsNumberSubobjectParser.TYPE, new XROAsNumberSubobjectParser());
199                 context.registerXROSubobjectParser(XROSRLGSubobjectParser.TYPE, new XROSRLGSubobjectParser());
200                 context.registerXROSubobjectParser(XROUnnumberedInterfaceSubobjectParser.TYPE, new XROUnnumberedInterfaceSubobjectParser());
201                 context.registerXROSubobjectParser(XROPathKeySubobjectParser.TYPE, new XROPathKeySubobjectParser());
202                 context.registerXROSubobjectParser(XROPathKeySubobjectParser.TYPE128, new XROPathKeySubobjectParser());
203
204                 context.registerXROSubobjectSerializer(IpPrefix.class, new XROIpPrefixSubobjectParser());
205                 context.registerXROSubobjectSerializer(AsNumber.class, new XROAsNumberSubobjectParser());
206                 context.registerXROSubobjectSerializer(Srlg.class, new XROSRLGSubobjectParser());
207                 context.registerXROSubobjectSerializer(Unnumbered.class, new XROUnnumberedInterfaceSubobjectParser());
208                 context.registerXROSubobjectSerializer(PathKey.class, new XROPathKeySubobjectParser());
209
210                 final TlvHandlerRegistry tlvReg = context.getTlvHandlerRegistry();
211                 context.registerTlvParser(NoPathVectorTlvParser.TYPE, new NoPathVectorTlvParser());
212                 context.registerTlvParser(OverloadedDurationTlvParser.TYPE, new OverloadedDurationTlvParser());
213                 context.registerTlvParser(ReqMissingTlvParser.TYPE, new ReqMissingTlvParser());
214                 context.registerTlvParser(OFListTlvParser.TYPE, new OFListTlvParser());
215                 context.registerTlvParser(OrderTlvParser.TYPE, new OrderTlvParser());
216                 context.registerTlvParser(PCEStatefulCapabilityTlvParser.TYPE, new PCEStatefulCapabilityTlvParser());
217                 context.registerTlvParser(LspSymbolicNameTlvParser.TYPE, new LspSymbolicNameTlvParser());
218                 context.registerTlvParser(LSPIdentifierTlvParser.TYPE, new LSPIdentifierTlvParser());
219                 context.registerTlvParser(LSPIdentifierTlvParser.TYPE_6, new LSPIdentifierTlvParser());
220                 context.registerTlvParser(LspUpdateErrorTlvParser.TYPE, new LspUpdateErrorTlvParser());
221                 context.registerTlvParser(RSVPErrorSpecTlvParser.TYPE, new RSVPErrorSpecTlvParser());
222                 context.registerTlvParser(LspDbVersionTlvParser.TYPE, new LspDbVersionTlvParser());
223                 context.registerTlvParser(PredundancyGroupTlvParser.TYPE, new PredundancyGroupTlvParser());
224
225                 context.registerTlvSerializer(NoPathVector.class, new NoPathVectorTlvParser());
226                 context.registerTlvSerializer(OverloadDuration.class, new OverloadedDurationTlvParser());
227                 context.registerTlvSerializer(ReqMissing.class, new ReqMissingTlvParser());
228                 context.registerTlvSerializer(OfList.class, new OFListTlvParser());
229                 context.registerTlvSerializer(Order.class, new OrderTlvParser());
230                 context.registerTlvSerializer(Stateful.class, new PCEStatefulCapabilityTlvParser());
231                 context.registerTlvSerializer(SymbolicPathName.class, new LspSymbolicNameTlvParser());
232                 context.registerTlvSerializer(LspIdentifiers.class, new LSPIdentifierTlvParser());
233                 context.registerTlvSerializer(LspErrorCode.class, new LspUpdateErrorTlvParser());
234                 context.registerTlvSerializer(RsvpErrorSpec.class, new RSVPErrorSpecTlvParser());
235                 context.registerTlvSerializer(LspDbVersion.class, new LspDbVersionTlvParser());
236                 context.registerTlvSerializer(PredundancyGroupId.class, new PredundancyGroupTlvParser());
237
238                 final ObjectHandlerRegistry objReg = context.getObjectHandlerRegistry();
239                 context.registerObjectParser(PCEPOpenObjectParser.CLASS, PCEPOpenObjectParser.TYPE, new PCEPOpenObjectParser(tlvReg));
240                 context.registerObjectParser(PCEPRequestParameterObjectParser.CLASS, PCEPRequestParameterObjectParser.TYPE,
241                                 new PCEPRequestParameterObjectParser(tlvReg));
242                 context.registerObjectParser(PCEPNoPathObjectParser.CLASS, PCEPNoPathObjectParser.TYPE, new PCEPNoPathObjectParser(tlvReg));
243                 context.registerObjectParser(PCEPEndPointsObjectParser.CLASS, PCEPEndPointsObjectParser.TYPE, new PCEPEndPointsObjectParser(tlvReg));
244                 context.registerObjectParser(PCEPEndPointsObjectParser.CLASS_6, PCEPEndPointsObjectParser.TYPE_6,
245                                 new PCEPEndPointsObjectParser(tlvReg));
246                 context.registerObjectParser(PCEPBandwidthObjectParser.CLASS, PCEPBandwidthObjectParser.TYPE, new PCEPBandwidthObjectParser(tlvReg));
247                 context.registerObjectParser(PCEPBandwidthObjectParser.E_CLASS, PCEPBandwidthObjectParser.E_TYPE,
248                                 new PCEPBandwidthObjectParser(tlvReg));
249                 context.registerObjectParser(PCEPMetricObjectParser.CLASS, PCEPMetricObjectParser.TYPE, new PCEPMetricObjectParser(tlvReg));
250
251                 context.registerObjectParser(PCEPExplicitRouteObjectParser.CLASS, PCEPExplicitRouteObjectParser.TYPE,
252                                 new PCEPExplicitRouteObjectParser(eroSubReg));
253                 context.registerObjectParser(PCEPReportedRouteObjectParser.CLASS, PCEPReportedRouteObjectParser.TYPE,
254                                 new PCEPReportedRouteObjectParser(rroSubReg));
255                 context.registerObjectParser(PCEPLspaObjectParser.CLASS, PCEPLspaObjectParser.TYPE, new PCEPLspaObjectParser(tlvReg));
256                 context.registerObjectParser(PCEPIncludeRouteObjectParser.CLASS, PCEPIncludeRouteObjectParser.TYPE,
257                                 new PCEPIncludeRouteObjectParser(eroSubReg));
258                 context.registerObjectParser(PCEPSvecObjectParser.CLASS, PCEPSvecObjectParser.TYPE, new PCEPSvecObjectParser(tlvReg));
259                 context.registerObjectParser(PCEPNotificationObjectParser.CLASS, PCEPNotificationObjectParser.TYPE,
260                                 new PCEPNotificationObjectParser(tlvReg));
261                 context.registerObjectParser(PCEPErrorObjectParser.CLASS, PCEPErrorObjectParser.TYPE, new PCEPErrorObjectParser(tlvReg));
262                 context.registerObjectParser(PCEPLoadBalancingObjectParser.CLASS, PCEPLoadBalancingObjectParser.TYPE,
263                                 new PCEPLoadBalancingObjectParser(tlvReg));
264                 context.registerObjectParser(PCEPCloseObjectParser.CLASS, PCEPCloseObjectParser.TYPE, new PCEPCloseObjectParser(tlvReg));
265                 context.registerObjectParser(PCEPPathKeyObjectParser.CLASS, PCEPPathKeyObjectParser.TYPE, new PCEPPathKeyObjectParser(eroSubReg));
266                 context.registerObjectParser(PCEPObjectiveFunctionObjectParser.CLASS, PCEPObjectiveFunctionObjectParser.TYPE,
267                                 new PCEPObjectiveFunctionObjectParser(tlvReg));
268                 context.registerObjectParser(PCEPClassTypeObjectParser.CLASS, PCEPClassTypeObjectParser.TYPE, new PCEPClassTypeObjectParser(tlvReg));
269
270                 context.registerObjectParser(PCEPGlobalConstraintsObjectParser.CLASS, PCEPGlobalConstraintsObjectParser.TYPE,
271                                 new PCEPGlobalConstraintsObjectParser(tlvReg));
272                 context.registerObjectParser(PCEPLspObjectParser.CLASS, PCEPLspObjectParser.TYPE, new PCEPLspObjectParser(tlvReg));
273                 context.registerObjectParser(PCEPSrpObjectParser.CLASS, PCEPSrpObjectParser.TYPE, new PCEPSrpObjectParser(tlvReg));
274                 context.registerObjectParser(PCEPExcludeRouteObjectParser.CLASS, PCEPExcludeRouteObjectParser.TYPE,
275                                 new PCEPExcludeRouteObjectParser(xroSubReg));
276
277                 context.registerObjectSerializer(Open.class, new PCEPOpenObjectParser(tlvReg));
278                 context.registerObjectSerializer(Rp.class, new PCEPRequestParameterObjectParser(tlvReg));
279                 context.registerObjectSerializer(NoPathObject.class, new PCEPNoPathObjectParser(tlvReg));
280                 context.registerObjectSerializer(EndpointsObj.class, new PCEPEndPointsObjectParser(tlvReg));
281                 context.registerObjectSerializer(Bandwidth.class, new PCEPBandwidthObjectParser(tlvReg));
282                 context.registerObjectSerializer(Metric.class, new PCEPMetricObjectParser(tlvReg));
283                 context.registerObjectSerializer(Ero.class, new PCEPExplicitRouteObjectParser(eroSubReg));
284                 context.registerObjectSerializer(ReportedRouteObject.class, new PCEPReportedRouteObjectParser(rroSubReg));
285                 context.registerObjectSerializer(Lspa.class, new PCEPLspaObjectParser(tlvReg));
286                 context.registerObjectSerializer(Iro.class, new PCEPIncludeRouteObjectParser(eroSubReg));
287                 context.registerObjectSerializer(SvecObject.class, new PCEPSvecObjectParser(tlvReg));
288                 context.registerObjectSerializer(CNotification.class, new PCEPNotificationObjectParser(tlvReg));
289                 context.registerObjectSerializer(ErrorObject.class, new PCEPErrorObjectParser(tlvReg));
290                 context.registerObjectSerializer(LoadBalancing.class, new PCEPLoadBalancingObjectParser(tlvReg));
291                 context.registerObjectSerializer(CClose.class, new PCEPCloseObjectParser(tlvReg));
292                 context.registerObjectSerializer(
293                                 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.key.object.PathKey.class,
294                                 new PCEPPathKeyObjectParser(eroSubReg));
295                 context.registerObjectSerializer(Of.class, new PCEPObjectiveFunctionObjectParser(tlvReg));
296                 context.registerObjectSerializer(ClassType.class, new PCEPClassTypeObjectParser(tlvReg));
297                 context.registerObjectSerializer(Gc.class, new PCEPGlobalConstraintsObjectParser(tlvReg));
298                 context.registerObjectSerializer(Lsp.class, new PCEPLspObjectParser(tlvReg));
299                 context.registerObjectSerializer(Srp.class, new PCEPSrpObjectParser(tlvReg));
300                 context.registerObjectSerializer(Xro.class, new PCEPExcludeRouteObjectParser(xroSubReg));
301
302                 context.registerMessageParser(PCEPOpenMessageParser.TYPE, new PCEPOpenMessageParser(objReg));
303                 context.registerMessageParser(PCEPKeepAliveMessageParser.TYPE, new PCEPKeepAliveMessageParser(objReg));
304                 context.registerMessageParser(PCEPReplyMessageParser.TYPE, new PCEPReplyMessageParser(objReg));
305                 context.registerMessageParser(PCEPRequestMessageParser.TYPE, new PCEPRequestMessageParser(objReg));
306                 context.registerMessageParser(PCEPErrorMessageParser.TYPE, new PCEPErrorMessageParser(objReg));
307                 context.registerMessageParser(PCEPCloseMessageParser.TYPE, new PCEPCloseMessageParser(objReg));
308                 context.registerMessageParser(PCEPUpdateRequestMessageParser.TYPE, new PCEPUpdateRequestMessageParser(objReg));
309                 context.registerMessageParser(PCEPReportMessageParser.TYPE, new PCEPReportMessageParser(objReg));
310                 context.registerMessageParser(PCCreateMessageParser.TYPE, new PCCreateMessageParser(objReg));
311
312                 context.registerMessageSerializer(OpenMessage.class, new PCEPOpenMessageParser(objReg));
313                 context.registerMessageSerializer(PcntfMessage.class, new PCEPNotificationMessageParser(objReg));
314                 context.registerMessageSerializer(KeepaliveMessage.class, new PCEPKeepAliveMessageParser(objReg));
315                 context.registerMessageSerializer(PcrepMessage.class, new PCEPReplyMessageParser(objReg));
316                 context.registerMessageSerializer(PcreqMessage.class, new PCEPRequestMessageParser(objReg));
317                 context.registerMessageSerializer(PcerrMessage.class, new PCEPErrorMessageParser(objReg));
318                 context.registerMessageSerializer(CloseMessage.class, new PCEPCloseMessageParser(objReg));
319                 context.registerMessageSerializer(PcupdMessage.class, new PCEPUpdateRequestMessageParser(objReg));
320                 context.registerMessageSerializer(PcrptMessage.class, new PCEPReportMessageParser(objReg));
321                 context.registerMessageSerializer(PcinitiateMessage.class, new PCCreateMessageParser(objReg));
322
323                 this.registrations = regs;
324         }
325
326         @Override
327         public void stop() {
328                 Preconditions.checkState(this.registrations != null);
329
330                 for (final AutoCloseable r : this.registrations) {
331                         try {
332                                 r.close();
333                         } catch (final Exception e) {
334                                 logger.warn("Failed to close registration", e);
335                         }
336                 }
337
338                 this.registrations = null;
339         }
340 }