The /boot partition in Fedora releases is by default sized at 500MB (new releases)
This will be very soon a problem that will cause a failure when updating your system with new packages (via yum update) or when you would like to upgrade to a new Fedora version (via preupgrade).
Usually the /boot partition is filled up by several kernels you still have on your system and you will never boot again.
To get size from the /boot partition the easiest way is to delete the old kernels; to do this run this command:
su -c ‘package-cleanup –oldkernels’
At prompt confirm the kernels you would like to delete.

Check the new size of your /boot with du -h /boot

Here you can find the slides of my talk presented at last codemotion 2011
Linux Gui Programming con Glade e PyGTK

This is a short list of resources that I consider very informative on JBoss ESB

JBoss ESB Forums
http://community.jboss.org/en/jbossesb?view=discussions
http://community.jboss.org/en/jbossesb/dev?view=discussions

Simple examples of esb projects
http://www.scribd.com/doc/33607804/JBoss-SOA-Platform-with-JBoss-Developer-Studio-Workshop

Description of esb quickstarts examples
http://community.jboss.org/wiki/JBossESBQuickStart

All about webservices and esb
http://jbossesb.blogspot.com/2009/11/proxying-soap-web-services-in-jbossesb.html

How to use drools in esb

http://java.dzone.com/articles/jbossesb-drools-integration?utm_source=am6_feedtweet&utm_medium=twitter&utm_campaign=toya256ForRSS

Gateway and non gateway listeners
http://community.jboss.org/thread/144694?tstart=450

ESB and jbpm integration
http://docs.redhat.com/docs/en-US/JBoss_Enterprise_SOA_Platform/5/html/ESB_Services_Guide/chap-jBPM_Integration.html
http://www.bpm-guide.de/2008/06/12/jboss-jbpm-meets-esb/

Service orchestration in jbpm processes

http://www.mastertheboss.com/soa-a-esb/120-esb-service-orchestration-with-jbpm.html

Convert a esb project in a maven project
http://community.jboss.org/wiki/JBossESBTrailblazerbuildingwithMaven2

How to pass dto from an esb service to a jbpm process
http://community.jboss.org/thread/160744

How to start jbpm process in esb
http://community.jboss.org/thread/154395

Synchronous comunication ws-esb
http://community.jboss.org/thread/155790

How to implement a message splitter service in jboss esb
http://code.google.com/p/breakingwoods/wiki/JBoss_ESB_Splitter

All about redelivery of messages and jta transactions

http://soa.dzone.com/articles/jms-transactions-soa-platform

ESB and EJB in transaction
http://community.jboss.org/thread/161696?tstart=0

How to access to beans created in smooks in esb services
http://community.jboss.org/thread/147985

Send a http response from a esb service
http://community.jboss.org/thread/151671

How to set global variables in esb
http://community.jboss.org/thread/153529?tstart=180

A sqlprocessor action example
http://community.jboss.org/thread/154702?tstart=210

How to use static routers

http://community.jboss.org/thread/144694?tstart=450

It seems an entire life passed since I was at 2005 Hackmeeting as speaker!
My talk wasn’t so bad :-)
http://www.slideshare.net/hifly81/java-security
http://www.hackmeeting.org/hackit05/seminari.html

SFTP client in Java

Posted: January 17, 2011 in Linux, Methodology, Uncategorized
Tags: , , , , , ,

Building a SFTP client in Java is a easy task thanks to a smart library called SSHTools.
The library provides all the necessary to wrap ssh functions in your java code; it seems that the library is not maintened anymore… anyway like wine, good code always works fine :-)
To download the library:
http://sourceforge.net/projects/sshtools
To have a look at the project that substitutes SSHTools (it seems not free):
http://www.sshtools.com/en/j2ssh-maverick

Let’s have a look at a simple SFTP client to transfer text file to a remote destination…

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;

import com.sshtools.j2ssh.SftpClient;
import com.sshtools.j2ssh.SshClient;
import com.sshtools.j2ssh.authentication.AuthenticationProtocolState;
import com.sshtools.j2ssh.authentication.PasswordAuthenticationClient;
import com.sshtools.j2ssh.transport.IgnoreHostKeyVerification;

