Showing posts with label rcp. Show all posts
Showing posts with label rcp. Show all posts

Saturday, December 6, 2008

GGBLOG – Single Source OSGi Enterprise Architecture Pattern

The following article documents an architectural solution to a problem which I’ve encountered in many enterprise computing environments.

Problem:

There are a wide variety of deployment artifacts which cannot be reused between different deployment environments. Copies of the artifacts are taken and modifications are made to enable compatibility for each different execution environments. Component dependencies on different deployment environments cause the code base to diverge over time and become specific to a particular execution environment. This causes the enterprise code base to grow exponentially for only a linear increase in functionality.

Solution and Consequence:

Utilise OSGi as the execution back plane for service, web and desktop applications. This solution delivers a unified approach to the creation, deployment and management of enterprise bundles. The consequence is that a linear relationship is formed between adding enterprise functionality and the size of the code base that enables it.

Structure:

The diagram below shows the architectural structure of this pattern.

Example Strategy and Code:

Example code is available for download at:

https://sourceforge.net/project/showfiles.php?group_id=228168&package_id=301845

Download OSGiEAPattern.zip

The example strategy and code makes use of:

1) Equinox as the OSGi execution environment,

2) Rich Ajax Platform as the rich web application

3) Rich Client Platform as the rich desktop application,

4) Apache CXF as the Web Service consumer

5) JAX-WS as the service layer

Installing the example code:

Pre requisites:

1) Install eclipse 3.4 (http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/ganymede/SR1/eclipse-java-ganymede-SR1-win32.zip)

2) Install the Rich Client Platform (http://www.eclipse.org/rap/gettingstarted.php)

Running the Rich Desktop Application

Start eclipse and new workspace.

Click window -> prefererences -> Plug in development -> target platform -> tick group plug-ins by location, Select or ensure that the target platform location is the standard directory and not pointing to the rich ajax platform plugins.

Click File -> import -> Existing projects into workspace:

Click next -> select archive file -> browse and select the OSGiEAPattern.zip which you can download from https://sourceforge.net/project/showfiles.php?group_id=228168&package_id=301845

Deselect galang.research.rap.hello and click finish

Select Run configurations -> select OSGi -> select new –> deselect workspace and target platform -> tick galang.research.esb -> add required bundles, you should now have 13 bundles selected

Click Run then double click plugin.xml within galang.research.rcp.hello -> click overview

click Launch eclipse application and type in your name and click “Call web service”

Running the Rich Web Application

Ensure that you have installed the Rich Ajax Platform.

http://www.eclipse.org/rap/gettingstarted.php

Start eclipse and a new workspace.

Click window -> prefererences -> Plug in development -> target platform -> tick group plug-ins by location, Select or ensure that the target platform location is the pointing to the rich ajax platform plugins which is located at [ECLIPSE_HOME]/ configuration/org.eclipse.rap.target-1.1.1/eclipse

Click File -> import -> Existing projects into workspace:

Click next -> select archive file -> browse and select the workspaces.zip which you can downloaded from

https://sourceforge.net/project/showfiles.php?group_id=228168&package_id=301845

Download OSGiEAPattern.zip

Deselect galang.research.rcp.hello and click finish

Right click galang.research.rap.hello.launch

type in your name click Call web service

If you have any questions or want to work with me to implement a strategy for this pattern based on your java technology stack feel free to drop me a line (glenn.galang@gmail.com).


Related Articles:

OSGi

http://ggalangblog.blogspot.com/2008/11/ggblog-light-weight-reporting-server-on.html

RAP

http://ggalangblog.blogspot.com/2008/11/ggblog-chat-on-rap.html

RCP

http://ggalangblog.blogspot.com/2008/11/ggblog-dynamic-jface-xml-tableviewer.html

Thursday, November 20, 2008

GGBLOG - Format the Nebula

The nebula project has a cool set of widgets for SWT which can be readily used in a RCP application.

I was playing around with nebula CalendarCombo and wanted to give it my own date format. As usual I started to read the source code and found that all you need to do is to define your own settings class, override getDateFormat and give it to the CalendarCombo constructor

eg:

new CalendarCombo(parent, SWT.NONE, new Settings(), null).

Settings class example below.

public class Settings extends DefaultSettings {

public Locale getLocale() {

return Locale.ENGLISH;

}

public String getDateFormat() {

return "dd/MM/yyyy";

}

}

Friday, November 14, 2008

GGBLOG - Dynamic jface XML TableViewer Tutorial

The following tutorial will show you how to build a dynamic jface TableViewer driven from an xml file. The beauty of this solution is that your data model is decoupled from view logic so when the xml data changes you don’t need to change the concrete code.


It’s a pretty simple tutorial which should take around 5 – 10 minutes to complete.

Step 1. Create a new project in eclipse 3.4

Open Eclipse -> Click File -> new Plug-in project -> Next

To keep the examples simple type galang.research in the project name and click next. You can type any name you want though you’ll need to factor this into all the code samples I will provide.

Select Yes in the Rich Client Application section, click next.

Select RCP application with a view, click next.

Select Add Branding.

Click finish, then Yes.

Unzip the file located at the URL below and save the test.xml within the zip file as /temp/test.xml to your local pc.

https://sourceforge.net/project/showfiles.php?group_id=228168&package_id=299144&release_id=640558

Right click project and configure build path, link source, then click browse and select the src location to where you have unzipped the file above.

Enter srcExt fo folder name

Your package explorer should look like this.

Modfy View.java in the galang.research package with the following code.

/**

* This is a callback that will allow us to create the viewer and initialize

* it.

*/

public void createPartControl(Composite parent) {

viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL

| SWT.V_SCROLL);


viewer.setContentProvider(new RowContentProvider());

RowLabelProvider labelProvider = new RowLabelProvider();

labelProvider.createColumns(viewer);

viewer.setLabelProvider(labelProvider);

viewer.setInput(getViewSite());

}

And add the following imports to View.java

import galang.research.jface.RowContentProvider;

import galang.research.jface.RowLabelProvider;

Double click plugin-xml and click the Lanch eclipse application.

Congratulations, you’ve just completed this tutorial. Have a play around with the /test/temp.xml and see how it dynamically impacts the RCP application after restarting it.

Monday, November 3, 2008

GGBLOG - Border Dispute

I've been playing around with Eclipse RCP lately and have found the eclipse forms a great way to prevent your application looking like ye olde VB app.

If you ever start using eclipse forms and find your text boxes don't have borders see if you have this line of code at the bottom of your eclipse form code.

toolkit.paintBordersFor(form.getBody());

If you don't have this your text boxes will apear invisible against the default white background colour.