Difference between revisions of "SCA/SCA Component/SCA Tips"
Latest revision as of 03:38, 9 November 2010
This page deals with good practice and avices to use the Eclipse SCA tools.
The following points are not mandatory but are coherent with Java naming conventions (checked with Java interfaces and implementations).
- Services should start with an upper-case letter and ends with the suffix "Service".
- References should start with a lower-case letter and ends with the suffix "Reference".
- Properties should start with a lower-case letter.
- Components should start with an upper-case letter and ends with the suffix "Component".
- Composites should start with an upper-case letter.
Bottom-up and top-down approaches
A bottom-up approach to create an SCA application consists in putting as much information as you can in the implementation (through annotations or component types) and to create a minimalist composite. This approach is interesting if you are going to reuse your code in several SCA applications. It is also interesting if you don't have SCA Tools at the moment you are working on your application. In this case, annotations may be much more convenient.
A top-down approach consists in having a complete composite and having the matching elements (implementations, interfaces, etc...) without any additional information. We can distinguish several sub-cases here:
Does the code already exists?
If you don't have too much code, you can use the drag-and-drop and the right-click > add... features with the SCA Designer to introspect the workspace. If you have a lot of code (e.g. legacy code), then you may appreciate a tool to introspect this code and propose you which elements you want to put in the composite. This tool would just create a full composite from your selection. Currectly, this tool does not exist in SCA Tools. But feel free to contribute or to make a request on the bugzilla.
How to do when starting with no code?
When you don't have any code, the easiest and fastest way to create your SCA application is to model it and then generate code.
SCA Tools comes with a feature to generate the skeleton for the implementations and the interfaces from a complete composite. Create your composite with the SCA Tools, specify all the Java properties (mainly class names) and you can generate the code skeleton. All you will have to do then is to define your operations in the interfaces and to implement them in the implementations.
Another approach which was mentionned on Apache Tuscany's mailing list relies on a UML model. This UML model is then transformed into an SCA application, generating both the composite and the code skeleton.
What about a mix between those two?
Meaning you have both existing code to reuse and code to create.
- The first step would consist to create the composite from the existing code, as described in the first sub-section of this section.
- Then, you would update your composite with the SCA Tools.
- And eventually, you would generate the code for the new composite elements, as explained in the previous sub-section. Indeed, this tool allows you to select which classes to generate, although it does not yet allow to merge generated code and code to generate.