Reference ( TERASOLUNA Global Framework on Accel Platform Architecture)¶
TERASOLUNA Global Framework (http://terasolunaorg.github.io/) is a Java framework that is configured on Spring Framework (http://projects.spring.io/spring-framework/) base.Details of TERASOLUNA Global Framework are published in TERASOLUNA Global Framework Development Guideline.This section describes full stack framework by intra-mart Accel Platform and TERASOLUNA Global Framework.
TERASOLUNA Global Framework on Accel Platform Architecture
TERASOLUNA Global Framework on Accel Platform Configuration¶
Concept of [Full Stack Framework] which incorporates TERASOLUNA Global Framework on intra-mart Accel Platform is shown in the figure below.
As shown below TERASOLUNA Global Framework is configured on Spring Framework base, and provides functions such as transaction token check, code list, exception handling, and logging. [ TERASOLUNA Global Framework Development Guideline] provides how to utilize these functions.
Application Layer Spring MVC / Bean Validation Domain Layer Spring Framework Infrastructure Layer Spring Data JPA (Hibernate) / MyBatis In TERASOLUNA Global Framework on Accel Platform you can efficiently develop TERASOLUNA Global Framework application programs by using the following functions provided by intra-mart Accel Platform.
- Authorization
- Access Context
- Authentication Function
- Internationalization
- Database
- Log
- UI (Design Guide Line)
- UI (Smart Phone Development Guideline)
- Error Prcess
- Storage
- Asynchronous Process
- Job Scheduler
- Lock Service
- Cache Service
- Shortcut Access Function
- Portlet
- IM-Workflow (under preparation)
- etc...
Note
Please access the links listed above for the usage of functions provided by intra-mart Accel Platform.
Default Value of Bean definition in TERASOLUNA Global Framework on Accel Platform¶
Spring MVC provides the servlet class DispatcherServlet.DispatcherServlet searches for the controller from the requested information by the client, and calls the controller.intra-mart Accel Platform has the [Routing Mechanism] which searches for the corresponding program based on client’s request, checks authorization, and calls the program that has been found.In intra-mart Accel Platform the mechanism to call Spring MVC controller from this [Routing Mechanism] is incorporated.Note
Please refer to the [Authorization] page for the mechanism of [Routing Mechanism].In Spring MVC you can usually register multiple DispatcherServlet for one Web applications, and make Bean definition for each servlet.In intra-mart Accel Platform only 1 servlet class is registered as an extension of DispatcherServlet, and it is not possible to register multiple number of this servlet class.Therefore, all the Bean definitions are shared by the Web applications in intra-mart Accel Platform.Bean definitions are provided in the following files in advance in intra-mart Accel Platform.
- <Juggling Project>/classes/META-INF/spring/applicationContext-im_tgfw_common.xml
- <Juggling Project>/classes/META-INF/spring/applicationContext-im_tgfw_web.xml
- <Juggling Project>/classes/META-INF/spring/SpringMVCServlet-servlet.xml
- <Juggling Project>/classes/META-INF/spring/applicationContext-jpa.xml
- <Juggling Project>/classes/META-INF/spring/applicationContext-mybatis.xml
Since these Bean definitions are shared among the tenants in intra-mart Accel Platform, contents that are described in the setup guide should not be basically changed.Contents of Spring MVC incorporated to intra-mart Accel Platform and initial values of Bean definitions shown above are listed below.
web.xml¶
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" metadata-complete="false" version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> : (omitted) <!-- Setting to load Bean definition file which starts with applicationContext in /META-INF/spring/ on clss path, when the Web application is started.--> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:/META-INF/spring/applicationContext*.xml</param-value> </context-param> <listener> <listener-class>jp.co.intra_mart.framework.extension.spring.web.servlet.SpringServletContextListener</listener-class> </listener> : (omitted) <!-- Register the servlet which extends DispatcherServlet for [Routing Mechanism] --> <servlet> <servlet-name>SpringMVCServlet</servlet-name> <servlet-class>jp.co.intra_mart.framework.extension.spring.web.servlet.IntramartDispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:/META-INF/spring/SpringMVCServlet-servlet.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> <multipart-config/> </servlet> : (omitted) </web-app>
applicationContext-im_tgfw_common.xml¶
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <!-- a bean which holds the root application context --> <bean class="jp.co.intra_mart.system.extension.spring.context.ApplicationContextHolder" /> <!-- message source which loads from 'WEB-INF/conf/message/**/*.properties' --> <bean id="messageSource" class="jp.co.intra_mart.framework.extension.spring.message.IntramartMessageSource" /> <!-- bean validation (JSR-303) --> <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"> <property name="validationMessageSource" ref="messageSource" /> </bean> <!-- transaction manager (JTA) --> <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager" /> <!-- enable the configuration of transactional behavior based on annotations --> <tx:annotation-driven transaction-manager="transactionManager"/> <!-- intra-mart tenant datasource --> <bean id="dataSource" class="jp.co.intra_mart.framework.extension.spring.datasource.TenantDataSource" /> <!-- intra-mart shared datasource --> <!-- [Note] If you use the shared datasource, please uncomment/enable the following setting and set the bean's id and the connectId's value. --> <!-- <bean id="sharedDataSource" class="jp.co.intra_mart.framework.extension.spring.datasource.SharedDataSource"> <constructor-arg name="connectId" value="xxxxxxxxxxxxxx" /> </bean> --> <!-- property placeholder setting --> <context:property-placeholder location="classpath*:/META-INF/spring/*.properties" /> <!-- dozer setting --> <bean class="org.dozer.spring.DozerBeanMapperFactoryBean"> <property name="mappingFiles" value="classpath*:/META-INF/dozer/**/*-mapping.xml" /> </bean> <!-- Exception Code Resolver. --> <bean id="exceptionCodeResolver" class="org.terasoluna.gfw.common.exception.SimpleMappingExceptionCodeResolver"> <!-- Setting and Customization by project. --> <property name="exceptionMappings"> <map> <entry key="ResourceNotFoundException" value="w.im.fw.0001" /> <entry key="BusinessException" value="w.im.fw.0002" /> <entry key="InvalidTransactionTokenException" value="w.im.fw.0004" /> </map> </property> <property name="defaultExceptionCode" value="e.im.fw.0001" /> </bean> <!-- Exception Logger. --> <bean id="exceptionLogger" class="org.terasoluna.gfw.common.exception.ExceptionLogger"> <property name="exceptionCodeResolver" ref="exceptionCodeResolver" /> </bean> </beans>
applicationContext-im_tgfw_web.xml¶
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:util="http://www.springframework.org/schema/util" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <!-- locale resolver --> <bean id="localeResolver" class="jp.co.intra_mart.framework.extension.spring.web.servlet.i18n.AccountLocaleResolver" /> <!-- SpringMVCRoute needs HandlerSelector bean. --> <bean id="handlerSelector" class="jp.co.intra_mart.system.router.spring.HandlerSelector" init-method="init" /> <!-- view components --> <context:component-scan base-package="jp.co.intra_mart.framework.extension.spring.web.servlet.view" /> <bean class="org.springframework.web.servlet.view.BeanNameViewResolver"> <property name="order" value="0" /> </bean> <!-- prefix for InternalResourceViewResolver --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/" /> <property name="order" value="1" /> </bean> <!-- multipart resolver --> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver" /> <!-- support for annotation-driven MVC controllers --> <mvc:annotation-driven conversion-service="conversionService"> <!-- transaction token --> <mvc:argument-resolvers> <bean class="org.terasoluna.gfw.web.token.transaction.TransactionTokenContextHandlerMethodArgumentResolver" /> </mvc:argument-resolvers> <!-- jackson message converter --> <mvc:message-converters register-defaults="true"> <bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"> <property name="objectMapper"> <bean class="jp.co.intra_mart.framework.extension.spring.http.converter.json.AccountDateObjectMapper" /> </property> </bean> </mvc:message-converters> </mvc:annotation-driven> <bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean"> <property name="formatters"> <set> <bean class="jp.co.intra_mart.framework.extension.spring.format.datetime.AccountDateFormatAnnotationFormatterFactory"/> <bean class="jp.co.intra_mart.framework.extension.spring.format.datetime.AccountDateTimeFormatAnnotationFormatterFactory"/> <bean class="jp.co.intra_mart.framework.extension.spring.format.datetime.AccountTimeFormatAnnotationFormatterFactory"/> </set> </property> </bean> <!-- MVC interceptors --> <mvc:interceptors> <!-- transaction token --> <mvc:interceptor> <mvc:mapping path="/**" /> <!-- configure the path to specify the package of controllers. --> <bean class="org.terasoluna.gfw.web.token.transaction.TransactionTokenInterceptor"> <constructor-arg value="10" /> </bean> </mvc:interceptor> <!-- code list --> <mvc:interceptor> <mvc:mapping path="/**" /> <!-- configure the path to specify the package of controllers. --> <bean class="org.terasoluna.gfw.web.codelist.CodeListInterceptor"> <property name="codeListIdPattern" value="CL_.+" /> </bean> </mvc:interceptor> <!-- [Note] If you use the JPA, please uncomment/enable the following setting. Please see the following link for more detail. > http://static.springsource.org/spring/docs/3.2.x/javadoc-api/org/springframework/orm/jpa/support/OpenEntityManagerInViewInterceptor.html [Note] configure the path to specify the package of controllers. --> <!-- <mvc:interceptor> <mvc:mapping path="/**" /> <bean class="org.springframework.orm.jpa.support.OpenEntityManagerInViewInterceptor" /> </mvc:interceptor> --> </mvc:interceptors> <!-- transaction token --> <bean name="requestDataValueProcessor" class="org.terasoluna.gfw.web.mvc.support.CompositeRequestDataValueProcessor"> <constructor-arg> <util:list> <bean class="org.terasoluna.gfw.web.token.transaction.TransactionTokenRequestDataValueProcessor" /> </util:list> </constructor-arg> </bean> <!-- Setting Exception Handling. --> <!-- Exception Resolver. --> <bean class="org.terasoluna.gfw.web.exception.SystemExceptionResolver"> <property name="exceptionCodeResolver" ref="exceptionCodeResolver" /> <!-- Setting and Customization by project. --> <property name="order" value="3" /> <property name="exceptionMappings"> <map> <entry key="ResourceNotFoundException" value="im_tgfw/common/error/resourceNotFoundError.jsp" /> <entry key="BusinessException" value="im_tgfw/common/error/businessError.jsp" /> <entry key="InvalidTransactionTokenException" value="im_tgfw/common/error/transactionTokenError.jsp" /> </map> </property> <property name="statusCodes"> <map> <entry key="im_tgfw/common/error/resourceNotFoundError" value="404" /> <entry key="im_tgfw/common/error/businessError" value="200" /> <entry key="im_tgfw/common/error/transactionTokenError" value="409" /> </map> </property> <property name="defaultErrorView" value="im_tgfw/common/error/systemError.jsp" /> <property name="defaultStatusCode" value="500" /> </bean> <!-- AOP. --> <bean id="handlerExceptionResolverLoggingInterceptor" class="org.terasoluna.gfw.web.exception.HandlerExceptionResolverLoggingInterceptor"> <property name="exceptionLogger" ref="exceptionLogger" /> </bean> <aop:config> <aop:advisor advice-ref="handlerExceptionResolverLoggingInterceptor" pointcut="execution(* org.springframework.web.servlet.HandlerExceptionResolver.resolveException(..))" /> </aop:config> </beans>
SpringMVCServlet-servlet.xml¶
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> </beans>
applicationContext-jpa.xml¶
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd" > <bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> <property name="showSql" value="false" /> <property name="database"> <value>POSTGRESQL</value> <!-- <value>DB2</value> <value>DEFAULT</value> <value>HSQL</value> <value>INFORMIX</value> <value>MYSQL</value> <value>ORACLE</value> <value>POSTGRESQL</value> <value>SQL_SERVER</value> <value>SYBASE</value> --> </property> </bean> <util:map id="hibernateProperties"> <entry key="hibernate.hbm2ddl.auto" value="none" /> <entry key="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.ImprovedNamingStrategy" /> <entry key="hibernate.connection.charSet" value="UTF-8" /> <entry key="hibernate.show_sql" value="false" /> <entry key="hibernate.format_sql" value="false" /> <entry key="hibernate.use_sql_comments" value="true" /> <entry key="hibernate.jdbc.batch_size" value="30" /> <entry key="hibernate.jdbc.fetch_size" value="100" /> <entry key="hibernate.temp.use_jdbc_metadata_defaults" value="false" /> <entry key="hibernate.transaction.jta.platform"> <value>org.hibernate.service.jta.platform.internal.ResinJtaPlatform</value> <!-- <value>org.hibernate.service.jta.platform.internal.ResinJtaPlatform</value> <value>org.hibernate.service.jta.platform.internal.WeblogicJtaPlatform</value> <value>org.hibernate.service.jta.platform.internal.WebSphereExtendedJtaPlatform</value> --> </entry> </util:map> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="packagesToScan" value="jp.co.intra_mart.framework.extension.spring.entity" /> <property name="jtaDataSource" ref="dataSource" /> <property name="jpaVendorAdapter" ref="jpaVendorAdapter" /> <property name="jpaPropertyMap" ref="hibernateProperties" /> <property name="persistenceUnitName" value="tenant" /> </bean> <!-- <bean id="sharedEntityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="packagesToScan" value="jp.co.intra_mart.framework.extension.spring.entity" /> <property name="jtaDataSource" ref="sharedDataSource" /> <property name="jpaVendorAdapter" ref="jpaVendorAdapter" /> <property name="jpaPropertyMap" ref="hibernateProperties" /> <property name="persistenceUnitName" value="shared" /> </bean> --> </beans>
applicationContext-mybatis.xml¶
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd" > <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean" scope="singleton"> <property name="configLocations" value="classpath*:/META-INF/mybatis/config/*sqlMapConfig.xml" /> <property name="mappingLocations" value="classpath*:/META-INF/mybatis/sql/**/*-sqlmap.xml" /> <property name="dataSource" ref="dataSource" /> </bean> <bean id="queryDAO" class="jp.terasoluna.fw.dao.ibatis.QueryDAOiBatisImpl"> <property name="sqlMapClient" ref="sqlMapClient" /> </bean> <bean id="updateDAO" class="jp.terasoluna.fw.dao.ibatis.UpdateDAOiBatisImpl"> <property name="sqlMapClient" ref="sqlMapClient" /> </bean> <bean id="spDAO" class="jp.terasoluna.fw.dao.ibatis.StoredProcedureDAOiBatisImpl"> <property name="sqlMapClient" ref="sqlMapClient" /> </bean> <bean id="queryRowHandleDAO" class="jp.terasoluna.fw.dao.ibatis.QueryRowHandleDAOiBatisImpl"> <property name="sqlMapClient" ref="sqlMapClient" /> </bean> <!-- <bean id="sharedSqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean" scope="singleton"> <property name="configLocations" value="classpath*:/META-INF/mybatis/config/*sqlMapConfig.xml" /> <property name="mappingLocations" value="classpath*:/META-INF/mybatis/sql/**/*-sqlmap.xml" /> <property name="dataSource" ref="sharedDataSource" /> </bean> <bean id="sharedQueryDAO" class="jp.terasoluna.fw.dao.ibatis.QueryDAOiBatisImpl"> <property name="sqlMapClient" ref="sharedSqlMapClient" /> </bean> <bean id="sharedUpdateDAO" class="jp.terasoluna.fw.dao.ibatis.UpdateDAOiBatisImpl"> <property name="sqlMapClient" ref="sharedSqlMapClient" /> </bean> <bean id="sharedSpDAO" class="jp.terasoluna.fw.dao.ibatis.StoredProcedureDAOiBatisImpl"> <property name="sqlMapClient" ref="sharedSqlMapClient" /> </bean> <bean id="sharedQueryRowHandleDAO" class="jp.terasoluna.fw.dao.ibatis.QueryRowHandleDAOiBatisImpl"> <property name="sqlMapClient" ref="sharedSqlMapClient" /> </bean> --> </beans>