1 2 3 4 Previous Next


48 posts

Hello guys,

This post reflects a thought around a case that I have been experiencing. There a lot of things that involves implementing a spec and one of them is that you need to guarantee that you are not exposing more than it is available on the Javadoc.

There are a few static factory methods and no constructors, means public and protected, in our Javadoc scenario. So, you need to guarantee, by code, that there are only private constructors and nobody will cut them off.

So we create a unit test that assures there are not other constructors then private. Reflection is used for finding the constructors array and if there are no protected and public, zero should be returned.



public void testThereAreOnlyPrivateConstructors() {  

            Constructor[] constructors = Foo.class.getConstructors();           

   assertEquals(0, constructors.length);      



public class Foo {

             private Foo() {      }            

   public static Foo createFoo(int s) {

               //do something           

     return new Foo();      




The thing is pretty much obvious, but the idea here was to shown something that does not happens everyday, but applies for a few interesting scenarios.

Bruno Ghisi

Hello guys,

I have just released a plugin for Scripting in Grails. It basically let you  create Groovy scripts as CRUDs, so you can use them for dynamic behaviors.  This is a first release, so feel free to send feedback for future  improvements.


If you want to learn more about how to create plugins for Grails, check this link.

Merry Xmas and Happy New Year!!!


Bruno Ghisi

My masters colleague, Guilherme Hobold, and his friend, Elinton Machado, have created a very interesting project for helping Java ME applications with dependency injection. Actually, it is not only for Java ME (CLDC), but because of there is no reflection, they have done some magic to make it work in a nice way.

The project is called DIME, which means Dependency Injection for Java ME. Basically it has a XML to configure the beans (it depends on kXML lib for parsing), a container to get the beans and the classes have to implemented a Bean interface that provides access to the hash table that is used to set the correct values. The XML file uses the same notation as Spring.

Here is some sample code that I got from the project page.

XML file (also supports map and other types).
<?xml version="1.0"?>
      <import resource="other_beans.xml" />

      <bean id="fooSet" class="test.collection.FooList">
            <property name="elements">

      <bean id="Foo" class="test.Foo">
            <property name="filename">
            <property name="fooSet" ref="fooSet"/>

Make a bean:
import java.util.Hashtable;
import org.dime.Bean;
import test.collection.FooList;

public class Foo extends FooAbstract implements Bean {

      private String filename;
      private FooList fooSet;

      public String getFilename() {
            return filename;

      public void setProperties(Hashtable properties) {
            filename = (String)properties.get("filename");
            fooSet = (FooList)properties.get("fooSet");

Load the XML file and get the bean:
BeanContainer container = new ClassPathXmlBeanContainer("file.xml");
Foo foo = (Foo)container.getBean("Foo");

Very nice job! Take a look in the project page for more information. Take a try!


Bruno Ghisi


Java DTV 1.2.1 is out! Blog

Posted by brunogh Oct 2, 2009

The new version of Java DTV specification, 1.2.1, was released at http://www.forumsbtvd.org.br/materias.asp?id=200.

Java DTV was created in order to prevent some royalty issues from some MHP APIs, like DAVIC e HAVI, in the Ginga-J subsystem of the Brazilian DTV middleware specification, which is also called Ginga. For more information around this soap opera, check this old blog entry.

So, what are the next steps? Java DTV will become a JSR?


Bruno Ghisi

After almost one year, Brazil's Digital Television Forum (SBTVD) has finally fixed the royalty confusion with Sun's help. We now have a royalty-free/open source specification that substitutes the GEM API in the Brazilian middleware Java subsystem (Ginga-J). This specification seems to be using LWUIT for the UI.  Download the javadoc here.

I do still have a few questions. How this specification will evolve since it is not standardized as a JSR in the JCP? Is there any tools/emulators to play with the specification? OpenGinga?

Finally, congrats for the people that have worked on that. Open source did one more point! You can check the announcement in portuguese here and find a nice recap in this Rob Glidden's blog entry.

Bruno Ghisi

Disclaimer: This post - and all the old and new ones - express my own opinion and does not reflect the opinion of my actual employee.

This post is simple. In the company that I am working, we have some local area books that have a different control. Because they are out of the normal process, we do not have anything to control the borrowing. That can cause a problem, because sometimes people can accidentally forget that borrowed a book (sometimes I cannot remember what day is in the week and I think I work with crazier guys). So, the problem is simple and the use case will be too. Basically, someone that is responsible for the books will rent them for the team. Why not develop this fast application using Grails?! Grails, which means Groovy on Rails, is an "agile" framework that uses Spring and Hibernate with a lot of code by convention. NetBeans 6.5 has an interesting support for its development, you can find instructions on how to start here. Anyway, I decided to start programming the application described using gedit and console in order to learn from the beginning and actually type the Gant commands. It took me a few hours to set a first version of the application and I am definitely still learning, but I can guarantee fore sure that Grails is very fast and fun. The application has two domain classes, a Book, that represents the instance itself (we usually do not have copies), and a Rent, that represents the act of borrowing the book. The application also contains other domain classes (User, Role, Requestmap) that came from the Acegi Plugin installed, which will manage permissions and URLs. All those domain classes have its controllers and views. I also have added a AdminController for the admin area and HomeController for the default home page, mapped in grails-app/conf/UrlMapping.groovy. The index home view uses a home decorator available at /grails-app/views/layout, specified by the meta name="layout" content="home" tag in its gsp page. The application uses a lot of scaffolding for the CRUDs and also have loved the dynamic finders to create the queries. Finally, have generated the war and deployed it on a Tomcat server using the production configuration with a MySQL database, specified in grails-app/conf/DataSource.groovy file. You can download BookBorrowing here. Feel free to modify and do whatever you want. Home - list all the availables books for borrow and has a search


Admin area


Rent view in the Admin area - "Devolver" means return this book, "Devolvido" means list of returned books and "Emprestados" means the currently borrowed. Need to i18n, gonna do it soon.


Cheers! Have fun!!!
Bruno Ghisi
Are you aged 26 or younger? What are you waiting to travel for free for Jazoon'09 and meet a lot of cool people?! Submit your technical talk before February, 28 at http://jazoon.com/en/contribute/rookie.html. The top 3 rookies will be invited to go there and give a 20 minutes talk. Wow! All Java conferences should copy this awesome initiative, Jazoon definitely rocks! These young guys need your support to become the speakers from tomorrow! http://jazoon.com/dms-static/8a95b0e6-75d3-4896-9491-8acafd65af64/Jazoon%20Rookie.jpg Cheers! Bruno Ghisi

A rewrite for Puzzle 17 Blog

Posted by brunogh Dec 23, 2008
A rewrite for Puzzle 17, from Java Puzzlers :) Compile it and run. Main.java \u0070\u0075\u0062\u006C\u0069\u0063\u0020\u0063\u006C\u0061\u0073\u0073\u0020\u004D\u0061\u0069\u006E\u0020\u007B\u000A\u0020\u0020\u0020\u0020\u0070\u0075\u0062\u006C\u0069\u0063\u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0076\u006F\u0069\u0064\u0020\u006D\u0061\u0069\u006E\u0028\u0053\u0074\u0072\u0069\u006E\u0067\u005B\u005D\u0020\u0061\u0072\u0067\u0073\u0029\u0020\u007B\u000A\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0053\u0079\u0073\u0074\u0065\u006D\u002E\u006F\u0075\u0074\u002E\u0070\u0072\u0069\u006E\u0074\u006C\u006E\u0028\u0022\u004D\u0065\u0072\u0072\u0079\u0020\u0058\u006D\u0061\u0073\u0021\u0020\u0048\u0061\u0070\u0070\u0079\u0020\u004E\u0065\u0077\u0020\u0059\u0065\u0061\u0072\u0021\u0022\u0029\u003B\u000A\u0020\u0020\u0020\u0020\u007D\u000A\u007D All the best for you and your family! Enjoy the end of the year! Looking for 2009! M3DD begins in 4 weeks! Bruno Ghisi

Have you seen this unofficial Java API for Google Translator? So, I was thinking that it could be interesting to mix this stuff with Java Speech API (JSAPI).

JSAPI was divided to support two things: speech recognizers and synthesizers. Speech synthesis is the process of generating human speech from written text for a specific language. Speech recognition is the process of converting human speech to words/commands. This converted text can be used or interpreted in different ways (interesting and simple definition from this article).

It seems that there are not too many open source projects that cares about the recognizer part. I have found a very interesting one called Sphinx, but did not have time to try it yet. I was thinking how cool would be to have an open source software to make possible a talk between two different people, like you say something in a language, it translates to another language and say that. Have anybody seen anything like that? Non commercial? For voip?

So, I work in part of a demo, but only with the the synthesizer part, the text input is manually. I used FreeTTS for that. Basically this piece of code gets an word input in Portuguese, translates it to English and then say the word.

package speech;

import com.google.api.translate.Language;
import com.google.api.translate.Translate;
import com.sun.speech.freetts.Voice;
import com.sun.speech.freetts.VoiceManager;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) {
        VoiceManager voiceManager = VoiceManager.getInstance();
        Voice voice = voiceManager.getVoice("kevin16");

        String text = null;
        do {
            try {
                System.out.println("Type a word in Portuguese and listen it in English -> ");
                text = new BufferedReader(new InputStreamReader(System.in)).readLine();
                voice.speak(Translate.translate(text, Language.PORTUGESE, Language.ENGLISH));
            } catch (Exception ex) {
        } while (!text.equals("!quit"));


If you got excited to work in an open source project like that, go ahead and write something! I can guarantee your fun!

Have a nice week!
Bruno Ghisi

More Quick Updates... Blog

Posted by brunogh Oct 1, 2008

Filter Blog

By date: