I intend this to become the beginners guide for the RTC java API’s. The reason is, I spend far too much time on the forums trying to answer beginner questions on how to get started over and over again. I intend this post to be my link to answer these questions without having to repeat everything all over.
Where to Start?
You first have to understand what API’s are available and what you can extend. If you don’t understand these basics, you can’t decide on how to proceed. It is also a good idea to understand RTC Process Customization and what you can and cannot do.
For more examples have a look at the Jazz Community. If you continue, consider also contributing there.
Setting up Your Development Environment
If you determined you are interested in one of the Java API’s, you need to set up your environment for Java API development. It is extremely important to perform the steps in that post to have an environment, that has the RTC SDK installed as well as the Plain Java Client Libraries. Do the whole workshop even if you just want to use the Plain Java Client Libraries to code up some automation. This familiarizes you with the concepts of plug-ins and give you some first glimpse on the API.
Even if you intent to develop only Plain Java Client Libraries, you should use a plug-in project to develop your code, because that allows to trick the Eclipse Plugin Development Environment (PDE) into showing you the whole source code of the RTC SDK. It requires to set up your environment as explained in Setting up Rational Team Concert for API Development. This requires to run at least the client parts of Lab 1 of the Rational Team Concert Extensions Workshop.
As a benefit this allows you to
- See the java doc, comments on interfaces, classes and on methods
- See the code of huge parts of the Plain Java Client Libraries and the RTC SDK
- Search interfaces, classes and methods even with using an asterisk if you are not sure about the names and packages
- Search for references to interfaces, classes, methods, extension points to go looking for inspiration and example code
To understand how that works read the post Understanding and Using the RTC Java Client API. Especially read the sections
- Getting Started With Developing for the Plain Java Client Libraries
- Debugging Client Code and Finding Information about the API
- Prepare Your Project to Allow Debugging
- Finding Information About the API
You should carefully read the whole post Understanding and Using the RTC Java Client API, as it explains how the basic mechanisms in the API work. This is also interesting if you intent to write server extensions.
Getting started with Eclipse Client and Server Extensions
If you are not (yet) interested in the content of this section, skip the rest of this section and go to “Where can I find Examples and Example Code?“.
The best place to start is following the Rational Team Concert Extensions Workshop. This provides you with a fully set up environment for debugging and guides you through all the important steps that are necessary to develop client and server extensions. You might also want to look at Bartosz Chrabskis post How to create Rational Team Concert – Advisor & Participant Extension (step by step) and the related video for creating a participant and the video for creating an advisor.
RTC provides a lot of ways to extend the Eclipse based clients and the server. The most important in general are
- Pre-conditions which are also referred to as Advisors, because they drive the process advisor behavior of operations
- Follow-up action which are also referred to as participants, because they participate in the process behavior of operations
- Attribute Customization which are also referred to as providers, because most of them provide values for work item attributes; please find examples here
- Components which are used to group extensions
The wiki topic Team Process Developer Guide provides a great overview about what you can do and what the rules are.
On the RTC Server side it is also possible to create asynchronous tasks, that can perform operations such as event generation and mail notification. An example with code and explanation can be found in the post Due Date Notifier – an Asynchronous Task Example.
There are additional extension points available on the client and on the server that can be used. Some examples are
- Eclipse Client UI Extension points
- RTC Web UI Extension points
There are still more, that I haven’t even looked at yet.
The most important part is to be able to develop and debug your server extensions using Jetty as explained in the Setting up Rational Team Concert for API Development. If you can’t do that, it is just a waste of time and I would consider not trying it out at all. You also always want to have a dedicated server for extensions development, deployment testing and functional testing.
The code used in advisors and participants is very similar except that the interface used is different and the result that is returned is also different.
Advisors and participants always run in the context of the user that calls the operation. This means they can only access data the user is able to access and perform operations the user is permitted to.
In advisors it is not permitted to modify the element for which the advisor is triggered. In participants this is allowed.
Participants that modify or create elements have to perform an additional save for the objects modified. Please note that this can trigger the same or another participant to be executed. This can result in a server crash, if it causes a recursive descent for a recursion that does not stop. To prevent that, it is possible to pass additional arguments in the save that the sub-sequentially called participant can use to prevent running into a recursion. See for example this post for how that can be used.
In general it is the best approach to extend the RTC Server if at all possible. The reason is that this makes deployment easier. Deployment basically has to only happen on the server and deploying on all the clients can be avoided.
If, and only if, your extension works in the Jetty based development and debug environment, you can deploy it on a real server. If you have not successfully tried your extension on Jetty as explained in the Rational Team Concert Extensions Workshop, it does not make any sense to try deploying it on a test server, let alone on a production server.
The Rational Team Concert Extensions Workshop handles deploying extensions very manual. The post A Custom Condition to Make Attributes Required or Read-Only by Role explains how this can be made more automatic in the section Deploying the Extension.
If the extension works on Jetty, the worst that can go wrong deploying it on a real server is that the dependencies in the extension include libraries that are not available on the server.
Other issues could be missing or not satisfiable dependencies, version issues, missing provision profiles or typos in the profile or corrupt files. This would show in the log file during server start up. Check the RTC Server log (i.e. server/logs/ccm.log).
Please note, a deployment error, a typo in the provision profile or missing or corrupted files in the sites folder can lead to the server crashing / not successfully starting up. The server start up can be interrupted and the server may not be reachable. See the server log for hints what might be the problem.
Client extensions are required if the data that it works with is only available on the client, or if the extension is needed on client and server anyway e.g. for Java based attribute customization provider.
Where can I find Examples and Example Code?
There are countless examples out there, here on Jazz.net, on Stackoverflow and on many other blogs and sites. But apparently this is not enough or too hard to find. So I will try to put guidance on how to get started here.
As already explained you can search for code that ships with the RTC SDK. This requires a working development environment as described above and here.
You can find examples and example code in this blog. The easiest way to do so is to search the blog. This is really easy. Type the interface, method or any other clue you search for in the search window on the top right section underneath the banner and then use the “Search” button.
Most posts have working code attached for download as well.
There is also a page with Interesting Links that I maintain and add stuff that I come across. There are many links to examples for API and other interesting sources.
We live in the times of search engines. In the past, like 25 years ago, you had to go to a public library and try to find relevant information or books that most likely were not there. Today you can use your preferred search engine and, with very few effort, find all you can ask for. It is of course always easier to ask someone else to “Google that for me”, but it is way better to skill up to do it yourself in these Darwin times.
A good approach in this case is to just come up with some keywords, interface or class name and run the search engine on it. In my experience some words what you are looking for and RTC usually is enough. I find the interesting information usually on the first two pages. If not, I try to change and refine my query. Examples for typical search paattern are
- “create work item java API RTC”
- “access work item attribute java API RTC”
- “RTC API IIteration”
If the results on page one are just too many and not promising it is possible – for Google at least – to limit the scope of the search to specific sites.
- “create work item java API RTC site:jazz.net”
This is most useful if you know that there has to be something there or recall something was there and you can’t remember where. I find this even more effective than using the search engine available on Jazz.net, because it usually shows the information I am looking for higher in the ranking.
Good sites are
If you want to get started with the RTC Java API’s, work through this blog post and the resources linked to it. I will try to extend this post with more detailed links for specific topics in the future.
As always I hope that helps users out there.