Remove hand-written ServiceLoader services
[bgpcep.git] / pcep / ietf-stateful / src / main / java / org / opendaylight / protocol / pcep / ietf / stateful / StatefulActivator.java
1 /*
2  * Copyright (c) 2014 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.ietf.stateful;
9
10 import java.util.ArrayList;
11 import java.util.List;
12 import org.kohsuke.MetaInfServices;
13 import org.opendaylight.protocol.pcep.spi.ObjectRegistry;
14 import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderActivator;
15 import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderContext;
16 import org.opendaylight.protocol.pcep.spi.TlvRegistry;
17 import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
18 import org.opendaylight.protocol.pcep.spi.pojo.AbstractPCEPExtensionProviderActivator;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Pcrpt;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Pcupd;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.error.code.tlv.LspErrorCode;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.LspIdentifiers;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.Lsp;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.path.binding.tlv.PathBinding;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.rsvp.error.spec.tlv.RsvpErrorSpec;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.srp.object.Srp;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.stateful.capability.tlv.Stateful;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.symbolic.path.name.tlv.SymbolicPathName;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Pcerr;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.Open;
31 import org.opendaylight.yangtools.concepts.Registration;
32
33 @MetaInfServices(value = PCEPExtensionProviderActivator.class)
34 public final class StatefulActivator extends AbstractPCEPExtensionProviderActivator {
35     @Override
36     protected List<Registration> startImpl(final PCEPExtensionProviderContext context) {
37         final List<Registration> regs = new ArrayList<>();
38
39         final ObjectRegistry objReg = context.getObjectHandlerRegistry();
40         regs.add(context.registerMessageParser(StatefulPCUpdateRequestMessageParser.TYPE,
41             new StatefulPCUpdateRequestMessageParser(objReg)));
42         regs.add(context.registerMessageSerializer(Pcupd.class, new StatefulPCUpdateRequestMessageParser(objReg)));
43         regs.add(context.registerMessageParser(StatefulPCReportMessageParser.TYPE,
44             new StatefulPCReportMessageParser(objReg)));
45         regs.add(context.registerMessageSerializer(Pcrpt.class, new StatefulPCReportMessageParser(objReg)));
46         regs.add(context.registerMessageParser(StatefulErrorMessageParser.TYPE,
47             new StatefulErrorMessageParser(objReg)));
48         regs.add(context.registerMessageSerializer(Pcerr.class, new StatefulErrorMessageParser(objReg)));
49
50         final TlvRegistry tlvReg = context.getTlvHandlerRegistry();
51         final VendorInformationTlvRegistry viTlvReg = context.getVendorInformationTlvRegistry();
52         regs.add(context.registerObjectParser(new StatefulLspObjectParser(tlvReg, viTlvReg)));
53         regs.add(context.registerObjectSerializer(Lsp.class, new StatefulLspObjectParser(tlvReg, viTlvReg)));
54         regs.add(context.registerObjectParser(new StatefulSrpObjectParser(tlvReg, viTlvReg)));
55         regs.add(context.registerObjectSerializer(Srp.class, new StatefulSrpObjectParser(tlvReg, viTlvReg)));
56         regs.add(context.registerObjectParser(new StatefulOpenObjectParser(tlvReg, viTlvReg)));
57         regs.add(context.registerObjectSerializer(Open.class, new StatefulOpenObjectParser(tlvReg, viTlvReg)));
58
59         regs.add(context.registerTlvParser(StatefulLSPIdentifierIpv4TlvParser.TYPE,
60             new StatefulLSPIdentifierIpv4TlvParser()));
61         regs.add(context.registerTlvParser(StatefulLSPIdentifierIpv6TlvParser.TYPE,
62             new StatefulLSPIdentifierIpv6TlvParser()));
63         regs.add(context.registerTlvSerializer(LspIdentifiers.class, new StatefulLSPIdentifierIpv4TlvParser()));
64         regs.add(context.registerTlvParser(StatefulLspUpdateErrorTlvParser.TYPE,
65             new StatefulLspUpdateErrorTlvParser()));
66         regs.add(context.registerTlvSerializer(LspErrorCode.class, new StatefulLspUpdateErrorTlvParser()));
67         regs.add(context.registerTlvParser(StatefulRSVPErrorSpecTlvParser.TYPE,
68             new StatefulRSVPErrorSpecTlvParser()));
69         regs.add(context.registerTlvSerializer(RsvpErrorSpec.class, new StatefulRSVPErrorSpecTlvParser()));
70         regs.add(context.registerTlvParser(StatefulStatefulCapabilityTlvParser.TYPE,
71             new StatefulStatefulCapabilityTlvParser()));
72         regs.add(context.registerTlvSerializer(Stateful.class, new StatefulStatefulCapabilityTlvParser()));
73         regs.add(context.registerTlvParser(StatefulLspSymbolicNameTlvParser.TYPE,
74             new StatefulLspSymbolicNameTlvParser()));
75         regs.add(context.registerTlvSerializer(SymbolicPathName.class, new StatefulLspSymbolicNameTlvParser()));
76         regs.add(context.registerTlvParser(PathBindingTlvParser.TYPE, new PathBindingTlvParser()));
77         regs.add(context.registerTlvSerializer(PathBinding.class, new PathBindingTlvParser()));
78         return regs;
79     }
80 }