Over a million developers have joined DZone.

Buzzing the Cloud with CloudBees and Roo

· Cloud Zone

Download the Essential Cloud Buyer’s Guide to learn important factors to consider before selecting a provider as well as buying criteria to help you make the best decision for your infrastructure needs, brought to you in partnership with Internap.

Looking to try out CloudBees for your Spring application?

Here is how you can get started quickly with CloudBees Run@Cloud platform.

  1. Get a CloudBees Account
  2. Configure a MySql instance on CloudBees
  3. Build a Spring Roo application
    see script below
  4. Create a cloudbees-web.xml file in WEB-INF
    same directory as web.xml
  5. Add Maven CloudBees Plugin
  6. Build and deploy with Maven
    mvn clean install bees:deploy

 

Roo 1.2.0 Script

Here is a simple item manager application script you can use/customize to create your application

# FOR SPRING ROO 1.2 - Spring Data JPA and Service Layer
 
development mode --enabled true
 
project --topLevelPackage com.gordondickens.roobees --java 6 --projectName roobees
 
jpa setup --provider HIBERNATE --database MYSQL --userName yourmysqluserid --databaseName yourmysqlinstancename --password yourmysqlpasswd
 
entity --class ~.domain.Item --activeRecord false
 
field string --fieldName name --sizeMin 3 --sizeMax 30 --class ~.domain.Item
field string --fieldName description --sizeMax 255 --class ~.domain.Item
 
repository jpa --interface ~.repository.ItemRepository --entity ~.domain.Item
 
service --interface ~.service.ItemService --entity ~.domain.Item
 
web mvc setup
web mvc all --package ~.web
 
logging setup --level DEBUG

 

Roo 1.1.5 Script

Here is a simple item manager application script you can use/customize to create your application

# FOR SPRING ROO 1.1.5
 
development mode --enabled true
 
project --topLevelPackage com.gordondickens.roobees --java 6 --projectName roobees
 
persistence setup --provider HIBERNATE --database MYSQL --userName yourmysqluserid --databaseName yourmysqlinstancename --password yourmysqlpasswd
 
entity --class ~.domain.Item
 
field string --fieldName name --sizeMin 3 --sizeMax 30 --class ~.domain.Item
field string --fieldName description --sizeMax 255 --class ~.domain.Item
 
web mvc setup
web mvc all --package ~.web
 
logging setup --level DEBUG

cloudbees-web.xml

<?xml version="1.0"?>
<cloudbees-web-app xmlns="http://www.cloudbees.com/xml/webapp/1">
  <appid>roobees</appid>
  <context-param>
    <param-name>application.environment</param-name>
    <param-value>prod</param-value>
  </context-param>
</cloudbees-web-app>

Maven CloudBees Plugin

Add the CloudBees repository to the pluginRepositories section.

<pluginRepositories>
  ...
  <pluginRepository>
    <id>bees-plugins-snapshots</id>
    <url>http://repository-cloudbees.forge.cloudbees.com/public-snapshot/</url>
    <releases>
      <enabled>false</enabled>
    </releases>
    <snapshots>
      <enabled>true</enabled>
    </snapshots>
  </pluginRepository>
  ...
</pluginRepositories>

Add the CloudBees Maven plugin to the plugins section.

<plugins>
  ...
  <plugin>
    <groupId>com.cloudbees</groupId>
    <artifactId>bees-maven-plugin</artifactId>
    <version>1.0-SNAPSHOT</version>
    <configuration>
       <!-- your username/appname -->
      <appid>youruserid/roobees</appid>
      <!-- your api key -->
      <apikey>BEBEBE2CEBEBEFBE</apikey>
      <!-- your secret key -->
      <secret>GEE0GERE0E-JE0EQETEHEPET+33MEIEIEI0EEZEEIEE00+</secret>
      <message>Roo ItemManager on CloudBees by Gordon Dickens</message>
    </configuration>
  </plugin>
  ...
</plugins>

 

Database Properties File

Edit the /src/main/resources/META-INF/spring/database.properties file.
Set the database.url to jdbc:cloudbees://yourmysqlinstance.
Set the database.driverClassName to com.cloudbees.jdbc.Driver.

database.username=yourmysqluserid
database.password=yourmysqlpasswd
 
database.url=jdbc:cloudbees://yourmysqlinstancename
database.driverClassName=com.cloudbees.jdbc.Driver

Download the Demo App

The demo app is in Git https://github.com/gordonad/roo-1.2-cloudbees for Spring Roo 1.2.

 

From http://gordondickens.com/wordpress/2011/09/26/buzzing-the-cloud-with-cloudbees-and-roo/

The Cloud Zone is brought to you in partnership with Internap. Read Bare-Metal Cloud 101 to learn about bare-metal cloud and how it has emerged as a way to complement virtualized services.

Topics:

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}