blob: b604b77319ea2a1d410846341d6e57ab717229e8 [file] [log] [blame]
Himal Kumarb43724d2016-04-29 14:15:57 +10001/*
2 * Copyright 2016-present Open Networking Laboratory
3 *
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.castor;
17
18import org.apache.felix.scr.annotations.Activate;
19import org.apache.felix.scr.annotations.Component;
20import org.apache.felix.scr.annotations.Deactivate;
21import org.apache.felix.scr.annotations.Reference;
22import org.apache.felix.scr.annotations.ReferenceCardinality;
23import org.onosproject.app.ApplicationService;
24import org.onosproject.core.ApplicationId;
25import org.onosproject.core.CoreService;
26import org.onosproject.routing.IntentSynchronizationService;
27import org.slf4j.Logger;
28
29import static org.slf4j.LoggerFactory.getLogger;
30
31/**
32 * Component of the Castor Class.
33 */
34
35@Component(immediate = true)
36public class Castor {
37
38 public static final String CASTOR_APP = "org.onosproject.castor";
39 private final Logger log = getLogger(getClass());
40
41 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
42 protected CoreService coreService;
43
44 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
45 protected ApplicationService applicationService;
46
47 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
48 protected IntentSynchronizationService intentSynchronizer;
49
50 private ApplicationId appId;
51
52 @Activate
53 protected void activate() {
54 appId = coreService.registerApplication(CASTOR_APP);
55 applicationService.registerDeactivateHook(appId, () -> {
56 intentSynchronizer.removeIntentsByAppId(appId);
57 });
58 }
59
60 @Deactivate
61 protected void deactivate() {
62 }
63}