Archive for November, 2009

Eclipse + Maven + OSGI + Spring DM Server – Settings and tips.

November 30, 2009

Recently I have watched SptringSource University video tutorial that describes how to work with OSGI using Spring Framework. And, taking into consideration that being familiar with IntelliJ IDEA I had a set of problems related to how to set up the Eclipse environment to be able to use it to implement this tutorial as well as other code that I’m going to make soon using the set of technologies like Java + Spring + SpringSource DM + OSGI(Spring DM) + Maven. So this short article might be interested for people who want to fulfil similar issue.

I could not find that video I mentioned above any more. But i’ve got some related to this video in you-tube.

Here we are considering settings which related to two projects where one project depends on other one and there is main project that is responsible for these two projects and holds them both. Those two projects have maven package = jar, but main project have package type = pom.

Step 1 – Creating two maven projects (let say: “client”, “server” projects)

Use Eclipse menu to so it – New->Project->Maven project->Creating simple project->Typing name of the project → Finish

Step 2 – Adding OSGI nature for the projects

We assume that we use SpringSource Suite Tool (based on Eclipse), so:
Using context menu clicking on particular project using right mouse button, selecting “Spring Tools” menu, select the “Enable OSGI bundle project nature”. Doing this for our two projects (but not for main one). When you added OSGI project nature it will add Spring nature (if it not so, you may add it by your own – in any case suing Spring Tools context menu you may check or add this nature).

Step 3 – Create some classes. Internal package

Create some classes in our projects (but not in main one). The best practices if to add an implementation of the classes to the sub-packages called “internal” but interfaces which this classes are implemented to put to above.
So, the hierarchy should be like this:

some interfaces for osgi services
some classes that implement osgi services

Step 4 – Adding META-INF and ‘spring’ folder

For every projects (but not for main one) select src/main/java node and add there new folder named as ‘META-INF’, then create there ‘spring‘ folder (as sub-folder of META-INF). Here we are going to add spring context files – it ‘s best practices to put them here.

Step 5 – Add to ‘spring’ folder two xml files

Select ‘spring’ directory, then select ‘New->Spring Bean Configuration File

  1. file name: module-context.xml
    xsd namespace declaration: beans
  2. file name: osgi-context.xml
    xsd namespace declaration: beans, osgi

It is also the best practices to divide pure spring beans from osgi ones. Names of the files it are the best practices also.

Step 6 – Make Spring config visible to each other and make them named

After this, when spring context files were created, we should make some extra settings related to them in our IDE. For this purpose clicking to the project’s top node, selecting the properties of a project. Select Spring->Spring support item there. Then go to Config Files tab and select check-box to enabled “Enable support of <import />‘ element…”. Then click to ‘Set config tab‘, pressing to ‘New‘ button to select our files grouping it and naming as somehow.
In other case if we didn’t do it then we would not refer from one file to another (suing context tips, context drop-downs, auto-filling etc.). So if we wish to be able us it – we must let Eclipse know about this.
So we should prepare two groups for our projects:
group one: module-context.xml, osgi-context.xml for/in “cleint module”
group two: module-context.xml, osgi-context.xml for/in “server module”


Selecting ‘META-INF’ folder (or select the top node of the current project where we are working on) that we have created recently and using context menu “Spring Tools->Run generation of MANIFEST.MF file“. After this it will be created in the /src/main/resource directory because we it havs to do with maven-nature project and maven supposes that MANIFEST.MF it is a resource.

Step 8 – Spring dependencies

Let’s say that we want to add Client class that use Spring framework like this:

