Results 1 to 3 of 3

Thread: A problem with using EL to determine a method name for an init-method value

  1. #1
    Join Date
    Sep 2007
    Posts
    11

    Question A problem with using EL to determine a method name for an init-method value

    Hi. Is it possible to use expression language as an init-method value?

    Code:
    <bean id="foo" class="Foo" init-method="#{myExpression}"/>
    causes:
    Code:
    BeanDefinitionValidationException: Couldn't find an init method named '#{myExpression}' on bean with name 'foo'
    The same works fine when used as a value for a property. Am I doing something wrong or it is a known limitation?

    In case it really doesn't work, I need to determine a method to call in Flyway (migrate, validate, etc.) when context is created, which should be configured based on a value in properties file. The mapping is not 1-to-1, so I wanted to create a class which takes a property value, do transformation and give proper method name which is later read using EL: #{myCalculatingBean.methodName} and used as an init-method value. Can it be done in some other way?

    Thanks
    Marcin

  2. #2
    Join Date
    Dec 2009
    Location
    India
    Posts
    108

    Default

    I'm not sure if this is supported but I've never come across such use case. Here's what I would do

    Extend the class
    com.googlecode.flyway.core.Flyway
    and expose the property value here and define an init method which based upon the injected property value executes some business logic and decides the method name to call. Then call that method in your init method. and ofcourse replace this class name when creating bean with id flyway with init-method name as init.

  3. #3
    Join Date
    Sep 2007
    Posts
    11

    Default

    I like your solution. It resolves problem in a different way. I will give it a try. Thanks.

Tags for this Thread

Posting Permissions

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