Wednesday, April 22, 2015

An Enterprise Developer's Journey to Internet-of-Things (IoT)


From Enterprise to Mobile to IoT (Internet-of-Things) Developer

This article by Alok Batra started me thinking about the unique differences between the Enterprise vs Mobile vs IoT development spaces and my own personal journey down this path.  I am sure my thinking will change as my IoT skills and knowledge mature - this is just a moment in time - but I thought writing it all down would be valuable.



Enterprise: I have primarily been an enterprise Java and .NET developer, building applications that had a browser/web front-end, a middle-tier on the server and a database tier.  Of course there are batch apps, reporting/business intelligence apps, integration via messaging and perhaps ESBs (enterprise service bus) in the average enterprise IT shop.  But at the end of the day, the vast majority of enterprise applications are used to shove data into a relational database and retrieve it back out again, normally using a web browser for data entry and display purposes.   For most of the early 2000's the enterprise web application developer only had to worry about one target desktop OS (Windows) and one target browser (Internet Explorer).   I have also spent time building things in Node.js - and the development model is fairly similar - web UI built in a HTML5 framework interacting with RESTful APIs/services and perhaps instead of a RDBMS taking advantage of a NoSQL db like Mongo.   Besides Java, .NET and Node.js, I have also spent a fair bit of time working with Vert.x - its asynchronous, reactive programming model gives you a result very similar to Node.js based real-time web apps.

Mobile: When it came to learning mobile application development a few years ago, it turned out that a fair bit of the architectural patterns from enterprise web app development could be reused.  For instance, most mobile applications that communicate with a back-end leverage HTTP and/or REST.   The good old GET, PUT, POST and DELETE HTTP verbs that we have been actively working with for 20 years. Building of the mobile front-end could be achieved via the smartphone's web browser or perhaps using something like Phonegap/Apache Cordova - the programming model was basically the same as it was for the average enterprise application.  The biggest learning curve was related to having more than a single target OS, a single target browser client and a single form-factor.  iOS + Safari, Android + Android's native browser and Android + Chrome become critical combinations for us to test our user interfaces on.  At the same time, FireFox and Chrome took marketshare from IE on the corporate desktop.  Responsive design became a thing and many developers simply took advantage of CSS libraries like Bootstrap to help address the differences in screen sizes.  In general, the transition to mobile was relatively easy - as many of the same skills you used in pre-mobile enterprise web application development could still be applied.

IoT:  I have been pushing myself through the IoT learning curve over the last few months.  It turns out that IoT is fairly unique and very different from the mobile universe.   IoT + Enterprise will be a much greater challenge for the following reasons:

1) Hardware: Most every developer has a smartphone, likely running either iOS or Android and those smartphones have all the same basic sensors and capabilities.   In the case of IoT development/prototyping boards, there are dozens of vendors running a myriad of operating systems.  No two platforms have the same sensors and capabilities.  You also have two major classes of a programmable Thing: microcontrollers (e.g. Arduino, mbed) and microcomputers (e.g. Raspberry Pi, BeagleBone Black, Intel Edison).  There are 'hobbyist' or maker platforms such as the insanely popular Arduino and its derivatives such as RFduino, LilyPad or Adafruit's FLORA.  Plus, Linux-based platforms such as the best selling UK-based computer Raspberry Pi (5 million units sold).   There are also many "professional" grade dev boards/kits from Freescale, TI and many others, therefore, the developer will have a whole lot to think about in terms of hardware selection.
How do you choose which of these platforms to invest your limited time and energy? I am still forming opinions about that myself - at this moment, I have the following sitting on my desk: Arduino, Raspberry Pi Model B (1 and 2), Spark Core, mbed LPC1768 and a BeagleBone Black.

Here is the ultra-short (90 seconds) demo teaser video:

Here is a video, drilling down on my exploration of IoT development hardware:


2) Networking: Unlike the average smartphone, the average programmable Thing does not include network connectivity out-of-the-box.  That is changing with companies like Spark pushing hard not only into Wifi-connected programmable controllers like the Core and Photon but also with the recently announced cell-based (think 2G/3G) developer kits like Electron.  For the typical enterprise web developer, having network access is assumed and this particular area is changing VERY rapidly.  In addition, the systems designer must consider power (battery or not) implications of various radios, ethernet and network stacks.

3) Client-side Operating Systems:  The client in the case of IoT is often known as the Edge. The microcontrollers are basically running C/C++ on their chip architectures, there is not really an OS in the traditional sense.  ARM's mbed offers a nice web-based IDE for crafting your C++ code and the "deployment" is a simple drag & drop of the binary to your USB-connected device.  In the case of various types of microcomputers, there are many derivatives of Linux and one of the more interesting flavors is Yocto - because you roll-your-own, including only the packages that you need to support your use case.  The bottom-line here is that unlike "desktop web" with primarily Windows or "mobile web" with primarily iOS and Android, your device-side operating systems will be highly varied and multifaceted.

4) Client-side Programming Language:  In the case of desktop and mobile, you could get by with just knowing HTML, JavaScript and CSS.  It was possible that someone in your IT organization might also know Objective-C or Android Java but in general, you do not need to "go native" for many classes of enterprise-focused mobile apps.  In the land of IoT, with some microcontrollers, you could use JavaScript: Tessel or Espruino.  But in general you will mostly be working with C/C++ in that space.  For the microcomputer class of devices, running Linux, you can get back to more enterprise developer friendly programming languages like Java, Python, JavaScript via Node.js and Ruby.  Even though I have primarily lived in the enterprise Java space and certainly do enjoy programming in Java, I do not expect Java to be the dominate language on IoT-focused devices. My programming preference running on the edge gateways/devices is Node.js at this time.

5) Physical Assembly: The phrase "Hardware is Hard" is tossed about a fair bit.  While I own a soldering iron, I have only recently learned to use it.  I think many enterprise developers will need to partner with someone who specializes in hardware and understands voltage, resistance, capacitance, and RF (radio frequency) intuitively.  Someone who can design the ultimate sensor/actuator/device package, with just the key attributes and capabilities you need.   Someone who is happy to design with Eagle CAD and create custom PCBs (printed circuit board) or at least work with the design house helping you build your custom field-deployed devices.   This is very different than buying your employees an iPhone.

6) Enterprise Architecture: In the desktop web, mobile web and even mobile apps (native, hybrid) we primarily focused on HTTPS access.  While HTTPS is still possible within the IoT universe, it is not the only connectivity protocol - it is one of MANY protocols vying for dominance: MQTT, AMQP, XMPP, DDS and CoAP are all possible candidates - and many of these are messaging-oriented, async pub-sub, not request-response.  Furthermore, some of the devices are simply too low-powered to handle any real encryption for messages.  This is something to be considered in your overall systems design.

