Announcement Announcement Module
No announcement yet.
Newbie: moving from avalon to spring Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Newbie: moving from avalon to spring

    Hi all,

    I am a Spring newbie user, today being the third consecutives day I am studying it using the spring-reference Manual.

    My company has a big corporate banking application developed with Cocoon and ApacheAvalon.

    We are now in the process of changing ApacheAvalon and start using Spring, so I am looking for a way to convert our Avalon Components ..

    I am missing something because I can't understand how I can replace the concept Avalon uses, such as the interfaces ThreadSafe, LogEnabled, Serviceable, Disposable, Configurable, Initializable. ( )

    I only found some PicoContainer equivalent here:

    and something in the article 'Introduction to the Spring Framework', where, btw, I found only differences bwtween Spring and EJBs

    any help appreciated

  • #2
    I haven't used avalon but from what I understand it uses IoC through interfaces (type 1 if I'm not mistaken). What you have to do is translate this interfaces into Spring by using Spring specific items namely interceptors or factory beans.

    For example - ThreadSafe I assume it makes your classes to be non-singleton - here you can define your beans as being non-singleton. You can create a very simple FactoryBean which will read the class interfaces and delegate the bean creation call to the main factory bean with the singleton true or false (you have to dig intot the javadocs for more details).

    LogEnabled - this can be achieved using a log interceptor - if the target contains the interface, the logging interceptor will be applied.

    About the rest of them I guess you can figure out yoursefl - for me at least Serviceable it's too abstract. Initializable I think it has a direct implemention in Spring, you can use however the init-method attribute when declaring a bean. Same with Disposable (destroy-method).
    It would be really nice if you can post your finding on the WIKI (more or less create a migration guide).


    • #3

      I have tried to add the attribute (init-method="init") in the bean definition and it works great.

      more and more in this way I have not to add Spring dependencies inside my beans

      now looking for interceptors meaning...



      • #4
        Indeed - spring is very transparent and can decouple from your code to great extend. About interceptors just read the standard documentation and do some examples (see also the samples).


        • #5
          the conversion from Avalon to Spring is proceeding.

          the way I am going on is the following:

          - I create a new Java project (a clone of the one using Avalon)

          - I started removing Avalon interfaces.. (Initializable, Configurable)

          - I started writing application-context.xml configuring all the beans

          - I started using only singleton="true", init-method="init", close-method="close" attributes

          - then I started to write relationship between components
          <property name="databaseManager">
          <ref bean="springDatabaseManager"/>

          - then I continued removing NullPointer's in my old java code ;-)

          - then I started trying one of my old and real CommandObject

          //creazione application context
          String[] config = new String[] {"applicationContext.xml"};
          ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(config);
          BeanFactory factory = (BeanFactory) appContext;

          //creazione CmdExecutor
          SpringCommandExecutorImpl cmdExecutor = (SpringCommandExecutorImpl)factory.getBean("cmdExe cutor", SpringCommandExecutorImpl.class);

          //eseguo il command
          try {

          delegheF24 = (DelegheF24) cmdExecutor.executeCommand( tClass().getName(),delegheF24);
"FOUND SOMETHING? " + delegheF24.getCollectionSize());

          } catch (ComponentLocationException e1) {
          // TODO Blocco catch generato automaticamente
          } catch (CommandExecutionException e1) {
          // TODO Blocco catch generato automaticamente
          } catch (ServiceLocationException e1) {
          // TODO Blocco catch generato automaticamente
          } catch (CommandCreationException e1) {
          // TODO Blocco catch generato automaticamente

          - then I started writing a Junit Test for comparing BusinessObject obtained using Avalon and Spring

          btw this conversion seems acceptable, indeed I found Spring easier to use even if this study is a preliminar one.

          Our code didn't use EJB but POJO so difficulties should arise only in the configuration phase.
          Our implementation code is quite the same as before.

          Now looking for a way to continue this porting also to the frontend code that is written and will be written using Cocoon.

          About the migration guide we have some document to review yet.



          • #6
            Great - don't forget about the wiki somewhere in the future when you have finished it