|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codegist.crest.config.XmlDrivenInterfaceConfigFactory
public class XmlDrivenInterfaceConfigFactory
Xml based config factory of any possible interfaces given to the factory.
Usefull when the end-point should be read externally instead, eg for profil (dev,integration,prod)
Expected format for a single Interface config is of the following :
- Any property not specified as mandatory is optional.
- The same logic as the annotation config applies here, config fallbacks from param to method to interface until one config is found, otherwise defaults to any respective default value (InterfaceConfig
, MethodConfig
, ParamConfig
).
package my.rest.interface;
class Interface {
String get();
String get(String s);
void push(String s);
}
<?xml version="1.0" encoding="UTF-8"?>
<crest-config>
<service class="my.rest.interface.Interface" encoding="utf-8">
<end-point>http://localhost:8080</end-point>
<context-path>/my-path</context-path>
<global-interceptor>my.rest.interceptor.MyRequestInterceptor</global-interceptor>
<methods>
<default socket-timeout="1" connection-timeout="2" method="DELETE">
<path>/hello</path>
<request-interceptor>my.rest.MyRequestHandler2</request-interceptor>
<response-handler>my.rest.MyResponseHandler</response-handler>
<error-handler>my.rest.MyErrorHandler</error-handler>
<retry-handler>my.rest.MyRetryHandler</retry-handler>
<params>
<static-param destination="BODY" name="my-param-name">value1</static-param>
<default destination="BODY" name="name">
<serializer>my.rest.serializer.MyParamSerializer</serializer>
<injector>my.rest.injector.MyRequestInjector</injector>
</default>
</params>
</default>
<method match="get\(.*\)" socket-timeout="3" connection-timeout="4" method="PUT">
<path>/get</path>
<request-interceptor>my.rest.interceptor.MyRequestInterceptor2</request-interceptor>
<response-handler>my.rest.MyResponseHandler2</response-handler>
<error-handler>my.rest.MyErrorHandler2</error-handler>
<params>
<static-param destination="HEADER" name="my-param-name-2">value</static-param>
<static-param destination="BODY" name="body-param-2">new-value</static-param>
<default destination="URL" name="name1">
<serializer>my.rest.serializer.MyParamSerializer2</serializer>
<injector>my.rest.injector.MyRequestInjector2</injector>
</default>
<param index="0" destination="URL" name="a">
<serializer>my.rest.serializer.MyParamSerializer3</serializer>
<injector>my.rest.interceptor.MyRequestInterceptor3</injector>
</param>
</params>
</method>
<method match="push\(\)" >
<path>/push</path>
</method>
</methods>
</service>
<service class="my.rest.interface.Interface2" encoding="utf-8">
(...)
</service>
</crest-config>
Can contain as much interface config as needed in a single Properties (or Map) object.
A shortcut to configure the server for all interfaces is :
service.end-point=My server url
The interface specific end-point if specified override the global one.
InterfaceConfig
Constructor Summary | |
---|---|
XmlDrivenInterfaceConfigFactory(Document config)
|
|
XmlDrivenInterfaceConfigFactory(Document config,
boolean useDefaults)
|
Method Summary | |
---|---|
InterfaceConfig |
newConfig(Class<?> interfaze,
CRestContext context)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XmlDrivenInterfaceConfigFactory(Document config, boolean useDefaults)
public XmlDrivenInterfaceConfigFactory(Document config)
Method Detail |
---|
public InterfaceConfig newConfig(Class<?> interfaze, CRestContext context) throws ConfigFactoryException
newConfig
in interface InterfaceConfigFactory
interfaze
- Interface to build the configuration fromcontext
- Current CRest context
ConfigFactoryException
- for any problem occuring during the configuration constructionInterfaceConfigFactory
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |