@Component(value="contextUtils") public class ContextUtils extends Object
getInstance()
Modifier and Type | Field and Description |
---|---|
protected org.springframework.context.ApplicationContext |
context |
static String |
MODULESMAP_BEAN_NAME |
protected SpringStaticConfigurtationSource<Map> |
springStaticConfigSource |
Constructor and Description |
---|
ContextUtils() |
Modifier and Type | Method and Description |
---|---|
<V> V |
getConfigProperty(String key,
Map defaultProperties,
V defaultValue)
A simple alternative that checks defaultProperties and if none found then applies a given default value
|
Object |
getConfigProperty(String namespace,
Object o,
Map defaultProperties,
Object keyDeriver,
String key)
Derive property config for modelId (if defined) else default from admin.properties
Class name . |
static ContextUtils |
getInstance() |
Module |
getModule(Class c)
Deprecated.
- @see
IModuleService & DefaultModuleService ; use the method from the Service instead |
Module |
getModuleFromContext(String name)
Deprecated.
- @see
IModuleService & DefaultModuleService ; use the method from the Service instead |
void |
init() |
public static final String MODULESMAP_BEAN_NAME
@Autowired protected org.springframework.context.ApplicationContext context
@Autowired protected SpringStaticConfigurtationSource<Map> springStaticConfigSource
@PostConstruct public void init()
public static ContextUtils getInstance()
public final Object getConfigProperty(String namespace, Object o, Map defaultProperties, Object keyDeriver, String key)
SpringStaticConfiguration
, the value is a Map of key, values of the key matching whats in the admin config for default categoriesnamespace
- as Stringo
- as Object for while overrides are being seeked. The Object is typically some UI component model.keyDeriver
- as String or Transformer which can be null, for the model this Panel instance represents for which we expect config overrides. It acts on the object (o).defaultProperties
- as Map
(nullable)key
- as String, as the key property we wish to fetch
Map configValueAsMap = springStaticConfigSource.get(
namespace,
(String)(keyDeriver instanceof Transformer?((Transformer)keyDeriver).transform(o):keyDeriver)
);
if (configValueAsMap!=null) {
value = (String)configValueAsMap.get(key);
}
TODO: All admin code should use this instead of a direct property accesspublic final <V> V getConfigProperty(String key, Map defaultProperties, V defaultValue)
key
- as StringdefaultProperties
- as Map
of key to output type VdefaultValue
- as output type V@Deprecated public Module getModuleFromContext(String name)
IModuleService
& DefaultModuleService
; use the method from the Service insteadModule
from the ApplicationContext
name
- @Deprecated public Module getModule(Class c)
IModuleService
& DefaultModuleService
; use the method from the Service insteadMountModuleUI
; and returns the Module the class belongs to.Copyright © 2018. All rights reserved.