public class SSHToolsFactory {
    private static SSHToolsFactory DEFAULT_FACTORY = null;
    private  SshClient sshClient = new SshClient();
    private  SSHToolsFactory() {}
    
    public synchronized static SSHToolsFactory getDefaultFactory() {
        if (DEFAULT_FACTORY == null)
        DEFAULT_FACTORY = new SSHToolsFactory();
        return DEFAULT_FACTORY;
    }
    
    private  synchronized void connect(
    String remoteHost,int remotePort,String username,String password) throws Exception {
        sshClient.connect(remoteHost,remotePort,
        new IgnoreHostKeyVerification());
        
        PasswordAuthenticationClient passwordAuthenticationClient =
        new PasswordAuthenticationClient();
        passwordAuthenticationClient.setUsername(username);
        passwordAuthenticationClient.setPassword(password);
        int result = sshClient.authenticate(passwordAuthenticationClient);
        if(result != AuthenticationProtocolState.COMPLETE) {
            throw new Exception("SSH auth failed!");
        }
    }
    
    public  synchronized void sftpPut(
    StringBuffer sb,String remoteDir,String filename) throws Exception {
        if(!sshClient.isConnected()) {
            throw new Exception("SSH not estabilished!");;
        }
        //Get an outputstream from a text buffer
        ByteArrayOutputStream os =new ByteArrayOutputStream();
        os.write(sb.toString().getBytes());
        
        //open an input stream from an output stream
        ByteArrayInputStream in =
        new  ByteArrayInputStream(os.toByteArray());
        
        SftpClient sftpClient = sshClient.openSftpClient();
        sftpClient.put(in,remoteDir+filename);
        
        sftpClient.quit();
        sshClient.disconnect();
        
        os.close();
        in.close();
    }
}

Just a note: a IgnoreHostKeyVerification() doesn’t prompt the user to verify the key sent by the ssh server, anyway You are free to use other key verification classes.

Il Javaday cambia e diviene Codemotion

Per quattro anni il Javaday Roma ha offerto un evento unico in Italia per contenuti, affluenza e spirito. L’atmosfera trascinante del Javaday ha saputo conquistare e coinvolgere i partecipanti e gli sponsor. Per continuare ad essere la manifestazione di riferimento degli sviluppatori, il Javaday si evolve e diviene Codemotion.

Codemotion compie un grande salto rispetto al Javaday: apre a tutti i linguaggi e tecnologie, catalizzando ancora di più sorgenti di creatività e opportunità di lavoro. Infine, sposta l’attenzione da un prodotto (Java, a suo tempo di Sun, ora di Oracle) ad una disciplina: la programmazione, a vantaggio di tutti.

Il Codemotion si terrà a Roma il 5 marzo 2011.
L’ingresso all’evento è come sempre gratuito.
Per ogni informazione: http://www.codemotion.it
Che cos’è Codemotion

Il programma di Codemotion verrà definito tramite Call for Paper pubblica e aperta a tutti. La selezione delle proposte avverrà mediate una valutazione a cura dei rappresentanti delle community ufficiali, sia legate ai diversi linguaggi che allo sviluppo del software.

Durante Codemotion si potrà consegnare alle aziende Sponsor il proprio curriculum vitae per avere nuove opportunità professionali.

L’agenda della giornata prevede una intensa mattina di talk tecnici e un pomeriggio dove verranno organizzate sessioni di Ignite.

E’ in fase di definizione un concorso per premiare le migliori idee innovative sviluppate da giovani studenti Universitari di tutta Italia.

L’ingresso al Codemotion è come sempre gratuito.
Per ogni informazione: http://www.codemotion.it
Contribuire al programma del Codemotion

Fino al 18 gennaio 2011 sarà possibile inviare le proprie proposte di talk per partecipare al programma della prima edizione del Codemotion, l’evento aperto a tutti i linguaggi e tecnologie.