7) Ingestion:  It is predicted that the Internet of Things will include billions of connected devices and if you work for a large enterprise, you should have a feel for the volume of trucks, pallets, boxes, warehouses, fork lifts, retail stores, bins, utility poles, meters, EKG machines, etc that are part of your organization.  What happens when many of these normally silent things begin to provide data, every few seconds?  For many enterprises, the average desktop web or mobile app, does not receive vast amounts of inbound data as human employees can only type so fast, but in the land of IoT, you can be overwhelmed with data.  As an enterprise developer, my 'tried and true' weapon of choice, the application server, may no longer be the most appropriate solution - some form of distributed message broker becomes a better solution, allowing you to more easily ingest the sheer volume of data coming your way.

8) Analytics: A traditional, CRUD (Create-Read-Update-Delete) focused enterprise web application, deposits data from your human users into a relational database like Oracle, DB/2 or SQL Server.  Countless technologies, both paid and FOSS (Free Open Source Software), exist for exploring, mining, reporting, dashboarding, etc.  Your web server logs can be digested and dissected using technologies like Splunk or ELK (Elasticsearch Logstash Kibana).  Some of these tools and techniques still apply in the world of IoT.  However, the volume and speed of the inbound data (sensor readings from your manufacturing lines) and the potential need for "real-time" analysis to prevent outages (e.g. motor temperature signals poor performing wheel bearing) may make you reconsider this area of your architecture.   Technologies like Apache Spark Streaming or Apache Storm become much more interesting as potential solutions.


In summary, as of early 2015, Internet of Things (IoT) development is fairly different from today's average enterprise web and mobile app development.   Now, the space is absolutely exploding in terms of new innovations and a massive amount of R&D investment is being liberally applied.  It could be that by the time you need to start exploring the IoT, that the average sensor/actuator device has a 64-bit multi-core processor, wifi connectivity, months of battery life, fits on your fingertip, runs a fairly standard Linux, Java and Node.js giving you a powerful yet simple programmable platform.



Wednesday, March 11, 2015

DevNexus Docker for Java Developers: Hands-On Lab

Hello DevNexus 2015
March 12 2015 at 1:00 PM

We have 75 minutes to get your laptop setup with Docker for building and running Java EE applications.   The good news is that you can come to the session prepared.   I made the assumption that most folks will have a Windows or Mac OSX laptop and can use boot2docker which bundles VirtualBox.

The complete tutorial (the core of the overall talk) is available on Github
https://github.com/burrsutter/docker_tutorial
and
https://github.com/burrsutter/docker_mysql_tutorial

If you can, make the attempt at getting boot2docker running on your Windows or Mac laptop prior to the session.  There can be numerous challenges with the installation process, most of which I have tried to describe workarounds in the tutorial document.   Once you have successfully executed:

docker run centos /bin/echo "Hello World"

You are ready to go!

You can also simply install Docker on your Linux machine directly:
Ubuntu: https://docs.docker.com/installation/ubuntulinux/
Debian: https://docs.docker.com/installation/debian/
Centos: https://docs.docker.com/installation/centos/


Saturday, March 7, 2015

Publish Subscribe with Spark Core (1+1=3)


Do not make the same mistake that I made.  I purchased a solitary Spark Core and nearly missed the awesomeness of Spark.   You must buy two (2) from Spark.io, Sparks need friend!

A few years ago, I spent many hours with Arduino Uno but did not find it to be that engaging.   By default an Arduino Uno lacks networking and it is not a member of the "Internet of Things" unless you add on an appropriate shield or integrate another component.  At the time, the ethernet shield was somewhat expensive and Wifi fairly challenging.  Fast forward to 2015 and the world has changed dramatically.

I started exploring the Spark Core, the Open Source IoT Toolkit, essentially a Wifi-enabled Arduino for $39 (I have two Photons on backorder and backed the Electron on Kickstarter),  just last weekend.  This included my dusting off my Arduino Uno for testing various resistors, sensors, actuators, logic, etc prior to trying those so things on the Spark.  By this weekend, I wanted to see what it would take to "integrate" a couple of Spark Cores.

The Spark Core is inherently network-aware, in its default state, you must have a Wifi connection even to flash/program it (which does mean it is slower to flash than a USB-connected Arduino).  More importantly, your code can expose variables or functions which can be invoked via a REST API call to the Spark Cloud.  You can use curl to interact with the physical world - for a Java/JavaScript coder like myself...this is pretty incredible.

In addition, you can engage in publish/subscribe messaging between two or more Spark devices.

My thinking is that an intelligent sensor (based on Spark Core) in one location can take readings and based on need (e.g. stock needs replenishing,  conveyor motor offline, temperature is rising), can alert other intelligent actuators to take some action in the physical world.



In this case, I used a Force Sensitive Resistor where its reported value rises based on the amount of pressure (squeeze) you apply and I used the super simple Spark.publish API to send out the event to the Internet.   On the other Spark Core, I set up a subscriber that invokes a simple function to "animate" the servo+gripper also from SparkFun.   Both Spark Cores are sitting on their respective breadboards (the Core ships with a breadboard) and the subscriber core (the gripper) is being powered by the Spark Battery Shield.

Publisher (with Force Sensitive Resistor) Code


#include "application.h"

/*
From the article: http://bildr.org/2012/11/force-sensitive-resistor-arduino
https://www.dropbox.com/s/dodvjb814uxfscs/2015-03-04%2019.59.21.jpg?dl=0
https://www.dropbox.com/s/rduygfde2irjyv7/2015-03-04%2019.59.34.jpg?dl=0
*/

int FSR_Pin = A0; //analog pin 0
int ledPin = 7;
bool wasHigh = false;

void setup(){
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
}

void loop(){
  int fsrReading = analogRead(FSR_Pin);

  Serial.println(fsrReading);

  if (fsrReading > 3000) {
    Serial.println(wasHigh);

    if (!wasHigh) {
      Serial.println("sending HIGH");
      wasHigh = true;
      digitalWrite(ledPin, HIGH);
      Spark.publish("burrsqueeze", "HIGH", 60, PRIVATE);
    }
  } else {

    if (wasHigh) { // the state is normally sub-3000
      Serial.println("sending LOW");
      digitalWrite(ledPin, LOW);
      Spark.publish("burrsqueeze", "LOW", 60, PRIVATE);
      wasHigh = false;
    }
  }

  delay(400); //just here to slow down the output for easier reading
}


