blob: f0012db6f552c005800ffacfc01da5c5c57f03cd [file] [log] [blame]
Jonathan Hart3604bbc2016-01-07 11:16:42 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Jonathan Hart3604bbc2016-01-07 11:16:42 -08003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.vrouter;
17
18import com.google.common.collect.ImmutableList;
19import org.apache.felix.scr.annotations.Activate;
20import org.apache.felix.scr.annotations.Component;
21import org.apache.felix.scr.annotations.Deactivate;
22import org.apache.felix.scr.annotations.Reference;
23import org.apache.felix.scr.annotations.ReferenceCardinality;
24import org.onosproject.core.ApplicationId;
25import org.onosproject.core.CoreService;
26import org.onosproject.incubator.component.ComponentService;
27import org.slf4j.Logger;
28import org.slf4j.LoggerFactory;
29
30import java.util.List;
31
32/**
33 * Virtual router (vRouter) application.
34 */
35@Component(immediate = true)
36public class Vrouter {
37
38 private final Logger log = LoggerFactory.getLogger(getClass());
39
40 private static final String APP_NAME = "org.onosproject.vrouter";
41
42 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
43 protected CoreService coreService;
44
45 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
46 protected ComponentService componentService;
47
48 private ApplicationId appId;
49
50 private final List<String> components = ImmutableList.<String>builder()
51 .add("org.onosproject.routing.fpm.FpmManager")
Jonathan Hart3604bbc2016-01-07 11:16:42 -080052 .add("org.onosproject.routing.impl.SingleSwitchFibInstaller")
Jonathan Hart6344f572015-12-15 08:26:25 -080053 .add("org.onosproject.routing.impl.ControlPlaneRedirectManager")
Jonathan Hart63eeac32016-06-20 15:55:16 -070054 .add("org.onosproject.routing.impl.DirectHostManager")
Jonathan Hart3604bbc2016-01-07 11:16:42 -080055 .build();
56
Jonathan Hart63eeac32016-06-20 15:55:16 -070057
Jonathan Hart3604bbc2016-01-07 11:16:42 -080058 @Activate
59 protected void activate() {
60 appId = coreService.registerApplication(APP_NAME);
61
62 components.forEach(name -> componentService.activate(appId, name));
63
64 log.info("Started");
65 }
66
67 @Deactivate
68 protected void deactivate() {
69 log.info("Stopped");
70 }
71
72}