Announcement Announcement Module
Collapse

JavaConfig forum decommissioned in favor of Core Container

As described at

http://static.springsource.org/sprin...fig/README.TXT

key features of the Spring JavaConfig project have been migrated into the core Spring Framework as of version 3.0.

Please see the Spring 3.0 documentation on @Configuration and @Bean support:

http://static.springsource.org/sprin...tml#beans-java

For any questions related to @Configuration classes and @Bean methods in Spring 3.0, please post in the dedicated 'Core Container' forum at

http://forum.springsource.org/forumdisplay.php?f=26
See more
See less
Hessian Exporter Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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, 11:32 PM. Reason: fixed a typo

    Comment

    Working...
    X