Announcement Announcement Module
Collapse
No announcement yet.
Dynamically Create a Bean after the context files are loaded Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dynamically Create a Bean after the context files are loaded

    Hi, All
    I have to create some set of beans dynamically after the main context file has loaded.
    I have some interface to implement by clients and after they implemented then they will plug services in to main application, when they plug in to my system, I have to create some special set of beans to handle those services that has been created by the clients. Each cleints will have some special beans to handle and up on run there services.

    I don't know the feasibility to create a bean dynamically in spring and onces we create, will it be active until the restart..? Please suggest a spring technique for me to do this.

    Thanks you..

  • #2
    I think to accomplish what you describe, the best solution would involve using OSGi. Have you looked at dm Server and/or Spring-DM?

    Comment


    • #3
      Thanks you very much Mark Fisher for you reply.
      But this is not dynamically loading the modules as you suggested. I'll explain the real scenario of my application.

      My application is an Auditing application. Which is providing the Auditing functionality to the whole system. This module have SpringAOP with AspectJ to monitor pointcuts which are defined in the system. When a pointcut is detected, inject a JMS message to a Topic which is listen my some listeners- using SpringJMS and ActiveMQ message broker. Then that listener will handle the audit section.

      Now I have the facility in my module to provided some external listeners which can be extend able some of Auditing interfaces by some other modules. When they register there listeners with the Audit module, then I have to create a Topic for that External listener ( This is some kind of reverse process what I have explained earlear.). That topic will handle all the special point-cuts which are required by the external listener. Now my problem is I can't predefined those JMS Topics in my context file. External listeners only register their listeners in their context file. So when I detect that listener bean I have to create a Topic bean for that listener and assign with the listener bean. The topic bean will create according to the listener from a generic Topic implementation. This is my problem.

      Please help me how can I resolve this problem..

      Thank you.

      Comment


      • #4
        Are you using the Spring Integration project?

        At first I assumed so, since you are posting in the forum category. However, I don't see any mention of it in your description.

        Comment


        • #5
          I'm using spring in my project. I think I have mistakenly posted here.. I'm new to this forum, hence I started my thread here.

          Comment


          • #6
            That's okay. You may actually want to have a look at Spring Integration, since it would allow you to create multiple "channels" that are backed by JMS Topics.

            http://www.springsource.org/spring-integration

            Comment


            • #7
              Thanks your kind information.. It will definitely help to my problem..

              Comment


              • #8
                Hi Mark Fisher again,
                I have gone through the important topics in the Spring Integration that you suggest me. But that also reflecting that we can only able to use the beans which are created according to the predefined bean configuration is in the context file.
                But my problem is I cannot predefine all the beans in the context file. According to the client configuration, I have to create the necessary beans to handle the client's services. Do you have any idea regarding this issue..

                Thanks you.

                Comment


                • #9
                  It sounds to me like you simply want to use the API programmatically at runtime. Anything that is created via <bean/> elements or any other namespace (such as those provided by Spring Integration) can also be created at runtime. So, for example, you can instantiate an implementation of MessageHandler and then configure it within an endpoint that connects it to a channel. On the other hand, think of the "beans" defined within an Application Context as those which you do know about at startup time. Does that make sense?

                  Comment


                  • #10
                    Thanks for your reply Mark Fisher.
                    //It sounds to me like you simply want to use the API programmatically at runtime.

                    Exactly, I have to create the bean for the API implementation programically. Thats my problem.

                    //On the other hand, think of the "beans" defined within an Application Context as those which you do know about at startup time.

                    I couldn't get it clear what you are mention above.

                    Thanks you.

                    Comment

                    Working...
                    X