Subscriber (with Servo+Gripper)

#include "application.h"

/*
 Receives a 'squeeze' HIGH event and closes the servo+gripper to close
*/

Servo myservo;

const bool DEBUG=true;

int minPos = 32;
int pos = 0;
int maxPos = 160;
int ledPin = 7;

int i = 0;

void close_gripper() {
  if (DEBUG) Serial.println("close");

  // close
  for(pos = maxPos; pos >= minPos; pos-=1) {
    myservo.write(pos);
    delay(25);
  }
}

void open_gripper() {
  if (DEBUG) Serial.println("close");

  // open
  for(pos = minPos; pos < maxPos; pos += 1) {
    myservo.write(pos);
    delay(25);
  }
}

void eventHandler(const char *event, const char *data)
{
  if (DEBUG) Serial.print(event);
  if (DEBUG) Serial.print(", data: ");
  if (data) {
    if (DEBUG) Serial.println(data);
    // assume LOW unless HIGH arrives
    if (String(data) == "HIGH") {
      digitalWrite(ledPin, HIGH);
      close_gripper();
    } else {
      open_gripper();
      digitalWrite(ledPin, LOW);
    }
  }
  else {
    Serial.println("NULL");
  }

}

void setup() {
  if (DEBUG) Serial.begin(9600);
  Spark.subscribe("burrsqueeze", eventHandler, MY_DEVICES);
  pinMode(ledPin, OUTPUT);
  myservo.attach(A0);
  myservo.write(maxPos);
}

void loop() {
  delay(400);
  if (DEBUG) {
    i++;
    Serial.print("I'm Alive: ");
    Serial.println(i);
  }
}

Note: I use the Spark Dev (on desktop Atom-based Spark tool) so I include application.h



Monday, February 16, 2015

docker, Docker, DOCKER!

My first run of the Docker Tutorial Live has been canceled for today, February 16 at TriJUG, alas, Old Man Winter has intervened and we are expecting snow & freezing rain during the TriJUG meeting time window.  And for those of you who have lived in the South, snowflakes are a cause for major alarm - I suspect the grocery stores have already been raided for bread, milk, eggs and ammunition :-)

The next live event will be DevNexus in Atlanta on March 10 to 12th 2015.   DevNexus is an excellent JUG-organized developer-focused event which basically equates to a great speaker line-up at a great price point.  

For those of you following along at home (not physically making it to TriJUG or DevNexus), please check out the written Docker Tutorial materials - the focus is on the Windows-based enterprise Java Developer.  With our JBoss Tools project, we receive opt-in usage data that shows us that the vast majority of enterprise Java developers run Windows as their primary desktop.  While Docker is a Linux innovation, it can be run on Windows via boot2docker (which includes VirtualBox in its installation).  And Java developers do want to understand how building Docker images and running containers could impact their future toolchain and workflow.

I wrote the tutorial documents in markdown (many thanks to Pete Muir for helping my formatting) and stored them in github to make them "forkable" - hopefully allowing anyone who wishes to run their own Docker Workshop use the materials and perhaps even send back a pull request.

Getting Started with Docker, boot2docker, on Windows for the Java Developer

Adding MySQL and additional tips for Java EE on Docker

Once you have a comfort level with Docker builds and runs...then it is time to learn one of the orchestration solutions - basically tools that allow you to start multiple docker containers, linking them, declaratively.  We (Red Hat) are focused on Kubernetes by Google as that piece of the infrastructure.  Check out this short recorded demo of Kubernetes in action.







Monday, February 9, 2015

New Technology Learning Process

I love learning.  I was a curious child and became an even more curious adult.  When it comes to all sorts of enterprise-related software development, I really wish to know what a new technology or technique might bring to the table.

One trick that I will use on myself is to sign up for a presentation as that will force me to learn the technology (or technique) well enough to at least get through a 60 to 90 minute presentation and demonstration...with a hard deadline.   The demonstration being the key thing for me - I tend to work backwards from the demos to the slides - so that the slides reflect what I can actually show off in the demos.

In the last few years, the set a presentation date trick was how I learned:
- Platform-as-a-Service and cloud computing in general
- HTML5
- Vert.x (minute 46)
- Apache Cordova (Phonegap)
and now I am doing it with Docker for TriJUG and DevNexus.

My basic learn something new technique is as follows:
1) 30 seconds: when I first hear about something check the term out on Wikipedia (e.g 6LoWPAN)
2) If the term is so new or esoteric that wikipedia does not have a entry, search Twitter
3) 5 minutes: try to find a sub-10 minute YouTube video on the subject.  
4) 30 minutes: find a decent tutorial/getting started guide - these are very critical to my learning path - therefore I try to craft my own tutorials when possible.
5) 1 hour: find some decent examples - I am definitely a learn by example kind of person.  Some folks call it a "copy & paste" programmer.  As part of my first hour or three of learning...finding some good examples and "playing" with the new technology is critical.  That early feeling of success is a huge motivational factor.  And if the examples fail, then you feel challenged.
6) Look for the deeper dive presentation on YouTube or if I am lucky, seeing it presented at a conference.  I find that the way someone presents the high points of a technology - the advantages and its warts is very helpful in my initial "wrapping my head around it".
7) Find the forums, the better technologies should have a community forum, perhaps a simple Google Group and/or tags out at StackOverflow.  I like scanning through the questions as that gives you a feel for how the technology is being used in the real world.  You can then compare the use cases to your own needs.   I use this same basic technique when reading reviews - does the reviewer (question asker) think as I would?

What is your learning process? How do you prioritize the list of things to be learned and then what steps do you follow to gain some (or great) insight into the new technology?







Saturday, February 7, 2015

HTML5, Vert.x, Leap Motion and other goodies

What follows are some of my favorite presentations/demonstrations of some very fun technology.  Leveraging technologies like HTML5 Canvas, Vert.x - a reactive async platform and Leap Motion for gesture UI.   


One of most fun demos I have created was related to Vert.x 2 and allowing for audience participation...in a live demonstration.   Here is a single-user recording of the demonstration I called "paint" as it is a multi-user painting tool.  Audience members use their phones to touch draw via HTML5 canvas something on their smartphone web browser,  those events were captured via JavaScript, sent up to Vert.x running on Openshift and then back to the dashboard running on my laptop's browser.  
This demonstrates not only the power of HTML5 Canvas, but also Websockets and a reactive async platform like Vert.x.  Warning: some of your audience members may draw some rated R or NC-17 images when you are displaying all the individual images via the dashboard, I have had that happen.  I used this demo at Great Wide Open 2014 and Devoxx 2013 (Vert.x is toward the very end). 

