blob: 7349c69ea35645b6838b0c0959063a35e41afab3 [file] [log] [blame]
Thomas Vachuska0fa2aa12015-08-18 12:53:04 -07001/*
2 * Copyright 2015 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.rest;
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;
23
24/**
25 * Self-registering REST API provider.
26 */
27@Component(immediate = true, componentAbstract = true)
28public abstract class AbstractApiDocRegistrator {
29
30 protected final ApiDocProvider provider;
31
32 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
33 protected ApiDocService service;
34
35 /**
36 * Creates registrator for the specified REST API doc provider.
37 *
38 * @param provider REST API provider
39 */
40 protected AbstractApiDocRegistrator(ApiDocProvider provider) {
41 this.provider = provider;
42 }
43
44 @Activate
45 protected void activate() {
46 service.register(provider);
47 }
48
49 @Deactivate
50 protected void deactivate() {
51 service.unregister(provider);
52 }
53}