La selezione delle proposte, pervenute tramite l’apposito modulo sul sito dell’evento, avverrà con una valutazione a cura dei rappresentanti delle community ufficiali italiane, legate ai diversi linguaggi e allo sviluppo del software, che collaborano con il Codemotion. Le proposte selezionate saranno rese pubbliche nel mese di febbraio e verranno inserite nel programma ufficiale del Codemotion.

Codemotion è l’evoluzione del Javaday Roma e si svolgerà nell’unica giornata di sabato 5 marzo 2011 a Roma. Durante la manifestazione i partecipanti potranno prendere parte ad un’intensa mattinata di talk tecnici mentre nel pomeriggio sono previsti sessioni di presentazione di idee innovative e workshop tecnici.

Codemotion compie un grande salto rispetto al Javaday: apre a tutti i linguaggi e tecnologie, catalizzando ancora di più sorgenti di creatività e opportunità di lavoro. Infine, sposta l’attenzione da un prodotto ad una disciplina: la programmazione, a vantaggio di tutti.

L’ingresso all’evento è come sempre gratuito.
Per ogni informazione: http://www.codemotion.it

Imagine you want to give access to your application even to android devices and (of course) you want to reuse the business logic exposed in a JEE application.
Android doesn’t implement RMI or some APIs useful to call remote methods (hessian, burlap).
The easiest way (maybe we will discuss performance issues of this approach in a new post) involves a transformation of the object you want to manage with Android in a json representation.
An android client can parse directly a json stream or can obtain again the “server-side” object calling a transformation from json to java object.

A smart library as gson is everyting we need to achieve our goal
http://code.google.com/p/google-gson
The same gson jar can be added to the jee application library path and to the android library path…

Let’s take a look to the “server side” code, a standard jee servlet:

public class SimpleServlet extends HttpServlet {
    public void doGet(
    HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        //Suppose we have a DummyObject
        DummyObject dummy = new DummyObject();
        dummy.setDescription("I'm a server-side object");
        
        response.setContentType("text/html");
        Gson gson = new Gson();
        //Get a json representation from an object
        String jsonstring = gson.toJson(dummy);
        PrintWriter out = response.getWriter();
        out.print(jsonstring);
        out.flush();
        out.close();
    }
}

The core method gson.toJson is not limited only to simple pojo’s but can give a representation even for “fat” java objects (objs that contain other objs,objs with maps,list,…).

Working in an android activity all you need is a way to call the servlet and how to obtain the java object from a json source.

Let’s look at the code:

public class SimpleActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        DummyObject dummy = runJSONParser();
        
        //Do something with your dummy obj
        .....
        .....
        .....
    }
    
    public DummyObject runJSONParser() {
        DummyObject dummy = null;
        try {
            Log.i("MY INFO", "Json Parser started..");
            Gson gson = new Gson();
            Reader reader = new InputStreamReader(
            getJSONData(
            "http://<servlet_url>"));
            Log.i("MY INFO", reader.toString());
            dummy = gson.fromJson(reader, DummyObject.class);
            } catch(Exception ex){
            ex.printStackTrace();
        }
        return dummy;
    }
    
    public InputStream getJSONData(String url){
        DefaultHttpClient httpClient = new DefaultHttpClient();
        URI uri;
        InputStream data = null;
        try {
            uri = new URI(url);
            HttpGet method = new HttpGet(uri);
            HttpResponse response = httpClient.execute(method);
            data = response.getEntity().getContent();
            } catch (Exception e) {
            e.printStackTrace();
        }
        
        return data;
    }
}

A DefaultHttpClient is a class provided by Android for http connections (a servlet responds over http/https).
gson.fromJson is the method from Gson library to obtain again the java object.
Remember to include in android library path the .class files of “server-side” java objects.

Show a jbpm process image

Posted: November 30, 2010 in jboss
Tags: , , , , , , , , ,

It’s very easy to access to the process image attached to a jbpm process.
In this example a simple servlet show the image getting the process definition through a request parameter (“definitionId”) and the name of the file image through another request parameter (“img”).

This good thread from jboss.org forum explains in detail how to create a custom bpm process visualizer:
http://community.jboss.org/thread/115282