Note: Paint is NOT a representation of great coding - it is cool hacking - to make something work with the least amount of pain.  :-)


Taking advantage of Leap Motion and Leap.js to capture the figure gestures to draw on my desktop browser but also leverage Vert.x EventBus to reflect the gestures out to mobile devices.  I think of it as a "reach out and touch somebody" kind of demo - where I can put my hands on the audience's phones.   In this case Leap's gestures are being sent up "to the Cloud" (Openshift) and then back out to the mobile devices.  Basically the opposite flow from the multi-user painting demonstration above.
 


The Hitchhikers Guide to the JBoss Galaxy presentation has been used on several occasions and different events and I took some time to move it from PowerPoint to Reveal.js.   Based on the experience with gesture tracking and finger painting,  I thought I can hack in simple gesture-based navigation.  It works fairly well but it is hard to capture via video.  
I used the ZiggiHD USB-powered document camera to make the Leap Motion controller visible in the bottom left corner - see video.



 






Wednesday, January 7, 2015

Docker for Java Developers (Lab)

Docker for Java Developers (Lab) 

We have been working on a hands-on tutorial to help people ram up on Docker!

Containers are enabling developers to package their applications (and underlying dependencies) in new ways that are portable and work consistently everywhere? On your machine, in production, in your data center, and in the cloud. And Docker has become the de facto standard for those portable containers in the cloud, whether you’re working with Amazon Web Services, Google Cloud Platform, or Microsoft Azure. Docker is the developer-friendly Linux container technology that enables creation of your stack: OS, JVM, app server, app, and all your custom configuration. So with all it offers, how comfortable are you and your team taking Docker from development to production? Are you hearing developers say, “But it works on my machine!” when code breaks in production? And if you are, how many hours are then spent standing up an accurate test environment to research and fix the bug that caused the problem? This lab offers developers an intro-level, hands-on session with Docker, from installation (including boot2docker on Windows/Mac), to exploring Docker Hub, to crafting their own images, to adding Java apps and running custom containers. This is a BYOL (bring your own laptop) session, so bring your Windows, OSX, or Linux laptop and be ready to dig into a tool that promises to be at the forefront of our industry for some time to come.

The First Tutorial (planning on more in the series)
https://github.com/burrsutter/docker_tutorial

And recommended blogs by Arun Gupta for more concepts:




Monday, December 1, 2014

Hybrid Mobile - Apache Cordova Training Series with Eclipse via JBoss Developer Studio

We have been developing Eclipse tools for HTML5 Hybrid Mobile applications, leveraging Apache Cordova, jQuery and AngularJS/Ionic for a few years now.   This set of videos is primarily for "training purposes".  The ultimate goal is to get you started and making you productive with our mobile-focused Eclipse tools.

The series has been published to YouTube. JBoss Mobile (Cordova, jQuery, AngularJS, Ionic, Push) - YouTube

 1 - Installation: Walks through the installation of the Hybrid Mobile Tools into JBDS 8 - allowing you to create Apache Cordova based applications leveraging HTML5, jQuery Mobile or AngularJS+Ionic. In this video, you are introduce to CordovaSim and LiveReload features for interactively building your mobile UI. Integration with the iOS Simulator is also demonstrated (note: iOS Simulator requires Mac OSX)
2 - REST: Addition of a localhost EAP server, configuration to allow for remote connections (mobile clients are remote), deployment of a REST endpoint. Creation of a mobile application that interacts with the EAP hosted REST endpoint.
3 - Native API: Demonstrates how to use Apache Cordova Plug-ins to leverage native device functionality, in this case, access to the Contacts on the device itself. Also demonstrates deployment to a USB-connected Android phone.
4 - AngularJS + Ionic: Demonstrates how to start an AngularJS + Ionic project and import into JBDS. Use of the new Ionic Palette in JBDS.
5 - Push: Introduces how to configure Push Notifications - primarily focused on the EAP setup required to install our UnifiedPush Server to a localhost EAP. Includes the configuration of Android Google Cloud Messaging push notifications - demonstrated on actual Android device.
6 - More Native: Brings in some additional Apache Cordova Plug-ins to demonstrate use of the accelerometer and battery status APIs. CordovaSim providing interactive testing support, deployment to real Android device.
7 - iOS: Taking the same application created for Contacts and deploying it to an iPhone. Demonstrates the steps involved with using http://developer.apple.com, JBDS' Export Native Project and XCode with actual deployment to a local iPhone.

Friday, January 31, 2014

iOS APNS & Android GCM Push with Apache Cordova (Phonegap)

Here are my instructions for Hello World, a tutorial with Aerogear's Unified Push Server that allows you to send iOS and Android push notifications to Apache Cordova/Phonegap/HTML5 client applications. If you need help, the best place to hang out is on irc.freenode.net #aerogear channel

The instructions can be found in the readme.txt file and the sample code, while not necessary to follow the tutorial is also available at github https://github.com/burrsutter/hellopush The primary difference between the instructions in the readme.txt and the provided solution is that I added logic to address the OS configuration. If you are an Eclipse user, JBoss is adding a plugin for Phonegap/Apache Cordova project creation - here is a video to see it in action: https://vimeo.com/82204444
https://vimeo.com/81565404

My Aerogear Unified Push Server instance is running at OpenShift - sign-up is free and it only takes a few clicks to select the Aerogear Push 0.X quickstart and you are up and running.

Aerogear Cordova Push Plugin (HelloWorld)

0. getting the Cordova command line tool installed for Mac
sudo npm install -g cordova
cordova -version
3.3.1-0.1.2
http://cordova.apache.org/blog/releases/2013/07/23/cordova-3.html

Cordova Command Line Guide
http://cordova.apache.org/docs/en/3.0.0/guide_cli_index.md.html

npm itself comes from Node.js http://nodejs.org/
npm -version
1.3.25
node --version
v0.10.25
You will also need the Android SDK installed for your OS and in your PATH - commands like "android" and "adb devices" should execute
You will also need "curl", if you type in "curl" and hit return
curl: try 'curl --help' or 'curl --manual' for more information

1. Cordova create has the following sequence: "cordova create folderName bundleID appName"

cordova create hellopush com.burrsutter.hellopush "Hello Push"

2. edit hellopush (bring up your editor) if you open config.xml, you should see <name>Hello Push</name> <widget id="com.burrsutter.hellopush" the widget id becomes the bundle identifier, it must unique identify your iOS app, globally when you setup your iOS provisioning profile, you will need this unique bundle ID

3. cd hellopush

4. cordova platform add android

