Various things you might want to copy-and-paste while creating a module.
config.xml (common values)
<updateURL>https://modules.openmrs.org/modules/download/<at:var at:name="MODULE_ID" />/update.rdf</updateURL> <require_modules> <require_module>org.openmrs.module.htmlformentry</require_module> </require_modules> <mappingFiles> AccountRequest.hbm.xml </mappingFiles> <messages> <lang>en</lang> <file>messages.properties</file> </messages>
moduleApplicationContext.xml (minimal with annotation-driven MVC)
<?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:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd"> <context:component-scan base-package="<at:var at:name="MODULE_PACKAGE" />" /> </beans>
moduleApplicationContext.xml (minimal with old-style MVC)
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <!-- Beans to add to the current Application context definition --> <beans> <bean id="<at:var at:name="MODULE_ID" />UrlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="order"><value>1</value></property> <property name="mappings"> <props> <prop key="module/<at:var at:name="MODULE_ID" />/something.form">someController</prop> </props> </property> </bean> <bean id="someController" class="<at:var at:name="MODULE_PACKAGE" />.web.controller.SomeController"> <property name="sessionForm"><value>false</value></property> <property name="commandName"><value>command</value></property> <property name="formView"><value>/module/<at:var at:name="MODULE_ID" />/someList</value></property> <property name="successView"><value>someForm.list</value></property> </bean> </beans>
moduleApplicationContext service creation
<bean parent="serviceContext"> <property name="moduleService"> <list> <value><at:var at:name="MODULE_PACKAGE" />.___Service</value> <!-- service interface name --> <bean class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager"><ref bean="transactionManager"/></property> <property name="target"> <bean class="<at:var at:name="MODULE_PACKAGE" />.impl.___ServiceImpl"> <property name="___DAO"> <bean class="<at:var at:name="MODULE_PACKAGE" />.db.hibernate.Hibernate___DAO"> <property name="sessionFactory"><ref bean="sessionFactory"/></property> </bean> </property> </bean> </property> <property name="preInterceptors"> <ref bean="serviceInterceptors"/> </property> <property name="transactionAttributeSource"> <bean class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource"/> </property> </bean> </list> </property> </bean>
Form controller annotations
@RequestMapping("/module/<at:var at:name="MODULE_ID" />/urlToMap")
Sqldiff.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE sqldiff PUBLIC "-//OpenMRS//DTD OpenMRS SQL Diff Config 1.0//EN" "http://resources.openmrs.org/doctype/sqldiff-1.0.dtd"> <sqldiff version="1.0"> <help></help> <diff> <version>0.1</version> <author></author> <date>Jan 1st 2009</date> <description> </description> <sql> </sql> </diff> </sqldiff>