2 * Copyright (c) 2016, Huawei Technologies Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.openo.baseservice.util.impl;
18 import org.openo.baseservice.util.inf.SystemEnvVariables;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
24 import java.io.IOException;
27 * System environment variable helper implementation.<br/>
32 * @version SDNO 0.5 24-Jun-2016
34 public class SystemEnvVariablesDefImpl extends SystemEnvVariables {
36 private static final Logger LOG = LoggerFactory.getLogger(SystemEnvVariablesDefImpl.class);
39 public String getAppRoot() {
40 String appRoot = null;
41 appRoot = System.getProperty("catalina.base");
43 appRoot = getCanonicalPath(appRoot);
49 * Gets the canonical path<br/>
51 * @param inPath input path
52 * @return the canonical path.
55 private String getCanonicalPath(final String inPath) {
59 final File file = new File(inPath);
60 path = file.getCanonicalPath();
62 } catch(final IOException e) {
63 LOG.error("file.getCanonicalPath() IOException:", e);