public abstract class API extends Manageable
Manageable.State
BOOTSTRAPPED, BOOTSTRAPPING, DEINITIALIZING, INITIALIZING, UNUSABLE, USABLE
Modifier | Constructor and Description |
---|---|
protected |
API(String name)
Constructs a new
API object. |
Modifier and Type | Method and Description |
---|---|
protected void |
add(Manageable m)
Adds the specified manageable object.
|
boolean |
allow(String ip,
String functionName,
String conventionName)
Determines if the specified IP address is allowed to access the
specified function, returning a
boolean value. |
protected void |
bootstrapImpl(Map<String,String> buildSettings)
Bootstraps this API (wrapper method).
|
protected void |
bootstrapImpl2(Map<String,String> buildSettings)
Bootstraps this API (implementation method).
|
protected void |
deinitImpl()
Performs shutdown of this XINS API.
|
APISpec |
getAPISpecification()
Get the specification of the API.
|
Map<String,String> |
getBootstrapProperties()
Gets the bootstrap properties specified for the API.
|
List<Function> |
getFunctionList()
Gets the list of the functions of this API.
|
String |
getName()
Gets the name of this API.
|
RuntimeProperties |
getProperties()
Gets the runtime properties specified in the implementation.
|
InputStream |
getResourceAsStream(String path)
Gets the resource in the WAR file.
|
long |
getStartupTimestamp()
Gets the timestamp that indicates when this
API instance
was created. |
TimeZone |
getTimeZone()
Returns the applicable time zone.
|
protected void |
initImpl(Map<String,String> runtimeSettings)
Initializes this API.
|
protected void |
reinitializeImpl()
Triggers re-initialization of this API.
|
assertUsable, bootstrap, deinit, getState, init, isBootstrapped, isUsable
protected API(String name) throws IllegalArgumentException
API
object.name
- the name of the API, cannot be null
nor can it be an
empty string.IllegalArgumentException
- if name == null
|| name.length()
< 1
.public final String getName()
null
and never an empty
string.public final List<Function> getFunctionList()
public Map<String,String> getBootstrapProperties()
null
.public RuntimeProperties getProperties()
null
.public final long getStartupTimestamp()
API
instance
was created.public final TimeZone getTimeZone()
null
.public final InputStream getResourceAsStream(String path) throws IllegalArgumentException
path
- the path for the resource, cannot be null
and should start with /.null
if
the resource cannot be found.IllegalArgumentException
- if path == null
or if the path doesn't start with /.protected final void bootstrapImpl(Map<String,String> buildSettings) throws IllegalStateException, MissingRequiredPropertyException, InvalidPropertyValueException, BootstrapException
bootstrapImpl2(Map)
.bootstrapImpl
in class Manageable
buildSettings
- the build-time configuration properties, not null
.IllegalStateException
- if this API is currently not bootstraping.MissingRequiredPropertyException
- if a required property is not given.InvalidPropertyValueException
- if a property has an invalid value.BootstrapException
- if the bootstrap fails.protected void bootstrapImpl2(Map<String,String> buildSettings) throws MissingRequiredPropertyException, InvalidPropertyValueException, BootstrapException
API
is empty.
Custom subclasses can perform any necessary bootstrapping in this
class.
Note that bootstrapping and initialization are different. Bootstrap
includes only the one-time configuration of the API based on the
build-time settings, while the initialization
The add(Manageable)
may be called from this method,
and from this method only.buildSettings
- the build-time properties, guaranteed not to be null
.MissingRequiredPropertyException
- if a required property is not given.InvalidPropertyValueException
- if a property has an invalid value.BootstrapException
- if the bootstrap fails.protected final void reinitializeImpl()
protected final void initImpl(Map<String,String> runtimeSettings) throws MissingRequiredPropertyException, InvalidPropertyValueException, InitializationException, IllegalStateException
initImpl
in class Manageable
runtimeSettings
- the runtime configuration settings, cannot be null
.MissingRequiredPropertyException
- if a required property is missing.InvalidPropertyValueException
- if a property has an invalid value.InitializationException
- if the initialization failed for some other reason.IllegalStateException
- if this API is currently not initializing.protected final void add(Manageable m) throws IllegalStateException, IllegalArgumentException
m
- the manageable object to add, not null
.IllegalStateException
- if this API is currently not bootstrapping.IllegalArgumentException
- if instance == null
.protected final void deinitImpl()
deinitImpl
in class Manageable
public final APISpec getAPISpecification() throws InvalidSpecificationException
APISpec
specification object, never null
.InvalidSpecificationException
- if the specification cannot be found or is invalid.public boolean allow(String ip, String functionName, String conventionName) throws IllegalArgumentException
boolean
value.
This method finds the first matching rule and then returns the
allow property of that rule (see
AccessRule.isAllowRule()
). If there is no matching rule, then
false
is returned.
ip
- the IP address, cannot be null
.functionName
- the name of the function, cannot be null
.conventionName
- the name of the calling convention, can be null
.true
if the request is allowed, false
if
the request is denied.IllegalArgumentException
- if ip == null || functionName == null
.See http://www.xins.org/.