The two main files used to configure GraniteDS are granite-config.xml
and services-config.xml
. By default these files
should be present in the web archive in WEB-INF/granite/granite-config.xml
and WEB-INF/flex/services-config.xml
.
If absolutely needed, they can be placed in another location, but then you will have to specify two servlet parameters in web.xml
to
indicate GraniteDS where to look for them:
<context-param>
<param-name>servicesConfigPath</param-name>
<param-value>/WEB-INF/flex/services-config.xml</param-value>
</context-param>
<context-param>
<param-name>graniteConfigPath</param-name>
<param-value>/WEB-INF/granite/granite-config.xml</param-value>
</context-param>
<granite scan="true">
: instructs GraniteDS to scan application archives and to automatically register the configuration elements it
discovers.
<amf3-deserializer type="com.myapp.custom.CustomAMF3Deserializer">
: registers a custom deserializer that should implement
the interface java.io.ObjectInput
. The default is org.granite.messaging.amf.io.AMF3Deserializer
.
<amf3-serializer type="com.myapp.custom.CustomAMF3Serializer">
: registers a custom serializer that should implement
the interface java.io.ObjectOutput
. The default is org.granite.messaging.amf.io.AMF3Serializer
.
<amf3-message-interceptor type="">
: registers an optional message interceptor that should implement
org.granite.messaging.amf.process.AMF3MessageInterceptor
.
<class-getter type="">
: registers a class getter that should implement
org.granite.messaging.amf.io.util.ClassGetter
.
<converters>
: registers a list of data converters that should implement
org.granite.messaging.amf.io.convert.Converter
.
<descriptors>
: registers a list of type descriptors that should extend either
org.granite.messaging.amf.io.util.ActionScriptClassDescriptor
or
org.granite.messaging.amf.io.util.JavaClassDescriptor
.
<exception-converters>
: registers a list of exception converters that should implement
org.granite.messaging.service.ExceptionConverter
.
<externalizers>
: registers custom externalizers that should implement
org.granite.messaging.amf.io.util.externalizer.Externalizer
. See also here.
<!-- XML : generated by JHighlight v1.0 (http://jhighlight.dev.java.net) --> <span class="xml_plain"></span><br /> <span class="xml_tag_symbols"><</span><span class="xml_tag_name">externalizers</span><span class="xml_tag_symbols">></span><span class="xml_plain"></span><br /> <span class="xml_plain"> </span><span class="xml_tag_symbols"><</span><span class="xml_tag_name">configuration</span><span class="xml_tag_symbols">></span><span class="xml_plain"></span><br /> <span class="xml_plain"> </span><span class="xml_tag_symbols"></</span><span class="xml_tag_name">configuration</span><span class="xml_tag_symbols">></span><span class="xml_plain"></span><br /> <span class="xml_plain"> </span><span class="xml_tag_symbols"><</span><span class="xml_tag_name">externalizer</span><span class="xml_plain"> </span><span class="xml_attribute_name">type</span><span class="xml_tag_symbols">=</span><span class="xml_attribute_value">""</span><span class="xml_tag_symbols">/></span><span class="xml_plain"></span><br /> <span class="xml_tag_symbols"></</span><span class="xml_tag_name">externalizers</span><span class="xml_tag_symbols">></span><span class="xml_plain"></span><br /> <span class="xml_plain"> </span><br />
<gravity>
: configures the Gravity internal parameters. See here.
<instantiators>
: registers custom instantiators that should implement
org.granite.messaging.amf.io.util.instantiator.AbstractInstantiator
.
<invocation-listener type="">
: registers an invocation listener that will be called at each invocation and should
implement org.granite.messaging.service.ServiceInvocationListener
.
<message-selector>
: registers a custom message selector implementation that should implement
org.granite.gravity.selector.MessageSelector
. 3 implementations are available, the default is GravityMessageSelector
.
<method-matcher type="">
: registers a custom method matcher that should implement
org.granite.messaging.service.MethodMatcher
.
<security>
: registers a custom security service that should implement
org.granite.messaging.service.security.SecurityService
.
<tide-components>
: registers a list of component matchers to enable remote access for Tide service factories. There are 4
ways or enabling or diabling access to Tide components:
<!-- XML : generated by JHighlight v1.0 (http://jhighlight.dev.java.net) --> <span class="xml_plain"></span><br /> <span class="xml_tag_symbols"><</span><span class="xml_tag_name">tide-components</span><span class="xml_tag_symbols">></span><span class="xml_plain"></span><br /> <span class="xml_plain"> </span><span class="xml_tag_symbols"><</span><span class="xml_tag_name">tide-component</span><span class="xml_plain"> </span><span class="xml_attribute_name">annotated-with</span><span class="xml_tag_symbols">=</span><span class="xml_attribute_value">""</span><span class="xml_tag_symbols">/></span><span class="xml_plain"></span><br /> <span class="xml_plain"> </span><span class="xml_tag_symbols"><</span><span class="xml_tag_name">tide-component</span><span class="xml_plain"> </span><span class="xml_attribute_name">instance-of</span><span class="xml_tag_symbols">=</span><span class="xml_attribute_value">""</span><span class="xml_tag_symbols">/></span><span class="xml_plain"></span><br /> <span class="xml_plain"> </span><span class="xml_tag_symbols"><</span><span class="xml_tag_name">tide-component</span><span class="xml_plain"> </span><span class="xml_attribute_name">name</span><span class="xml_tag_symbols">=</span><span class="xml_attribute_value">""</span><span class="xml_tag_symbols">/></span><span class="xml_plain"></span><br /> <span class="xml_plain"> </span><span class="xml_tag_symbols"><</span><span class="xml_tag_name">tide-component</span><span class="xml_plain"> </span><span class="xml_attribute_name">type</span><span class="xml_tag_symbols">=</span><span class="xml_attribute_value">""</span><span class="xml_plain"> </span><span class="xml_attribute_name">disabled</span><span class="xml_tag_symbols">=</span><span class="xml_attribute_value">"true"</span><span class="xml_tag_symbols">/></span><span class="xml_plain"></span><br /> <span class="xml_tag_symbols"></</span><span class="xml_tag_name">tide-components</span><span class="xml_tag_symbols">></span><span class="xml_plain"></span><br /> <span class="xml_plain"> </span><br />
annotated-with
: component class is annotated with the specified annotation class.
instance-of
: component class extends or implements the specified interface or class.
name
: component name matches the specified name regular expression.
type
: component class matches the specified class name regular expression.
A channel definition mostly contains the endpoint url and the client channel implementation:
<channels>
<channel-definition id="my-graniteamf" class="mx.messaging.channels.AMFChannel">
<endpoint
uri="http://{server.name}:{server.port}/{context.root}/graniteamf/amf"
class="flex.messaging.endpoints.AMFEndpoint"/>
</channel-definition>
</channels>
GraniteDS provides 4 implementations of the Flex Channel
:
mx.messaging.channels.AMFChannel
: standard HTTP remoting channel.
mx.messaging.channels.SecureAMFChannel
: standard HTTPS remoting channel.
org.granite.gravity.channels.GravityChannel
: standard HTTP messaging channel.
org.granite.gravity.channels.SecureGravityChannel
: standard HTTPS messaging channel.
<services>
<service
id="granite-service"
class="flex.messaging.services.RemotingService"
messageTypes="flex.messaging.messages.RemotingMessage">
<destination id="cars">
<channels>
<channel ref="my-graniteamf"/>
</channels>
<properties>
<factory>guiceFactory</factory>
<source>test.granite.guice.services.Cars</source>
</properties>
</destination>
</service>
</services>
A destination can also define a list of security roles that are allowed to access the remote component. See Remoting Security.
<service id="gravity-service"
class="flex.messaging.services.MessagingService"
messageTypes="flex.messaging.messages.AsyncMessage">
<adapters>
<adapter-definition id="simple" class="org.granite.gravity.adapters.SimpleServiceAdapter"/>
<!--adapter-definition id="jms" class="org.granite.gravity.adapters.JMSServiceAdapter"/-->
</adapters>
<destination id="addressBookTopic">
<properties>
<!--jms>
<destination-type>Topic</destination-type>
<connection-factory>ConnectionFactory</connection-factory>
<destination-jndi-name>topic/testTopic</destination-jndi-name>
<destination-name>dataTopic</destination-name>
<acknowledge-mode>AUTO_ACKNOWLEDGE</acknowledge-mode>
<transacted-sessions>true</transacted-sessions>
<no-local>true</no-local>
</jms-->
<no-local>true</no-local>
<session-selector>true</session-selector>
</properties>
<channels>
<channel ref="gravityamf"/>
</channels>
<adapter ref="simple"/>
<!--adapter ref="jms"/-->
</destination>
</service>
A destination can also define a list of security roles that are allowed to access the remote component. See Messaging Security.