5. cordova plugin search push

6. cordova plugin add org.jboss.aerogear.cordova.push

7. There is a console.log in the default project as well as in the suggested example code, so make sure to also add the console plugin

cordova plugin add org.apache.cordova.console

and to know the mobile OS install the device plugin

cordova plugin add org.apache.cordova.device

8. index.html - insert the following below <div id="deviceready"> but inside <div class="app"> <font size="6"> <div id="notify">notifications </div> <div id="debug">debug </div> </font>

9. index.js

   successHandler: function (message) {
            var debug = document.getElementById("debug");
            console.log(message);
            debug.innerHTML = "success: " + message;
   },
   errorHandler: function (message) {
            var debug = document.getElementById("debug");
            console.log(message);
            debug.innerHTML = "error: " + message;
   },  
   onNotification: function (e) {
            // alert(e.alert);
            var notify = document.getElementById("notify");
            notify.innerHTML = e.alert;
   },  

    // deviceready Event Handler
    //
    // The scope of 'this' is the event. In order to call the 
    // 'receivedEvent' function, we must explicity call 
    // 'app.receivedEvent(...);'
    onDeviceReady: function() {
        var config = {
                senderID: "492580885002",
                pushServerURL: "https://aerogear-html5.rhcloud.com",
                variantID: "b3852e72-92e1-4b05-a4bd-b549438d4943",
                variantSecret: "13c9daca-457e-4837-bc26-769ba572a940"
        };
        push.register(
            app.successHandler,
            app.errorHandler,
            {
            	"badge": "true",
                "sound": "true",
                "alert": "true",
                ecb: "app.onNotification",
                pushConfig: config
            });
            
        app.receivedEvent('deviceready');
   },
Note: senderID, variantID and variantSecret were all setup in the Push Console at pushServerURL

http://aerogear.org/docs/guides/aerogear-push-android/google-setup/

http://aerogear.org/docs/guides/AdminConsoleGuide/

10. Run "adb devices" to see if an android device is plugged in correctly then cordova run android

this will install and launch the app on your plugged in, developer-ready Android phone/tablet

11. then send a message

curl -3 -u \
"f07c43a6-bb0a-4bb7-a1eb-a368db272212:e2cf19c3-6636-4712-bbe8-26b7c1ac9c09" \
   -v -H "Accept: application/json" -H "Content-type: application/json" \
   -X POST -d '{"message": {"alert":"Hello AeroGear", "badge":1}}' \
   https://aerogear-html5.rhcloud.com/rest/sender
NOTE: this is not wrapping correctly here in Blogger, here is the gist and I included a send.sh to make sending in numerous messages a little easier. Usage: ./send.sh "My Message" 3

where f07c43a6-bb0a-4bb7-a1eb-a368db272212
is your Application ID from the web console
where e2cf19c3-6636-4712-bbe8-26b7c1ac9c09
is the Master Secret also from the web console

Success, send a few more messages, changing the "Hello AeroGear Unified Push!"

Note: If you wish to deploy the app to another Android device, unplug the current one and plug in the new one - use "cordova run android" again and it will deploy to the new device - the app will still function and receive push notifications without being plugged in on USB.

12. Add iOS, if on Mac OS X, with XCode installed (via Mac AppStore is easiest) and you have previously paid your $99 and know how to get around at http://developer.apple.com

cordova platform add ios
13. Setup your provisioning profile:

http://aerogear.org/docs/guides/aerogear-push-ios/app-id-ssl-certificate-apns/ and

http://aerogear.org/docs/guides/aerogear-push-ios/provisioning-profiles/ and

http://aerogear.org/docs/guides/AdminConsoleGuide/

14. Add the variant for iOS via the Unified Push Server web console - uploading the .p12 file and its associated passphrase

15. look under platforms\ios and you should see a Hello Push.xcodeproj - double click on the .xcodeproj

If you see the General tab, double check the bundle identifier of com.burrsutter.hellopush or whatever you made yours

Modify the index.js (in XCode) for the proper variantID and variantSecret from the Unified Push Server console

16. Assuming you have previously registered your plugged in iOS device with the developer.apple.com portal, you can now hit the big arrow and target your device.

When the app installs it should prompt you to accept push notifications.

17. Look for a new installation/device token under your newly added iOS variant in the UPS web console. If you see no instance/device token then something failed.

18. Finally, send a message, it should hit all the android & iOS devices that you have deployed the app to.

Wednesday, December 18, 2013

Eclipse does not contain the JNI_CreateJavaVM - Mac OS X (10.9) Mavericks

Based on a recent experience, I thought it would be useful to post this blog for others who might also be struggling with this particular error message. After the Mac OS X Mavericks (10.9) upgrade, I hit the following error message from Eclipse Kepler (4.3.1) 32-bit
The JVM shared library "/Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/bin/../jre/lib/server/libjvm.dylib" does not contain the JNI_CreateJavaVM symbol.
Also, there is another error message you might receive from Eclipse:
To open “Eclipse.app” you need a Java SE 6 runtime. Would you like to install one now?
I read through this bug report at eclipse.org - https://bugs.eclipse.org/bugs/show_bug.cgi?id=411361 and that gave me some ideas as to how to workaround my Eclipse on Mavericks issues. Easy solution, download & install the Oracle JDK 7 and make sure to use the 64-bit version of Kepler. I have had Java 7 on the machine for a while and Java 8. I have historically used the 32-bit version of Eclipse which worked great with Java 6 which was the default from the Mac OS X perspective. Here is what I think happened, Mac OS X Lion (10.7) included Apple's Java 6 JRE, with Mac OS X Mavericks (10.9) it is no longer included. The Apple Java 6 supported 32-bit & 64-bit with a command line switch, Eclipse Juno & Kepler were seemingly able to handle that scenario. Now, Java 7 comes directly from Oracle and is installed separately on my box. In order to address the "you need a Java SE 6 runtime" specifically, I also needed to update your Info.plist in the JDK7 at /Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Info.plist with the following in the JVMCapabilities section:
                JVMCapabilities
                
                        CommandLine
                        JNI
                        BundledApp
                        WebStart
                        Applets
                
