Thursday, December 18, 2008

EclipseCON 2009 Riena - EMF - oAW and more

This time I'll not only visit the eclipseCON - one of my submissions was accepted:

I'm very happy about this. This was the second really good news last time - first was at german W-Jax where I became a member of the oAW Team.

redView (Riena - EMF - Dynamic View) is a sub-project of my model-driven OSGI Enterprise Application. redView  will be Open Source (EPL). Dynamic views from redView can be used stand-alone or in combination with openArchitectureWare (oAW).  ... I'll talk more about this next weeks 

This week was a heavy update - week: 

  • OSX 10.5.6
  • MagicDraw 16.0
  • openArchitectureWare 4.3.1RC3 und RC4
  • Riena M6
  • EasyBeans 1.1.0 Snapshots
Thanks to EasyBeans - Team (they added some properties for Declarative Services) I can continue my work to switch from ServiceTracker to Declarative Servics (DS) and there'll be new blogs also coming soon.

stay tuned...

BTW: dont wonder if my submission 391 has no author. I tried to add my assistant as co-author, got an error and now the submissions has lost author and assistant. reported a bugzilla...

Wednesday, December 10, 2008

Logging in OSGI Enterprise Applications, Part 6

This part of my blog series "Logging in OSGI Enterprise Applications" will talk about openArchitectureWare 

...and logging with SLF4J / LogBack.

The previous blog entries from this series described logging from the Runtime of an OSGI Enterprise Application. The whole Client / Server Project is model-driven based on Eclipse Modeling Project: EMF, UML2 and as engine the generator framework openArchitectureWare. 

The MDSD - aspects of the application will be part of another blog series.

Now we want to take a look at logging with SLF4J / LogBack while working with openArchitectureWare.

openArchitectureWare (oAW) in Target Platforms

If you want to use oAW in a Target Platform with SLF4J / LogBack as Logging Framework together with bridges to Commons Logging and Log4J, you'll notice some problems: Many of the oAW bundles are using Require - Bundles instead of Import - Packages as dependency to logging bundles.

I opened a Bugzilla, but it seems its too late for 4.3.1.

If you need it now, thanks to PDE its easy: Import Bundles in your Workspace, change Dependencies to Import Package, then export the Bundle als Plug-In again.

openArchitectureWare (oAW) Workflows

There's an own Launcher for oAW Workflows (Run Configurations | oAW Workflow) - we have to change the Classpath:

Click on User Entries and then Add Projects...

...choose the Logging - Projekts from workspace

...and save changes with Apply.

You have to put the logback.xml (or logback-test.xml) directly under src/ into the project which starts the oAWworkflow. In this xml file we configure the logging from the workflow - doesn't matter if the logoutput was originally sent to Log4J, Commons-Logging or OSGI LogServices.

To control please start a Workflow with debug="true" in your logback.xml.

If all is configured right, then the Console will list at first the logback - configuration and then all log - output from the Workflow sent to our configured Appender (Console, Socket, usw)

Blog Series "Logging in OSGI Enterprise Applications":

Part 1: An overview
Part 6: Logging and openArchitectureWare Workflows
Part 7: ... follows (Stay tuned...)

Perhaps some of my older blogs about Logging und OSGI are also interesting:

Comparing Files And Folders After Codegeneration

Eclipse has great possibilities to compare files and folders with each other or history.
But I'm also using external tools: 

Some time ago I blogged how to use NameChanger (Freeware) under OSX to rename files where the bundle names aren't named like eclipse bundles (plug-ins) using "name_version".

Also for creating of target platform - locations I'm using a tool to get unique sets of bundles. My blog „Avoid Duplicate Bundles“ desribes the use of FileMerge (under OSX part of XCode Tools).

Now I was looking for an intelligent tool to see if generated code is identical to an older version. This generated code is not checked into a sourcecode repository, because its always regenerated. Before starting the generation those directories werde cleared, so there's also no local history in Eclipse.

While testing 4.3.1RC2 of openArchitectureWare I was interestd to see if the generated code is identical to version 4.3.0.

Its not so easy because there are some allowed differences like:

* generation started at: 9. Dezember 2008 08:04:13 CET

Those generation timestamps should be "identical" to lines with another timestamp. FileMerge from OSX was no help, because these files are reported as different.

Next try: Compare Folders compares the size of files and also reports added or missing files. If the generation timestamp hase same length, then the files are identical otherwise not: 

... I also dont know if the other content is identical - I need the compare more detailed. I found DeltaWalker where I can do waht I want. But the best of all is:

