Announcement Announcement Module
Collapse
No announcement yet.
static property instantiation Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • static property instantiation

    I need to instantiate via a static property

    ThirdPartyObject.Instance

    so I tried

    <object id="newObject" type="ThirdPartyObject, TheAssembly",
    factory-method="Instance"/>

    but through an exception.

    I only saw the static factory method approach. Is there one that works with a property?
    Reply With Quote

  • #2
    Originally posted by hallatie View Post
    I need to instantiate via a static property

    ThirdPartyObject.Instance

    so I tried

    <object id="newObject" type="ThirdPartyObject, TheAssembly",
    factory-method="Instance"/>

    but through an exception.

    I only saw the static factory method approach. Is there one that works with a property?
    Reply With Quote




    <bean id="exampleBean" class="examples.ExampleBean2" factory-method="createInstance"/>

    "createInstance" method must be static method, now when ever you have dependency on some other bean this the "createInstance" method will be called to create a objcet of the class "examples.ExampleBean2"

    For more information you can follow the topic --
    3.2.3. The bean class
    3.2.3.1. Bean creation via constructor
    3.2.3.2. Bean creation via static factory method
    3.2.3.3. Bean creation via instance factory method
    from http://static.springframework.org/sp...-reference.pdf

    Comment


    • #3
      if you want that a "third-party-object" to "create some-other-object" using "third-party-objects-factory-method" then you should try like this---


      <bean id="third-party-object" class="third-party-class"/>
      <bean id="some-id" factory-bean="third-party-object" factory-method="third-party-objects-factory-method"/>

      Comment


      • #4
        bikanermarket

        hey guys.......i feel good to introduce you guys to a very well designed and nicely made website..everyone should watch it...this is really awesum......


        http://www.bikanermarket.com/

        Comment

        Working...
        X