Once the changes to Info.plist have been made you will need to reboot for it to take effect. Some other settings that might be important: JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home And I do not recall making any changes to Eclipse.ini that mattered, what follows is what I have right now on my machine, provided in case there is something tweaked in your installation. EDIT: It turns out that I did need to update my eclipse.ini, eclipse was picking up a Java 8 installation that I had and I needed to force it back to Java 7 as it was causing some other problems. Eclipse.ini for the 64-bit installation of Eclipse (underneath Eclipse.app-Contents-MacOS)
-startup
../../../plugins/org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar
--launcher.library
../../../plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.1.200.v20130807-1835
-product
org.eclipse.epp.package.standard.product
--launcher.defaultAction
openFile
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vm
/Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/bin/java
-vmargs
-Dosgi.requiredJavaVersion=1.6
-XstartOnFirstThread
-Dorg.eclipse.swt.internal.carbon.smallFonts
-XX:MaxPermSize=256m
-Xms40m
-Xmx512m
-Xdock:icon=../Resources/Eclipse.icns
-XstartOnFirstThread
-Dorg.eclipse.swt.internal.carbon.smallFonts
Also, I did make the change recommended at Eclipse.org/downloads. It should be noted that you won't actually see something named "gatekeeper" in the UI.
Hopefully that helps, I spent plenty of time using Google looking at Bugzilla and StackOverflow entries but could not find something like this blog post that helped me address both issues (64-bit required, missing Java SE 6 runtime).

Tuesday, November 26, 2013

Personal Technology Radar: How to keep up?

I gave a short presentation/demonstration to NCSU Computer Science students last night, it was full of various buzzwords, thoughts, random associations, high speed talking, etc. :-)

I focused on things like Aerogear (SDKs for mobile app dev, Push Notifications, storage), Vert.x (polyglot async services for the JVM) and showed off JBoss Tools for mobile app dev (https://vimeo.com/67480300).

One fellow posed a very interesting question to me, "how do you keep up?" and what follows was my off-the-cuff response.

Personally,

  • I am no longer able to follow news sites such as HackerNews
  • I am no longer to follow RSS feeds
  • I am no longer to keep up with the blogs (via RSS) that show up in my Flipboard account and
  • I am unable to read even 10% of the messages that follow through Google+ or Twitter, which is where I follow key colleagues and industry experts.
Basically, I am unable to consume the "push" news, I am only able to consume the topics I seek out.

So, how does a topic show up on my personal technology radar, I follow conference agendas. If you simply look at key conference agendas and then drill-down on those topics yourself it is pretty easy to keep your finger on the pulse of things. Conferences that I have participated in and always enjoy attending when I can are:

and we, Red Hat folks, are working on a really cool developer conference ourselves - watch the twitter stream for that announcement. Plus, I am also very interested in UberConf and The Rich Web Experience - anything that Jay Zimmerman is putting on.

There is one slight disadvantage of using this particular filtering mechanism, your feeling for how important a topic is can be slanted based on the abilities of the associated speakers. For instance, someone like James Ward, who is one of the best developer advocates in our industry is not only a great public speaker but he is also fairly high volume - therefore you may be more inclined to delve deeper into one of his topics. The same could be said for many of the excellent presenters that show up for these conferences.

There is another more significant disadvantage, if a particular innovation/tool/technique has no evangelist, nobody to talk about it, is so "unpopular" that it does not show up at a conference...well then it tends to miss my radar. So I do have a personal bias towards "popular" topics, ones with buzz, ones with somebody willing to talk about it in public. I allow for this bias because, at the end-of-the-day, I have found that "popular" topics are more likely to have staying power over the course of several years.

You would rather not invest dozens if not hundreds of hours in learning a new thing to only have that item fade into history with nobody left using it. Granted, learning for learning sake is still a very good thing. :-)

Burr

Thursday, July 19, 2012

JBoss Toy Store Screencast

In a previous blog, I wrote an introduction to the various components included in the JBoss Toy Store - that is the name we gave our demo application for JBoss World 2012's Keynote address. The name "toy store" was because we were allowing our "sales staff" to acquire/giveaway cool electronic gadgets or JBoss "schwag" like t-shirts and coffe mugs. I recently sat down and recorded a screencast of the demo application, making it much easier to see and hopefully easier to following than the recording of the staged event. Your feedback and comments are always welcome - plus, the JBoss Toy Store codebase is open source, I would love to see others forking it on github, making improvements, running the demo at their local JUG with a room full of attendees and then making contributions of code, videos, blogs, etc.

JBoss Toy Store Demonstration from JBoss Developer on Vimeo.


And if you are interested in JBoss technical content, we have over 150 videos hosted at Vimeo.com/jbossdeveloper

Monday, July 2, 2012

JBoss World Keynote Demo 2012

In June 2011, we focused our keynote demonstration on JBoss' AS7 and Infinispan technology which we delivered as fully supported products (Enterprise Application Platform 6 and JBoss Data Grid 6) this year.

For 2012, we wanted to make a killer demonstration that was more accessible today - leveraging a core technology that is already officially supported - jBPM 5 in JBoss BRMS 5.3.   The BPM landscape, normally only accessible by large corporations due to license costs and complex proprietary software offerings...is changing.    This blog provides a high-level overview for the various elements that went into the making of the demonstration.   We have already opensourced the codebase at JBoss Developer Framework (jdf).


Recording of the JBoss World 2012 Keynote on YouTube.  The demonstration starts at 14:33.


- BPMN2 modeling (jBPM & Drools - BRMS 5.3)
- Mobile Tasks - HTML5 based task interactions (Aerogear)
- Enterprise Application Provisioning (AppBlade)
- Real-time web-based dashboard (Errai)
- Cloud/Platform-as-a-Service (OpenShift)
- Gamification 
- Open Source - makes all of this technology more accessible to all developers



BPMN2 Web Designer

BPMN2 + Business Process, Rules & Events

With jBPM & Drools, we are able to model the core business logic via BPMN2 and a decision table using a web-based repository and modeling tool.  This means the workflow and its associated rules can easily be changed, in production, without programming and without service disruption.


HTML5 + Cordova Application

AppBlade Provisioning

HTML5, Apache Cordova & AppBlade

We then extended the business logic layer via RESTful services that were consumed by a HTML5 application wrapped with Apache Cordova and delivered via AppBlade - the application was to enable "employees" to use a simple catalog and shopping cart to order schwag (promotional items, giveaways), we had a little sales contest, encouraging audience members to pound in orders via the AppBlade provisioned application or the mobile web using their smartphone's browser.

Leaderboard - Errai-based Dashboard

Dashboard
As a live, audience-interactive demonstration, we needed a "dashboard" that could tell us, instantly, how a particular participant was performing - much like any organization would love to have to real-time analytics - we took advantage of Drools Fusion (BRMS 5.3), eventing and then leveraged Errai+GWT to push those events out to a waiting web browsers running on Linux, Mac and Windows.  Our dashboard is also an HTML5 application that can leverage the current capabilities of advanced web browsers.   This was a great risk - we had several hundred people in the audience, with a saturated WIFI and leveraging free resources at OpenShift.   Our Errai-based Leaderboard turned out to be a huge hit!  And it clearly demonstrates how the average web browser can be used for real-time process monitoring and it runs great on the iPad.


