Results 1 to 2 of 2

Thread: Hessian Exporter

  1. #1
    Join Date
    Aug 2005
    Posts
    14

    Default Hessian Exporter

    Hi to all,
    How can I export an Hessian sevice with java-config?
    Suppose you have the following xml configuration:
    Code:
        <bean name="/ServiceRoles"
            class="org.springframework.remoting.caucho.HessianServiceExporter">
            <property name="service" ref="roleManager" />
            <property name="serviceInterface"
                value="my.org.IRoleManager" />
        </bean>
    How can I convert to java-config? If I use this configuration:
    Code:
       @Bean(aliases = { "/ServerRoles" } )
       public HessianServiceExporter ServerRoles() {
          HessianServiceExporter exporter = new HessianServiceExporter();
          exporter.setService(roleManager());
          exporter.setServiceInterface(IRoleManager.class);
          return exporter;
       }
    And inside the ApplicationContext.xml in Tomcat I have activate java-config from XML:
    Code:
    <beans>
     ...
        <bean class="org.springframework.config.java.process.ConfigurationPostProcessor"/>
    <beans>
    The Exporter would not work!
    How can I export the service ?

  2. #2
    Join Date
    Aug 2008
    Location
    Billings, Montana
    Posts
    47

    Default

    Michele,

    This should work for you. It also includes a simple test.
    Code:
    public class HessianTest {
        @Test
        public void testHessianConfig() {
            ClassPathXmlApplicationContext bf = new ClassPathXmlApplicationContext("hessianTest.xml", getClass());
    
            HessianServiceExporter exporter = (HessianServiceExporter) bf.getBean("/ServerRoles");
            IRoleManager service = (IRoleManager)exporter.getService();
            assertEquals("role", service.getRole());
        }
    
        @Configuration
        static class HessianConfig {
            @Bean(aliases = { "/ServerRoles" } )
            public HessianServiceExporter ServerRoles() {
               HessianServiceExporter exporter = new HessianServiceExporter();
               exporter.setService(roleManager());
               exporter.setServiceInterface(IRoleManager.class);
               return exporter;
            }
    
            @Bean
            public IRoleManager roleManager() {
                return new RoleManager();
            }
        }
    
        static interface IRoleManager {
            public String getRole();
        }
    
        static class RoleManager implements IRoleManager {
            public String getRole() {
                return "role";
            }
        }
    }
    Here is the Spring hessianTest.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"
    >
    
    <beans>
    
    	<bean class="org.springframework.config.java.process.ConfigurationPostProcessor"/>
    
    	<bean class="HessianTest$HessianConfig" />
    
    </beans>
    Hope this helps.

    -Arul
    Last edited by aruld; Oct 1st, 2008 at 11:32 PM. Reason: fixed a typo

Posting Permissions

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