T
- the base service classpublic class ServiceProfile<T extends Service> extends Object
<prefix> = <fully qualified class name which extends T>
<prefix>.<key1> = <value1>
<prefix>.<key2> = <value2>
...
Constructor and Description |
---|
ServiceProfile(String prefix,
Class<? extends T> serviceClass,
Map<String,String> configuration,
ProfileContext context)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
ClassLoader |
getClassLoader()
Deprecated.
use
getContext() instead |
Map<String,String> |
getConfiguration()
Return the optional configuration for the service.
|
String |
getConfiguration(String key,
boolean mandatory,
boolean resolve)
Returns the target configuration.
|
ProfileContext |
getContext()
Returns the current profile context.
|
String |
getPrefix()
Returns the key prefix of this profile.
|
Class<? extends T> |
getServiceClass()
Returns the service class.
|
static <T extends Service> |
load(Properties properties,
String prefix,
Class<T> serviceBaseClass,
ClassLoader classLoader)
Deprecated.
use
load(Properties, String, Class, ProfileContext) instead |
static <T extends Service> |
load(Properties properties,
String prefix,
Class<T> serviceBaseClass,
ProfileContext context)
Loads a service profile with the specified key prefix.
|
T |
newInstance()
Creates a new instance using context parameters.
|
T |
newInstance(VariableResolver variables)
Deprecated.
use
newInstance() instead |
String |
normalize(String key,
String value,
boolean mandatory,
boolean resolve)
Normalizes the configuration value.
|
void |
storeTo(Properties properties)
Merges this profile into the specified properties.
|
public ServiceProfile(String prefix, Class<? extends T> serviceClass, Map<String,String> configuration, ProfileContext context)
prefix
- the key prefix of this profileserviceClass
- the service classconfiguration
- configuration for service classcontext
- the current profile contextIllegalArgumentException
- if some parameters were null
public String getPrefix()
public Class<? extends T> getServiceClass()
public Map<String,String> getConfiguration()
public String getConfiguration(String key, boolean mandatory, boolean resolve)
key
- the configuration keymandatory
- whether the configuration is mandatoryresolve
- whether resolves the configurationnull
if is not defined/emptyIllegalArgumentException
- if some parameters were null
public String normalize(String key, String value, boolean mandatory, boolean resolve)
key
- the configuration keyvalue
- the configuration value (nullable if only is not mandatory)mandatory
- whether the configuration is mandatoryresolve
- whether resolves the configurationnull
if is not defined/emptyIllegalArgumentException
- if some parameters were null
, or failed to normalizepublic ProfileContext getContext()
@Deprecated public ClassLoader getClassLoader()
getContext()
insteadpublic T newInstance() throws InterruptedException, IOException
configured
by using this profile.InterruptedException
- if interrupted in configuring the target serviceIOException
- if failed to create or configure the service@Deprecated public T newInstance(VariableResolver variables) throws InterruptedException, IOException
newInstance()
insteadconfigured
by using this profile.variables
- the variable resolverInterruptedException
- if interrupted in configuring the target serviceIOException
- if failed to create or configure the service@Deprecated public static <T extends Service> ServiceProfile<T> load(Properties properties, String prefix, Class<T> serviceBaseClass, ClassLoader classLoader)
load(Properties, String, Class, ProfileContext)
insteadT
- the base class of target classproperties
- source propertiesprefix
- the key prefixserviceBaseClass
- the base class of service classclassLoader
- the class loader to load the service classIllegalArgumentException
- if the target profile is invalid, or parameters contain null
public static <T extends Service> ServiceProfile<T> load(Properties properties, String prefix, Class<T> serviceBaseClass, ProfileContext context)
T
- the base class of target classproperties
- source propertiesprefix
- the key prefixserviceBaseClass
- the base class of service classcontext
- the current profile contextIllegalArgumentException
- if the target profile is invalid, or parameters contain null
public void storeTo(Properties properties)
properties
- target propertiesIllegalArgumentException
- if some parameters were null
Copyright © 2011–2019 Asakusa Framework Team. All rights reserved.