DeltaWalker is an Eclipse RCP Application :-)

...and available for OSX, Windows, Linux. Now it was easy to see if the generated code is the same as before:

Create a File - Filter, where lines of different generation timestamps are identical:

Create a Folder- Filter ignoring OSX-specific .DS_Store Files:

Then hitting Compare::

All the same :-)

congratulations openArchitectureWare 

- in all my projects no differences found between 4.3.0 and 4.3.1RC2 after re - generation.

Without the File - Filter DeltaWalker lists the differences:

...think that DeltaWalker will be a good helper and a great example for RCP Apps.

Thursday, December 4, 2008

Properties in OSGI Declarative Services and ServiceTracker

As proposed in my last blog "Dependencies and Services in OSGI Enterprise Applications" it seems that a new blog series was started ;-)

ServiceTracker vs Declarative Services

There was only a short statement last time - now some tips follow how to use properties in ServiceTracker vs Declarative Services (DS).

A ServiceTracker from my OSGI Server project was opened with this Filter: 

final String filterPool = "("
+ "="
+ JDBCPoolComponent.class.getName()

So the ServiceTracker will get Services of Type JDBCPoolComponent - we are interested into the attribut JndiName:

private void processDataSources(JDBCPoolComponent service) {
  if (service.getJndiName().equals("foo_entity_data_source_hsql")) {
  // do something

How could this be done using Declarative Services (equinox.ds): 

We're defining a reference to get exactly one specific service of type JDBCPoolComponent to know that a DataSource is ready. 

A first idea to declare this reference could be:

Launching the OSGI application, but the reference wasn't resolved. 

How could we find the reason ? At first we should test if the Filter is correct and there's no typo in the Interface.

Tip: Use of Equinox OSGI Console to test the Filter !

Try this command:

services (&(objectclass=org.ow2.easybeans.component.jdbcpool.JDBCPoolComponent)

But no Service was found: No registered Services.

As next we try only to look for Services of Interface JDBCPoolComponent. Now our command looks like: 

services (objectclass=org.ow2.easybeans.component.jdbcpool.JDBCPoolComponent)

Some Services were listet - we also see the one we're looking for:

{org.ow2.easybeans.component.jdbcpool.JDBCPoolComponent}={classname=org.ow2.easybeans.component.jdbcpo......, xmlconfig=
  Registered by bundle: .../easybeans-component-jdbcpool_1.1.0-M3-SNAPSHOT.jar/

Analyzing the printed text we found: jndiName="foo_entity_data_source_hsql"
But there's a small difference: its the Property xmlconfig containing the informations. Thats the solution:

services (&(objectclass=org.ow2.easybeans.component.jdbcpool.JDBCPoolComponent)

The Service we want to reference will be found and we know how to declare the reference inside the Service Component:

Why can the ServiceTracker use  getJndiName(), but the target Filter can't ?
getJndiName() is a Methode of JDBCPoolComponent, but JndiName isn't registered as Service Property ! 

Target Filter cannot access methods of implementation - only Service Properties. 

You maybe run into this using 3rdParty bundles where you have to live with their services as-is. If you're in luck its Open Source, you write a Bugzilla or JIRA and get it fixed in hours :-)

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 ;-)

blog in german

Tuesday, December 2, 2008

Dependencies and Services in OSGI Enterprise Applications

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

But now lets start and report some of my experiences of:

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.

PDE Tooling

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:

... and also an entry in the MANIFEST.MF as reference to this file:

Good news: Dopwnload and test Eclipse 3.5M3: PDE Tooling supports now Declarative Services :-)

Managing Dependencies

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:

or the easy to understand visuell way:

(here's the Updatesite from Graph Visualization Plug-In)

But bundle - dependencies are only one part - we're missing the service - dependencies

If you look at the DataSource example from above:

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.

If our declarative Service Component would include bind / unbind methods, then we would have Import-Package dependencies.

Till now I couldn't find a tool displaying service - dependencies in a visual graph.

And if you think more about service - dependencies: there are some different strategies to use services and you can even mix them in one application:

As an Software Architekt I like to get an overview of used Bundles, Services and dependencies. Because there's no tool to show the existing dependencies I'll come the way from another direction: my server project is model-driven, so I can model service - dependencies and -strategies :-)

using openArchitectureWare I'll then generate service - components in XML - files or Javacode for ServiceTracker or Riena - Injection ...

This will be part of another blog ;-)

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 ;-)

blog in german