Results 1 to 3 of 3

Thread: HOWTO: Use Spring core in a J2EE application server like weblogic

  1. #1
    Join Date
    Sep 2005
    Posts
    16

    Thumbs up HOWTO: Use Spring core in a J2EE application server like weblogic

    Hi,

    Please advise if the query below is in-appropriate for this forum.
    Would appreciate if you indicate the proper one.

    My query in the simplest form is: How can you use spring core in an application server?

    To elaborate;

    My last project in developed using the spring f/w, was something like

    Process-A is message aware and is awaiting a JMS message. Upon receipt it parses the text and calls business logic implemented in other POJO’s and injected into this message-aware component.Ultimately using iBatis spring helper templates to persist to a database.

    All classes were packaged into .JAR and executed off a command-prompt using a bootstrap-loader
    basically a class implementing the org.springframework.beans.factory.InitializingBean interface
    and defined in the application-context xml with the init-method attribute.

    Upon start it would call another bean which was a Runnable, an infinitely executing thread, within which was the message-aware POJO. And thus I had an infinitely running daemon, listening for JMS messages.

    It could be killed by a simple Ctrl+C.

    Could such an application be deployed to work in an application server? If yes how?

    As I understand to deploy in an app server, I need to package everything in a EAR which has either a WAR (Web application archive) or EJB-JAR (Enterprise Java bean archive)

    My application developed using spring is neither, so the query

    TIA
    ~g1

  2. #2
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Look ate Spring MVC (chapter 3.8.5 in particular). All you need is to integrate your Application Context with your Application container via web.xml and use ContextLoader to bootstrap your application context as shown below.

    Code:
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/your-config.xml
        </param-value>
    </context-param>
    
    <listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>
    Then if you want to access it within your environment, Spring provides a convenience API
    Code:
    . . . . . . .
    ApplicationContext context = WebApplicationContextUtils.
                    getRequiredWebApplicationContext(getServletContext());
    YourBean bean = (YourBean)context.getBean("yourBean");
    . . . . . . .

  3. #3
    Join Date
    Sep 2005
    Posts
    16

    Question HOWTO: Use Spring core in a nonUI J2EE application and deploy in weblogic

    oleg,

    Thank you.

    Yes I was aware of the ContextLoader and have used it to integrate a Struts based web application and Spring and use the benefits of the IOC pattern in my web application.

    But the issue in hand is the application to be developed has no UI (is not a WEB application) it is more of a batch level (daemon), but I want it packaged in EAR and deployed in an application server.

    I have the option of developing the app with message-driven-beans listening off the JMS bus and calling standard java classes to do the further processing. I cannot use Spring.

    ~g1

Posting Permissions

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