Difference between revisions of "Northwind Tutorial"
From RifidiWiki
Line 5: | Line 5: | ||
To get started see [[Edge Server Development Environment|Setting up a Development Environment]]. | To get started see [[Edge Server Development Environment|Setting up a Development Environment]]. | ||
− | =Creating the new project= | + | ==Creating the new project== |
− | =Stating Dependencies in the Manifest= | + | =First Things First: Injecting Esper= |
− | =Creating the Application= | + | What you will learn: |
+ | * Declaring OSGi bundle dependencies in the manifest | ||
+ | * Dependency injection via spring | ||
+ | * Running an OSGi application in eclipse | ||
+ | * Redeploying bundles without restarting the server | ||
+ | ==Stating Dependencies in the Manifest== | ||
+ | ==Creating the Application== | ||
<pre> | <pre> | ||
package com.mycompany.rfid.app; | package com.mycompany.rfid.app; | ||
Line 38: | Line 44: | ||
} | } | ||
</pre> | </pre> | ||
− | =Creating the Spring Context XML= | + | ==Creating the Spring Context XML== |
<pre> | <pre> | ||
<beans xmlns="http://www.springframework.org/schema/beans" | <beans xmlns="http://www.springframework.org/schema/beans" | ||
Line 59: | Line 65: | ||
</beans> | </beans> | ||
</pre> | </pre> | ||
− | =Running the Application= | + | ==Running the Application== |
− | =Modifying and redeploying the Application= | + | ==Modifying and redeploying the Application== |
Revision as of 23:11, 24 September 2009
This document provides step-by-step instructions on how to get started on developing your first application that runs on the Rifidi Edge Server. The application we will develop will use Esper to collect tag reads from a reader and put them on a JMS queue to be consumed by a client application. Many of the steps are applicable to many kinds of plugins for the edge server, including creating a sensor plugin.
Contents
Prerequisites
For this tutorial, we will use Eclipse to develop the application. While it would be possible to develop the application in any IDE that you are familiar with, Eclipse provides great tooling around OSGi application development and deployment, and thus makes this process much easier. If this is your first time developing with eclipse, there will be a learning curve. However, the payoff is worth it.
To get started see Setting up a Development Environment.
Creating the new project
First Things First: Injecting Esper
What you will learn:
- Declaring OSGi bundle dependencies in the manifest
- Dependency injection via spring
- Running an OSGi application in eclipse
- Redeploying bundles without restarting the server
Stating Dependencies in the Manifest
Creating the Application
package com.mycompany.rfid.app; import org.rifidi.edge.core.services.esper.EsperManagementService; /** * @author Kyle Neumeier - kyle@pramari.com * */ public class MyApplication { /**Esper service*/ private volatile EsperManagementService esperService; /** * Constructor */ public MyApplication() { } /** * Called by spring * @param esperService */ public void setEsperService(EsperManagementService esperService) { this.esperService = esperService; } }
Creating the Spring Context XML
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:osgi="http://www.springframework.org/schema/osgi" xmlns:amq="http://activemq.apache.org/schema/core" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd"> <!-- Create the Application bean and inject dependencies--> <bean id="rfidapp" class="com.mycompany.rfid.app.MyApplication"> <property name="esperService" ref="esper" /> </bean> <!-- Get a reference to the Esper Management Service from the OSGi Service Registry --> <osgi:reference id="esperManagementService" interface="org.rifidi.edge.core.services.esper.EsperManagementService" /> </beans>