<?xml version="1.0" encoding="utf-8"?>
<feed version="0.3" xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="en">
<title>Edgar Silva&apos;s Blog</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/edgars/" />
<modified>2008-08-05T02:08:05Z</modified>
<tagline></tagline>
<id>tag:weblogs.java.net,2008:/blog/edgars/338</id>
<generator url="http://www.movabletype.org/" version="3.01D">Movable Type</generator>
<copyright>Copyright (c) 2008, edgars</copyright>
<entry>
<title>Creating a Process Server based on OpenSource Technologies using REST</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/edgars/archive/2008/08/creating_a_proc.html" />
<modified>2008-08-05T02:08:05Z</modified>
<issued>2008-08-05T02:01:18Z</issued>
<id>tag:weblogs.java.net,2008:/blog/edgars/338.10222</id>
<created>2008-08-05T02:01:18Z</created>
<summary type="text/plain">This is an entry where I show how combine REST and BPM to build a Process Server engine based on Open-Source technologies.</summary>
<author>
<name>edgars</name>

<email>edgar.silva@redhat.com</email>
</author>
<dc:subject>Community: Java Web Services and XML</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/edgars/">
<![CDATA[<P>This is a post where I will try share some thoughts about where
REST could be useful inside a SOA architecture using Business Process
Management, in that case we will be using jBPM and RESTEasy, which is
the JBoss's implementation for <A HREF="https://jsr311.dev.java.net/">JSR311
- Java Restful WebServices</A>. 
</P>
<H3>RESTEasy</H3>
<P>RestEasy is a project that is getting a good relevance in terms of
integration with some projects inside JBoss.ORG and even other
projects. If you are trying use a simple REST implementation you
should take a look on this projects, basically there are few steps
you must to do to put RestEasy working for your Application, so see
the following Steps:</P>
<OL>
	<LI><P>Download the <A HREF="http://wiki.jboss.org/wiki/RESTeasyJAXRS">RESTEasy</A>
	from JBoss.ORG</P>
	<LI><P>There is a worth documentation in <A HREF="http://wiki.jboss.org/wiki/RESTeasyJAXRS">RESTEasy
	Wiki</A>, which I strongly recommend you read it first, in addition
	to this, in order to see some foundation for practical REST
	application, you can read this great<A HREF="http://weblogs.java.net/blog/caroljmcdonald/archive/2008/07/a_dynamic_ajax_1.html">
	blog entry</A> written by <A HREF="http://weblogs.java.net/blog/caroljmcdonald">Carol
	McDonald</A></P>
	<LI><P>To make the things works, I recomend you read this link:
	<A HREF="http://wiki.jboss.org/wiki/RESTeasyInstall">http://wiki.jboss.org/wiki/RESTeasyInstall</A>
	, RESTEasy is pretty easy to understand and apply in even legacy
	Java applications, where you can expose some methods simply putting
	some annotations into your pojos. Basically the steps are:</P>
</OL>
<UL>
	<LI><P>RESTeasy is deployed as a WAR archive and thus depends on a
	Servlet container. When you download RESTeasy and unzip it you will
	see that it contains an exploded WAR. Make a deep copy of the WAR
	archive for your particular application. Place your JAX-RS annotated
	class resources and providers within one or more jars within
	/WEB-INF/lib or your raw class files within /WEB-INF/classes.
	RESTeasy is configured by default to scan jars and classes within
	these directories for JAX-RS annotated classes and deploy and
	register them within the system:</P>
</UL>
<H4 STYLE="margin-left: 1.58in">Custom configuration</H4>
<P STYLE="margin-left: 1.58in">RESTeasy is implemented as a
<U>ServletContextListener</U><A HREF="http://wiki.jboss.org/wiki/ServletContextListener">?</A>
and a Servlet and deployed within a WAR file. If you open up the
WEB-INF/web.xml in your RESTeasy download you will see this: 
</P>
<PRE STYLE="margin-left: 1.58in">&lt;web-app&gt;
   &lt;display-name&gt;Archetype Created Web Application&lt;/display-name&gt;
   &lt;context-param&gt;
      &lt;param-name&gt;resteasy.scan&lt;/param-name&gt;
      &lt;param-value&gt;true&lt;/param-value&gt;
   &lt;/context-param&gt;

   &lt;listener&gt;
      &lt;listener-class&gt;org.resteasy.plugins.server.servlet.ResteasyBootstrap&lt;/listener-class&gt;
   &lt;/listener&gt;

   &lt;servlet&gt;
      &lt;servlet-name&gt;Resteasy&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.resteasy.plugins.server.servlet.HttpServletDispatcher&lt;/servlet-class&gt;
   &lt;/servlet&gt;

   &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Resteasy&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
   &lt;/servlet-mapping&gt;

&lt;/web-app&gt;</PRE><P STYLE="margin-left: 1.58in">
The <TT><U>ResteasyBootstrap</U></TT> listener is responsible for
initializing some basic components of RESTeasy as well as scanning
for annotation classes you have in your WAR file. It receives
configuration options from &lt;context-param&gt; elements. Here's a
list of what options are available 
</P>
<UL>
	<LI><P>And that's all! Everything you need is ready to run your REST
	Services in any JEE App Server.</P>
</UL>
<H3>Proof of Concept of a “Process Server”</H3>
<P>We have several open source BPM Engines , I am using JBoss jBPM
because I wanna show you a Web-Console where the process are running
on, in addition a graphical tool to design my processes. 
</P>
<P>First of all I have a really simple “Controller” based on REST
principles, nothing too complex or beautiful so far, but is useful,
so I created a simple class called <B>RestService.java </B><SPAN STYLE="font-weight: medium">where
you can find many useful methods to operate business process using
jBPM. Based on my own experience could be considered a “best
practice” you design your URLs first, who knows some day we could
create a tool (ant or maven), that could based on a text file
containing one URL per line, where after reading it could create an
abstract class with the methods. (Maybe a good way to forget any
XML). Based on this practice I wanna give the ability for PHP, .net
or even HTML interact with my “Process Server”, to do that I can
have the following URLs:</SPAN></P>
<OL>
	<LI><P STYLE="font-weight: medium">/start/process/{some
	process}/{some user to be associated to my Swilanes}, it I can pass
	via a GET method and I can keep the process id as my return</P>
	<LI><P STYLE="font-weight: medium">/signal/process/{the process id I
	must have stored somewhere}/{user} , via a GET I can navigate into
	my process 
	</P>
	<LI><P STYLE="font-weight: medium">/process/{process id}/add/var ,
	via a GET I can get a way to add some variables for my process
	execution</P>
</OL>
<OL>
	<P STYLE="font-weight: medium">Based on these 4 actions I defined
	above, I can show you now how implement them:</P>
</OL>
<H3>1- Start a new Process Instance</H3>
<UL>
	<LI><P STYLE="font-weight: medium">For jBPM you must have access to
	Context, which is the key object to operate processes using jBPM.</P>
	<LI><P STYLE="font-weight: medium">The following code shows this
	method in action:</P>
</UL>
<P STYLE="margin-left: 0.79in; margin-bottom: 0in; font-weight: medium">
<FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#646464">@GET</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">	</FONT><FONT COLOR="#646464">@Path</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#2a00ff">&quot;/start/process/{processdefinition}/{user}&quot;</FONT><FONT COLOR="#000000">)</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">	</FONT><FONT COLOR="#646464">@ProduceMime</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#2a00ff">&quot;text/plain&quot;</FONT><FONT COLOR="#000000">)</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">	</FONT><B><FONT COLOR="#7f0055">public</FONT></B><FONT COLOR="#000000">
String startProcesInstance(</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">			</FONT><FONT COLOR="#646464">@PathParam</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#2a00ff">&quot;processdefinition&quot;</FONT><FONT COLOR="#000000">)String
processDefintion, </FONT></FONT></FONT>
</P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">			</FONT><FONT COLOR="#646464">@PathParam</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#2a00ff">&quot;user&quot;</FONT><FONT COLOR="#000000">)String
user) {</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">		JbpmContext
ctx = JbpmConfiguration.<I>getInstance</I>().createJbpmContext();</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">		</FONT><B><FONT COLOR="#7f0055">try</FONT></B><FONT COLOR="#000000">
{</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">			ProcessInstance
instance = ctx.newProcessInstance(processDefintion);</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">			instance.getContextInstance().setVariable(</FONT><FONT COLOR="#2a00ff">&quot;user&quot;</FONT><FONT COLOR="#000000">,
user);</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">			Token
t = instance.getRootToken();</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">			t.signal();</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">		
   ctx.save(instance);</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><BR>
</P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">			</FONT><B><FONT COLOR="#7f0055">return</FONT></B><FONT COLOR="#000000">
</FONT><B><FONT COLOR="#7f0055">new</FONT></B><FONT COLOR="#000000">
Long(instance.getId()).toString();</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"> <FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">		}</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">		</FONT><B><FONT COLOR="#7f0055">catch</FONT></B><FONT COLOR="#000000">
(Exception e) {</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">			e.printStackTrace();</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">		}</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">		</FONT><B><FONT COLOR="#7f0055">finally</FONT></B><FONT COLOR="#000000">
{</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">			ctx.close();</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">		}</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">		</FONT><B><FONT COLOR="#7f0055">return</FONT></B><FONT COLOR="#000000">
</FONT><FONT COLOR="#2a00ff">&quot;ERROR&quot;</FONT><FONT COLOR="#000000">;</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><BR>
</P>
<OL>
	<OL>
		<P><FONT SIZE=2 STYLE="font-size: 11pt"><FONT FACE="Courier New, monospace"><FONT COLOR="#000000">	}</FONT></FONT></FONT></P>
	</OL>
</OL>
<H3>2 - Signaling your Process</H3>
<P>Once you have your Process Id, you can operate it and do whatever
you want, this is one of the “Key-benefits” in jBPM, the ability
to keep everything related to the process stored in the database, and
not in the memory, it allow you have several application interacting
with your <B>Process Engine</B>, for my testing, I have jBPM Server
(jBPM+JBoss [could be any other AppServer]) in one IP address, and a
TomCat with my simple REST application based in RESTEasy. Keep in
mind, that having your process stored in regular tables in many
Databases supported by Java, you shall create many kinds of
applications, you may use Hibernate for persistence, query and cache
as well as JDBC or even Spring helpers. See the following source code
to allow this action:</P>
<P STYLE="margin-left: 0.79in; margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#646464">@GET</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">	</FONT><FONT COLOR="#646464">@Path</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#2a00ff">&quot;/signal/process/{id}/{user}&quot;</FONT><FONT COLOR="#000000">)</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">	</FONT><FONT COLOR="#646464">@ProduceMime</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#2a00ff">&quot;text/plain&quot;</FONT><FONT COLOR="#000000">)</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">	</FONT><B><FONT COLOR="#7f0055">public</FONT></B><FONT COLOR="#000000">
String signalProcess(</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">			</FONT><FONT COLOR="#646464">@PathParam</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#2a00ff">&quot;id&quot;</FONT><FONT COLOR="#000000">)String
id, </FONT></FONT></FONT>
</P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">			</FONT><FONT COLOR="#646464">@PathParam</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#2a00ff">&quot;user&quot;</FONT><FONT COLOR="#000000">)String
user) {</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
     JbpmContext ctx =
JbpmConfiguration.<I>getInstance</I>().createJbpmContext();</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
</FONT></FONT></FONT>
</P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">	
       </FONT><B><FONT COLOR="#7f0055">try</FONT></B><FONT COLOR="#000000">{</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
       GraphSession graphSession = ctx.getGraphSession();</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">	
       ProcessInstance processInstance =
graphSession.loadProcessInstance((</FONT><B><FONT COLOR="#7f0055">new</FONT></B><FONT COLOR="#000000">
Long(id)).longValue());</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000">      
      </FONT>
</P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
       processInstance.signal();</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
       </FONT></FONT></FONT>
</P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
       ctx.save(processInstance);</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
      </FONT></FONT></FONT>
</P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
       </FONT></FONT></FONT>
</P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">	
       </FONT><B><FONT COLOR="#7f0055">return</FONT></B><FONT COLOR="#000000">
processInstance.getRootToken().getNode().getName(); </FONT></FONT></FONT>
</P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
       </FONT></FONT></FONT>
</P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">	
       } </FONT><B><FONT COLOR="#7f0055">catch</FONT></B><FONT COLOR="#000000">
(Exception e ) {</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
       	e.printStackTrace();</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">	
       	</FONT><B><FONT COLOR="#7f0055">return</FONT></B><FONT COLOR="#000000">
</FONT><FONT COLOR="#2a00ff">&quot;ERROR&quot;</FONT><FONT COLOR="#000000">;</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
       }</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">	
       </FONT><B><FONT COLOR="#7f0055">finally</FONT></B><FONT COLOR="#000000">
{</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
       	ctx.close();</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
       }</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT FACE="Courier New, monospace">	}</FONT></FONT></FONT></P>
<P><BR><BR>
</P>
<H3>3 – Adding variables to your processes via a simple URL 
</H3>
<UL>
	<LI><P><FONT COLOR="#000000">For many reasons, you might need some
	variables for your processes, maybe for a decision taken or for
	anything else, so the following source shows how you can get the
	HttpServletRequest using the injection executed by the REST
	implementation. This method shows you how you can use contextual
	http objects, besides your variables from URL.</FONT></P>
	<LI><P><FONT COLOR="#000000">This could be really useful to capture
	other information, or even process some files not using GET method,
	but the POST method for instance, see the following implementation:</FONT></P>
</UL>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">	</FONT><FONT COLOR="#646464">@GET</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">	</FONT><FONT COLOR="#646464">@Path</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#2a00ff">&quot;/process/{id}/add/var&quot;</FONT><FONT COLOR="#000000">)</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">	</FONT><FONT COLOR="#646464">@ProduceMime</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#2a00ff">&quot;text/plain&quot;</FONT><FONT COLOR="#000000">)</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">	</FONT><B><FONT COLOR="#7f0055">public</FONT></B><FONT COLOR="#000000">
String addVariables(</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">			</FONT><FONT COLOR="#646464">@PathParam</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#2a00ff">&quot;id&quot;</FONT><FONT COLOR="#000000">)String
id,</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">			</FONT><FONT COLOR="#646464">@Context</FONT><FONT COLOR="#000000">
HttpServletRequest request) {</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
     JbpmContext ctx =
JbpmConfiguration.<I>getInstance</I>().createJbpmContext();</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
</FONT></FONT></FONT>
</P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">	
       </FONT><B><FONT COLOR="#7f0055">try</FONT></B><FONT COLOR="#000000">{</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
       GraphSession graphSession = ctx.getGraphSession();</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">	
       ProcessInstance processInstance =
graphSession.loadProcessInstance((</FONT><B><FONT COLOR="#7f0055">new</FONT></B><FONT COLOR="#000000">
Long(id)).longValue());</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000">      
      </FONT>
</P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
       Enumeration  params = request.getParameterNames();</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
       String param;</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">	
       StringBuilder b = </FONT><B><FONT COLOR="#7f0055">new</FONT></B><FONT COLOR="#000000">
StringBuilder();</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">	
       </FONT><B><FONT COLOR="#7f0055">while</FONT></B><FONT COLOR="#000000">
(params.hasMoreElements()) {</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
       	</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
       	param = (String) params.nextElement();</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
       	processInstance.getContextInstance().setVariable(param,
request.getParameter(param));</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">	
       	b.append(String.<I>format</I>(</FONT><FONT COLOR="#2a00ff">&quot;Param:%s=%s
is Stored in BPM Context\n&quot;</FONT><FONT COLOR="#000000">,param,request.getParameter(param)));</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
       }</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
       </FONT></FONT></FONT>
</P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
       </FONT></FONT></FONT>
</P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
       ctx.save(processInstance);</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
      </FONT></FONT></FONT>
</P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
       </FONT></FONT></FONT>
</P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">	
       </FONT><B><FONT COLOR="#7f0055">return</FONT></B><FONT COLOR="#000000">
b.toString(); </FONT></FONT></FONT>
</P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
       </FONT></FONT></FONT>
</P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">	
       } </FONT><B><FONT COLOR="#7f0055">catch</FONT></B><FONT COLOR="#000000">
(Exception e ) {</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
       	e.printStackTrace();</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">	
       	</FONT><B><FONT COLOR="#7f0055">return</FONT></B><FONT COLOR="#000000">
</FONT><FONT COLOR="#2a00ff">&quot;ERROR&quot;</FONT><FONT COLOR="#000000">;</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
       }</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT COLOR="#000000">	
       </FONT><B><FONT COLOR="#7f0055">finally</FONT></B><FONT COLOR="#000000">
{</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
       	ctx.close();</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT FACE="Courier New, monospace"><FONT SIZE=2 STYLE="font-size: 11pt">	
       }</FONT></FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0in"><FONT COLOR="#000000"><FONT SIZE=2 STYLE="font-size: 11pt"><FONT FACE="Courier New, monospace">	}</FONT></FONT></FONT></P>
<H3>Time for Testing</H3>
<P><FONT COLOR="#000000">As far you can see, everything on our
example just returns basic “plain texts” as results, so we can
use those everywhere, in The <A HREF="http://www.thedevelopersconference.com.br/">Developers
Conference</A> (A Brazilian Java Conference) I did an examples really
“old school”, I used a Borland Delphi 5 client, in terms of
integration, I can get an existing Delphi or Visual Basic Application
and integrate them with my “Process Server”, than for our Proof
of Concept. My process for testing is really easy, as far you can see
in the following image:</FONT></P>
<P><IMG SRC="processimage2.jpg" NAME="graphics1" ALIGN=LEFT WIDTH=749 HEIGHT=468 BORDER=0><BR CLEAR=LEFT><BR><BR>
</P>
<P><FONT COLOR="#000000">This is a simple “Buying Process”, where
could be used for many different scenarios, on our case, we try
simulate a simple Delphi client interacting with this process. On
Delphi's side, I need just a component to interact with HTTP requests
and nothing else, so in my case I used  TidHTTP object for it.</FONT></P>
<H3>My Process Server in Action</H3>
<P><FONT COLOR="#000000">When we execute the following URL:
<A HREF="http://192.168.161.1:8080/flowlet/start/process/buyticket/edgar">http://192.168.161.1:8080/flowlet/start/process/buyticket/edgar</A>
, we are informing the process name: <I>buyticket </I><SPAN STYLE="font-style: normal">and
the user ir </SPAN><I>edgar </I><SPAN STYLE="font-style: normal">,
and the result we can expect is a text with process id as the text
returned via Http, see the following image:</SPAN></FONT></P>
<P STYLE="font-style: normal"><IMG SRC="rest1.png" NAME="graphics2" ALIGN=LEFT WIDTH=785 HEIGHT=282 BORDER=0><BR CLEAR=LEFT><BR><BR>
</P>
<P STYLE="font-style: normal"><FONT COLOR="#000000">After execute our
method, the process instance id is <B>124</B><SPAN STYLE="font-weight: medium">,
this id might be used for this process interaction, at this moment,
my application is used a process which was deployed in my Process
Server, and then we can create a new instance from the process called
</SPAN><B>buyticket </B><SPAN STYLE="font-weight: medium"><I>, </I>so
everything is stored in the database, and we can create any kind of
information based on database tables about our process instances,
such as: “Execution time”, “Troubleshooting”  and so on. </SPAN></FONT>
</P>
<P STYLE="font-style: normal; font-weight: medium"><FONT COLOR="#000000">Now,
it's time to see our JBoss jBPM Console in action, take a look on my
process listing and you can see the process instance id: <B>124</B></FONT></P>
<P STYLE="font-style: normal"><IMG SRC="rest2.png" NAME="graphics3" ALIGN=LEFT WIDTH=858 HEIGHT=534 BORDER=0><BR CLEAR=LEFT><BR><BR>
</P>
<P STYLE="font-style: normal; font-weight: medium"><FONT COLOR="#000000">And
you can see where in the process, you process instance actually is
stopped:</FONT></P>
<P STYLE="font-style: normal; font-weight: medium"><IMG SRC="rest3.png" NAME="graphics4" ALIGN=LEFT WIDTH=1051 HEIGHT=789 BORDER=0><BR CLEAR=LEFT><BR><BR>
</P>
<P><FONT COLOR="#000000">Now, it's time to navigate through the
process instance, so I will execute the following rest URL:
<A HREF="http://192.168.161.1:8080/flowlet/signal/process/124/edgar">http://192.168.161.1:8080/flowlet/signal/process/124/edgar</A>
, the result are the following screen shots:</FONT></P>
<P><IMG SRC="rest4.png" NAME="graphics5" ALIGN=LEFT WIDTH=782 HEIGHT=271 BORDER=0><BR CLEAR=LEFT><BR><BR>
</P>
<P><FONT COLOR="#000000">This method, basically execute the <I>signal
</I><SPAN STYLE="font-style: normal">into the process instance, and
move the process to the next node, as far you can in the result and
in the following image in the jBPM Console:</SPAN></FONT></P>
<P STYLE="font-style: normal"><IMG SRC="rest5.png" NAME="graphics6" ALIGN=LEFT WIDTH=1054 HEIGHT=787 BORDER=0><BR CLEAR=LEFT><BR><BR>
</P>
<P><SPAN STYLE="font-style: normal"><FONT COLOR="#000000">Adding the
variables based on HttpServletRequest shall be executed using the
following URL:
<A HREF="http://192.168.161.1:8080/flowlet/process/124/add/var?payment=Yes&amp;blog=Edgar"></A><A HREF="http://192.168.161.1:8080/flowlet/process/124/add/var?payment=Yes&amp;blog=Edgar">http://192.168.161.1:8080/flowlet/process/124/add/var?payment=Yes&amp;blog=Edgar</A><A HREF="http://192.168.161.1:8080/flowlet/process/124/add/var?payment=Yes&amp;blog=Edgar"></A>
, so based on the Java Web technologies, you can assume that you have
2 variables: <I>payment </I>and <I>blog</I>, so what we wanna do now
is to transfer these variables from http context, which are durable
just while the server is running or some clustering replication in
really durable information stored in the database as <I>process
variables. </I>In addition to this capacity, imagine that we need
some variable to define some execution path in the process instance
handling, like a decision handler based on some expression(EL) based
on some variable, for instance: <B><I> </I></B></FONT></SPAN><B><FONT SIZE=2 STYLE="font-size: 11pt"><FONT FACE="Courier New, monospace"><FONT COLOR="#7f007f">expression</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#2a00ff">'#{payment==&quot;No&quot;}'</FONT></FONT></FONT></B><FONT COLOR="#000000"><SPAN STYLE="font-weight: medium"><SPAN STYLE="font-style: normal">;
this expression can decide in the decision-node </SPAN></SPAN><B><I>“Is
Payment Approved?” </I></B><SPAN STYLE="font-weight: medium"><SPAN STYLE="font-style: normal">which
path(direction) the process will go as the next execution node and
transitions. See the results in the following images:</SPAN></SPAN></FONT></P>
<P STYLE="font-style: normal; font-weight: medium"><IMG SRC="rest6.png" NAME="graphics7" ALIGN=LEFT WIDTH=954 HEIGHT=351 BORDER=0><BR CLEAR=LEFT><BR><BR>
</P>
<P STYLE="font-style: normal; font-weight: medium"><FONT COLOR="#000000">Now,
we can signal the process again, and the results in our <B>jBPM
Server </B><SPAN STYLE="font-weight: medium">could be as the
following </SPAN><B><I>:</I></B></FONT></P>
<P><IMG SRC="rest7.png" NAME="graphics8" ALIGN=LEFT WIDTH=992 HEIGHT=780 BORDER=0><BR CLEAR=LEFT><BR><BR>
</P>
<H3>Conclusion</H3>
<P STYLE="font-style: normal; font-weight: medium"><FONT COLOR="#000000">Basically,
as far you can see <B>Process Server </B><SPAN STYLE="font-weight: medium">is
something beyond a product, can be a <I>concept </I><SPAN STYLE="font-style: normal">that
you can apply in many different ways, and one of that, for sure could
be using Open-Source technologies, such as we had shown here on this
entry.</SPAN></SPAN></FONT></P>
<P STYLE="font-style: normal; font-weight: medium"><BR><BR>
</P>
<P><BR><BR>
</P>
<P STYLE="font-style: normal; font-weight: medium"><BR><BR>
</P>
<P><BR><BR>
</P>]]>

