이번 장에서는 Glue Framework 기반의 application 개발시 알아야 할 주요 파일들을 다룬다
glue-config.xml 은 Glue Plug-In과 관련된 설정 정보를 관리한다. GlueSDK에 포함되어 있으며, Eclipse IDE의 Preference에서 SDK Location 이 지정되면, 그 위치에서 config/glue-config.xml 파일의 설정을 이용하는 것이다.
glue-config.xml 은 activities와 common 으로 구성된다. activities 에서는 n개의 activity로 구성된다. common은 document, service, query, class-generator, activity-template 로 구성된다.
glue-config.xml 의 XML Schema 정의인 GluePluginConfig.xsd 파일은 glue-schema 모듈에 포함되어 있다. glue-schema 모듈은 GlueSDK_HOME/lib/gluelib/glue-schema-[version].jar 파일이며, jar 파일내 schemaorg_apache_xmlbeans/src 위치에 GluePluginConfig.xsd 가 있다.
<?xml version="1.0" encoding="UTF-8"?> <glue-eclise-config xmlns="http://www.poscoict.com/glueframework/plugin/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.poscoict.com/glueframework/plugin/config GluePluginConfig.xsd "> <activities> <activity name="Router" icon="icons/activity_router.gif" addSeperator="true"> <bubble-tip>Default Router Activity</bubble-tip> <template>Glue Router template</template> <color>green</color> <default-properties> <property name="class" value="com.poscoict.glueframework.biz.activity.GlueDefaultRouter" /> </default-properties> </activity> <activity name="SubService" icon="icons/activity_subservice.gif"> <bubble-tip>SubService Activity</bubble-tip> <template>Glue SubService template</template> <color>lightBlue</color> <default-properties> <property name="class" value="com.poscoict.glueframework.biz.activity.GlueSubService" /> <property name="service-name" value="sample-service" /> <property name="new-transaction" value="false" /> </default-properties> </activity> <!-- 생략 --> </activities> <common> <document> <file-type>EUC-KR</file-type> <project-name>project-name</project-name> <phase>phase</phase> <task-name>task-name</task-name> <service-id>service-id</service-id> <current-date>current-date</current-date> <service-brief>service-brief</service-brief> <activity-subject>activity-subject</activity-subject> <activity-description>activity-description</activity-description> </document> <service> <file-type>UTF-8</file-type> </service> <query> <file-type>UTF-8</file-type> </query> <class-generator> <exclude-package>com.poscoict.glueframework</exclude-package> </class-generator> <activity-template> <![CDATA[ package #PACKAGE#; import com.poscoict.glueframework.biz.activity.GlueActivity; import com.poscoict.glueframework.biz.control.GlueBizControlConstants; import com.poscoict.glueframework.context.GlueContext; public class #CLASS# extends GlueActivity<GlueContext> { // Do not define the Class Member Variable!! public String runActivity(GlueContext ctx) { this.logger.info("test"); return GlueBizControlConstants.SUCCESS; } } ]]> </activity-template> </common> </glue-eclise-config>
Glue Framework은 spring 기반의 개발 프레임워크이며, application개발시 applicationContext.xml을 항상 필요로 한다. 그리고 applicationContext.xml에는 serviceManager bean을 포함해야 한다.
다음은 serviceManager를 갖고 있는 applciationContext.xml 의 내용이다. XML 스키마(xsd, XML Schema Definition) 기반의 applicationContext.xml을 사용하고 있다. XML 스키마 대신 DTD를 기반으로 해도 되나, 확장성을 위해 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-3.0.xsd"> <bean id="serviceManager" class="com.poscoict.glueframework.biz.control.GlueServiceManagerImpl"> <property name="cacheManager" ref="cacheManager" /> <property name="serviceLoader" ref="serviceLoader" /> </bean> <bean id="cacheManager" class="com.poscoict.glueframework.cache.ehcache.GlueEhCacheManager"/> <bean id="serviceLoader" class="com.poscoict.glueframework.biz.control.GlueServiceLoader"/> </beans>
다음은 DTD(Document Type Definition) 기반의 applicationContext.xml 입니다.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="serviceManager" class="com.poscoict.glueframework.biz.control.GlueServiceManagerImpl"> <property name="cacheManager" ref="cacheManager" /> <property name="serviceLoader" ref="serviceLoader" /> </bean> <bean id="cacheManager" class="com.poscoict.glueframework.cache.ehcache.GlueEhCacheManager"/> <bean id="serviceLoader" class="com.poscoict.glueframework.biz.control.GlueServiceLoader"/> </beans>
web application 에서 web.xml 이라 불리는 deployment descriptor는 WEB-INF 디렉토리에 위치해야 한다.
다음은 Eclipse IDE(Eclipse Java EE IDE for Web Developers, Kepler버전)를 통해 servlet spec 별로 생성되는 default web.xml이다.
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <display-name>sample</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> </web-app>
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>test</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> </web-app>
<?xml version="1.0" encoding="UTF-8"?> <web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>test</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> </web-app>
<?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 id="WebApp_ID"> <display-name>test</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> </web-app>
<?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:dwr="http://www.directwebremoting.org/schema/spring-dwr" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.directwebremoting.org/schema/spring-dwr http://www.directwebremoting.org/schema/spring-dwr-3.0.xsd"> <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="mappings"> <value> /*.mvc=controller </value> </property> </bean> <bean id="controller" class="com.poscoict.glueframework.web.control.spring.GlueSimpleController" /> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/springmvc/" /> <property name="suffix" value=".jsp" /> </bean> </beans>
<?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:dwr="http://www.directwebremoting.org/schema/spring-dwr" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.directwebremoting.org/schema/spring-dwr http://www.directwebremoting.org/schema/spring-dwr-3.0.xsd"> <bean id="urlMapping" class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/> <bean id="/hello.mvc" class="com.poscoict.glueframework.web.control.spring.GlueSimpleController" /> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/springmvc/" /> <property name="suffix" value=".jsp" /> </bean> </beans>
다음은 Glue에서 정의한 XML스키마입니다.
<?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.poscoict.com/glueframework/service" targetNamespace="http://www.poscoict.com/glueframework/service" elementFormDefault="qualified"> <xsd:element name="service"> <xsd:complexType> <xsd:sequence> <xsd:element name="transaction-manager" minOccurs="0" maxOccurs="unbounded"> <xsd:complexType> <xsd:attribute name="id" type="xsd:string" use="required" /> <xsd:attribute name="commit" type="xsd:boolean" use="required" /> </xsd:complexType> </xsd:element> <xsd:element name="activity" minOccurs="1" maxOccurs="unbounded"> <xsd:complexType> <xsd:sequence> <xsd:element name="transition" minOccurs="1" maxOccurs="unbounded"> <xsd:complexType> <xsd:attribute name="name" type="xsd:string" use="required" /> <xsd:attribute name="value" type="xsd:string" use="required" /> </xsd:complexType> </xsd:element> <xsd:element name="property" minOccurs="0" maxOccurs="unbounded"> <xsd:complexType> <xsd:attribute name="name" type="xsd:string" use="required" /> <xsd:attribute name="value" type="xsd:string" use="required" /> </xsd:complexType> </xsd:element> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" /> <xsd:attribute name="class" type="xsd:string" use="required" /> </xsd:complexType> </xsd:element> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" /> <xsd:attribute name="initial" type="xsd:string" use="required" /> </xsd:complexType> </xsd:element> </xsd:schema>
<?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.poscoict.com/glueframework/query" targetNamespace="http://www.poscoict.com/glueframework/query" elementFormDefault="qualified"> <xsd:element name="queryMap"> <xsd:complexType> <xsd:sequence> <xsd:element name="query" minOccurs="0" maxOccurs="unbounded"> <xsd:complexType> <xsd:simpleContent> <xsd:extension base="xsd:string"> <xsd:attribute name="id" type="xsd:string" use="required" /> <xsd:attribute name="desc" type="xsd:string" use="optional" /> <xsd:attribute name="resultType" type="xsd:string" use="optional" /> <xsd:attribute name="isNamed" type="xsd:boolean" use="optional" /> </xsd:extension> </xsd:simpleContent> </xsd:complexType> </xsd:element> </xsd:sequence> <xsd:attribute name="desc" type="xsd:string" use="optional" /> </xsd:complexType> </xsd:element> </xsd:schema>
<?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.poscoict.com/glueframework/layout" targetNamespace="http://www.poscoict.com/glueframework/layout" elementFormDefault="qualified"> <xsd:element name="msgs"> <xsd:complexType> <xsd:all> <xsd:element name="msg" minOccurs="1" maxOccurs="1"> <xsd:complexType> <xsd:sequence> <xsd:element name="attribute" type="attributeType" minOccurs="1" maxOccurs="unbounded"/> </xsd:sequence> <xsd:attribute name="id" type="xsd:string" use="required" /> <xsd:attribute name="name" type="xsd:string" use="optional" /> </xsd:complexType> </xsd:element> </xsd:all> </xsd:complexType> </xsd:element> <xsd:complexType name="attributeType"> <xsd:attribute name="type" use="required" > <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:enumeration value="E"/> <xsd:enumeration value="G"/> <xsd:enumeration value="GE"/> </xsd:restriction> </xsd:simpleType> </xsd:attribute> <xsd:attribute name="seq" use="required"> <xsd:simpleType> <xsd:restriction base="xsd:integer"> <xsd:minInclusive value="1"/> </xsd:restriction> </xsd:simpleType> </xsd:attribute> <xsd:attribute name="id" type="xsd:string" use="required" /> <xsd:attribute name="name" type="xsd:string" use="required" /> <xsd:attribute name="datatype" use="required"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:enumeration value="STRING"/> <xsd:enumeration value="NUMBER"/> <xsd:enumeration value="DATE"/> <xsd:enumeration value="ARRAY"/> </xsd:restriction> </xsd:simpleType> </xsd:attribute> <xsd:attribute name="length" use="required"> <xsd:simpleType> <xsd:restriction base="xsd:integer"> <xsd:minInclusive value="1"/> </xsd:restriction> </xsd:simpleType> </xsd:attribute> <xsd:attribute name="precision" use="optional"> <xsd:simpleType> <xsd:restriction base="xsd:integer"> <xsd:minInclusive value="0"/> </xsd:restriction> </xsd:simpleType> </xsd:attribute> </xsd:complexType> </xsd:schema>