ItEr08S11HistoriaLaboralTraballador: Adds infraestructure for adding required data.

This commit is contained in:
Óscar González Fernández 2009-05-15 16:05:06 +02:00 committed by Javier Moran Rua
parent 9db92a8626
commit 661dd40860
5 changed files with 78 additions and 13 deletions

View file

@ -0,0 +1,7 @@
package org.navalplanner.business;
public interface IDataBootstrap {
void loadRequiredData();
}

View file

@ -0,0 +1,26 @@
package org.navalplanner.business.resources.bootstrap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.navalplanner.business.IDataBootstrap;
import org.navalplanner.business.resources.services.ResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
@Component
@Scope("singleton")
public class CriterionsBootstrap implements IDataBootstrap {
private static final Log LOG = LogFactory.getLog(CriterionsBootstrap.class);
@Autowired
private ResourceService resourceService;
@Override
public void loadRequiredData() {
LOG.info("TODO: load criterions");
assert resourceService != null;
}
}

View file

@ -39,14 +39,15 @@
<tx:annotation-driven transaction-manager="transactionManager" />
<!--
For enabling annotation-based configuration (in particular,
required for "@Autowired")
For enabling annotation-based configuration (in particular, required
for "@Autowired")
-->
<context:annotation-config />
<context:component-scan base-package="org.navalplanner.business"/>
<!--
======================== Business Objects
========================
======================== Business Objects ========================
-->
<!-- Resource DAOs and registry -->

View file

@ -0,0 +1,33 @@
package org.navalplanner.web.bootstrap;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.navalplanner.business.IDataBootstrap;
import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
public class BootstrapListener implements ServletContextListener {
@Override
public void contextDestroyed(ServletContextEvent servletContextEvent) {
}
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
WebApplicationContext webApplicationContext = WebApplicationContextUtils
.getWebApplicationContext(servletContextEvent
.getServletContext());
String[] beanNames = BeanFactoryUtils
.beanNamesForTypeIncludingAncestors(webApplicationContext,
IDataBootstrap.class);
for (String name : beanNames) {
IDataBootstrap bootstrap = (IDataBootstrap) webApplicationContext
.getBean(name);
bootstrap.loadRequiredData();
}
}
}

View file

@ -44,7 +44,6 @@
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener</listener-class>
@ -52,6 +51,11 @@
<!-- end Spring listeners -->
<!-- Loads all IDataBootstrap and executes them -->
<listener>
<listener-class>org.navalplanner.web.bootstrap.BootstrapListener</listener-class>
</listener>
<servlet>
<description>ZK loader for ZUML pages</description>
<servlet-name>zkLoader</servlet-name>
@ -85,12 +89,8 @@
</servlet-mapping>
<!-- //// -->
<welcome-file-list>
<welcome-file>/planner/main.zul</welcome-file>
</welcome-file-list>
<error-page>
@ -99,9 +99,7 @@
</error-page>
<error-page>
<error-code>404</error-code>
<location>/common/page_not_found.zul</location>
<error-code>404</error-code>
<location>/common/page_not_found.zul</location>
</error-page>
</web-app>