</content>
</entry>
<entry>
<title>Some thoughts about opensource BPMs</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/edgars/archive/2008/06/some_thoughts_a.html" />
<modified>2008-06-23T21:45:09Z</modified>
<issued>2008-06-23T21:44:45Z</issued>
<id>tag:weblogs.java.net,2008:/blog/edgars/338.10011</id>
<created>2008-06-23T21:44:45Z</created>
<summary type="text/plain">This is an entry where we discuss a little about BPM and tis relation with OSS world.</summary>
<author>
<name>edgars</name>

<email>edgar.silva@redhat.com</email>
</author>
<dc:subject>Business</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/edgars/">
<![CDATA[<p>Business Processing Modeling – BPM, I was starting my career when I heard the word “Workflow” by the first time, of course I had many other things to learn, instead to pay attention on some thing that seems to be too complicated, however in during any computer science or related course we learn some about “State Machines”, well, I wanna tell you a history that I heard when I worked for one of the biggest  federal bank in Brazil: Workflow products had arrived down here in end of 90's, this bank tried implement a Workflow, although instead to map the the activities into a “State Machine Diagram” where would be possible figure out where the process's drawbacks or too long waits came from, they mixed business logic to process logic, obtaining serious performance problems and not too accurate information, the word “workflow” was abolished for a long time on this bank after this first frustrated try. Maybe, such things like that happened in all over the world, that's why during too much time, the concept to try get the company's process and map all of them represented using cool colored diagrams, which internally are not much more than a “State Machine”. The workflow products getting started so to hibernate, and then as a “pheonix” are relaunched but now with a new name: BPM (Business Process Modeling)! Maybe now, many people will stop to read this entry, but sorry, I can't figure out BPM in any other way, but now it is dressed much better, with new terminologies and concepts that make it “hot” or “fashion”. </p>

<p>All the text above is just to call your attention for BPM Opensource implementations as an alternative for commercial licensing vendors,as such alternatives I can recommend you the following: OSWorkflow, IntalioBPM and jBPM, actually I respect all of them, but I've been using jBPM most frequently, that's why I will point some about it here. But, I recommend you take a look about the other ones. From this point of this entry, I don't wanna promote any project marketing, in despite of the fact I wanna tell you my particular vision about jBPM as a solution, and based on my professional experience show you where and how you may apply it into your projects. </p>

<p>The best way I found to look at jBPM, is that it is a great BPM Engine, and it is not a weakness, I mean: When you think about BPM you can take many scenarios, since from modeling, management, governance and so on. JBPM is a really cool BPM framework and Engine. When you have an Application that has an internal workflow with a complete User Interface or a set of Services to do everything you want without. In other words, imagine you have a HelpDesk System built 10 years ago with OracleForms , and you have mapped a kind of workflow on that, however you never figured out how measure your business activity monitoring(BAM). Now, keep in mind that you can during your regular activities in your system call a procedure to generate a simples text file with some information, which can be used to fill information into a process execution of a  jBPM process instance, and from another system you can handle such information to get some report or any other issue. If we are speaking about text file generating, it could be a serious candidate for an ESB listener to process it, well but  ESB is out of this scope, but keep ESBs usage in mind.</p>

<p>In general, jBPM can be your best option when you want embed a BPM engine into your application, good scenarios contributes for that, such as: JBPM has a native extensible and open language called jPDL, that can process both HumanTasks in addition to invoke WebServices via Java components, it counts with BPEL support as well. In a near future, jBPM will have a PVM(Process Virtual Machine), which basically is “State Machine Framework”, which will render a process independent from the language source, support for BPEL, XPDL using PVM are in the plans of jBPM new versions. A really nice Eclipe plugin where is possible design all process visually, in addition to this, you can use Java components to interact with Node events(node-enter, node-leave for example) or during a transition from a node to another, and everything associating Java objetcs to some specific event during the process execution. The last good reason to use jBPM is the Seam intergration, which make the process management really easy for any developer.</p>

<p>For sure, that you may use jBPM as a “BPM Suite” as well, but keep in mind that you will keep Business Analyst designing the process in UML or in some BPMN tool, and you will need a tech-guy to transform this design in to a jpdl diagram, where a Eclipse plugin is available.</p>

<p>By the way, when you made an option by use an Opensource engine such as jBPM, you can do that because your plan can be get culture about BPM first, and it is really important for a SOA strategy. No matter if you have many boxes with SOA solutions with you have no idea how use them, and even worst when you already paid for them. </p>

<p>Well, if you need more information, you can go to <a href="http://www.jboss.org/jbossjbpm">jBPM web site</a>, and download the lastest jbpm-jpdl-suite, which contains the framework and the eclipse plugin all together. Watch the demos, and take a look into documentation.</p>]]>

