T
- public class DefaultConfigurationService<C extends AbstractConfiguration> extends Object implements ConfigurationService<String,String,C>
ConfigurationService
implementation that wrap the following services over base configuration fetching and setting configs via AbstractConfigurationJPADaoImpl
:
AbstractAuthorizableConfiguration
sModifier and Type | Field and Description |
---|---|
protected org.springframework.cache.Cache |
cache |
CONFIGURATION_CACHE_NAME
NAMESPACE_DELIM
Constructor and Description |
---|
DefaultConfigurationService() |
Modifier and Type | Method and Description |
---|---|
void |
addChangeListener(ChangeListener changeListener)
Allow Notify all
ChangeListener s about a change |
void |
clearCache(String namespace)
Will clear the namespace hierarchy from the cache
|
void |
delete(C config)
Remove a configuration
|
Long |
delete(Long id)
A special Delete operation on the entity that will remove the entity and related entities based on id.
|
Map |
get(String namespace)
Get a Map of key name and corresponding
IConfiguration for the specific namespace. |
String |
get(String namespace,
String key) |
String |
get(String namespace,
String key,
Collection<Authorization> authorizations)
If an
authorizationService is defined it will use it, else will delegate to get(String, String) and log a warning. |
String |
get(User user,
String namespace,
String key)
Get a configuration in the context to a
User |
Map |
getAll(String namespace)
Get a Map of key name and corresponding
AbstractConfiguration for the specific namespace. |
AuthorizationService |
getAuthorizationService()
Optional service to perform Authorization on config fetches.
|
org.springframework.cache.Cache |
getCache()
Optional cache, if provided will clear the cache fore related entries being set
|
C |
getConfig(C proxy) |
C |
getConfig(String namespace,
String key) |
List<C> |
getConfigs(String namespace)
Get configurations for a namespace and nested namesapces, as a collection of C
|
List<Class> |
getConfigTypes() |
<CD extends ConfigurationDao<String,String,C>> |
getDao()
DAO backing this service
|
List |
getListeners()
Get list directly.
|
List<String> |
getNamespaces()
Get list of namespaces
|
void |
init() |
String |
keyGen(String namespace,
String key) |
C |
load(Object id) |
C |
load(Object id,
Class c)
In some situations the DAO represents an Interface or perhaps a parent of the actual Entity./
The exact type of the entity would have to be Supplied.
|
void |
notifyAllListeners(C event)
Whenever a node is selected/updated, it also notifies its listeners.
|
C |
put(C config)
Will evict the namespace hierarchy, under which this configuration exists
|
C |
put(C config,
Collection<Authorization> authorizations) |
List |
query(String ql,
String dialect,
Object... params)
Execute a raw Query in the native implementation language.
|
Page |
query(String ql,
String dialect,
PageInfo pageInfo,
Object... params)
Execute a raw Query in the native implementation language.
|
C |
save(C c) |
void |
setAuthorizationService(AuthorizationService authorizationService)
Optional service to perform Authorization on config fetches.
|
void |
setCache(org.springframework.cache.Cache cache)
Optional cache, if provided will clear the cache fore related entries being set
|
void |
setConfigTypes(List<Class> configTypes) |
void |
setDao(ConfigurationDao<String,String,C> dao)
DAO backing this service
|
void |
setListeners(List listeners)
Set list directly.
|
int |
update(String arg0,
boolean arg1,
Object... arg2)
An Update query with optional params
|
@PostConstruct public void init()
public String keyGen(String namespace, String key)
keyGen
in interface ConfigurationService<String,String,C extends AbstractConfiguration>
public void clearCache(String namespace)
ConfigurationService
clearCache
in interface ConfigurationService<String,String,C extends AbstractConfiguration>
@Transactional public C put(C config)
put
in interface ConfigurationDao<String,String,C extends AbstractConfiguration>
public C put(C config, Collection<Authorization> authorizations) throws AuthorizationException
put
in interface ConfigurationService<String,String,C extends AbstractConfiguration>
config
- as CAbstractConfiguration
AuthorizationException
public C getConfig(C proxy)
getConfig
in interface ConfigurationDao<String,String,C extends AbstractConfiguration>
public C getConfig(String namespace, String key)
getConfig
in interface ConfigurationDao<String,String,C extends AbstractConfiguration>
namespace
- as Stringkey
- as StringAbstractConfiguration
public String get(String namespace, String key)
get
in interface ConfigurationDao<String,String,C extends AbstractConfiguration>
get
in interface ConfigurationService<String,String,C extends AbstractConfiguration>
get
in interface ConfigurationSource<String,String>
namespace
- as Stringkey
- as Stringpublic Map get(String namespace)
IConfiguration
for the specific namespace.
get
in interface ConfigurationService<String,String,C extends AbstractConfiguration>
get
in interface ConfigurationSource<String,String>
namespace
- as StringIConfiguration
public Map getAll(String namespace)
AbstractConfiguration
for the specific namespace.
ConfigurationSource.NAMESPACE_DELIM
This method respects hierarchy based on default convention.getAll
in interface ConfigurationDao<String,String,C extends AbstractConfiguration>
namespace
- public List<String> getNamespaces()
ConfigurationDao
getNamespaces
in interface ConfigurationDao<String,String,C extends AbstractConfiguration>
public String get(User user, String namespace, String key)
User
get
in interface ConfigurationSource<String,String>
public String get(String namespace, String key, Collection<Authorization> authorizations) throws AuthorizationException
authorizationService
is defined it will use it, else will delegate to get(String, String)
and log a warning.get
in interface ConfigurationService<String,String,C extends AbstractConfiguration>
namespace
- as Stringkey
- as Kauthorizations
- as Collection
of Authorization
AbstractConfiguration
AuthorizationException
public void delete(C config)
ConfigurationDao
delete
in interface ConfigurationDao<String,String,C extends AbstractConfiguration>
delete
in interface GenericDao<C extends AbstractConfiguration>
public List<C> getConfigs(String namespace)
ConfigurationDao
getConfigs
in interface ConfigurationDao<String,String,C extends AbstractConfiguration>
namespace
- as StringCollection
of Cpublic List<Class> getConfigTypes()
getConfigTypes
in interface ConfigurationService<String,String,C extends AbstractConfiguration>
AbstractConfiguration
by the Apppublic AuthorizationService getAuthorizationService()
public void setAuthorizationService(AuthorizationService authorizationService)
public <CD extends ConfigurationDao<String,String,C>> CD getDao()
getDao
in interface ConfigurationService<String,String,C extends AbstractConfiguration>
public void setDao(ConfigurationDao<String,String,C> dao)
public org.springframework.cache.Cache getCache()
public void setCache(org.springframework.cache.Cache cache)
public void addChangeListener(ChangeListener changeListener)
ChangeGenerator
ChangeListener
s about a changeaddChangeListener
in interface ChangeGenerator<C extends AbstractConfiguration>
public void notifyAllListeners(C event)
ChangeGenerator
notifyAllListeners
in interface ChangeGenerator<C extends AbstractConfiguration>
public List getListeners()
ChangeGenerator
getListeners
in interface ChangeGenerator<C extends AbstractConfiguration>
public void setListeners(List listeners)
ChangeGenerator
setListeners
in interface ChangeGenerator<C extends AbstractConfiguration>
public Long delete(Long id)
GenericDao
delete
in interface GenericDao<C extends AbstractConfiguration>
Long
public C load(Object id)
load
in interface GenericDao<C extends AbstractConfiguration>
public C load(Object id, Class c)
GenericDao
load
in interface GenericDao<C extends AbstractConfiguration>
id
- as Id for Entityc
- as Class
of entitypublic C save(C c)
save
in interface GenericDao<C extends AbstractConfiguration>
public List query(String ql, String dialect, Object... params) throws Exception
FreeQuery
query
in interface FreeQuery
ql
- as String in native Schema languagedialect
- as String. NULL or empty or "NATIVE" implies NATIVE, "JPA" implies JPA will be used. Additional dialects can be supported but they will be implementation dependent.params
- as Query parameters to the string.
List
Exception
public Page query(String ql, String dialect, PageInfo pageInfo, Object... params) throws Exception
FreeQuery
query
in interface FreeQuery
ql
- as String in native Schema languagedialect
- as String. NULL or empty or "NATIVE" implies NATIVE, "JPA" implies JPA will be used. Additional dialects can be supported but they will be implementation dependent.pageInfo
- as PageInfo
for pagination of resultparams
- as Query parameters to the string
Page
Exception
Copyright © 2018. All rights reserved.