After the last analysis of the work done in V 0.7, began to refine the implementation of the details, because the technical details and the previous thought of a little different, in the refinement at the same time also slightly adjusted, the system is still unchanged, in this blog to see the implementation of the technical details of each task, then you can enter the coding implementation phase.
1. Service model
With the service model of OSGi, the service model used in spring is basically consistent with the Osgi:service and osgi:reference in Spring-dm, as in the following example:
Publishing Service (publish Bulletinlistaction as a Jndi DSF service):
<dsf:service id="BulletinListCommandService" version="1.0" ref="bulletinListAction"
interface="cn.org.osgi.xwork.action.IAction">
<dsf:service-properties>
<prop key="command">LIST</prop>
</dsf:service-properties>
<!--以jndi的方式对外发布-->
<dsf:jndi/>
</dsf:service>
Referencing services (referencing DSF services):
<dsf:reference id="extensionRegistry" interface="org.eclipse.core.runtime.IExtensionRegistry" version="[1.0,2,0)" cardinality="1..x" retries="3" timeout="5000">
<dsf:service-properties>
<prop key="command">LIST</prop>
</dsf:service-properties>
<!--以jndi的方式调用远程服务-->
<dsf:jndi/>
</dsf:reference>
For all spring configurations supported by the service model, I will publish the corresponding XSD file later.
2. Service Center
After querying the relevant data of memcachedb, it feels that its Java interface is still not very good, and decided to use the memcached to implement the storage itself, because the data of service model information is very small, and the frequency of maintenance changes is not so high, Temporary file way to store, the service center in the registration of the file stored in the shared space, after the file resolution as a service model object, put into memcached, when there are updates, delete action also do the corresponding processing, file storage and memcached interaction is relatively easy to do, Resolves the file to a service model object using XStream.
Service Center is based on SPRING-DM, Webwork-osgi simple implementation.
3. Publishing Service
The usage method is already in the example above, and the implementation steps are:
Provides support for the extended spring XML namespace;
Write Dsfjndiexporter class, which implements the process of registering a spring bean into jndi based on the spring jnditemplate (required to start the Jndi server locally, by default, JBoss JNP).
4. Call Service
This section analyzes the error before, ignoring the service application is not aware of the target service address, need to pass the distributed cache query to know, so not directly with the spring Jndiobjectfactorybean can be achieved, You need to write your own dsfobjectfactorybean, the implementation steps are:
Provides support for the extended spring XML namespace;
Write Dsfobjectfactorybean class, which is responsible for invoking the distributed cache, querying the target service address, because there are only jndi methods, Still completes the remaining work through spring's Jndiobjectfactorybean after obtaining the target service address.
After the four-step technology to achieve the details of the analysis, can be coded to complete the V 0.7 implementation.