Results 1 to 4 of 4

Thread: static property instantiation

  1. #1

    Default 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. #2
    Join Date
    Feb 2011
    Posts
    9

    Default

    Quote 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

  3. #3
    Join Date
    Feb 2011
    Posts
    9

    Default

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

  4. #4

    Default 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/

Posting Permissions

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