Something about the sample-imagedb in Spring

Start from the web.xml

    Every web application has a web descriptor which will be parsed by the web server.So it is prefered to start learning with  the sample application from the web.xml file.There is a tag called context-param , from its literal meaning i can know that the parameters defined here can be used through the singleton web application.In this sample, a parameter called contextConfigLocation are paired with the values:applicationContext and schedulingContext, which i have checked the reference can be comma-separated , colon-separated and space-separated and the wildcards can be used to match the fazzy files.Following that a spring-specific listener called ContextLoadListner is registered which would call the ContextLoader to load the spring context.Note that Log4jConfigListener should be registered before the ContextLoadListener if Log4j exists.

    After that is Spring MVC DispatcherServlet which dispatches requests to registered handlers and has its own servlet context abiding by the convention servletname-servlet.xml ,which can be overridden by specifying the init-param contextConfigLocation. There can exist several DispatcherServlets, which are actually servlet.

The root applicationContext.xml

    First, note that namespaces - tx,beans,context which should be declared.

  1. context:property-placeholder (context are the prefix of some particular namespace which is declared in the root element beans )defines the external properties.
  2. define a pooled datasource which can also be defined throug jndi.
  3. TransactionManager for a single datasource.
  4. Active @Transactional for the datasources registered in the TransactionManager.

The schedule schedulingContext-quartz.xml

      This is an useful application tool, which facilitates the background jobs such as checking for emails,backuping databases,copying statistic files.

       1.define SchedulerFactoryBean , which is responsible for the management of all kinds of scheduled jobs.It has a property called triggers in which the scheduling jobs are stored as triggers.

       2.CronTriggerBean defines the trigger detail such as jobdetail and the running time expression which contains seven fields:second,minute,hour,day,month,week,year.There are several principles,asterisk(*) means every value in that field,0/2 stands for start from 0 and the increase interval is 2.and day and week can exist only one and the hidden field identified by question symbol(?).

        3.Followed those is the JobDetailBean . The jobclass must extend super class QuartzJobBean and properties in it are injected through a property called jobDataAsMap in the JobDetailBean.

 

你可能感兴趣的:(spring)