Sample ApplicationContext.xml


This is a sample ApplicationContext.xml for Spring Webflow, with JDBC, Hibernate,  Spring mail etc

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:webflow="http://www.springframework.org/schema/webflow-config"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/webflow-config http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">

<!-- Message source for this context, loaded from localized "messages_xx" files -->
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="alwaysUseMessageFormat" value="true"/>
<property name="useCodeAsDefaultMessage" value="true"/>
<property name="basenames">
<list>
<value>messages</value>
</list>
</property>
</bean>

<!-- Properties configuration -->
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
lazy-init="false">
<property name="locations">
<list>
<value>classpath:datasource.properties</value>
</list>
</property>
</bean>

<!-- Default View Resolver -->
<bean id="jspViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="cache" value="false"/>
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>

<!-- Abstract Default Exception Handler Bean -->
<bean id="defaultExceptionHandlerTemplate"
class="org.springframework.web.portlet.handler.SimpleMappingExceptionResolver"
abstract="true">
<property name="defaultErrorView" value="defError"/>
<property name="exceptionMappings">
<props>
<prop key="javax.portlet.PortletSecurityException">notAuthorized</prop>
<prop key="javax.portlet.UnavailableException">notAvailable</prop>
</props>
</property>
</bean>

<!-- Executes flows: the central entry point into the Spring Web Flow system -->
<webflow:flow-executor id="flowExecutor">
<webflow:flow-execution-attributes>
<webflow:always-redirect-on-pause value="false"/>
</webflow:flow-execution-attributes>
</webflow:flow-executor>

<!-- The registry of executable flow definitions -->
<webflow:flow-registry id="flowRegistry">
<webflow:flow-location-pattern value="WEB-INF/flows/**/*.xml"/>
</webflow:flow-registry>

<!-- Account registration service -->
<bean id="accountRegistrationService"
class="org.jasig.portlet.accountregistration.impl.AccountRegistrationServiceImpl">
<property name="accountDao" ref="accountDao"/>
<property name="passwordService" ref="passwordService"/>
<property name="notificationService" ref="notificationService"/>
</bean>

<!-- Password generation and encryption service -->
<bean id="passwordService"
class="org.jasig.portlet.accountregistration.impl.PasswordServiceImpl">
<property name="secureRandom">
<bean class="java.security.SecureRandom" factory-method="getInstance">
<constructor-arg value="SHA1PRNG"/>
</bean>
</property>
<property name="algorithm" value="SHA"/>
<property name="salted" value="true"/>
<property name="encryptedPrefix" value="{SSHA}"/>
</bean>

<!-- Password generation for older MD5 encryption -->
<!--
<bean id="passwordService"
class="org.jasig.portlet.accountregistration.uportal.impl.PasswordServiceUportalImpl">
</bean>
-->

<!-- Spring mail-sending service -->
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="smtp.gmail.com" />
<property name="port" value="465" />
<property name="protocol" value="smtps" />
<property name="username" value="unicon.sales"/>
<property name="password" value="xxxxxxx"/>
<property name="javaMailProperties">
<props>
<prop key="mail.smtps.auth">true</prop>
<prop key="mail.smtps.starttls.enable">true</prop>
<prop key="mail.smtps.debug">true</prop>
</props>
</property>
</bean>

<!-- Base template message for Spring email notifications -->
<bean id="templateMessage" class="org.springframework.mail.SimpleMailMessage">
<property name="from" value="portal@myportal.org"/>
<property name="subject" value="uPortal Registration"/>
</bean>

<!-- Default email-based notification service -->
<bean id="notificationService"
class="org.jasig.portlet.accountregistration.impl.AccountNotificationServiceDoNothingImpl">

</bean>

