blob: 00188ee441a8732b933cfd175da3b3f63bb2a1f2 [file] [log] [blame]
Gaurav Agrawal8ce6d5c2017-05-03 18:23:00 +05301/*
2 * Copyright 2017-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 */
16
17package org.onosproject.yang;
18
19import com.google.common.annotations.Beta;
20import org.apache.felix.scr.annotations.Activate;
21import org.apache.felix.scr.annotations.Component;
22import org.apache.felix.scr.annotations.Deactivate;
23import org.apache.felix.scr.annotations.Reference;
24import org.apache.felix.scr.annotations.ReferenceCardinality;
25import org.apache.felix.scr.annotations.Service;
26import org.onosproject.core.CoreService;
27import org.onosproject.yang.compiler.api.YangCompilationParam;
28import org.onosproject.yang.compiler.api.YangCompiledOutput;
29import org.onosproject.yang.compiler.api.YangCompilerException;
30import org.onosproject.yang.compiler.api.YangCompilerService;
Gaurav Agrawalce2686a2017-05-13 14:27:40 +053031import org.onosproject.yang.compiler.tool.YangCompilerManager;
Gaurav Agrawal8ce6d5c2017-05-03 18:23:00 +053032import org.slf4j.Logger;
33import org.slf4j.LoggerFactory;
34
35import java.io.IOException;
36
37/**
38 * Represents implementation of YANG live compiler manager.
39 */
40@Beta
41@Service
42@Component(immediate = true)
43public class YangLiveCompilerManager implements YangCompilerService {
44
45 private static final String APP_ID = "org.onosproject.yang";
46 private final Logger log = LoggerFactory.getLogger(getClass());
47 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
48 protected CoreService coreService;
Gaurav Agrawal8ce6d5c2017-05-03 18:23:00 +053049
50 @Activate
51 public void activate() {
52 coreService.registerApplication(APP_ID);
Gaurav Agrawal8ce6d5c2017-05-03 18:23:00 +053053 log.info("Started");
54 }
55
56 @Deactivate
57 public void deactivate() {
58 log.info("Stopped");
59 }
60
Gaurav Agrawal8ce6d5c2017-05-03 18:23:00 +053061 @Override
62 public YangCompiledOutput compileYangFiles(YangCompilationParam param)
63 throws IOException, YangCompilerException {
Gaurav Agrawalce2686a2017-05-13 14:27:40 +053064 return new YangCompilerManager().compileYangFiles(param);
Gaurav Agrawal8ce6d5c2017-05-03 18:23:00 +053065 }
66}