Cloud
Not only do we believe that HTML5 and the explosion of mobile devices is having a profound impact on the BPM industry, PaaS, Platform-as-a-Service, will enable many more organizations who could not afford a large IT capital expenditure to roll-out a new system to leverage business rule and business process systems.  We also needed to leverage the cloud for a purely practical reason - we were enabling random individuals using their 3G/4G (or conference WIFI) mobile devices - this meant the system had to have a public IP address - OpenShift was the answer.

Gamification
We were doing a live, in-person event, where we required audience participation for the software to even function properly.  No volunteers, software that was too hard to use or simply the lack of motivation, would have completely changed the dynamic of the demonstration.   The leaderboard was the secret ingredient - players were able to see their name on the board and instantly see how their activities on their phones were impacting the business scenario.   The concepts of gamification for BPM can obviously get much more sophisticated than what you see in our demo, however, the core concepts are there - make it competitive, recognize and reward the winner, build a team to play along and acknowledge and reward as many random players as possible - encouragement & motivation.  Perhaps in a future version we would offer badges!

Open Source
Not only is are the key products behind this demonstration open source, the actual demo code is itself also open source - we hope that many of you grab the codebase and run this same presentation at your local JUG - run it on OpenShift - have your audience break out their phones and give it a try!

A huge thank you to Kevin Conner who served as a our overall architect and engineering lead for the project.   All of us took this project on knowing that the actual products upon which the demonstration was based was also being delivered in the same month.  It was an exciting challenge and we had a fantastic team - now we get a weekend off and it is time to start planning our next crazy demo - bring on the robots and gesture UI.  ;-)



Monday, April 23, 2012

My Getting Started Experience/Tutorial with Appcelerator Titanium 2.0 and Appcelerator Cloud Services (formerly known as CocoaFish)


First, I am a complete newbie when it comes to Appcelerator though I am comfortable with JavaScript and cloud related technologies.  I have spent time with Azure (C# via Visual Studio), Cloud Foundry, Heroku, Google App Engine, Amazon's Beanstalk and of course Red Hat's OpenShift as PaaS (platform-as-a-service) offerings.
And I have been able to start digging into various client-side development technologies like jQuery Mobile + PhoneGap/Apache Cordova (see Kris' article) and just recently I tried out some Objective-C via XCode and the fantastic Kinvey quickstart tutorial.

Recently, I have had several people I know and respect tell me that Appcelerator Titanium is the best solution for cross-platform mobile application development, it uses JavaScript as its primary language therefore the average jQuery front-end to Java back-end guy like myself should be able to learn it easily.  Plus, Appcelerator Titanium is based on Eclipse which is something I have spent a lot of time with for my JBoss "day job" as evidenced by all kinds of screencasts.

My specific interest in mobile is mostly related to how to communicate with a "backend" - and now it seems the term "BaaS" for backend-as-a-service is starting to become more popular with several offerings now available such as Parse, Kinvey, and StackMob.   The primary difference between a BaaS vs a PaaS is that BaaS assumes the developer wishes to focus only on his/her client-side code written in Objective-C, Android Java, JavaScript,  HTML5 + a JS lib (e.g. Backbone) - all the user management, data & blob storage, push notifications, etc are all managed through a client-side API and a web console.  In other words, a BaaS has no server-side coding to worry with.   A PaaS on the other hand, assumes the developer wishes to write custom server-side logic in PHP, Perl, Java, JavaScript for Node.js, etc.

On April 17. 2012, Appcelerator announced Titanium 2.0 where the most important feature (IMHO) is integration with the recently acquired CocoaFish - cloud services for the mobile developer, now called Appcelerator Cloud Services.

And here it is April 21st and I decided to spend my Saturday giving it a try and writing up this blog. :-)

Keep in mind that my primary goal is to be able to store & retrieve data associated with my mobile application "in the cloud" and ideally, share data between multiple instances (multiple devices) of my application.  Unfortunately, that particular use case does not have a tutorial and what follows are the basic steps that I followed to get some simple things working.

Note: There are a few documents that I found to be useful:

and there are some examples that are installed on your local machine.  In the case of a Mac, you might be able to find them at:

$HOME/Library/Application Support/Titanium/modules/commonjs/ti.cloud/2.0.1/example

For this particular weekend (April 21st),  I was unable to find a "from scratch" tutorial, so I had to dig around and follow some hunches.   Hopefully this blog post inspires the good folks at Appcelerator to provide a nice getting started/tutorial for ACS with a Titanium client application.

1) Register at Appcelerator.com - this was a little bit tricky, I had originally went to "cocoafish.com" which redirected me to http://www.appcelerator.com/cloud and from there I clicked on the Start Using Cloud Services For Free button.  This was a bit awkward as it had me fill in a form and await an email verification, it then would ask me to login, sign-up, login again.  After about four attempts at the login it seemed to feel that I belonged and settled down.  It could be I was just trying to move to fast for the system.  Preserving pays off - just login a couple of more times. :-)  Why did I start with "cocoafish"? Because I did not read the press release until after I attempted to sign up, so I did not really know what the new name/website was.

2) Download Titanium Studio - I won't bore you with the details of download & installation as it is very straightforward - and I had previously installed Titanium Studio but never really used it - so upon launching it this past Friday night - it automatically knew the 2.0 update was ready - I just followed the typical Eclipse update process and was painlessly upgraded.  I do believe you will need XCode and the iOS SDK installed on your machine as well and I already had that installed from previous attempts at using PhoneGap and Objective-C.

3) Back at the ACS web console, I created a ACS only application called ToDo - why did I choose ACS only and name it ToDo?  I really cannot say, it was somewhat random and "felt right".



Then I went back to Titanium Studio to begin the development project - perhaps it was possible to create the ACS App from within Studio but I did not/have not notice it - so my process is to build both halves, client & server and then connect the two.

4) File -> New -> Titanium Mobile Project


Project name: CloudUsers (note: screenshot shows CloudUsers2 because I ran through this twice)
App Id: com.yourcompany.cloudusers (note: I am Java guy so I used a "package name")
Company/Personal URL: http://www.yourcompany.com
and Automatically cloud-enable this application should be checked by default.

Select Next

Select Single Window Application

and Select Finish

Note: After working with several cloud offerings, I was expecting that the New wizard would prompt me for my ACS app - ideally provide a list of the apps described in the ACS web console.   The next step is how I addressed this disconnect between my client-side app and the ACS service.

