2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6 * ===========================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END====================================================
22 package org.onap.aaf.cadi;
24 import java.util.Enumeration;
26 import javax.servlet.FilterConfig;
27 import javax.servlet.ServletContext;
29 public class ServletContextAccess extends PropAccess {
31 private ServletContext context;
33 public ServletContextAccess(FilterConfig filterConfig) {
34 super(filterConfig); // protected constructor... does not have "init" called.
35 context = filterConfig.getServletContext();
37 for (Enumeration<?> en = filterConfig.getInitParameterNames();en.hasMoreElements();) {
38 String name = (String)en.nextElement();
39 setProperty(name, filterConfig.getInitParameter(name));
41 init(getProperties());
45 * @see org.onap.aaf.cadi.PropAccess#log(org.onap.aaf.cadi.Access.Level, java.lang.Object[])
48 public void log(Level level, Object... elements) {
50 StringBuilder sb = buildMsg(level, elements);
51 context.log(sb.toString());
56 * @see org.onap.aaf.cadi.PropAccess#log(java.lang.Exception, java.lang.Object[])
59 public void log(Exception e, Object... elements) {
60 StringBuilder sb = buildMsg(Level.ERROR, elements);
61 context.log(sb.toString(),e);
64 public ServletContext context() {