public class TestClient {

private Server theService;

public TestClient(Server server) {
theService = server;

public void init() {
String name = theService.getServerName();
System.out.println(“The Server name: ” + name);

we must add dependencies to the pom.xml for “client” projects. To do this we may add use drop-down context menu that appears when we are clicking on the red marks near spring annotations. Selecting ‘find a dependencies’ and adding new spring dependency. It may look like this:


Here we use “provided” scope because we assume that we are going to use SpringSource DM server that already has (provides) spring bundles in itself. It would be nice (of course) if you use the same version of Spring framework that SpringSources DM sever uses.

After this you might find that it still marked with red, using the tip you set your project “to be in compliance with java5” – just do it.

Step 9 – Be sure you added maven-dependencies that says that a client-side depends on server one

Step 10 – Maven settings

If one module doesn’t see another module (or it can see but it shouldn’t see, because there are no dependencies that make a project visible for others), or if you want to be sure that Eclipse works well with your project using only maven plugin, i.e. without using some extra settings (like adding class paths from one to other like we are using when work with ant-based projects) that lead to be far from the production version of an application (that why it’s bad having not maven setting related to visibilities and scopes). To resolve this problem or be sure you are on the right way you must select context menu of particular maven project and select the menu Maven->Update project configuration clicking on it. This action will lead to removing all unnecessary configurations that might be took place before you doing this action and will add maven oriented configuration (only) to your projects. Yo may do it periodically with every project you have (or do it if you suspect that something might be wrong with your project’s settings).

11. Deployment

In order to deploy the application, or bundle (in our calse “client“, “server” bundles) it takes you only to drop the application to your application server that is located somewhere in our ide’s tab (depending on how you have configured your IDE). It’s very easy in fact. Also you may configure console output that comes from the server to be able to see a result of the deployment.

12. OSGI console

In order to use the OSGI console – to be able to call OSGI commands like ss, bundle, diag etc. you may use the telnet typing in a console window like this: telnet localhost 2401. I.e. when we start SpringSource DM server from our IDE it opens 2401 port that telnet can use to show OSGI console.

13. Server logs

In order to be able to look at the logs of SpringSource DM server you should go to the path <ourserver_unstall_path>/serviceability/trace and to find there some folders which named like your bundles. Inside every of this folder you can find a log file named as trance.log, there you can find detail information about activities of particular bundle.


killer app

November 29, 2009

killer app (app=application) – жаргон программистов: компьютерная программа, которая очень полезная, нужная, которую нельзя заменить чем-либо другим.

only game town

November 26, 2009

the only game in town –  единственный вариант

Using transparent windows in Ubuntu

November 25, 2009

If you are using Ubuntu (if you aren’t – you must :)) and if you often work with lots of windows simultaneously (like I do), then, must be, you already faced with that general problem when one window is over the another one, but you need an information that is appearing on both of them at one moment. So, that’s of course not very comfortable to switch between those two windows every time. If you using Ubuntu then you will able to find convenient way to fix this problem and it will be elegant way to fix it btw. So, the steps to fix this problem are:

  1. In command line call the command: sudo apt-get install compizconfig-settings-manager
  2. After this you can see new item in “System->Preferences our CompizConfig Settings Manager” item – clicking on it
  3. Find there item called “Opacity Brightness and Saturation” and make it enabled clicking on the check-box there

That’s it. Now, open any window you want, set it focused and press the button ALT and keeping it pressed, scroll the mouse roller up and down. You will find that it works! The current windows beginning to be transparent while you are scrolling.

And now when you want to see what is under the current window you are using now, you may use this action. So you may see both window’s content simultaneously. For example you may read some manual (that is under) and typing some commands into an editor (that is above the manual) or whatever you are using at this moment. There is a sample screen-shot below how it may look like.

pimp a ride

November 24, 2009

pimp a ride – затюнить тачку (настроить, усовершенствовать автомобиль)

drive the point home

November 23, 2009

to drive the point/message home – объяснять (доказывать) свою точку зрения приводя существенные доводы

I’m explaining to my daughter the dangers of drinking and driving and to really drive the point home, I showed her pictures of accident victims. It was gruesome, but I think she gets it now.

The speaker really drove his message home, repeating his main point several times.

Чтобы запомнить: доставить точку зрения на свое место (в дом) т.е. так чтобы она была востребована (принята)

call the shots

November 23, 2009

to call the shots If you call the shots, you are in charge and tell people what to do.

news anchor

November 23, 2009

news anchor – диктор новостей

Roo and IDE

November 23, 2009

Recently I’ve added the issue about OSGI and IDE. There is one more about new Spring technology called Spring Roo and IDEs. This technology helps to create Java enterprise level applications very quickly (it supposed). It has rich console ui that provides some useful hints that makes it to be rich… where a developer can type special commands which lead to the creation of an application structure, using maven (optionally) structure, creating configs, adding other popular frameworks and so on. It seems like like Ruby On Rails only for Java people (other comparisons are possible as well – for example it similar to PAX Construct, but it can do more), it even seems more flexible as for me. Now this project existent only as beta version, but it works in spite of this. So a programmer can use command line to generate some code as well as write a code by hand. Also Roo able to scan file system where a project lives to react somehow to an user actions.

There is only one problem, it requires IDE support as well. So, for now only one IDE can provide this – Spring Source Suite Tool (based on Eclipse).  I have investigated this question and found that IntelliJ idea will able to provide this support only beginning from v 9.x (bot not even with 9.0 that now is beta).

So, as for me I will plan to play with it using Eclipse, but actually I prefer IDEA (actually I know that many guys from SpringSource like IDEA also)… I think for many people who want to try Roo it might be the problem if they are not familiar with Eclipse.

Piece of thougts about writing skills

November 22, 2009

Today I got very simple idea about how to train yourself to get better writing skills (I mean in term of English learning). So when you write something using computer or laptop, you of course use spell checking mechanism (as I do) to check yourself immediately if something you are typing is wrong, ie. incorrect. You, of course, click to right mouse button and select right variant of particular word you are typing. That’s ok, that means you can use computer power well 🙂 , but this way, however, blocks your mind to write well. So this is not that variant when laziness can help you. When you need to write something on paper you may find that you are making mistakes in many words and you have not any spell checker near you. That is bad, isn’t?

So the idea is: just when you can see that you are wrong, seeing red marking bottom of your phrase of word, just try to type it again, if you are wrong again then just see a suggesting that write-checker proposes and try to write this word again, you you are still wrong repeat the procedure again. 🙂 When you eventually typed your word right try to remember this variant. 🙂 I believe it should help. So, from this minute I will follow these rules.

%d bloggers like this: