blob: 82478eecb4bd654dbd76757986d9c43df50df247 [file] [log] [blame]
Thomas Vachuska0fa2aa12015-08-18 12:53:04 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Thomas Vachuska0fa2aa12015-08-18 12:53:04 -07003 *
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
Ray Milkeyd84f89b2018-08-17 14:54:17 -070018import org.osgi.service.component.annotations.Activate;
Ray Milkeyd84f89b2018-08-17 14:54:17 -070019import org.osgi.service.component.annotations.Deactivate;
20import org.osgi.service.component.annotations.Reference;
21import org.osgi.service.component.annotations.ReferenceCardinality;
Thomas Vachuska0fa2aa12015-08-18 12:53:04 -070022
23/**
24 * Self-registering REST API provider.
25 */
Thomas Vachuska0fa2aa12015-08-18 12:53:04 -070026public abstract class AbstractApiDocRegistrator {
27
28 protected final ApiDocProvider provider;
29
Ray Milkeyd84f89b2018-08-17 14:54:17 -070030 @Reference(cardinality = ReferenceCardinality.MANDATORY)
Thomas Vachuska0fa2aa12015-08-18 12:53:04 -070031 protected ApiDocService service;
32
33 /**
34 * Creates registrator for the specified REST API doc provider.
35 *
36 * @param provider REST API provider
37 */
38 protected AbstractApiDocRegistrator(ApiDocProvider provider) {
39 this.provider = provider;
40 }
41
42 @Activate
43 protected void activate() {
44 service.register(provider);
45 }
46
47 @Deactivate
48 protected void deactivate() {
49 service.unregister(provider);
50 }
51}