</content>
</entry>
<entry>
<title>Using DWR inside a Portlet deployed into JBoss Portal</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/edgars/archive/2007/12/using_dwr_insid_1.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2007-12-11T16:14:51Z</issued>
<id>tag:weblogs.java.net,2007:/blog/edgars/338.8802</id>
<created>2007-12-11T16:14:51Z</created>
<summary type="text/plain">This entry shows how create a simple portlet using DWR as an Ajax framework inside a Portlet running on JBoss Portal. </summary>
<author>
<name>edgars</name>

<email>edgar.silva@redhat.com</email>
</author>
<dc:subject>Community: Portlet</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/edgars/">
<![CDATA[<p>JBoss Portal is in its 2.6.2 GA version, which counts with an easy administration console, however it also counts with a strong foundation in terms of technologies.</p>

<p>In other hand, you have DWR (Direct Web Remoting), which provide you many interesting features in its 2.0 version, such as Comet(see some <strong>Grizzly</strong>). In my point of view a great approach behind the scenes in DWR is hide the Java Script from Java developers like. Un/fortunately I can use the time I would spend studing it for focus in other technologies.</p>

<p>I've been using Netbeans for Portlets development, in fact a portlet is an Web Application with some additional configuration files (xml). Basically, my structure for this sample is:</p>

<pre>
--portletdwr
---src (Java Sources)
---web (Web sources)
-----WEB-INF
---------lib (libraries)
---------classes (classes)
---------jsp (my jsp)
------------dwr (my jsp)
---------------view.jsp (my jsp)
---------web.xml (standard web descriptor)
---------dwr.xml (dwr descriptor)
---------dwrobject.xml (portlet dwr descriptor)
---------portlet.xml (standard portlet descriptor)
---------jboss-app.xml (jboss portal descriptor)

<p><br />
</pre></p>

<p>Basically, in order to compile your examples you need the portlets API jars, where you can find in JBoss Portal if you want. In addition, you must have available the dwr.jar and other dependencies as well. You can see the entire project here on <a href="http://weblogs.java.net/blog/edgars/archive/portletdwr.zip">this zip file</a>.</p>

<p><strong>Creating a Portlet Controller</strong></p>

<p>If you have any other MVC experience, for example Struts or WebWork, you will see that the javax.portlet.GenericPortlet works as a Controller, handling http requests and dispatching responses to clients. For our example with DWR you just need override the method doView(), responsible for forward the some response to be rendered by the client browser. See the following source code:</p>

<pre>
package org.jboss.portal.samples.dwr;

<p>import java.io.IOException;<br />
import javax.portlet.GenericPortlet;<br />
import javax.portlet.PortletException;<br />
import javax.portlet.PortletRequestDispatcher;<br />
import javax.portlet.RenderRequest;<br />
import javax.portlet.RenderResponse;<br />
public class DWRPortlet extends GenericPortlet {</p>

<p>@Override<br />
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {<br />
  response.setContentType("text/html");<br />
  PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher<br />
                                 ("/WEB-INF/dwr/view.jsp");<br />
   prd.include(request, response);</p>

<p>    }<br />
}</p>

</pre>

<p>The view.jsp</p>

<p>Using DWR you must create a reference with DWR gerenated scripts, the correct way to do that is use Java request objects in order to get dinamically the context path, so the src portion from Javascript references must be exactlly as you can in the following code:</p>

<pre>
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
 <portlet:defineObjects/>
<%
String contextPath = renderResponse.encodeURL(renderRequest.getContextPath());
%>
script type="text/javascript" src='<%=contextPath%>/dwr/interface/Destination.js
script type="text/javascript" src='<%=contextPath%>/dwr/engine.js   
script type="text/javascript" src='<%=contextPath%>/dwr/util.js
</pre>

<p>Everything else is exactlly the same way you can do using DWR in simple java web applications.</p>

<p><strong>References<br />
</strong><br />
- DWR (<a href="http://getahead.org/dwr/getstarted">http://getahead.org/dwr/getstarted</a>)<br />
- JBoss Portal (<a href="http://labs.jboss.com/jbossportal/">http://labs.jboss.com/jbossportal/</a>)</p>

<p><strong>Screeshots</strong></p>

<p><img alt="JBoss Portal 2.6.2-GA - Mozilla Firefox-1.png" src="http://weblogs.java.net/blog/edgars/archive/JBoss Portal 2.6.2-GA - Mozilla Firefox-1.png" width="826" height="427" /></p>]]>

</content>
</entry>
<entry>
<title>JBoss ESB 4.2 - New Editors</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/edgars/archive/2007/10/jboss_esb_42.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2007-10-02T14:58:25Z</issued>
<id>tag:weblogs.java.net,2007:/blog/edgars/338.8354</id>
<created>2007-10-02T14:58:25Z</created>
<summary type="text/plain">This post covers some new features in JBoss ESB 4.2</summary>
<author>
<name>edgars</name>

<email>edgar.silva@redhat.com</email>
</author>
<dc:subject>Community: Java Enterprise</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/edgars/">
<![CDATA[<p>I am very happy with new features inside JBoss ESB 4.2, mainly about Consoles and Editors! Yep, JBoss is well knowed by their black console screens logging everything you want into console/cms window. However, in the SOA World, some visual effort is required to be considered "An Enterprise Player", so far, some of this requirements are present in JBoss ESB 4.2.
</p>
<h3>JBoss ESB Config Console</h3>
<p>
Now, you can specify your providers, services and servers with no XML anymore (if you really prefer), so take a look in the following images:
<br>
<img alt="Screenshot-ESBConfigEditor.swf (application-x-shockwave-flash Object) - Mozilla Firefox.png" src="http://weblogs.java.net/blog/edgars/archive/Screenshot-ESBConfigEditor.swf (application-x-shockwave-flash Object) - Mozilla Firefox.png" width="972" height="756" />
<br>
<img alt="Screenshot-ESBConfigEditor.swf (application-x-shockwave-flash Object) - Mozilla Firefox-1.png" src="http://weblogs.java.net/blog/edgars/archive/Screenshot-ESBConfigEditor.swf (application-x-shockwave-flash Object) - Mozilla Firefox-1.png" width="972" height="756" />
<br>
<img alt="Screenshot-ESBConfigEditor.swf (application-x-shockwave-flash Object) - Mozilla Firefox-2.png" src="http://weblogs.java.net/blog/edgars/archive/Screenshot-ESBConfigEditor.swf (application-x-shockwave-flash Object) - Mozilla Firefox-2.png" width="972" height="756" />
</p>
<p>
Not only JBoss ESB, but jBPM also counts with a new Console, which allows user's interactions and proccess management.
<br>
<img alt="Screenshot-JBoss jBPM Administration Console - Mozilla Firefox.png" src="http://weblogs.java.net/blog/edgars/archive/Screenshot-JBoss jBPM Administration Console - Mozilla Firefox.png" width="972" height="756" />
</p>
<p>
JBoss ESB team is working hard to provide a high level set of tools to turn easier commons taks we have been doing day by day in terms of ESB Applications. 
</p>]]>

</content>
</entry>
<entry>
<title>MockSoft: Just for fun</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/edgars/archive/2007/08/mocksoft_just_f.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2007-08-29T12:05:02Z</issued>
<id>tag:weblogs.java.net,2007:/blog/edgars/338.8126</id>
<created>2007-08-29T12:05:02Z</created>
<summary type="text/plain">This entry introduce you the MockSoft (just for fun, a Dilbert-like site)</summary>
<author>
<name>edgars</name>

<email>edgar.silva@redhat.com</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/edgars/">
<![CDATA[Take a look on this: <a href="http://www.killrates.com/">http://www.killrates.com</a>/

Check it out some cartoons like that:

<img src="http://www.killrates.com/strips/en-10.gif">

Have fun!]]>

</content>
</entry>
<entry>
<title>Understanding jBPM based on Struts background</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/edgars/archive/2007/08/understanding_j_1.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2007-08-28T10:45:25Z</issued>
<id>tag:weblogs.java.net,2007:/blog/edgars/338.8117</id>
<created>2007-08-28T10:45:25Z</created>
<summary type="text/plain">This entry aims make you understand some jBPM issues based on Struts background.</summary>
<author>
<name>edgars</name>

<email>edgar.silva@redhat.com</email>
</author>
<dc:subject>Community: Java Enterprise</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/edgars/">
<![CDATA[When you try teach anything new for someone, IMHO the easiest way is to do that relating with something you already know. So far Struts is a framework that almost everybody touched at least once. So I will use some of Strtus concepts to explain jBPM process execution.

<h3>Process Languages</h3>

jBPM is not just a Process Machine, locked in just one way to promote interaction between tasks, in fact jBPM is a process-language engine, which you can use JPDL, Seam Page Flow or even BPEL as an execution language. By default, jBPM uses JPDL, however you may use others. 

<h3>Understanding a Process</h3>

A process shall be a number of tasks described in several flows, which depending of some condition or behavior you may get different ways. So I will show you guys a very simples process, where you can see an expenses-report approval process:
<p align="center">
<img alt="processimage.jpg" src="http://weblogs.java.net/blog/edgars/archive/processimage.jpg" />
<p>


<p>We have just one TASK, so we may think we have just one ACTION, so is really easy to compare a process execution context with a HttpSession execution context, because both may have variables, a sequence of facts and interactions with Systems or Humans. But you may ask: “What? Are you trying convince that a Process Execution Instance may be as simple as an HttpSession?”. My answer: Exactly!
<h3>Creating a Servlet Controler to handle the Process execution </h3>

In jBPM a task is represented by a Token, each one has a name, in addition may have an action associated with some event. These events can be for example “node-enter”, “node-leave”, so we must tell via a Servlet forward the execution for a specific Node, which in that case can be our Action (like in Struts).

<pre>
 public class ServletBPM extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {

	ProcessDefinition processDefinition;
	
	static JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
	
	static JbpmContext bpmContext = jbpmConfiguration.getCurrentJbpmContext(); 

....

	public void init() throws ServletException {
		super.init();
		processDefinition = 
ProcessDefinition.parseXmlInputStream
(getServletContext().getResourceAsStream
("/WEB-INF/processes/reembolso/processdefinition.xml"));
		}


	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		ProcessInstance instance = 
			new ProcessInstance(processDefinition);
		
		instance.getContextInstance().setVariable("request", request);
		instance.getContextInstance().setVariable("response", response);

		Token token = instance.getRootToken();

		String acao = request.getParameter("action");
		
        token.signal(acao);
        }

</pre>
 Look that into doGet method we are creating a new ProcessInstance and putting 2 variables (request and response), and through the value into parameter action, we know the node(task) to execute, in other words, the “Action” to execute.

When you can the method signal is fired, this Token invoke its associated Action class, which may be similar to common Action from Struts. Take a look on the following piece of code:
<pre>
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;

import br.com.redhat.bpm.pojo.Reembolso;

public class EntregaReportAction implements ActionHandler {
	
	HttpServletRequest request;
	
	HttpServletResponse response;
	

	private static final long serialVersionUID = -2649703227240922449L;

	public void execute(ExecutionContext ctx) throws Exception {
		
		//getting an HttpResponse from Context
		
		request = (HttpServletRequest) ctx.getVariable("request");
		
		response =  (HttpServletResponse) ctx.getVariable("response");
		
		
		Reembolso r = new Reembolso();
		
		r.setFuncionario(request.getParameter("funcionario"));
		
		r.setPeriodo(request.getParameter("data"));
		
		r.setValor(new Double(request.getParameter("valor")));
		
		
                       JPAResolver.getResolver(Reembolso.class).save(r);
		
		RequestDispatcher rd = request.getRequestDispatcher("aguardeProcessamento.jsp");
		
		rd.forward(request, response);

	}

</pre>
So, as you can see this ActionHandler gets the request and response variables from the process context and execute some business logic and from this ActionHandler we forward the next page, quite similar we can do with Struts's Action, or much easier based on  Seam Framework.
<p>
Keep in mind that all context variables and process instance you may store into a Database for any other further information or management. 
<p>
<h3>Conclusion</h3>

BPM is not a so complicated discipline inside SOA world, however I've talked with many people in Brazil with some difficulties to understand some BPM Concepts.  I hope this post help no only my Brazilian friend but anybody with similar doubts about that. ]]>

</content>
</entry>
<entry>
<title>Grizzly Facts</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/edgars/archive/2007/07/grizzly_facts_1.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2007-07-30T18:00:12Z</issued>
<id>tag:weblogs.java.net,2007:/blog/edgars/338.7330</id>
<created>2007-07-30T18:00:12Z</created>
<summary type="text/plain">This is entry shares some of Grizzly Facts.</summary>
<author>
<name>edgars</name>

<email>edgar.silva@redhat.com</email>
</author>
<dc:subject>Open Source</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/edgars/">
<![CDATA[Hi everyone,

<p> We are living in the collaborative times, so I would like to introduce you now the Grizzly Facts!
<p> Grizzly is an awesome NIO framework, you can solve any kind of related non-blocking IO and even other issues using Grizzly, however one of its Core-Developers: <a href="http://weblogs.java.net/blog/jfarcand/">Jean-Francois Arcand</a>, <a href="http://blogs.sun.com/charliebrown/">Charlie Hunt</a> and I created a "joke" in last <a href="http://fisl.softwarelivre.org/">FISL</a> in Porto Alegre(Brazil) to make Grizzly even more popular, so We created: <strong>Grizzly FACTS</strong>!
<p>So now, please publish here your Grizzly Fact as a Comment in this entry please! I will publish some now in the Comments Section now!]]>

</content>
</entry>
<entry>
<title>Looking as deep as possible with JBoss Profiler</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/edgars/archive/2007/06/looking_as_deep.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2007-06-14T06:22:01Z</issued>
<id>tag:weblogs.java.net,2007:/blog/edgars/338.7631</id>
<created>2007-06-14T06:22:01Z</created>
<summary type="text/plain">This entry talks about how enable JBoss Profiler for pre-production Applications using JBoss AS as the solution for Application Server JEE.</summary>
<author>
<name>edgars</name>

<email>edgar.silva@redhat.com</email>
</author>
<dc:subject>Deployment</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/edgars/">
<![CDATA[<p>I will show you now how you can use JBoss Profiler as your default choice for pre-production profiling tests.
<h2>Step 1 - Download the JBoss Profiler </h2>
<p>Go to the JBoss Profiler Project page <a href="http://labs.jboss.com/jbossprofiler/">here</a>, and download the CR4 Version from that page</p>

<h2>Step 2 - For Linux Users </h2>
<p>
  Copy to /usr/lib the file libjbossInspector.so from <JBOSS_EXTRACTED_FOLDER>/jvmpi/linux. You should put on this folder, because for Linux it works as Windows/System, so for Windows users, please copy the .dll file from jvmpi/windows into your System folder.
</p>

<h2>Step 3 - Testing your Java Library Loading </h2>
<p>
You can test if Java is really loading our profiler Library, to do that execute the following command line in console: <br>

<pre> 
[root@esilva jdk1.5.0_12]# java -XrunjbossInspector:/tmp Foo
Running process 9330
Exception in thread "main" java.lang.NoClassDefFoundError: Foo

</pre> 
If you see on the screen a result like that, you library is working fine.
</p>

<h2>Step 4 - Deploying a Spring Sample: countries.war for Profiling issues </h2>
<p>
After to build the sample using ANT, I copied the war file to my JBOSS_HOME/servers/default/deploy and that´s all! It is ready to be deployed.
</p>

<h2>Step 5 - Deploying the profiler Agent into JBoss AS </h2>
<p>
Go to JBOSS_PROFILER_EXTRACTED_FOLDER and from there, copy to JBOSS_HOME/servers/default/deploy the file: jboss-profiler-noAOP.sar. This is a JMX agent, which could be useful for you. Don't forget to deploy the jboss-profiler.war file into JBoss as well.
</p>

<h2>Step 6 - Setting JAVA_OPTS enviroment variable and starting JBoss  </h2>
<p>
We will check what happens with class inside packages beggining with org.springframework , in addition the profiler will keep the results into a folder located in /opt/profiledata. So to make it possible, we must export the variable JAVA_OPTS, and after this we can run JBoss AS. 
</p>
<p> 
Declaring JAVA_OPTS:
<pre>
  export JAVA_OPTS=-XrunjbossInspector:/opt/profiledata,include=org.springframework,ignore=*,
</pre>
And after you can start JBoss using the command ./run.sh from folder JBOSS_HOME/bin.
</p>
<p>
As sooner you see JBoss starting, you will see a proccess identifier, this number will be useful for us to start the profiling task. 
</p>

<h2>Step 7 - Profiling the Application </h2>
<p>
I prefer the hard-core way to start to profile the Application, first of all you must go to the command-line window, and type:
<pre>
 ps ax
</pre>
You will see a resulting screen as the following:
<pre>
 7865 pts/0    S+     0:00 /bin/sh ./run.sh
 7888 pts/0    Sl+    5:44 /opt/jdk1.5.0_12/bin/java -Dprogram.name=run.sh -serv
 8011 pts/1    S      0:00 su
 8014 pts/1    S      0:00 bash
 9928 ?        S      0:00 pickup -l -t fifo -u
10061 ?        Z      0:00 [ifconfig] <defunct>
10062 pts/1    R+     0:00 ps ax
[root@jsilva jdk1.5.0_12]# 

</pre>
So, you if you are using Sun's JDK you might use the kill -3 command in the proccess number 7888, and than if you go to the other screen where you can see JBoss output, you will see profiler initializing. Than the full syntax is the following:
<pre>
kill -3 7888
</pre>
And then, in the JBoss output window you will see messages like the followin:
<pre>
JBossProfiler:GCSTART
JBossProfiler:GCFINISH
ContendedEnter ThreadId -1428133384 681764947
ContendedEnterED ThreadId -1428133384 681764949
ContendedEnter ThreadId -1428133720 681764949
ContendedEnter ThreadId -1428133832 681764949
ContendedEnterED ThreadId -1428133832 681764950
ContendedEnterED ThreadId -1428133720 681764951
ContendedEnter ThreadId -1428133944 681764952
ContendedEnter ThreadId -1428134056 681764952
ContendedEnter ThreadId -1428134280 681764952
ContendedEnterED ThreadId -1428133944 681764952
ContendedEnterED ThreadId -1428134280 681764952
ContendedEnterED ThreadId -1428134056 681764952
ContendedEnter ThreadId -1428133944 681765959
ContendedEnterED ThreadId -1428133944 681765960
ContendedEnter ThreadId -1428134280 681766962
ContendedEnterED ThreadId -1428134280 681766963
ContendedEnter ThreadId -1428133944 681766966
ContendedEnterED ThreadId -1428133944 681766966
ContendedEnter ThreadId -1428133720 681767971
ContendedEnterED ThreadId -1428133720 681767972
ContendedEnter ThreadId -1428133608 681768978
ContendedEnterED ThreadId -1428133608 681768978

</pre>
You profiler is running, so go to the Application http://localhost:8080/countries and try to do some simple tests.
</p>
<p>
If you wanna stop Profiler, please call the kill -3 process # again, and than on the folder you had selected on the JAVA_OPTS variable contains many files which profiler will proccess and show you the results.
<p>
<p>Now, it's time to see the JBoss-Profiler User Interface, so type http://locahost:8080/jboss-profiler and than you will see the Profiler UI, click in the Runtime Profiler link and inform the folder where profiler is actually storing the informations, in our case: /opt/profiledata and click next. See the image 1:</p>
<img alt="profiler1.png" src="http://weblogs.java.net/blog/edgars/archive/profiler1.png" width="853" height="653" />
<br>Image 1 - The Profiler Initial Screen
<p>
And then inform the proccess number,in the next screen: <br>
<img alt="profile2.png" src="http://weblogs.java.net/blog/edgars/archive/profile2.png" width="853" height="653" />
<br>Image 2 - Getting a specific process execution

</p>
<p>
After the processing phase, you will able to identify some drawbacks into your Application. See the last image as an example: <br>
<img alt="profiler3.png" src="http://weblogs.java.net/blog/edgars/archive/profiler3.png" width="853" height="653" />

</p>

<p>I hope it could be as useful for you as it have been these last days for me! See you!</p>]]>

</content>
</entry>
<entry>
<title>JavaOne 2007 finished, time to flight back to Brazil</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/edgars/archive/2007/05/javaone_2007_fi.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2007-05-13T21:37:16Z</issued>
<id>tag:weblogs.java.net,2007:/blog/edgars/338.7388</id>
<created>2007-05-13T21:37:16Z</created>
<summary type="text/plain">Just some comments about JavaOne 2007</summary>
<author>
<name>edgars</name>

<email>edgar.silva@redhat.com</email>
</author>
<dc:subject>Community</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/edgars/">
<![CDATA[<p>This JavaOne was really cool and special for
Brazilians,&nbsp; I would like to point the following facts there: </p>
<ul>
  <li><span style="font-weight: bold;">Fabiane Nardon</span>,
as the member of OpenJDK Board, not only I am agree
completely&nbsp; that she deserve it but also I am sure she can
contribute with same passion, quality and enthusiasm that everybody can
see at Java Tool Community in Java.Net.</li>
  <li><span style="font-weight: bold;">JEDI Project</span>
is growing up, and with help of guys such as <span
 style="font-weight: bold;">Daniel de Oliveira</span>
in Brazil, and even <span style="font-weight: bold;">Felipe
Gaucho</span> in Switzerland, those guys can deliver Java
Learning with quality and passion no matter where they are.&nbsp;</li>
  <li>I met people from<span style="font-weight: bold;">
UOL - Universo Online</span> and <span
 style="font-weight: bold;">Petrobras</span> there,
well it's not an advertisement, however is a way I can say
congratulations to those&nbsp;people behind the scenes, in fact
their managers in Brazil and to say that is really relevant to attend
at JavaOne. If there are other Brazilians companies as sponsors for
their professionals, please let me know, I can add it here as soon as
you send this information to me.</li>
  <li>I attend on <span style="font-weight: bold;">Vinicius
Senger</span> and <span style="font-weight: bold;">Felipe
Leme's</span> Session, was very good, congratulations my friends.</li>
  <li>Unfortunatelly, due to the time, I have no chance to attend
at <span style="font-weight: bold;">Michael's Session</span>
(Date and Time API), but as far as I heard about comments, they did a
good job as well.&nbsp;</li>
  <li>My friend <span style="font-weight: bold;">Juggy</span>
was a really good <span style="font-weight: bold;">speaker</span>
at JavaOne, he spoke on the session talking about Open for Business.
Congratulations Juggy!</li>
  <li>I don't like to talk about myself , in third person I hate,
but I would like to say Thanks again for the big audience tuesday and
friday on the <span style="font-weight: bold;">TS 4721</span>.
I talked to Fabiane (co-speaker) about the impressive number and
quality of people in the audience, some people asking and talking about
the subject of our talking: EJB 3.0 - New Design Patterns. For me as one of 
really good things was to talk with Linda DeMichiel in the end of the
session, besides a lot of e-mails that I still have to answer.
Fabiane said that the Session from friday was better (Guys is really
complicated to make Fabiane laugh or smile with a joke). I think the
first one was better and I was less tired than friday, at least the joke about Session Facade and Waiter
worked pretty good. Summarizing we have more or less<span
 style="font-weight: bold;"> </span>from<span
 style="font-weight: bold;"> </span><span
 style="font-weight: bold;">2300(Tuesday+Friday) </span>people
attending this session, thanks each one of you.</li>
<li>I talked and met so many people that if I try do a list for sure I will forget some names, but there are people that I have also to say thanks here, such as my co-workers at JBoss, in special <strong>Cindy Schenek and Michael Yuan</strong>, which helped me with the logistic to go to JavaOne. </li>
  <li>Last point, perhaps not less or more relevant is about the
parties, if you go to JavaOne, keep in mind that one of the most
important event of entire event are the parties! Well, you can say:
"Are you crazy? I wanna learn more about Java!". Well, I have an advice
to share with you guys: <span style="font-weight: bold;">Go
to the parties</span>, always is a good chance to meet smart
people and until learn a lot. Well, and the following picture is to
show that : " Yes, we have women at JavaOne !", it does not means that
you can dating girls, but at least you try change some business cards, a lot of people told me that this year was impressive the number of women comparing with previous editions, congratulations Girls, because of you the JavaOne can be not only technical but really beautyful and more friendly! <p>
 I
hope to see everybody next year!&nbsp; </li>
</ul>
<div align="center">
<p><a href="http://farm1.static.flickr.com/226/496509827_c382bcf223.jpg?v=0"><img border="0"  src="http://farm1.static.flickr.com/226/496509827_c382bcf223.jpg?v=0" alt="OpenJDK party"></a>
<br><small>OpenJDK Party - I really liked this party.
</div>
]]>

</content>
</entry>
<entry>
<title>Thanks for the audience at TS 4721 in JavaOne</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/edgars/archive/2007/05/thanks_for_for.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2007-05-09T19:48:56Z</issued>
<id>tag:weblogs.java.net,2007:/blog/edgars/338.7328</id>
<created>2007-05-09T19:48:56Z</created>
<summary type="text/plain">This entry is only to say thanks to everyone present at our session (TS 4721) on tuesday morning.</summary>
<author>
<name>edgars</name>

<email>edgar.silva@redhat.com</email>
</author>
<dc:subject>Community: Java Patterns</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/edgars/">
<![CDATA[<p>First of all, thank you everyone for being present at our session TS4721, I took some pictures of you guys (almost 1700 people) to prove to my boss why it is really important to speak at JavaOne. Of course it is a joke, my boss really knows how important it is.
</p>
<p>
<strong>Fabiane</strong> and I  really worked hard to deliver as good as possible of a presentation, because we respect individually any person in the audience, We received good feedback, and it makes us really happy, Thank you. Besides, as I said in the end yesterday, some of our next steps is to publish the EJB 3 Design Patterns here on my blog, and maybe who knows into a traditional book.
<p>
I would like to remind you that We will be presenting again on Friday , so if you could not make it to tuesday's session, or would like to attend again, you are welcome there. Of course, there are some good things we can do on that second time. 

<p> <img src="http://farm1.static.flickr.com/227/491538718_c7be2d859d.jpg?v=0" alt="people">
<p> <img src="http://farm1.static.flickr.com/229/491538714_f358ace681.jpg?v=0" alt="People at TS4721"><br>
Thank you Everybody
<p>
If you have any question feel you free to reach me on edgar.silva (em) redhat.com . Or edgarsilva (em) gmail.com 
<p>

<p> Sincerely, Edgar Ankiewsky Silva]]>

</content>
</entry>
<entry>
<title>Moving to JBoss, a division of Red Hat</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/edgars/archive/2007/04/moving_to_jboss.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2007-04-24T23:50:48Z</issued>
<id>tag:weblogs.java.net,2007:/blog/edgars/338.7141</id>
<created>2007-04-24T23:50:48Z</created>
<summary type="text/plain">Edgar Silva talks about his moving to JBoss, a division of Red Hat.</summary>
<author>
<name>edgars</name>

<email>edgar.silva@redhat.com</email>
</author>
<dc:subject>Business</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/edgars/">
I had cool experiences and lessons working for Summa Technologies since 2004, but since last April,16th I am working for RedHat in JBoss division, as a Solution Architect in Sales Engineers department. I will be working in Brazil, in São Paulo, helping many customers to know JBoss products  and working together with our really awesome Java community here. I am learning a lot of new stuff, and as soon as possible I will be publishing some interesting stuff about JBoss, besides other subjects that I like, such NetBeans.

</content>
</entry>
<entry>
<title>TS4721 Done! And some new stuff we will show at JavaOne 2007</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/edgars/archive/2007/03/ts4721_done_and_1.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2007-03-21T21:56:10Z</issued>
<id>tag:weblogs.java.net,2007:/blog/edgars/338.6871</id>
<created>2007-03-21T21:56:10Z</created>
<summary type="text/plain">Doing our presentation for JavaOne, Fabiane Nardon and I, we had several points about what we could put on slides. Unfortunately, we can&apos;t put everything we already done using EJB3, because we have only 1 hour to speak. This post shows some stuff we decided take out from official presentation.</summary>
<author>
<name>edgars</name>

<email>edgar.silva@redhat.com</email>
</author>
<dc:subject>J2EE</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/edgars/">
<![CDATA[<p>Doing our presentation for JavaOne, Fabiane Nardon and I, we had several points about what we could put on slides. Unfortunately, we can't put everything we already done using EJB3, because we have only 1 hour to speak. This post shows some stuff we decided take out from official presentation.</P>
<h2> Patterns out from Presentation </h2>
<p>When we decided to show new Design Patterns, the main idea was to show which patterns still are on the shelf, and which are not so necessary. If you would like to learn new tricks and design patterns for EJB 3, you should consider attending this JavaOne2007 session <strong>TS 4721 - Implementing Java EE Applications, Using Enterprise JavaBeans (EJB) 3 Technology: Real-World Tips, Tricks, and New Design Patterns</strong>, so we selected only real good new design patterns, and then some of what we expected as new Design Patterns, are not so good, however, I can publish them here, and maybe I can hear some opinions. The first one is <strong>Load Data Decorator</strong>.</p>
<h2>Load Data Decorator</h2>
<p><strong><em>Problem</em></strong>:<br>
After to load or update data, maybe you want to check the value and change it for presentations issues.<br>
<strong><em>Solution</em></strong>:<br>
Use also Life Cycle Callback Methods for Entities 
</p>
<p> Look the following example: </p>
<pre>
@EntityListener (AtendeeEmailDecorator.class)
public class Atendee implements Serializable{
 …
}

</pre>
<p>Basically you register a class to act as a listener for this Entity. Check this class in the following code listing:
<pre>
public class AtendeeEmailDecorator {
    @PostLoad
    public void evaluateEmail(Atendee atendee){
       if (atendee.getEmail().indexOf("@")<=0) {
          atendee.setEmail("Email contains errors!");
       }
    }

</pre>
<p> Now, if you want to present this information into a dataTable using JSF as Client View tier, the correct information is ready to be presented.
<p> Maybe you can agree with us, and you could remove it too, or anybody else can look to this, and use it as good solution.
<p>cya.]]>

</content>
</entry>
<entry>
<title>NetBeans Dream Team as a Community Team</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/edgars/archive/2007/01/netbeans_dream.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2007-01-19T17:40:49Z</issued>
<id>tag:weblogs.java.net,2007:/blog/edgars/338.6364</id>
<created>2007-01-19T17:40:49Z</created>
<summary type="text/plain">This post talks some about the NetBeans Dream Team Project, and some initial visions.</summary>
<author>
<name>edgars</name>

<email>edgar.silva@redhat.com</email>
</author>
<dc:subject>Community: NetBeans</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/edgars/">
<![CDATA[<table>
<tr>
<td valing="top">
<p>
<a href="http://blogs.sun.com/roumen/">Roumen</a> is a really fast blogger, <a href="http://blogs.sun.com/roumen/entry/hello_netbeans_dream_team">this already </a>is in his blog =). As I am one of these guys, I wanna say thanks to NetBeans's Team, and I hope we can do a good job on <a href="http://www.netbeans.org/community/contribute/dreamteam.html">NetBeans Dream Team</a>.
</p>
<p>First of all,  we are defining how the project will work, however I can say that you will have very interesting good news, and please prepare yourself to join with us in that interesting Project.</p>
</p> 
<p> Is not so usual I write non-techinical stuff, although I would like to share a funny initial view :
<br> The NBDT is composed by 11 founding members, as I am a typical Brazilian, is really impossible don't think in Soccer! (Team+11 Players==Soccer). However, instead of the the brazilian soccer team <strong> terrible failure </strong>in the last world cup, where all players wanted the attentions individually, I am sure We have to be completelly different </strong> and to turn the <a href="http://www.netbeans.org/community/contribute/dreamteam.html">NBDT </a>an open channel where we can hear the community ,  where we can see a real good team (such as German and Italy =) on last WorldCup)!.
</p>
<p> 
I wanna also say hello to all <a href="http://www.netbeans.org/community/news/index.html#987">NBDT members</a>! There is another Brazilian involved: <a href="http://www.globalcode.com.br">Vinicius Senger</a>, which is my friend, but I guess that he prefers surf =).
</p>
<p> 
I will keep you in touch about the news from NetBeans Dream Team here on my Java.Net blog, and if you understand portuguese, you can go to my <a href="http://www.edgarsilva.com.br">PT_BR blog</a>.
</p>


</td>
<td valing="top">
<div align="right">
<img alt="Italy" src="http://www.worldcup2006news.net/wp-content/italy.jpg" width="215" height="160"/>
<br><small>Italy, the WorldCup 2006 Champion (a good example of a Team)<br>
<img alt="inter.jpg" src="http://www.elcomercio.com/nv_images/fotos/2006/12/ec23_p_deportes.jpg" width="215" height="160" />
<br><small>Internacional from Brazil, the Toyota 2006 World Champion, another good example of "No Stars...Yes Union".</small>
</div>
</td>
</table>]]>

</content>
</entry>
<entry>
<title>Simple Project Creator command line for Maven2</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/edgars/archive/2007/01/simple_project_1.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2007-01-19T01:09:57Z</issued>
<id>tag:weblogs.java.net,2007:/blog/edgars/338.6343</id>
<created>2007-01-19T01:09:57Z</created>
<summary type="text/plain">Simple Project Creator command line for Maven2</summary>
<author>
<name>edgars</name>

<email>edgar.silva@redhat.com</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/edgars/">
<![CDATA[<p>I've been using Maven 2.x, and I am very happy with their new features. I create a simple but usefeul command line to allow you create project easier. <br>
<br>If you are using Windows, you can create a file called createproject.bat , ant put the following text: 
</p>
<pre>
@ echo offecho 
Maven - Create Projects
mvn archetype:create -DgroupId=%1 -DartifactId=%2echo 
Project %2 Created sucessfully
</pre>
<p>

Then, you can create in any folder a Maven Project, calling your new command line as the following example:  <br>
<pre>
E:\java\maven2>createproject net.java.dev.greenbox greenbox2
</pre><br>
<p>See that %1 is your package, and %2 your project name. Look the output result: </p>
<pre>
E:\java\maven2>createproject net.java.dev.greenbox greenbox2

Maven - Create Projects[INFO] Scanning for projects...
[INFO]Searching repository for plugin with prefix: 'archetype'.
[INFO]org.apache.maven.plugins: checking for updates from centra
[INFO] org.codehaus.mojo: checking for updates from 
centralin-1.0-alpha-3.jar6K downloaded
[INFO] --------------------------------------
</pre>
<p>I hope it could be as useful for you as it is for me !  After execute this command, you'll can see a Maven2's project structure, <br>to put you java sources files, in addition a pom.xml file, which will guide you to build really inteligent projects :)
</p>
]]>

</content>
</entry>
<entry>
<title>Using the Java Source Editor and Syntax highlight in any JEditorPane</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/edgars/archive/2007/01/using_the_java.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2007-01-17T18:52:48Z</issued>
<id>tag:weblogs.java.net,2007:/blog/edgars/338.6347</id>
<created>2007-01-17T18:52:48Z</created>
<summary type="text/plain">This post shows how to use the NetBean´s Java Source Editor with Syntax highlight in any JEditorPane.</summary>
<author>
<name>edgars</name>

<email>edgar.silva@redhat.com</email>
</author>
<dc:subject>Community: NetBeans</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/edgars/">
<![CDATA[<p> On the my new JSF Palette Components I've been doing, It allows users get any BackingBean (bean) from the Project, to make it possible, I was looking for on <a href="http://wiki.netbeans.org/wiki/">NetBeans Dev Wiki</a>. And I get this entry: <a href="http://wiki.netbeans.org/wiki/view/DevFaqEditorJEPForMimeType">http://wiki.netbeans.org/wiki/view/DevFaqEditorJEPForMimeType</a> . However, I think this might works on NetBeans 6.0, cause doing like this entry says ... <br>
<pre>
EditorKit kit = CloneableEditorSupport.getEditorKit("text/x-java");
JEditorPane jep = new JEditorPane();
jep.setEditorKit(kit);
</pre>
<br>
<p>I in fact did not have success. But, 
NetBeans Platform, offers great resources, as I did something similar to <a href="https://greenbox.dev.java.net">Greenbox for NetBeans </a>, I did the following code for what I was needing: </p>
<br>
<pre>
      /** Creates new form JavaCodePanel */
    public JavaCodePanel() {
        initComponents();
        beanCode.setContentType("text/x-java");
        EditorKit kit = JEditorPane.createEditorKitForContentType("text/x-java");
        kit.install(beanCode);
        beanCode.setEditorKit(kit);
    }
</pre>
<br><p>
On the code the <strong>beanCode</strong> is a JEditorPane, and now this will have the same actions you can see on default Java Editor.
<br> Look on the following image this component working: </p>

<br>
<img alt="javacode.PNG" src="http://weblogs.java.net/blog/edgars/archive/javacode.PNG" width="691" height="566" />
<br>
<img alt="javacode2.PNG" src="http://weblogs.java.net/blog/edgars/archive/javacode2.PNG" width="687" height="568" />
<br>
<img alt="javacode3.PNG" src="http://weblogs.java.net/blog/edgars/archive/javacode3.PNG" width="690" height="569" />
]]>

</content>
</entry>

</feed>