Wednesday, June 8, 2011

How to create a Apache Tuscany SCA component for Apache PhotArk



Apache PhotArk is an open source rich photo gallery application where you can do many things what a typical photo gallery app can do as well as some additional features such as it contains a Google app engine to function in cloud. Apache Tuscany is what PhotArk uses for message passing bridge between front and and back end under Service Component Architecture. This is how you do $Title.

  • Step-1
In Tuscany way first you have to put and SCA component entry to the Tuscany composite, which is in photark, named as web.composite.xml.

 













  • Step2
In Photark web app, there is a sca-contribution.xml file for each of your PhotArk module. So There you have to define the packages you use externally as well as you own package name. So suppose I dont have any dependent external packages to import my service component implementation class. Then your sca-contribution.xml file can be something similar to this.









NOTE : If you are using a brand new PhotArk module, make sure you add the dependency of it not only to the parent pom, but also to the pom inside photark-webapp as well, because in deploying it on tomcat, maven can't find your dependency if you don't add it to this pom.
  • Step 3
Now everything is ready. Make sure you use proper annotations for your service component interface and its implementation. For instance, @Scope("COMPOSITE") for the impl and @Remotable for the interface.
  • Step 4

Call your service through JSON, in PhotArk we make JSON calls through DOJO. So to use the service use the absolute binding url (in composite you define the relative path only..visit constant.js file in PhotArk and you will find the absolute path..)

i.e add PhotArk context root to your tuscany binding url.

In this example it should be /photark/FaceRecognitionService?smd . NOTE : make sure you add "smd" param as well.


I think now its done :) Enjoy Apache products.





No comments:

Post a Comment