• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Application context

 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hello all,

I am pretty new to spring. Recently joined a new job where spring framework is used and needed to understand this.

How does the ApplicationContext gets instantiated, when the server starts up. Is it provided automatically by the framework or do we create it in our Code.

Here is the piece of code we have, that I dont understand.

web.xml
<servlet>
<servlet-name>business</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
**********************************************************************
business-servlet.xml has a class called Businessregistry that is declared in the business-servlet.xml
business-sevlet.xml also has all the other business or service objects also.


business-servlet.xml
<bean class="com.weather.north.Businessregistry" />

**********************************************************

BusinessRegistry is a ApplicationContextAware that has the ClassPathXMLApplicationContext which is instantiated as below

Class BusinessRegistry {
context =null;
filename = "weather-Client.xml";

public void setApplicationContext(ApplicationContext context) {
this.context = context;
}

private static synchronized void init(String fileName)
{

if (isInitialised()) return;
log.info("Initialising registry [" + fileName + "]");
context = new ClassPathXmlApplicationContext(fileName);
}
***************

So, as you see the context seems to be getting intialised with the weather-client.xml which has all the proxy beans defnitition in it, which I dont understand.

Any explanantion of how ApplicationContext is created at start up of app server is appreciateed. Also, this is a Java swing client app

THanks,
Mary

 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please UseCodeTags when posting code or configuration. Unformatted code and configuration is unnecessarily difficult to read. You can edit your post by using the button.

 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you be more specific about what you're asking? Are other Spring listeners defined in web.xml?
 
Mary John
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks David, I am posting again the code with code tags. We have a hava swing client/server application that uses Spring for remoting.

I am trying to understand how the application context is getting created on server side. Also, what is the purpose does an applicationContextAware class does. Note, we have 2 XML files, 1. business-servlet.xml (has business objects) and the other is weather-client.xml(has proxy beans).

My question is when the BeanRegistry is instantiated does it use weather-client.xml to create the application context ???
Appreciate your help with this.


Here is web.xml



As seen above, web.xml does not have any spring listeners. This is all it has.
business-servlet.xml contains a BusinessRegistry as seen below


Also the business-servlet.xml, contains a Bean - BusinessRegistry class

abstractServerRemotingBean is an HttpInvokerServiceExporter

BusinessRegistry is applicationcontextaware that has a BeanFactory defined in it


 
reply
    Bookmark Topic Watch Topic
  • New Topic