001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.configuration2.interpol; 018 019import org.apache.commons.lang3.text.StrLookup; 020 021/** 022 * <p> 023 * A specialized implementation of the {@code Lookup} interface that allows 024 * access to system properties. 025 * </p> 026 * <p> 027 * This implementation relies on {@code StrLookup.systemPropertiesLookup()} from 028 * the Commons Lang project to resolve system properties. It can be used for 029 * referencing system properties in configuration files in an easy way, for 030 * instance: 031 * </p> 032 * 033 * <pre> 034 * current.user = ${sys:user.name} 035 * </pre> 036 * 037 * <p> 038 * {@code SystemPropertiesLookup} is one of the standard lookups that is 039 * registered per default for each configuration. 040 * </p> 041 * 042 * @version $Id: SystemPropertiesLookup.java 1679786 2015-05-16 17:47:09Z oheger $ 043 * @since 2.0 044 */ 045public class SystemPropertiesLookup implements Lookup 046{ 047 /** The underlying StrLookup object. */ 048 private final StrLookup<String> sysLookup = StrLookup 049 .systemPropertiesLookup(); 050 051 @Override 052 public Object lookup(String variable) 053 { 054 return sysLookup.lookup(variable); 055 } 056}