Presentia: Sarbarian’s incubator

May 26, 2010 Leave a comment

Hi all,

I would like to introduce Presentia. Presentia ( is a Brazilian Consulting and Services company focused on IT. Presentia is our business incubator and through them we’ll be able to start developing software as a service (SAAS) and finally release some interesting software and components. Thanks Presentia for join us!


Olá a todos,

Eu gostaria de apresentar a Presentia. Presentia ( é uma empresa Brasileira de consultoria e serviços em TI e a partir deles a Sarbarian poderá começar a desenvolver software como um serviço junto aos clientes da Presentia.  A Presentia estará atuando como uma incubadora para a Sarbarian e juntas oferecerão mais valor aos clientes de serviços.

Obrigado Presentia.

Um abraço,


Categories: About me, Java, JavaScript

RESTEasy and OSGi: Perfect match

March 7, 2010 1 comment

I used to develop Eclipse plugins which have been implemented since version 3.0 as OSGi bundles. Also, it is possible to run OSGi bundles inside a web container allowing these bundles to provide services and resources to a web application providing an outstanding modular platform.

As I’m a big fan of jBoss and of jBoss RESTEasy (JAX-RS implementation) I started looking for a solution to integrate these frameworks and build a web application based on REST services and bundles.

How things get together

First of all, you need to run an OSGi framework inside a web container. Today there are many possibilities however, I choose to use the Eclipse Equinox bridge servlet. You can find more about this implementation here.

Second, you need to convert the jBoss RESTEasy libraries and dependencies into OSGi bundles. You can easy create these bundles by creating Eclipse plugins from existent jar archives (Eclipse: File -> new -> Other, Plug-in form existent JAR archives) and follow the wizard to create a bundle adding the RESTEasy jar files.

Third, we need to use my plugin to start the RESTEasy framework inside the web container as an OSGi service.

And them, you start creating your JAX-RS resources as bundles.


Create a new Eclipse Plug-in project (Tip: In the wizard select an OSGi framework as Standard). You can download an example plugin here.

Sample Activator class

package sample1;

import org.jboss.resteasy.plugins.server.osgi.IResteasyService;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.util.tracker.ServiceTracker;

public class Activator implements BundleActivator {

 private ServiceTracker serviceTracker;
 private IResteasyService service;

 public void start(BundleContext context) throws Exception {

    serviceTracker = new ServiceTracker(context, IResteasyService.SERVICE_NAME, null);;

    service = (IResteasyService) serviceTracker.getService();

    if(service != null) {
       System.out.println("Registering singleton");
       service.addSingletonResource(new SampleResource());
       System.out.println(SampleResource.class.getName() + " registered");

 public void stop(BundleContext context) throws Exception {

    System.out.println("Removing singleton");

    serviceTracker = null;

Sample JAX-RS Resource class

package sample1;


public class SampleResource2 {

 public String sayHello() throws WebApplicationException {
    return "Hello from OSGi";

If you start this bundle your will be able to access the url http://localhost:8080/osgi/rest/sample2/hello, and if you stop this bundle the path /sample2/hello will be no longer available for client requests. In this implementation the path /osgi is the application context and /rest is the RESTEasy mapping prefix from the web.xml file.

Download here a complete WAR file to deploy this solution and test yourself the power of RESTEasy and OSGi together.

Download here the experimental code develop to connect the RESTEasy and OSGi.

Categories: Java Tags: , , , , ,

JavaScript Dependency Injection

February 15, 2010 Leave a comment

Some time ago I had this idea: – How to create a JavaScript dependency injection container in Java? The beginning of this idea can be read here.

This idea is redundant if you think that now a days we have lots of JavaScript frameworks or even GWT which helps us to write JavaScript applications in Java. However, this is not I want. I want something complete different, something that help me to have the best of two worlds: Java and JavaScript.

How it works is pretty simple: Inject resources (variables, code, objects etc) into the JavaScript code before sending to the client (browser in this case). The draft version of this application allow us to put i18n in action into JavaScript using Apache Velocity as engine.

You can check the development at Google’s code website here.

I’ll update this blog with examples as soon as the development is ready for real things.


Categories: Java, JavaScript Tags: , , , ,

Moqueca de peixe

February 15, 2010 Leave a comment

Moqueca de peixe

I’m Brazilian and I live in São Paulo state. If you are from Brazil or went here before probably, you know Brazil’s traditional dish called Moqeuca de peixe.

One of my favorite hobbies is cooking (I have few) and the picture of this post is from my own recipe of Moqueca de peixe.



  • 1 Kg de Abadejo fresco;
  • 1 Pimentão verde e 1 Pimentão amarelo;
  • Cebola e alho batidos no liquidificador, a gosto (eu prefiro pouco);
  • 500 ml de Vinho branco seco;
  • Sal e tempero a gosto (aqui no Brasil eu uso um tempero pronto chamado Fondor);
  • 3 Kg de tomate italiano;
  • Salsinha e coentro a gosto.

Modo de preparo

Tempere o peixe com o vinho, sal, cebola e o Fondor, deixando na geladeira por 24 horas. Corte o peixe em postas e separe os pedaços menores para o molho.

Com os tomates faça um molho de tomate natural e cozinhe os pedaços pequenos de peixe por cerca de 30 minutos. Bata tudo no liquidificador em seguida para fazer o pirão.

Em uma panela de barro, coloque em camadas os pimentões cortados em tiras, as postas de peixe e o molho de tomate, tempere com a salsinha e o coentro deixando no fogo baixo por cerca de 30 minutos e em seguida, com o fogo desligado por mais 30 minutos.

Diferentemente de outras receitas de Moqueca, essa não será preparada com camarões e leite de coco. Acredite em mim, é muito melhor sem.



  • 1 kg of fresh Abadejo;
  • 1 green pepper and 1 yellow pepper;
  • Onion and garlic smoothies in the blender, at taste (I prefer little);
  • 500 ml dry white Wine;
  • Salt and seasoning at taste (here in Brazil I use a spice called Fondor);
  • 3 Kg Italian Tomato;
  • Parsley and cilantro at taste.

How to prepare

Season the fish with the wine, salt, onion and Fondor, leaving in the refrigerator for 24 hours. Cut the fish into slices, and separate the smaller pieces to the tomato’s sauce.

With the tomatoes make a natural tomato sauce and cook the small pieces of fish for about 30 minutes. Use a blender to make the fish sauce called Pirão (tomate sauce and fish).

In a clay pot (panela de barro), place the peppers in layers cut into strips, put the fish and tomato sauce, sprinkle with parsley and cilantro leaving at low heat for about 30 minutes and then to fire off, waiting for an additional 30 minutes to start eating.

Unlike other Moqueca recipes, this will not be prepared with shrimp and coconut milk. Believe me, it’s much better without these ingredients.

Have a great dish!


Categories: Cuisine Tags:

Changing jBoss DefaultDS

February 15, 2010 Leave a comment

jBoss Application Server 5.x comes shipped with HQSQL as default database backend  called DefaultDS. However, sometimes using HSQL isn’t a good approach when you are deploying the application server on production. The following steps will guide you to change DefaultDS to use another database backend such as PostgreSQL 8.x.

1. Create a PostgreSQL database as usual

This procedure is out-of-scope of this post.

2. Configure login-config.xml

Add the following lines to your running jBoss login-config.xml

<module-option name="principal">postgres-user</module-option>
<module-option name="userName">postgres-user</module-option>
<module-option name="password">postgres-password</module-option>
<module-option name="managedConnectionFactoryName">

3. Configure JMS

  • Copy postgresql-persistence-service.xml from the jboss_instalation/docs/examples/jms/ to jboss_instalation/server/all/deploy/messaging
  • Remove or rename hsqldb-persistence-service.xml from jboss_instalation/server/all/deploy/messaging

4. Create a new DefaultDS file

  • Create a new file called postgresql-ds.xml on the deploy folder.

(Example file. You can change it based on your needs)

<?xml version="1.0" encoding="UTF-8"?>
  • Remove or rename the hsqldb-ds.xml file on deploy folder.

5. Start jBoss and enjoy

Categories: Java


February 14, 2010 Leave a comment


This is my very first blog entry.  I’ve never wrote a post in the Internet before, I don’t have a Twitter account and I almost never update my profile on Facebook and others.  Why not? – Because I always have my own infrastructure.  I used to work as a system administrator so I’m a computer Geek. However, running your own network infrastructure has a huge impact in your electricity bill and in your home. Two months ago one of the disks of my 1Tb RAID5 died and I realized that I never used my infrastructure to make money or to share (well) my ideas so it is time to shutdown everything (routers, servers, storages etc) and save money, space and time. Trust me, making backups, checking access logs and S.M.A.R.T reports is a loss of time if you don’t make money doing it. From now on I’ll post my ideas in this just born WordPress blog and as I’m still a computer Geek, my ideas (software) on the Google code website (the OpenSource ideas of course…). Finally, writing everything in English improving my linguistic skills.

Follow me and enjoy it!



Categories: About me