facebook

Getting Spring ApplicationContext

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #250161 Reply

    I am beginner in Struts – Spring and Hibernate Technologies.
    I am developing my first project.
    I add Hibernate and Spring capabilities to my project and myeclipse generates serveral files.

    In MytableDAO class appears the method getFromApplicationContext(ApplicationContext ctx)

    How do I call to this method in a Struts Action execute method?
    How do I get a ApplicationContext?

    Any example or Tutorial?

    Thanks.

    #250304

    Haris Peco
    Member

    Fernando,

    You have to make spring context (probably in some static method) like this :

    ApplicationContext context = new ClassPathXmlApplicationContext(“/applicationContext.xml”);

    this is example utility class (for idea only)

    
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    
    public class SpringUtil {
            private static ApplicationContext ctx;
            private static String[] springXmls = { "/applicationContext.xml" };
            public static ApplicationContext getSpringContext() {
                    if (ctx == null)
                            ctx = new ClassPathXmlApplicationContext(springXmls);
                    return ctx;
            }
    }
    

    you have different tutorials/artcles here http://www.springframework.org/articles

    best

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Getting Spring ApplicationContext

You must be logged in to post in the forum log in