A busy week has started again:
- Refactoring my OSGI Enterprise Server: Using Declarative Services instead of ServiceTracker where possible. (I'll report soon in my other blog series)
- openArchitectureWare 4.3.1RC1 is published and has to be tested against my many modeling templates
- Some more tests using Eclipse 3.5M3: PDE - supporting Declarative Services and Cycles in 3rd Party Bundles
- Development of a new soon-coming project: redView (Riena - EMF - Dynamic Views) and integration of these dynamic view models into my modeling workflow
Dependencies and Services in OSGI Enterprise Applications
If you follow my blog series „HowTo Build an OSGI Enterprise Server“, you probably have read in the last entry that its difficult to use a ServiceTracker with much logic and dependencies inside. Its not so hard to make it run, but hard to manage all the dynamic of an OSGI application. So the next task is to use Declarative Services instead as possible to solve the requirements. While working in this area I noticed some points I want to blog about.
This is really the first what happens: you'll miss the comfortable PDE tooling.You have to describe the service components in a XML file without support:
Under OSGI the management of dependencies is very important and fundamental to get a well structured application achitecture.
We already know dependencies using Import-Package or Require-Bundle. We can also look at these dependencies from inside eclipse.
The classic way as Plug-In - Dependencies:
There are no more bundle dependencies ? Indirectly we have dependencies from Declarative Services: The DataSourceService will only be provided if exactly one service of Type Ejb3ServerComponentsService and one service of type JDBCPoolComponent is available. These two referenced services are declared in two other bundles.
- Declarative Services
debug - trace - log Declarative Services
While refactoring my project of course from time to time I reached a point asking why a specific declarative service reference is not resolved from eqinox.ds ;-)
With the help from Equinox - Newsgroup and some searches I learned some important System Properties I didn't found in the Eclipse Help or Equinox Wiki:
- equinox.ds.debug=true switch debugmode on
- equinox.ds.print=true prints the trace-logs on the console. I dont need it because I catch the OSGI LogServices and log them by myself.(s.a. blog series Logging)
- equinox.ds.perf=true logs the execution times in ms
- equinox.scr.waitTimeOnBlock=10000 how many ms should equinox.ds wait until a service component is ready. Was very helpful because 10000 ms is default and some 3rdParty components need more then 50000 ms in DEBUG log - mode.
ServiceTracker vs Declarative Services
Can a Service Tracker completely be replaced by Declarative Services ? No - this isn't always possible. One example: Using a ServiceTracker you can get access to all methods of a service - using Declarative Services instead you can only use service properties in target - filters.
...enough for the first blog about Declarative Services - there are so many things to talk about in this context, so I can imagine to start a blog series about this - but at first I have to finish the already started blog series ;-)
You can take a look at my blog series about OSGI Enterprise Applications - the index is in the column right beside this blog.
There are also some submissions for EclipseCon 2009 - if you want to hear more about: comments are welcome ;-)