blob: 0689eb01132dfcf1a75ac1dcf5fa14369e489aca [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")
52 .add("org.onosproject.routing.impl.Router")
53 .add("org.onosproject.routing.impl.SingleSwitchFibInstaller")
Jonathan Hart6344f572015-12-15 08:26:25 -080054 .add("org.onosproject.routing.impl.ControlPlaneRedirectManager")
Jonathan Hart3604bbc2016-01-07 11:16:42 -080055 .build();
56
57 @Activate
58 protected void activate() {
59 appId = coreService.registerApplication(APP_NAME);
60
61 components.forEach(name -> componentService.activate(appId, name));
62
63 log.info("Started");
64 }
65
66 @Deactivate
67 protected void deactivate() {
68 log.info("Stopped");
69 }
70
71}