miércoles, 20 de marzo de 2013

Usando Spring MVC SimpleUrlHandlerMapping y hessian (RMI)

Definir el mapeo en la configuracion del servlet: hessianService Definir el servlet en el web.xml whif-api org.springframework.web.servlet.DispatcherServlet 1 whif-api /v1/*

lunes, 12 de noviembre de 2007

Several applicationContext, split applicationContext

Para dividir el appCtx.xml en varios files:

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext*.xml,/WEB-INF/security.xml
</param-value>
</context-param>

viernes, 9 de noviembre de 2007

Access the BeanFactory through ServletContext

Para acceder a la beanFactory dentro de alguna clase se registra el ContextListener en el web xml (generalmente ya está registrado para struts2):
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

En el código se accede a la factory:
WebApplicationContextUtils.getWebApplicationContext(servletContext);

jueves, 1 de noviembre de 2007

SQLServer express spring datasource config

    <bean id="dataSource"

class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
<property name="url" value="jdbc:sqlserver://localhost\SQLEXPRESS;databaseName=workflow;" />
<property name="username" value="root" />
<property name="password" value="xxxx" />
</bean>

<property name="hibernateProperties">
<props>
<prop key="hibernate.hbm2ddl.auto">none</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</prop>
</props>
</property>
</bean>

miércoles, 24 de octubre de 2007

null Bean

Testeando con JUnit4 después de inicializar un bean a través de spring y asignarlo a un field en el @BeforeClass cuando intento acceder a este bean en el test me encuentro con un null pointer. No se como se manejarán los scopes en JUnit o si es natural de Spring:

SpringWorkflowTest test = new SpringWorkflowTest();
MyWorkflow workflow = (MyWorkflow) beanFactory.getBean("workflow");
test.setWorkflow(workflow);

La beanFactory es un global field.
Creo que el problema pasa porque la instancia que se testea debe ser una nueva y no la que tiene asignado el workflow. Cambié el getBean adentro del test para que funcione.

jueves, 13 de septiembre de 2007

Struts2 action wiring (not wired)

En el appctx el wiring del bean cableando la property quedaba en null

bean name="countryAction"
class="edu.matias.region.web.struts.actions.CountryAction"
property name="manager" ref="countryManager" /
/bean

sin embargo por constructor (creando el constructor en el action) enlazo:

bean id="countryAction" scope="prototype"
class="edu.matias.region.web.struts.actions.CountryAction"
constructor-arg ref="countryManager" /
/bean



Bean xml annotation change STR1>STR2

En vez del campo name, los bean en el appctx se identifican con el campo id.