hivemind-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Jakarta-hivemind Wiki] Update of "UsingSpringRemoting" by robortluo
Date Wed, 03 Aug 2005 13:06:18 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Jakarta-hivemind Wiki" for change
notification.

The following page has been changed by robortluo:
http://wiki.apache.org/jakarta-hivemind/UsingSpringRemoting

New page:
== Problem ==

You want to access a remote service by RMI or web service transparently.

== Idea ==

Obviously there should be a ''remoting'' implementation instead of normal ''local'' implementation
of your service. However, we still need to write code to do real thing. Why reinvent wheels?
There is a package named spring-remoting in spring framework, it handle this problem well,
and the solution has been proved. Let's make it hivemind way!

== Solution ==

First, a service point to provide service like usual:
 
{{{
    <service-point id="FinanceService" interface="mypackage.FinanceService"/>
}}}

Then, a remote implementation:

{{{
    <service-point id="rmiFinanceInterceptor" 
        interface="org.aopalliance.intercept.MethodInterceptor">
        <invoke-factory>
            <construct class="org.springframework.remoting.rmi.RmiClientInterceptor">
                <set property="serviceUrl" value="rmi://myserver:1399/financeService"/>
                <set-object property="serviceInterface"
                   value="class:mypackage.FinanceService"/>
            </construct>
        </invoke-factory>    
    </service-point>
    <implementation service-id="mypackage.FinanceService">
       <invoke-factory service-id="hivemind.lib.PlaceholderFactory"/>
       <interceptor service-id="hivemind.lib.MethodInterceptorFactory">
           <impl object="service:rmiFinanceInterceptor"/>
       </interceptor>
    </implementation>
}}}

That's it! The magic here is the hivemind.lib.!MethodInterceptorFactory service, it opens
the door to spring interceptors. In this way, we can even use spring transaction package to
declare hivemind transactional service!

== How about go further ==

Make a !ServiceImplementationFactory (let's name it ''RMI!RemotingServiceFactory'') to declare
the service easier and cleaner, so we can do:

{{{
    <implementation service-id="mypackage.FinanceService">
        <invoke-factory service-id="hivemind.contrib.RMIRemotingServiceFactory">
            <remote url="rmi://myserver:1399/financeService"/>
        </invoke-factory>
    </implementation>
}}}

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-cvs-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-cvs-help@jakarta.apache.org


Mime
View raw message