Results 1 to 6 of 6

Thread: Newbie: moving from avalon to spring

  1. #1
    Join Date
    Aug 2005
    Posts
    8

    Default 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. ( http://cocoon.apache.org/2.1/developing/avalon.html )

    I only found some PicoContainer equivalent here:
    http://www.picocontainer.org/Differentiators

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

    any help appreciated
    thks
    Leonardo

  2. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    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).
    Thanks.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  3. #3
    Join Date
    Aug 2005
    Posts
    8

    Default

    Hi,

    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...

    thks
    Leonardo

  4. #4
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    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).
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  5. #5
    Join Date
    Aug 2005
    Posts
    8

    Default

    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"/>
    </property>

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

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

    example:
    //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(elencoDelegheCommand.ge tClass().getName(),delegheF24);
    logger.info("FOUND SOMETHING? " + delegheF24.getCollectionSize());

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

    - 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.

    thks
    Leo

  6. #6
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Great - don't forget about the wiki somewhere in the future when you have finished it
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

Similar Threads

  1. Spring MVC Web Framework versus Struts
    By biguniverse in forum Web Flow
    Replies: 27
    Last Post: Aug 29th, 2012, 03:57 AM
  2. Moving from Exalibur to Spring
    By Leonets in forum Architecture
    Replies: 2
    Last Post: Sep 15th, 2005, 10:24 AM
  3. Newbie Question - The Ideal Spring Solution
    By conorp in forum Architecture
    Replies: 3
    Last Post: Aug 23rd, 2005, 03:22 AM
  4. A Spring Class Loader?
    By azzoti in forum Architecture
    Replies: 8
    Last Post: May 7th, 2005, 04:02 AM
  5. Replies: 14
    Last Post: Feb 21st, 2005, 05:41 PM

Posting Permissions

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