blob: 475e4f72c621fc8e56eb5d315dee9523843e1d22 [file] [log] [blame]
<!--
/***************************************************************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
***************************************************************************************************************************/
-->
{8.0.0-new, 8.1.2-deprecated}
VarResolver
<p>
The Microservice API incorporates the {@doc juneau-marshall.SimpleVariableLanguage Simple Variable Language} API.
</p>
<p>
The variable resolver can be augmented through the following methods:
</p>
<ul class='javatree'>
<li class='jc'>{@link oaj.microservice.MicroserviceBuilder}
<ul>
<li class='jm'>{@link oaj.microservice.MicroserviceBuilder#vars(Class...) vars(Class...)}
<li class='jm'>{@link oaj.microservice.MicroserviceBuilder#varContext(String, Object) varContext(String,Object)}
</ul>
</ul>
<p>
A typical usage pattern is shown below:
</p>
<p class='bpcode w800'>
<jc>// $A used in variable resolver.</jc>
VarResolver vr = Microservice.<jsm>getInstance</jsm>().getVarResolver();
System.<jsf>out</jsf>.println(vr.resolve(<js>"Main class is set to $MF{Main-Class, unknown}"</js>));
</p>
<p>
The variable resolver becomes much more powerful when used in REST resource annotations which will be
described latter in {@doc juneau-microservice-jetty}
</p>
<p>
By default, support for the following variables are provided:
</p>
<ul>
<li><c>$S{key[,default]}</c> - {@link oaj.svl.vars.SystemPropertiesVar}
<li><c>$E{key[,default]}</c> - {@link oaj.svl.vars.EnvVariablesVar}
<li><c>$A{key[,default]}</c> - {@link oaj.svl.vars.ArgsVar}
<li><c>$C{key[,default]}</c> - {@link oaj.config.vars.ConfigVar}
<li><c>$MF{key[,default]}</c> - {@link oaj.svl.vars.ManifestFileVar}
<li><c>$IF{arg,then[,else]}</c> - {@link oaj.svl.vars.IfVar}
<li><c>$SW{arg,pattern1:then1[,pattern2:then2...]}</c> - {@link oaj.svl.vars.SwitchVar}
<li><c>$CO{arg[,arg2...]}</c> - {@link oaj.svl.vars.CoalesceVar}
<li><c>$PM{arg,pattern}</c> - {@link oaj.svl.vars.PatternMatchVar}
<li><c>$UC{arg}</c> - {@link oaj.svl.vars.UpperCaseVar}
<li><c>$LC{arg}</c> - {@link oaj.svl.vars.LowerCaseVar}
<li><c>$NE{arg}</c> - {@link oaj.svl.vars.NotEmptyVar}
</ul>