Thursday, 28 February 2008

Transforming Pojo / Web / Enterprise Services into Semantic Services / Agents using jSemanticService

Let's suppose that you have an existing service (pojo in this case) in a Spring context, (or that you need to write a new service) that needs to use semantics.

How would you do that? Well, in just three steps:

First Step

Writing a SemanticServiceFactory bean (and it's collaborators if needed) in the Spring Context file.

Second Step.

Either inject a reference to the SemanticServiceFactory directly in the service or extend the SemanticServiceSupport abstract class.

public class EvenService {

private SemanticSessionFactory semanticSessionFactory = null;

public Collection check(Collection numbers) {
SemanticSession session = semanticSessionFactory.getInstance();

Collection results = session.execute(numbers);
session.dispose();
session = null;
return results;
}


public void semanticSessionFactory(SemanticSessionFactory semanticSessionFactory){
this.semanticSessionFactory = semanticSessionFactory:
}

}


Now a method that uses the new added semantics functionality can be written. For that matter there is a method in the base class: getInstance(). This method returns a Semantic Session instance that is bound to the current thread. If we dispose the session then we'll get a new one. If not, the same session will be reused.

Third Step

Inject the Semantic Session Factory in the service bean.

And that's all, now the Semantic Service is ready to roll!.

Read the complete article in:

http://code.google.com/p/jservicerules/wiki/TransformServicesIntoSemantics

Sunday, 24 February 2008

About the jServiceRules alpha working release.

Well, after some months of development (well, not really that much but as I do it in my spare time, clocks that long) I've finally been able to release an alpha working version. 
In fact, it´s a stripped down version compared what I had in mind, but it's more focused (service oriented) and it can be used as a base for future developments.

Even though it's functional and I've tested it in different enviroments (windows, linux, mac os) using unit and stress testing, still some bugs could appear. Also I'm still improving it, so minor changes could be found in the next version. But that's the reason it's an alpha release :) .

About the release.

This release includes the dist binaries, dependencies (if you choose so), API docs, and two examples. 

It does not include the support package therefore there is no Spring (and the rest of the bunch)  integration yet, so the only option to use and configure the framework is through code (see examples and further posts). I'll release it at the end of this week or early next.


About the examples.

The even numbers example is simple, just a service that returns if a number is even or not. Two  simpe rules are produced to do that. The objective of this example is to show how to use the basic features.

The Energy example is a more complex one producing  the energy invoice of a customer, giving his personal data and energy readings. In this case, a number of rules are produced to generate the Tariffs available.