<!-- email-based notification service that uses a basic spring mail service -->
<bean id="notificationService"
class="org.jasig.portlet.accountregistration.impl.AccountNotificationServiceEmailImpl">
<property name="passwordService" ref="passwordService"/>
<property name="stringTemplateGroup">
<bean id="stringTemplateGroup" class="org.antlr.stringtemplate.StringTemplateGroup">
<constructor-arg type="java.lang.String" value="GroupName"/>
</bean>
</property>
<property name="stringTemplateMap">
<map>
<entry key="ACCOUNT_CREATE_TEMPLATE" value="templates/accountCreate"/>
<entry key="PASSWORD_RESET_TEMPLATE" value="templates/passwordReset"/>
<entry key="ATTRIBUTE_CHANGE_TEMPLATE" value="templates/attributeChange"/>
</map>
</property>
<property name="mailSender" ref="mailSender"/>
</bean>

<bean id="jcaptchaServiceImpl"
class="com.octo.captcha.service.image.DefaultManageableImageCaptchaService"/>

<bean id="captchaService" class="org.jasig.portlet.accountregistration.impl.CaptchaServiceImpl">
<property name="jcaptchaServiceImpl" ref="jcaptchaServiceImpl"/>
</bean>

<bean id="accountFormValidator"
class="org.jasig.portlet.accountregistration.mvc.form.AccountFormValidator">
<property name="captchaService" ref="captchaService"/>
</bean>

<!--
|	Default uPortal database account store implementation
+-->

<!-- Account persistence service -->

<!-- Account creation configuration service -->
<!--
<bean id="accountCreationConfigurationService"
class="org.jasig.portlet.accountregistration.jdbc.AccountCreationConfigurationServiceImpl"
init-method="init" destroy-method="destroy">
<property name="hibernateTemplate">
<bean class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
</property>
</bean>
-->

<!-- Simple JDBC Template alternativet to the above hibernate impl -->
<!--
<bean id="simpleJdbcTemplate"
class="org.springframework.jdbc.core.simple.SimpleJdbcTemplate">
<constructor-arg><ref bean="datasource"/></constructor-arg>
</bean>
-->

<bean id="accountCreationConfigurationService"
class="org.jasig.portlet.accountregistration.api.AccountCreationConfigurationServiceGenericImpl" />

<!-- JDBC datasource -->
<bean id="datasource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
<value>${hibernate.connection.driver_class}</value>
</property>
<property name="url">
<value>${hibernate.connection.url}</value>
</property>
<property name="username">
<value>${hibernate.connection.username}</value>
</property>
<property name="password">
<value>${hibernate.connection.password}</value>
</property>
</bean>

<!-- Hibernate session factory -->
<!--
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref bean="datasource"/>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.hbm2ddl.auto">create</prop>
</props>
</property>
<property name="annotatedClasses">
<list>
<value>org.jasig.portlet.accountregistration.jdbc.impl.AccountRegistrationConfigJdbcImpl</value>
</list>
</property>
</bean>
-->

<!--
| Example LDAP configuration
+-->
<!--
<bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">
<property name="url" value="ldap://localhost:389"/>
<property name="base" value=""/>
<property name="userDn" value="uid=apetro,ou=People,dc=enc4me,dc=com" />
<property name="password" value="test123" />
</bean>

<bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
<constructor-arg ref="contextSource"/>
</bean>

<bean id="accountDao"
class="org.jasig.portlet.accountregistration.ldap.impl.UserAccountDaoLdapImpl">
<property name="ldapTemplate" ref="ldapTemplate"/>
<property name="ldapUrl" value="ldap://localhost:389"/>
<property name="baseDn" value="ou=People,dc=enc4me,dc=com"/>
<property name="searchBase" value="ou=People,dc=enc4me,dc=com"/>
<property name="passwordService" ref="passwordService"/>
</bean>
-->

<bean id="accountDao"
class="org.jasig.portlet.accountregistration.memory.impl.UserAccountDaoMemoryImpl">

</bean>

<!-- example Uportal implementation
<bean id="accountDao"
class="org.jasig.portlet.accountregistration.uportal.impl.UserAccountDaoJdbcUportalImpl">
<property name="simpleJdbcTemplate" ref="simpleJdbcTemplate"/>
</bean>
-->
</beans>
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s