Purpose
The Appcelerator framework allows for the extension of the build and deployment process so that you can add components and modify the behavior of your service implementations. It is quite powerful and not only restricted to services, plugins for example could span across to the modification of applications and the entire build and deployment process for that matter. For simplicity, this article will identify how to create a new component added to our java service for monitoring performance.
Install Appcelerator
I’ve assumed that you’ve successfully downloaded and installed Appcelerator from http://www.appcelerator.org/products. Once you’ve gone through the installer you can get the java service
1 | app install:service java |
You may wan to get an existing plugin:
1 | app install:plugin java:spring |
Plugin Creation
Lets assume that our plugin is going to be called java:perf, to create the plugin project:
1 2 | cd $HOME/workspace app create:plugin . java:perf |
This will create a sub directory named java_perf, now you will want to create a proper license entry in your build.yml for example check out build.yml. You now ave the opportunity to modify the entry points in your java_perf.rb. I personally wanted to setup my install script so that:
- dynamically builds the jar when we add the plugin to a project
- modified the spring.xml to include the bean entries for my component
All of this is in before_add_plugin(event) callback. If you want to see where this is called, check out add_plugin.rb. Once my coding is complete (added my source files to java_perf/src), I created the plugin distribution:
1 | rake zip |
Install the plugin
As you noticed, I haven’t covered debugging the plugin just yet, this is because i want to first set up the plugin for installation and then work with it in my install directory. Lets install it to my local machine:
1 | app install:plugin java_perf.zip |
Add the plugin to my project
I thought that I’d create a blank java project real quick
1 2 | cd workspace app create:project . myproject java |
now we can add the spring plugin and our new java:perf plugin to our project
1 2 3 | cd myproject app add:plugin java:spring app add:plugin java:perf |
You can now directly modify the java_perf.rb file in your install directory
- windows: c:/Program Files/Appcelerator/releases/plugin/java_perf/1.0
- unix: /usr/local/Appcelerator/releases/plugin/java_perf/1.0
- mac os: /Library/Appcelerator/releases/plugin/java_perf/1.0
I suggest that you continue to modify the java_perf.rb this way to debug it and then finalize by copying back over to $HOME/workspace/java_perf
Next Steps
As a final parting you can release your new plugin so that others may be able to leverage it
1 2 | cd $HOME/workspace/java_perf app release java_perf.zip |
Popularity: 12% [?]
