samedi 30 janvier 2010

Provide a Service thank to OSGi

Hi everybody !

In this article I demonstrate to you, how to create and deploy a service thank to OSGi.

But for the moment, we just focus on OSGi acronym and explanations on the subject.

OSGi : Open Services Gateway initiative

OSGi is considered as a framework, it's a modular system for Java in order to implements a complete and dynamic component model, something that does not exist in standalone Java/VM environments, unfortunately.

OSGi can be represented as a set of stacking bricks, applications or components. These things in OSGi context as often called "bundle", the main purpose of OSGi is to management bundle life cycle which can be you Java packages, classes provided as "services". The management life cycle can be done remotely and regroup five states (installed, started, stopped, updated, uninstalled), but the real challenge for OSGi is to perform the changement status without requiring a reboot.




For this article I choose Felix the OSGi implementation of The Apache Software Foundation, but several implementations are also available like Equinox from Eclipse, Knopflerfish OSGI, OSCAR ...


http://felix.apache.org


In this article, I create a bundle that implements and provide a People Access Service. First we need to define the service interface :

This interface define a function that allow to check the person existence in the world, by providing the firstname and lastname.

Take attention to the package aruffie.osgi.tutorial.service because it will has a really importance afterward. I do this because I need to share the service interface with other bundles, it is better to separate service interface that need to be shared from code that doesn't need to be shared. This OSGi approach provides a high separation between interface and service implementation.

In order to respect this approach I create the service implementation in other package, aruffie.osgi.tutorial.implementation:


Now the Person.java for model:



Now, I need to create the bundle activator class of my service. you can find the source code in ServiceActivator.java:




The main purpose of this activator is as its name indicates, activate my people access service into the Felix OSGi Context.


To finish I need to provide the linked manifest.mf that contains the bundle meta-data for its package, deployement ... (its must be provided with the linked service into the jar archive)




I precise the activator for my bundle thank to "Bundle-Activator", and specify the shared package by using "Export-Package".
For my bundle, I need to import the org.osgi.framework bundle dependency. Why ? because I use an activator in order to activate my service in OSGi context (need org.osgi.framework.BundleActivator)


To finish I package the jar with all classes and the manifest file.
The next step is to launch Felix with this command, in my Felix environment "java -jar bin\felix.jar":


When Felix running, deploy the People Access Service packaged into "osgitutorial.jar" with the following command line "start file:[your jar path]"

But wait, "start" aggregate "install" and "start" the bundle ... (but you can use install command, and after start)

Now your People Access Service is running into the Felix OSGi Context ...


Adrien

jeudi 28 janvier 2010

OpenSUIT Maven Dependencies

In order to use OpenSUIT in your project as a presentation framework, and if your project is "mavenised"

Please use the 1.0 Version, because is now available !


To use OpenSUIT base core, just insert these three dependencies:





The last two dependencies are required, because OpenSUIT core is based on XMLMap annotations method for the XML binding to HTML components.




If you need display several chart in your application, please use OpenSUIT chart module !
Based on JFreeChart, you can set this dependency in your pom.xml:


artifactId: opensuit-chart
groupId: org.ow2.opensuit 
version: 1.0


For the Spring users, you can easily integrate Spring and OpenSUIT, thank to this dependency:


artifactId: opensuit-spring
groupId: org.ow2.opensuit 
version: 1.0


Adrien

mardi 26 janvier 2010

OpenSUIT 1.0V released !

Today Pierre and me, we completed the 1.0 version for OpenSUIT Framework !


We are really happy, and we already offer to you several tutorials available on the website, for different OpenSUIT modules.


We hope that you find OpenSuite easier to use than Struts, JSF, Echo ...

For information :

SUIT stands for "Simple UI Toolkit" Open SUIT targets the rapid development of presentation layers especially dedicated to SOA.

If you are interested to start, go ahead  http://opensuit.ow2.org/

More article on OpenSUIT Framework coming soon here !


Adrien

jeudi 21 janvier 2010

WSIT between Java & .Net

I just like to inform you in this article, the existence of the WSIT "Web Services Interoperability Technologies".

WSIT specification was thought in order to handle and ensure interoperability of web services in the enterprise technologies scope. Sun, Microsoft ... and other technology pundits work together on several subjects, such as message optimization, reliable messaging, security ...
WSIT handle differents features aggregate many topics in high level categories, for example:

- SOAP, MTOM, WS-addressing are aggreated in "Optimization" purpose.
- WS-ReliableMessaging, WS-Coordination, WS-AtomicTransactions are grouped into "Reliability" subject.
- "Bootstrapping" category containt WSDL, WS-Policy, WS-MetadataExchange topics.
- "Security" handler WS-Security Policy, WS-Security, WS-Trust and WS-SecureConversation


Thank to DotNet France, I have publish a simple course about ".NET WCF and Java Interoperability", available here:

http://www.dotnet-france.com/Documents/WCF/WCF%20et%20int%C3%A9ropabilit%C3%A9%20avec%20JAVA.pdf