import java.io.IOException;
import java.io.OutputStream;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.graph.def.ProcessDefinition;

public class ShowProcessImgServlet extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        long processDefinitionId = 
        Long.parseLong( request.getParameter( "definitionId" ) );
        JbpmContext jbpmContext = null;
        try{
            jbpmContext  = JbpmConfiguration.getInstance().createJbpmContext();
            ProcessDefinition processDefinition = jbpmContext.getGraphSession().loadProcessDefinition(processDefinitionId);
            byte[] bytes = processDefinition.getFileDefinition().getBytes(request.getParameter( "img" ));
            OutputStream out = response.getOutputStream();
            out.write(bytes);
            out.flush();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
        finally {
            jbpmContext.close();
        }
   }
}

If you’ve ever worked with jboss jbpm and with tasklists, you know that users of your app should never use the jbpm console to interact with task forms.
Typically tasklist should be available inside user web app.
What you need is a way to “connect” to an active jbpm context in order to control the workflow.
The code attached shows a method (you can wrap it in a servlet or wherever you want) that interact with the bpm context to manage process instances blocked in a task node. It works with jbpm 3.x (that at the moment is the version supported by jboss soa platform 5)
I apologize for the indentation used to let work decent the wordpress code plugin :-(

So let’s show us the code…

public void manageBpmTasks() {
	JbpmContext context = null;
	try {
		//Get a jbpm context 
		context = JbpmConfiguration.getInstance().createJbpmContext();
		GraphSession session = context.getGraphSession();
		//Get all process deployed
		List<ProcessDefinition> processDefinitions = 
		(List<ProcessDefinition>)session.findAllProcessDefinitions();
		if(processDefinitions!=null && !processDefinitions.isEmpty()) {
			for(ProcessDefinition process:processDefinitions) {
				//Get all process instances linked to a specific process
				List<ProcessInstance> processInstances = 
				(List<ProcessInstance> )
                                session.findProcessInstances(process.getId());
				if(processInstances!=null && !processInstances.isEmpty()) {
					for(ProcessInstance instance:processInstances) {
						//Work only with running instances
						if(!instance.hasEnded()) {
							//Get all task inside the instance
							Collection taskInstances = 
							instance.getTaskMgmtInstance().getTaskInstances();     
							Iterator iter = 
							taskInstances.iterator();     
							while (iter.hasNext()) {      
								TaskInstance task = (TaskInstance)iter.next();  
								System.out.println(""+
								"Process Name:["+process.getName()+"]\n" +
								"Instance:["+instance.getId()+"]\n" +
								"Task Name["+task.getName()+"]\n" +
								"Task creation time["+task.getCreate()+"]");
								//If the task is noit started, start it!
								if(task.getStart()==null) {
									task.start();  
								}
								task.addComment("Tasksignaled outside bpm");
								System.out.println("Taskstart["+task.getStart()+"]");
								//End the task and proceed to the next bpm node
								task.end();
								System.out.println("\nTaskend["+task.getEnd()+"]");
							}
						}
					}
				}
			}
		}
	}
	catch(Exception ex) {
		ex.printStackTrace();
	}
	finally {
		//!!!IMPORTANT:Commit the operations done on process instance 
		context.close();
	}
}

This discussion is not focused on what is a pojo and the differences between pojo and javabean…
If you want to be involved check:
http://stackoverflow.com/questions/1612334/difference-between-dto-vo-pojo-javabeans

But maybe during last years the discussion was too much focused on clarifying the differences between pojo,javabean,dto without real results.
In java projects I’ve experienced a big proliferation of useless objects defined only with the purpose to expose getter and setter methods.
But objects are artifacts with a state and behaviours and they must be used to capture domain facts inside your project.
What is the domain information inside objects without behaviours? Of course there is no information!
And the bad practices used in projects guided to a proliferation of Service objects with the aim to realize the behaviour not exposed by the objects…
A business domain should be defined by first class objects not by services class. There is no chance to reuse or to extend a domain if it’s made by “weak” objects…

Maybe it’s better to forget the discussion about differences between pojo and javabean in favour of a “promotion” of weak objects in domain objects.