Announcement Announcement Module
Collapse
No announcement yet.
Quartz : Standalone Job Invoke Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Quartz : Standalone Job Invoke

    Hi ,
    I'm newbie to Quartz, Spring. I've gone thr' reference docs.
    Doubt is :
    If I want the job (specified in applicationContext.xml) to be executed do I need to load this XML in my standalone client program explicitiely?
    I mean the statement
    "ApplicationContext ctx = new ClassPathXmlApplicationContext(
    "applicationContext.xml");"
    is must?
    OR Sping framework automatically searches "applicationContext.xml" and starts Quartz Job automatically after "startDelay"?
    As far as I know , in Quartz framework
    " scheduler.scheduleJob(job, trigger);"
    starts the job execution immediately (as per trigger definition).

    In Spring framework what if I don't load applicationContext.xml and time at which the job is scheduled is over? Are such misfires handled in framrwork?

    Any help is appreciated.
    Thanks,
    Anagha

  • #2
    Re: Quartz : Standalone Job Invoke

    Originally posted by anagha
    Hi ,
    I'm newbie to Quartz, Spring. I've gone thr' reference docs.
    Doubt is :
    If I want the job (specified in applicationContext.xml) to be executed do I need to load this XML in my standalone client program explicitiely?
    I mean the statement
    "ApplicationContext ctx = new ClassPathXmlApplicationContext(
    "applicationContext.xml");"
    is must?
    In most cases this is not required. You can glue most components of your system in Spring and (almost) nobody needs a reference to the app context.

    OR Sping framework automatically searches "applicationContext.xml" and starts Quartz Job automatically after "startDelay"?
    You have to see Spring as the master-gluer of your system. Spring doesn`t do much else.. it only glues together components you have defined (like the scheduler and the job).

    If you app is glued together, and you have created a scheduler and jobs, then those jobs will be executed (when they are scheduled to be executed).

    In Spring framework what if I don't load applicationContext.xml and time at which the job is scheduled is over?
    In 99.99% of the cases the app context will be loaded when the system starts up, I think it would be wise if you did this to.

    Comment


    • #3
      Standalone Job Invoke

      In most cases this is not required. You can glue most components of your system in Spring and (almost) nobody needs a reference to the app context.
      Then how does Spring come to know about bean definitions?

      If you app is glued together, and you have created a scheduler and jobs, then those jobs will be executed (when they are scheduled to be executed).
      Being a newbie I'm not aware of what is meant by "glueing of app". Pls. elaborate.

      In 99.99% of the cases the app context will be loaded when the system starts up, I think it would be wise if you did this to.
      Does this mean I 've to write code to load app context in system initialization scripts?

      Can you pls. explain with the example so that above points would be clear to me?

      Thanks,
      Anagha

      Comment


      • #4
        Re: Standalone Job Invoke

        Originally posted by anagha
        In most cases this is not required. You can glue most components of your system in Spring and (almost) nobody needs a reference to the app context.
        Then how does Spring come to know about bean definitions?
        With webpplications I add the paths to the web.xml, example:

        Code:
        <web-app>
        	<display-name>Keying</display-name>
        	<description>Keying into the brain</description>
        
        	<context-param>
        		<param-name>contextConfigLocation</param-name>
        		<param-value>
        			/WEB-INF/applicationContext-database.xml<-- here
        			/WEB-INF/applicationContext-business.xml<-- here
        			/WEB-INF/applicationContext-security.xml<-- here   
        		</param-value>
        		
        	</context-param>
        	
        	<listener>
        		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        	</listener>
          .... more web.xml stuff .....
        If you app is glued together, and you have created a scheduler and jobs, then those jobs will be executed (when they are scheduled to be executed).
        Being a newbie I'm not aware of what is meant by "glueing of app". Pls. elaborate.
        example: I`m going to glue a doa, sessionFactory, and a service together.
        Code:
        <bean id="sessionFactory" class="HibernateSessionFactory"/>
        
        <bean id="personDao" class="com.dao.PersonDao">
            <constructor-arg index="0" ref="sessionFactory"/>
        </bean>
        
        <bean id="personService" class="com.services.PersonService">
             <constructor-arg index="0" ref="personDao"/>
        </bean>
        This is what I mean with glueing your system together.

        In 99.99% of the cases the app context will be loaded when the system starts up, I think it would be wise if you did this to.
        Does this mean I 've to write code to load app context in system initialization scripts?

        Can you pls. explain with the example so that above points would be clear to me?


        Thanks,
        Anagha
        Check the web.xml example I have given. The web.xml is parsed when the webapplication is deployed. In the web.xml the appcontext files can be found and there also is a 'listener'
        Code:
        <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
        This is a hack to let Spring know it should load all the app context files and start glueing your system. In most situations you want the app context to be build as soon as your system is started/deployed.

        Comment

        Working...
        X