Julien Dollon in his vision asked to me, a presentation about these communication technologies. The goal was not to start a controversy or a fight, but to really show the ease of communication.

In this article I use WCF (Windows Communication Foundation) in .NET 3.5 and Metro in Java . These two technologies are based on standards interoperability has been really easy to implement, but in order to adding quality of service and .NET interoperability to Metro I recommend you throw an eye on the WSIT specification.


Why ? because, even these two Web Services Stacks (WCF .NET and Metro Java) are well-built, different interoperability problems can be appear, for example the Java long, double ... are broader than long, double in .NET

samedi 16 janvier 2010

SSC "Simple Security Checking"

I've had enough, of all these articles which tell you about how this technology works, or how to install a web server on a network for example ... it's really boring with time !


For this article I will show you, although this is a rudimentary subject it can become a point of failure in critical architecture ! 

Because nowadays, developpers don't pay attention to these notions of algorithmic, I'm rubbing slat into the wound, mouhaha !


But what it is ? The validation of input parameters, simply ...


I think several developpers can do this type of error, and with that can bring down an entire system !




You don't believe it ? Let me introduce to you a critical context, for example a calculating system for trajectory embedded in a space shuttle, spaceship ...


One method used in order to calculate the trajectory is the following:







Imagine, if the "updateTarget" method, calculates the new trajectory with the "distortion" parameter with its value set to 0 ?

Imagine, the beautifil memory leak, error, exception ... that can cause ! For this context, just a disfunction of the calculating system of trajectory, and lead to the "destruction, alteration, damage, deterioration, mischief, loss, devastation ..." of the space shuttle.




In this article I trying just to remember to you, that simple little things must be taken seriously in critical environment, because the security architecture can be impacted ...


I give you, though it should be done :) 















The input parameters checking !

First Draft Architecture

For one of my project, I designed this architectural scheme. I love take my pencil and think on paper ...


In order to provide a packaged software for an association, I started thinking about the architecture of the application on paper.

This following drawing is my first idea and my view of the deployment on association's network (click on the picture in order to display it fully):




The first part of my drawing, is the Server 1 where are hosted the database, several Hibernate entities, and the core of my architecture --> the JMX server.

The JMX  server allow to expose through the network several services as Managed Beans

I will explain afterwhy this choice !


On Server 2  a web server like Tomcat, Jetty, ... is deployed. But why not a Glassfish, JBoss, Websphere ... ? Because, I needn't an heavy application server (for example in order to use EJB, JMS ...)


We can just found my web application deployed on the web server, and a linked JMX Connector that allows the web app to use the differents services, deployed on the first server.


The web server will allow to deploy the web app of the association, on the world wide web.






Now  return to our sheep ! Why did I use JMX Managed Bean instead EJBs, RMI objects, ... ?


I simply preferred publish all services on network as Managed Beans instead EJBs, because my services are wrapped with JMX layer and allow me to manage, monitor, change dynamically the behavior of my these !


Because this application can evolve quickly, it's a good point to allow change, remove, add components at the runtime.


Wrappe my services with managed beans allow to me to generate statistics on each service and notify dysfunction.


Another interesting point is that JMX can explose your MBean with RMI but also HTML thank to HTML adapter, IIOP adapter and several other with MX4J adapters.

mardi 12 janvier 2010

Package Architecture

I don't clame that my vision is the best, but I think it's a good practice.


First time, several programmers, developers ... can structure their packages, as follow:









In order to isolate the different parts of your package architecture, I propose to you the followed hierarchy:


But, why this hierarchy?

Because, I think this package hierarchy is more suitable and representative of a really good architecture.

Now the Hibernate implementation of your DAO is hidden into the impl package, besides the dao package

is now free of the hibernate dependencies.

The dao package with DAO interface now, can be extract in order to be used without knowing the explicit hibernate dependencies.


These Hibernate dependencies can cause problems in several projects, but this package hirerachy is now, more clear and more flexible.


Several huge packages can be splitted into sub packages, their contents become more consistent and more understandable.

mercredi 6 janvier 2010

How to integrate Spring & Struts2 into your web application

In order to integrate these two frameworks, you need to declare each utilization in the web.xml file.

The content of your web descriptor file should be:



The first filter declaration represent the Struts 2 filter. It's necessary in your web application, if you decide to use Struts 2 into your web application architecture:

org.apache.struts2.dispatcher.FilterDispatcher




The filter mapping of your Struts 2 filter is mapped to all requests coming into your web application, but you can provide a specific url pattern like : /GUI


In this example:

struts2 --> /*
  

All requests coming into you web application with .action extension will normally be processed as a Struts Action.




After that, you need to declare the Spring listener which handler and manage your Spring Web Application Context. The ContextLoaderListener will load the Spring applicationContext.xml file and manage each call to its context. Also, its enable the Spring object factory and the wiring interceptors



org.springframework.web.context.ContextLoaderListener