Professional Documents
Culture Documents
Inicializacin y arranque
Contenidos
Sistema de Inicializacin Declaracin de objetos inicializables Desarrollo de objetos inicializables Arranque de las aplicaciones
13/04/2012 2
Sistema de Inicializacin
Estructura
13/04/2012
Sistema de Inicializacin
Permite definir, de forma declarativa, los componentes que deben ser creados, configurados e iniciados durante el arranque de las aplicaciones Generalmente son objetos de utilidad que tienen alcance global a toda la aplicacin
Sigue la DTD de los ficheros de inicializacin del framework Spring Identificador Clase
Propiedad: todo mtodo que empiece por la cadena set y tenga un solo parmetro
13/04/2012 7
${nombre}
13/04/2012
Princast-init-script.xml
13/04/2012
princast-init-script.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <!-- Resolves ${...} placeholders from client.properties --> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location"><value>deploy.properties</value></property> </bean> ..... <bean id="securityRulesPlugin" class="es.princast.framework.web.filter.security.corp.conf.SecurityRulesConfigurationPlugin"> <constructor-arg><value>security-rules</value></constructor-arg> <property name="file"><value>/WEB-INF/princast-security-rules.xml</value></property> <property name="contexts"> <list> <value>SECURITY</value> </list> </property> </bean> <bean id="ivaPlugin" class="es.princast.framework.core.configuration.plugins.PropertiesFileConfigurationPlugin"> <constructor-arg><value>iva</value></constructor-arg> <property name="file"><value>classpath://resources/iva.properties</value></property> <property name="contexts"> <list> <value>IVA.CONTEXT</value> </list> </property>
</bean>
...
13/04/2012
10
13/04/2012
11
Atributo factory-method. Objetos que se pueden crear/destruir Objetos que se pueden encender/apagar
Interface Launchable:
Interface Manageable:
13/04/2012
13
princast-init-script.xml
<bean id="ivaPluginCap" class="es.princast.framework.core.management.configuration.ConfigurationPluginJMXAdapter"> <property name="plugin"><ref bean="ivaPlugin"/></property> </bean> <!-- Gestor de configuracion --> <bean id="configurationManager" class="es.princast.framework.core.configuration.FrameworkConfigurator" factory-method="getConfigurator" lazy-init="false" singleton="true"> <property name="plugins"> <list> <ref bean="baseConfigurationPlugin"/> <ref bean="jaasConfigPlugin"/> <ref bean="securityRulesPlugin"/> <ref bean="ivaPlugin"/> </list> </property> </bean> <!-- Gestor de logging --> <bean id="loggingManager" class="es.princast.framework.core.logging.LoggingManager" factory-method="getLogging" lazy-init="false" singleton="true"> </bean> <bean id="managementFactory" class="es.princast.framework.core.management.ManagementFactory" factory-method="getFactory" lazy-init="false" singleton="true"> <property name="serverName"><value>${JMX.SERVER.NAME}</value></property> <property name="port"><value>${JMX.PORT}</value></property> <property name="password"><value>${JMX.PASS}</value></property> <property name="username"><value>${JMX.USER}</value></property> <property name="adaptorFactoryClass"><value>${JMX.ADAPTOR.FACTORY}</value></property> </bean>
13/04/2012
14
Debe ser declarado en el fichero web.xml Se debe declarar un parmetro de contexto (<context-param>) que indique la ruta del fichero de arranque princast-init-script.xml
13/04/2012
16
web.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <context-param> <param-name>INIT.SCRIPT.FILE</param-name> <param-value>/WEB-INF/princast-init-script.xml</param-value> </context-param> .... <listener> <listener-class>es.princast.framework.web.startup.PrincastStartupListener</listener-class> </listener>
13/04/2012
17
Sistemas disponibles
ManagementFactory.
FrameworkConfigurator
Sistema de configuracin
13/04/2012
18