5) Edit tiapp.xml to inject your ACS App's keys.  You will wish to match up the various ACS keys with what is in the web console.  Unfortunately, the web console and this XML file have slightly different names for each key - that can be an issue for the newbie.


"acs-api-key-development"= APP Key
Note: double clicking on the APP Key data does not highlight it correctly in the web console.   So be a little cautious with your highlight to copy & paste - double clicking tends to also grab the string "Key".

In the top right-hand corner of the web console, there is an option for PRODUCTION and DEVELOPMENT, make sure DEVELOPMENT is selected for the "acs-api-key-development" property. Then click on PRODUCTION to get it's APP Key.

Click on Show OAuth Credentials

"acs-oauth-key-development"= OAuth Consumer Key
"acs-oauth-secret-development" = OAuth Secret
You can follow the same basic steps to get the Production keys.

Save your changes to tiapp.xml 

6) Create some users, you can not create data (custom objects) without first having a user.   Open up ui/common/FirstView.js and modify it so you have several textfields and a button - to create a new user.  First, declare the Cloud variable to interact with ACS:

var Cloud = require('ti.cloud');
Cloud.debug = true;

I placed these lines directly inside of "function FirstView", perhaps they should have gone elsewhere but I am brand new to Appcelerator and it worked fine in this location.

Then add a series of textfields, I found that if you type in "text" and hit Control-Space, Titanium Studio will then drop in a generic declaration of a Ti.UI.createTextField block as well as an eventlistner.  This is a tremendous aid to developer productivity.  Just note that there are some odd things about this content assist feature:
a) A textfield comes with the following property set:
softKeyboardOnFocus : Ti.UI.Android.SOFT_KEYBOARD_DEFAULT_ON_FOCUS
which causes a runtime error in the iOS simulator, you will need to comment it out.
Ideally, Titanium Studio would recognize that my project is not setup for Android and would leave that property out.
b) Any component added via this trick "text" with Control-Space or "button" with Control-Space, creates a particular line of code to add the component to the overall "window":
parentView.add(componentName);
"parentView" needs to be changed to "self" for these Single Window Applications.
c) If you use "button" and Control-Space, it creates a button with myHeight, myWidth, myTop and myLeft - those are not valid values - you will need to change them to numbers.  Leaving those variable names in your project will result in a nice big red error message.



The fields you need for a new user form are:
username
password
password_confirmation
first_name
last_name
email

and then you will need a button, in my case, I called it "Create"

    // Listen for click events.
    Create.addEventListener('click', function() {
        Cloud.Users.create ({
            username: userNameField.value,
            password: passwordField.value,
            password_confirmation : passwordConfirmation.value,
            first_name: firstName.value,
            last_name: lastName.value,
            email: emailAddress.value
        }, function (e) {
            if (e.success) {
                alert('Success');
            } else {
                alert('Fail');
            }
        });
    });


Complete listing

7) Test - Hitting the small green arrow in the Titanium Studio toolbar will launch the iOS Simulator (on a Mac, not sure what happens on a Windows machine).


Enter some data in the fields that should be valid and hit the Create button, I am not sure if invalid data (e.g. poorly formed email address) will be rejected by ACS.  

And then check out the ACS web console for your application - as you create new users.
and drill-down on "Users"

Like magic, your  mobile application's, client-side code is able to modify server-side resources - with no server-side coding required.

8) Now that you have some users in the system, you can create custom objects with the following block of code:
  label.addEventListener('click', function(e) {
    Cloud.Users.login({
      login  : 'username3',
      password: '123password',
    }, function(e) {
      if (e.success)   {

        Cloud.Objects.create({
          classname : 'cars',
          fields : {
            make : 'Ford',
            color : 'green',
            year : 2010
          }
        }, function(e) {
          if(e.success) {
            var car = e.cars[0];
            alert('Success:\\n' + 'id: ' + car.id + '\\n' + 'make: ' 
            + car.make + '\\n' + 'color: ' + car.color + '\\n' + 'year: ' 
            + car.year + '\\n' + 'created_at: ' + car.created_at);
          } else {
            alert('Create Error:\\n' + ((e.error && e.message) || JSON.stringify(e)));
          }
        }); // Cloud.Objects.create
                    
      } else {
        alert('Login Error:\\n' +
                ((e.error && e.message) || JSON.stringify(e)));
      } 
    }); // Cloud.Users.login
    
  }); // label.addEventListener


And the result of running this code will create new custom objects which are visible in the ACS web console.
and when you drill-down on Custom Objects

Now, one trick that I use is to start new projects to test out new things.  In the case of adding a custom object, I made yet another Titanium Mobile Project following the same steps as the one for CloudUsers.

Warning: If you do not first login then you will receive a runtime error of "401: You need to sign in or sign up before continuing" 


This error message can be a real head scratcher.   Searching in Appcelerator's Q&A (pitiful attempt at forum) does not yield great results (I have a screenshot of that as well).   It is also funny that the documentation tells you how to put in the Error message but the result has the "\n" in the string.   

9) Querying for the custom objects does not actually require a user/login - I was able to query in a completely different project using the following block of code in FirstView.js

function FirstView() {
  //create object instance, a parasitic subclass of Observable
  var self = Ti.UI.createView();
  var Cloud = require('ti.cloud');
  Cloud.debug = true;
  
  // Create a Button.
  var Query = Ti.UI.createButton({
    title : 'Query Cars',
    height : 35,
    width : 100,
    top : 50
  });
  
  // Listen for click events.
  Query.addEventListener('click', function() {
    Cloud.Objects.query({
      classname: 'cars',
      page: 1,
      per_page: 10
    }, function(e) {
      if (e.success) {
        alert('Success:\\n' +
                'Count: ' + e.cars.length);
      } else {
           alert('Error:\\n' +
                ((e.error && e.message) || JSON.stringify(e)));        
      } // else - fail
    }) // Cloud.Objects.query
  });
  
  // Add to the parent view.
  self.add(Query);
  
  return self;
}


With this level of effort, one real day of digging in, including writing up this long blog post. I think I could finish my little application with Appcelerator.   My 14 year old son is more interested in using Objective-C and ACS does have a iOS SDK for that style of development.   You might see a future blog post where we compare our experiences with building a mobile based apps using both Objective-C and Appcelerator with the same backend services.

Project Sources



Why did I put all of this into a blog?  I may not get back to looking at ACS and Appcelerator Titanium for several days or weeks - so this posting will help jog my memory and it might be useful for someone else who is trying to get started with Appcelerator Cloud Services