2. Sample Projects
How To Choose the Right Sample for Your Application
If your application does not require any database features, the right choice is to use Granite POJO services. Your Flex application will be able to communicate with server-side simple Java class services that may be deployed in a simple servlet container such as Tomcat or Jetty. Then, you may start with the examples/graniteds_pojo example project from the GraniteDS distribution or read the next section, "Hello, world" (POJO), if you want to start from scratch.
If your application does require database features, the right choice depends on the persistence and service framework you are familiar with. Since GraniteDS comes with powerful JPA/Hibernate support, this should be the right persistence system choice for most people. Services framework is a matter of feature requirements and personal preferences:
- EJB 3 Session Services: Standard Java EE5 services framework, supported with no additional dependencies in JBoss-4.2+ application servers. Choose this if you do not know anything about the other frameworks. Most advanced Granite features such as Tide are supported.
- JEE6 / CDI Services: This is the right choice if you expect to setup a JEE6 compliant server like GlassFish 3 or JBoss 6. It is fully supported with Tide advanced features.
- JBoss Seam Services: This is the right choice if you want to use Tide advanced features and Seam integration.
- Spring Services: This is the right choice if you are already a Spring user. Most Tide features are supported.
- Guice/Warp Services: This may be the right choice if you already know it.
When you have made your choice, see the next subsections for further information.
How To Install and Test Sample Applications
Installing and testing GraniteDS sample application is a quick process, provided that you have downloaded Eclipse 3.4+, JBoss 4.2.3+ and Flex 3 SDK.
Let's say you have installed a vanilla JBoss 4.2.3.GA and fresh Flex SDK at the root of your main datadrive (C:\jboss-4.2.3.GA and C:\flex_sdk_3 on Windows).
Follow these few steps:
- Download graniteds-***.zip and save it somewhere.
- Start Eclipse, right click in your "Package Explorer", choose Import... -> General/Existing Project into Workspace -> Next, select the Select archive file option, browse to graniteds-***.zip.
- You should now see the main "graniteds" project as well as all example projects ready to be imported. When you have made your choice, choose Finish. NOTE: you must import the core graniteds project (it contains libraries required by sample projects).
- Read the graniteds/examples/README.txt file in order to setup your environment.
- For each imported example, open the corresponding build.xml file and run the "deploy" target.
- Start JBoss and point your browser to revelant URL (see the README.txt file again).
You may now look at the code of each example and understand how each sample works.
