Developer

Creating Dynamic Template Plug-Ins

To create a dynamic template that you can plug in to a custom-state bundle, configure the State SDK SmappTemplateProvider class as a Spring bean.

This example configures the SmappTemplateProvider class for the GetDate.xml file, which contains an application that demonstrates how to use the custom state Get Date. To configure the SmappTemplateProvider class, edit both the beans-context.xml and the services-context.xml files.

beans-context.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.1.xsd">     

<!--   
***********************************     
       Beans Configuration   
***********************************   
-->     
 <bean id="SampleState" class="com.sap.example.SampleState">       
   <property name="country" value="${sample.country}"/>     
 </bean>        

 <!-- Template -->    
 <bean id="SampleApplication" class=
               "com.sybase365.mobiliser.brand.template.SmappTemplateProvider">      
   <property name="name" value="Sample Get Date Application" />      
   <property name="description" value="Type: Training. 
                   A sample application to demonstrate the Get Date state." />      
   <property name="resource" value="classpath:META-INF/template/GetDate.xml" />
 </bean>    
</beans>

services-context.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:osgi="http://www.eclipse.org/gemini/blueprint/schema/blueprint"          
   xsi:schemaLocation="http://www.springframework.org/schema/beans          
   http://www.springframework.org/schema/beans/spring-beans-3.1.xsd          
   http://www.eclipse.org/gemini/blueprint/schema/blueprint         
   http://www.eclipse.org/gemini/blueprint/schema/blueprint/gemini-blueprint-1.0.xsd"> 

   <!--       
   ***********************************        
     Register state as OSGi Service       
   ***********************************    
   -->    
   <osgi:service id="SampleStateService"                    
                 ref="SampleState"
                 interface=
                   "com.sybase365.mobiliser.brand.plugins.api.smapp.StatePlugin"/> 
   
   <!-- 
   Template Service       
   -->       
   <osgi:service id="SampleApplicationService" 
                 ref="SampleApplication" 
                 interface=
                   "com.sybase365.mobiliser.brand.plugins.api.smapp.SmappTemplate"
                 context-class-loader="service-provider"/>       
</beans>