Results 1 to 2 of 2

Thread: Defining a new auto-proxy creator

  1. #1
    Join Date
    Apr 2007
    Posts
    2

    Default Defining a new auto-proxy creator

    Hi,

    I would like to expose services (classes that implement an interface called Service) using RMI. I can export them one by one using RmiServiceExporter, but in order to avoid bloating the XML config I'd like to have an auto-proxy creator that automatically creates an RMI service exporter for any bean implementing the Service interface.

    The manual way:
    Code:
    <!-- Service class -->
    class MyService1 implements Service { 
    ... 
    }
    
    <!-- Service config in Spring -->
    <bean id="MyService1Bean" class="mycompany.MyService1"/>
    
    <!-- Publish service using RMI -->
    <bean class="org.springframework.remoting.rmi.RmiServiceExporter">
    	<property name="serviceInterface" value="mycompany.MyService1" />
    	<property name="serviceName" value="MyService1" />
    	<property name="service" ref="MyService1Bean" />
    </bean>
    
    (repeat this for each service)
    How can this be replaced with a standard Spring auto proxy creating mechanism?

    Thanks,
    Peter

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,632

    Default

    If you use Spring 2.5.x you could even define your own annotation for that. You could extend @Component or @Service and create a @RmiService annotation. Then create a BeanPostProcessor which knows what to do with it.

    You might want to take a look at the CommonAnnotationBeanPostProcessor and AutowireAnnotationBeanPostProcessor for some information. Also looking at the transcational stuff (@Transactional) might clear things.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •