<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1664614986140858201</id><updated>2011-11-27T15:59:20.922-08:00</updated><category term='Synchronous'/><category term='ValueExpression binding jsf property map HtmlInputText  dynamic control'/><category term='dynamic parameters jsf navigation'/><category term='Certification'/><category term='TimeOut'/><category term='slow'/><category term='Enterprise Applications'/><category term='BMP'/><category term='JSF Dynamic controls binding parameters'/><category term='Hibernate'/><category term='WADI'/><category term='javaxcross'/><category term='CMP'/><category term='Community Edition'/><category term='Java'/><category term='3 tier'/><category term='Swing'/><category term='n-tier'/><category term='Websphere'/><category term='SCEA'/><category term='Client-server'/><category term='JMS TemporaryQueue createTemporaryQueue Send/Response Asynchronous Synchronous TimeOut'/><category term='Response'/><category term='createTemporaryQueue'/><category term='persistence'/><category term='ORM'/><category term='Clustering'/><category term='TemporaryQueue'/><category term='.net'/><category term='JMS'/><category term='WAS CE'/><category term='Asynchronous'/><category term='scalable'/><category term='extensibility'/><category term='JDO'/><category term='How to pass SCEA 5'/><category term='JEE'/><title type='text'>Java x Cross</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://javaxcross.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1664614986140858201/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://javaxcross.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Cross</name><uri>http://www.blogger.com/profile/17985383212473053331</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>12</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1664614986140858201.post-1087357876047134244</id><published>2010-11-29T11:59:00.001-08:00</published><updated>2010-11-29T13:52:46.749-08:00</updated><title type='text'>c++ is the future? the present?</title><content type='html'>I was away for a long time, not because I don't have anything to say, just because I was working on my own product, I created d-jon (check it out in &lt;a href="http://d-jon.com"&gt;http://d-jon.com&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;But why am I telling you this? because I want to discuss what is the best language for multi-platform desktop applications.&lt;br /&gt;&lt;br /&gt;I've been working in c++ for the last few months, and I'm in love with that language, but... as most of the love experiences it started with hate... sometime ago  I'd to work in c because most of our Universities had it as the main language and you should do all the homeworks on it... as usual you felt on some typical mistakes like memory leaks, unwanted behaviours, etc. But lately I started to wonder how difficult is to create applications for desktop in java... (hey... wait, don't kick your reading, let me explain why), I'm one of the java swing lovers, I think it's a great part of java and it has a very good architecture, it's flexible and etc. &lt;br /&gt;&lt;br /&gt;But one of the problem of java desktop applications it's the java itself, imagine the following scenario. You created a desktop application and you want to distribute it, you're going to face one problem... you can redistribute the jre with your application or you could let the user use their current version (if they've any) or download the lastest jre version available on internet. Both scenarios have their own challenges, like: where am I going to put the java in order to avoid the JAVA_HOME and/or CLASSPATH environment settings problem?, what if they already have another java version required by some other applications? I know, you can install as much as java versions as you need, but that's true if you know what you're doing and face the settings in a batch file... not if you want to put your software and get 100 downloads every day and expect that each user has this knowledge. Other problems that comes to my mind, is how are you going to handle some native tasks relying on the operating system? let's use d-jon as an example of this, if I need to get the "idle time" you cannot install a hook or something using java... maybe you will jump and say: "hey!!! you can use the native calls to create this" that's true... but you'll need to create all the stuff that comes to this approach, it's not easy after all, and what if you are creating an application that will be deployed in several platforms? like linux, windows and mac? each platform has its unique APIs to do the same thing, in C you could use conditional compilation and create a different executable for each platform and that's it, if you address this in your architecture you will be able to do what ever you want. Other issues that comes to my mind, now that I wrote apple, is how to you create a native look and feel in java? it's not possible, you could use look'd feel and put your buttons with the same look as mac... but you will not be able to put the menu in the mac's main menu, like the native applications does. And what about system tray icon? I know that java implemented that in java 6... but mac does not have java 6, their last version is 5.&lt;br /&gt;&lt;br /&gt;Last, but not least, what about the swing performance? d-jon should be deployed in new computers as well as old pcs, and I need to address a very big gantt diagrams, swing is not really that good.&lt;br /&gt;&lt;br /&gt;My conclusion is... if you want to do a good shopping cart web application use java... it's the killer, if you want to use an application that will be on internet, and you don't have the money or infrastructure to create your own public server, use PHP and if you want to create a very good desktop application that will be portable across all kind of OS and architectures use C++ with Qt, GTK or any other multi-platform framework, my advice... use the right tool for the right job.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1664614986140858201-1087357876047134244?l=javaxcross.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaxcross.blogspot.com/feeds/1087357876047134244/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1664614986140858201&amp;postID=1087357876047134244' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1664614986140858201/posts/default/1087357876047134244'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1664614986140858201/posts/default/1087357876047134244'/><link rel='alternate' type='text/html' href='http://javaxcross.blogspot.com/2010/11/c-is-future-present.html' title='c++ is the future? the present?'/><author><name>Cross</name><uri>http://www.blogger.com/profile/17985383212473053331</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1664614986140858201.post-5039566437688456660</id><published>2009-10-14T12:22:00.001-07:00</published><updated>2009-10-14T12:35:08.009-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='dynamic parameters jsf navigation'/><title type='text'>Dynamic Navigation in JSF</title><content type='html'>The last two post was about the use of dynamic JSF components and properties, but the other problem I faced is referred with the dynamic navigation,&lt;br /&gt;&lt;br /&gt;"How can I extend or write a more dynamic navigation in JSF? for example to create dynamic parameters or calls to a non jsf pages with GET parameters?"&lt;br /&gt;&lt;br /&gt;Ok, here's how I solved this. In the method of the backing bean that will be called when I the button is pressed I added this code:&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 11px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;&lt;br /&gt;FacesContext currentInstance = FacesContext.getCurrentInstance();&lt;br /&gt;HttpServletResponse response = (HttpServletResponse) currentInstance.getExternalContext().getResponse();&lt;br /&gt;HttpServletRequest request = (HttpServletRequest) currentInstance.getExternalContext().getRequest();&lt;br /&gt;String url = request.getContextPath();&lt;br /&gt;if (a == 1) {&lt;br /&gt;   url += "testpage.jsp?arg1=1&amp;arg2=2";&lt;br /&gt;} else {&lt;br /&gt;   url += "testpage2.jsp?arg1=1&amp;arg2=3";&lt;br /&gt;}&lt;br /&gt;response.sendRedirect(url);&lt;br /&gt;currentInstance.responseComplete();&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;As you can see here the solution it's very simple and works very well.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1664614986140858201-5039566437688456660?l=javaxcross.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaxcross.blogspot.com/feeds/5039566437688456660/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1664614986140858201&amp;postID=5039566437688456660' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1664614986140858201/posts/default/5039566437688456660'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1664614986140858201/posts/default/5039566437688456660'/><link rel='alternate' type='text/html' href='http://javaxcross.blogspot.com/2009/10/dynamic-navigation-in-jsf.html' title='Dynamic Navigation in JSF'/><author><name>Cross</name><uri>http://www.blogger.com/profile/17985383212473053331</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1664614986140858201.post-7266658591189021136</id><published>2009-10-13T15:20:00.000-07:00</published><updated>2009-10-13T16:06:37.264-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ValueExpression binding jsf property map HtmlInputText  dynamic control'/><title type='text'>How Can I bind the jsf properties dynamically?</title><content type='html'>In my previous post I explained how you would be able to create the controls dynamically, now it's time to bring this baby alive!&lt;br /&gt;&lt;br /&gt;First, let me explain how you would create Value Expressions (that will be used by faces to get the values) and bind them to your recently created HtmlInputText,&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 11px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;&lt;br /&gt;        FacesContext facesInstance = FacesContext.getCurrentInstance();&lt;br /&gt;        Application application = facesInstance.getApplication();&lt;br /&gt;        ExpressionFactory expressionFactory = application.getExpressionFactory();&lt;br /&gt;&lt;br /&gt;        String expression = "#{myMode.myProperty}";&lt;br /&gt;        ValueExpression valExpression = expressionFactory.createValueExpression(facesInstance.getELContext(), expression, String.class);&lt;br /&gt;        &lt;br /&gt;        HtmlInputText text = new HtmlInputText();&lt;br /&gt;        input.setValueExpression("value", valExpression);&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Easy, isn't it? the first 3 lines will get the context required to create the ValueExpression, the line "String expression = ..." just creates the string expression, the one that you usually put in the value of the h:inputText in your jsf page. The next two lines create the expression and assign it to the "value" property of the html input text. You could use this in the required or rendered fields (any property that you could use as EL in your page).&lt;br /&gt;&lt;br /&gt;This solution works well if you have your properties hardcoded in your bean, but how will this work with a really dynamic solution? (if you already know them, why will you need to create all the dynamic controls in the first place?)&lt;br /&gt;&lt;br /&gt;Ok, here the Expression Language will do the trick, the Expression Language allow you to put Maps as properties in your code, so you could create your own Map to your dynamic properties and that's it! here's a sample of the Map (I will not put all the methods you should figure out how to solve the others, but it's very simple)&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 11px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;&lt;br /&gt;public class MyPropertyMap implements java.util.Map {&lt;br /&gt;     private java.util.HashMap internalMap;&lt;br /&gt;     public EntityMap() {&lt;br /&gt;         internalMap = new java.util.Map();&lt;br /&gt;         internalMap.put("PropertyA", 1);&lt;br /&gt;         internalMap.put("PropertyB", "A text property");&lt;br /&gt;         internalMap.put("PropertyC", True);&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     public Object get(Object key) {&lt;br /&gt;        return internalMap.get(key);&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     public void put(Object key, Object value) {&lt;br /&gt;        internalMap.put(key, value);&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     ... (all the other methods required by the Map interface)&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public MyModel {&lt;br /&gt;     private MyPropertyMap map = new MyPropertyMap();&lt;br /&gt;     &lt;br /&gt;     public Object getMyPropertyMap() {&lt;br /&gt;         return map;&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     public void setMyPropertyMap(MyPropertyMap map) {&lt;br /&gt;         this.map = map;&lt;br /&gt;     }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;finally your dynamic control creation should look like this:&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 11px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;&lt;br /&gt;        FacesContext facesInstance = FacesContext.getCurrentInstance();&lt;br /&gt;        Application application = facesInstance.getApplication();&lt;br /&gt;        ExpressionFactory expressionFactory = application.getExpressionFactory();&lt;br /&gt;&lt;br /&gt;        String expression = "#{myMode.myPropertyMap['PropertyA']}";&lt;br /&gt;        ValueExpression valExpression = expressionFactory.createValueExpression(facesInstance.getELContext(), expression, Integer.class);&lt;br /&gt;        &lt;br /&gt;        HtmlInputText text = new HtmlInputText();&lt;br /&gt;        input.setValueExpression("value", valExpression);&lt;br /&gt;        myPanel.getChildren().add(input);&lt;br /&gt;&lt;br /&gt;        String expression2 = "#{myMode.myPropertyMap['PropertyB']}";&lt;br /&gt;        ValueExpression valExpression2 = expressionFactory.createValueExpression(facesInstance.getELContext(), expression2, String.class);&lt;br /&gt;       &lt;br /&gt;        HtmlInputText text2 = new HtmlInputText();&lt;br /&gt;        input2.setValueExpression("value", valExpression2);&lt;br /&gt;        myPanel.getChildren().add(input2);&lt;br /&gt;&lt;br /&gt;        String expression3 = "#{myMode.myPropertyMap['PropertyC']}";&lt;br /&gt;        ValueExpression valExpression3 = expressionFactory.createValueExpression(facesInstance.getELContext(), expression3, Boolean.class);&lt;br /&gt;       &lt;br /&gt;        HtmlSelectBooleanCheckbox chk = new HtmlSelectBooleanCheckbox();&lt;br /&gt;        chk.setValueExpression("value", valExpression3);&lt;br /&gt;        myPanel.getChildren().add(chk);&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;and that's it... you have a full Dynamic page! (I hope you noticed how the 3rd parameter of the createValueExpression changed for each control, Integer, String and Boolean).&lt;br /&gt;&lt;br /&gt;Ok, with this you will have a full dynamic solution, the next part will show you how you could create dynamic navigation using dynamic parameters.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1664614986140858201-7266658591189021136?l=javaxcross.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaxcross.blogspot.com/feeds/7266658591189021136/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1664614986140858201&amp;postID=7266658591189021136' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1664614986140858201/posts/default/7266658591189021136'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1664614986140858201/posts/default/7266658591189021136'/><link rel='alternate' type='text/html' href='http://javaxcross.blogspot.com/2009/10/how-can-i-bind-jsf-properties.html' title='How Can I bind the jsf properties dynamically?'/><author><name>Cross</name><uri>http://www.blogger.com/profile/17985383212473053331</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1664614986140858201.post-4374442846363198561</id><published>2009-10-13T12:40:00.000-07:00</published><updated>2009-10-13T16:26:02.264-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JSF Dynamic controls binding parameters'/><title type='text'>Dynamic JSF</title><content type='html'>Recently I came across with a "problem", how can I create some JSF pages more dynamic than usual?, for example adding new controls on the fly using metadata from somewhere else. I decided to write this article because it's a little hard to find information about this subject, and when you find it you could not spot all the solution and all the problems that will face in the real life :D.&lt;br /&gt;&lt;br /&gt;This is not a solution I invented and I can barely remember all the links I read in order to understand the whole picture, later I will try to look at my browser history in order to compile them and give the credit they deserved.&lt;br /&gt;&lt;br /&gt;Ok, here is the description of the problem I want to solve:&lt;br /&gt;&lt;br /&gt;How can I create dynamic controls for a page that needs to be solved on runtime? the application I'm working on is a BPM engine (&lt;a href="www.bizagi.com"&gt;BizAgi&lt;/a&gt;) that constructs its pages based on metadata information stored in a DB, so it's not possible to write the controls from the beginning.&lt;br /&gt;&lt;br /&gt;The solution is fairly simple and has 3 parts:&lt;br /&gt;&lt;br /&gt;1. Dynamic creation of the controls&lt;br /&gt;2. Dynamic mapping of the properties&lt;br /&gt;3. Dynamic redirection to a JSP using parameters.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Dynamic control creation&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This is the easy part and there's a lot of documentation in internet about this subject, and the steps are easy:&lt;br /&gt;&lt;br /&gt;1. Create a Panel in your JSF page&lt;br /&gt;2. Bind the panel to a property in your backing bean&lt;br /&gt;3. Add the controls in your backing bean&lt;br /&gt;&lt;br /&gt;so, here's how it's done:&lt;br /&gt;&lt;br /&gt;create a bean class (model class) with a property of type javax.faces.component.UIPanel like this:&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 11px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;&lt;br /&gt;public class MyModel {&lt;br /&gt;   private javax.faces.component.UIPanel myPanel;&lt;br /&gt;&lt;br /&gt;   public javax.faces.component.UIPanel getMyPanel() {&lt;br /&gt;      return myPanel;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   public void setMyPanel(javax.faces.component.UIPanel myPanel) {&lt;br /&gt;      this.myPanel = myPanel;&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Next just bind it in your jsf page like this:&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 11px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;&lt;br /&gt;   &amp;lt;f:view&amp;gt;&lt;br /&gt;       &amp;lt;h:panelGrid binding="#{myModel.myPanel}"  /&amp;gt;&lt;br /&gt;   &amp;lt;/f:view&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;we're close to finish, the next step is where the fun begins, just add the code to create dynamically the controls, like this:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 11px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"&gt;&lt;code&gt;&lt;br /&gt;   public void setMyPanel(javax.faces.component.UIPanel myPanel) {&lt;br /&gt;      this.myPanel = myPanel;&lt;br /&gt;      if (myPanel.getChildCount() &lt;= 1) {&lt;br /&gt;         HtmlInputText input = new HtmlInputText();&lt;br /&gt;         input.setValue("my dynamic text");&lt;br /&gt;         myPanel.getChildren().add(input);&lt;br /&gt;      }&lt;br /&gt;   }&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;At this point, I'm sure you noticed the "getChildCount() &lt;= 1"... why is that? just because everytime the postback is called the faces framework will set the panel with the last controls added to it, if you don't control that you will get a panel with multiple text everytime you hit the "save" button. I know, you can do this in several ways, but this is an example!&lt;br /&gt;&lt;br /&gt;Ok, this is the point where all the "blog" gurus stop and you get yourself in the middle of nowhere!, you must ask questions like... how will I bind that to dynamic properties instead of static texts? or, how would I manage the state... etc.&lt;br /&gt;&lt;br /&gt;Because the blog is getting longer than I thought I will split this in some parts...&lt;br /&gt;&lt;br /&gt;&lt;a href="http://javaxcross.blogspot.com/2009/10/how-can-i-bind-jsf-properties.html"&gt;How can I bind the jsf properties dynamically?&lt;/a&gt;&lt;br /&gt;How can I send dynamic parameters to other JSPs? or JSFs?&lt;br /&gt;&lt;br /&gt;As usual please forgive my pour english, I'm hoping to improve it with every post xD&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1664614986140858201-4374442846363198561?l=javaxcross.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaxcross.blogspot.com/feeds/4374442846363198561/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1664614986140858201&amp;postID=4374442846363198561' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1664614986140858201/posts/default/4374442846363198561'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1664614986140858201/posts/default/4374442846363198561'/><link rel='alternate' type='text/html' href='http://javaxcross.blogspot.com/2009/10/dynamic-jsf.html' title='Dynamic JSF'/><author><name>Cross</name><uri>http://www.blogger.com/profile/17985383212473053331</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1664614986140858201.post-4953249491151245958</id><published>2008-09-05T12:51:00.000-07:00</published><updated>2008-09-08T15:11:54.815-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WAS CE'/><category scheme='http://www.blogger.com/atom/ns#' term='Clustering'/><category scheme='http://www.blogger.com/atom/ns#' term='Community Edition'/><category scheme='http://www.blogger.com/atom/ns#' term='Websphere'/><category scheme='http://www.blogger.com/atom/ns#' term='WADI'/><title type='text'>Websphere Application Server Community Edition (WAS CE) Clustering using WADI</title><content type='html'>by Rockfield.&lt;br /&gt;&lt;br /&gt;Working on the latest version of &lt;a href="http://www.bizagi.com/"&gt;BizAgi&lt;/a&gt;, we were looking for an app server that supported JDK 1.6, EJB 3.0 and, of course, clustering. One of our targets was WAS CE, and as the WAS CE Cluster through WADI is explained at the &lt;a href="http://publib.boulder.ibm.com/wasce/V2.1.0/en/configuring-wadi-clusters.html"&gt;IBM website&lt;/a&gt;, you might think it's easy to build. However, as long as you start following the instructions you'll soon realize it's not as simple, clear and quick as shown in there. So this will be a "for dummies" walkthrough for most people who are not expert enough to overcome the possible problems that might occur when building the cluster.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Previous considerations&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;For this specific example WAS CE 2.1 was previously installed on 2 machines called server1 and server2. No special configuration was used, just the plain default installation.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Default ports are used, and they are the same for both machines.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;In order to check the cluster behavior, a load balancing HTTP server is necessary.  A plain Apache HTTP Server installation and configuration is provided at the end of this tutorial.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:courier new;"&gt;&lt;wasce_home&gt;&lt;/wasce_home&gt;&lt;/span&gt; &amp;lt;WASCE_HOME&amp;gt; is the WAS CE installation directory.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;WAS CE cluster configuration&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;NOTE:&lt;/span&gt; These steps must be executed on both servers!&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Go to the  file &lt;span style="font-family:courier new;"&gt;&lt;wasce_home&gt;&lt;/wasce_home&gt;&lt;/span&gt; &lt;span style="font-family:courier new;"&gt;&amp;lt;WASCE_HOME&amp;gt;&lt;wasce_home&gt;/var/config/config-substitutions.properties &lt;/wasce_home&gt;&lt;/span&gt;and assign a name to each node of the cluster replacing the value of the clusterNodeName property (by default this property's value is "NODE"). For this example we used "node1" on server1 and "node2" on server2.&lt;br /&gt;&lt;pre&gt;clusterNodeName=node1&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;On the same &lt;span style="font-family:courier new;"&gt;config-substitutions.properties&lt;/span&gt; file go to the RemoteDeployHostname property and replace the default value "localhost" with the actual server name or IP address.&lt;br /&gt;&lt;pre&gt;RemoteDeployHostname=server1&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Go to the &lt;span style="font-family:courier new;"&gt;&amp;lt;WASCE_HOME&amp;gt;&lt;/span&gt;&lt;wasce_home style="font-family: courier new;"&gt;&lt;/wasce_home&gt;&lt;span style="font-family:courier new;"&gt;&lt;wasce_home&gt;/var/config/config.xml&lt;/wasce_home&gt;&lt;/span&gt; file (&lt;span style="font-weight: bold;"&gt;NOTE:&lt;/span&gt; Make sure the server is &lt;span style="font-weight: bold;"&gt;NOT &lt;/span&gt;RUNNING while editing the config.xml, because when stopped all changes made while running will get lost) and look for the following tags in order to switch the &lt;span style="font-family:courier new;"&gt;load&lt;/span&gt; property to "true" if it does exist and is set to "false":&lt;br /&gt;&lt;pre&gt;&amp;lt;module name="org.apache.geronimo.configs/tomcat6-clustering-wadi/2.1.1/car" load="true"/&amp;gt;&lt;br /&gt;&amp;lt;module name="org.apache.geronimo.configs/wadi-clustering/2.1.1/car" load="true"&amp;gt;&lt;br /&gt;&amp;lt;module name="org.apache.geronimo.configs/farming/2.1.1/car" load="true"&amp;gt;&lt;/pre&gt;&lt;span style="font-weight: bold;"&gt;NOTE: &lt;/span&gt;If the value is set to "true" while not running, when the server starts up, the load property disappears. It is only shown explicitly when its value is set to "false".&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;On the same &lt;span style="font-family:courier new;"&gt;config.xml&lt;/span&gt; file, look for the &lt;span style="font-family:courier new;"&gt;org.apache.geronimo.configs/farming/2.1.1/car &lt;/span&gt;key. You must add all the cluster nodes except for the current one which is already there by default. This is how the key would look like for our server1:&lt;br /&gt;&lt;pre&gt;&amp;lt;module name="org.apache.geronimo.configs/farming/2.1.1/car"&amp;gt;&lt;br /&gt;  &amp;lt;gbean name="NodeInfo"&amp;gt;&lt;br /&gt;     &amp;lt;attribute name="name"&amp;gt;${clusterNodeName}&amp;lt;/attribute&amp;gt;&lt;br /&gt;  &amp;lt;/gbean&amp;gt;&lt;br /&gt;  &amp;lt;gbean name="ClusterInfo"&amp;gt;&lt;br /&gt;     &amp;lt;attribute name="name"&amp;gt;${clusterName}&amp;lt;/attribute&amp;gt;&lt;br /&gt;  &amp;lt;/gbean&amp;gt;&lt;br /&gt;  &amp;lt;gbean name="org.apache.geronimo.configs/farming/2.1.1/car?ServiceModule=org.apache.geronimo.configs/farming/2.1.1/car,j2eeType=NodeInfo,name=NodeInfo2" gbeanInfo="org.apache.geronimo.farm.config.BasicNodeInfo"&amp;gt;&lt;br /&gt;     &amp;lt;attribute name="name"&amp;gt;&lt;span style="font-weight: bold;"&gt;node2&lt;/span&gt;&amp;lt;/attribute&amp;gt;&lt;br /&gt;     &amp;lt;attribute propertyEditor="org.apache.geronimo.farm.config.BasicExtendedJMXConnectorInfoEditor" name="extendedJMXConnectorInfo"&amp;gt;&lt;br /&gt;        &amp;lt;ns:javabean class="org.apache.geronimo.farm.config.BasicExtendedJMXConnectorInfo" xmlns="" xmlns:ns4="http://geronimo.apache.org/xml/ns/attributes-1.2" xmlns:ns="http://geronimo.apache.org/xml/ns/deployment/javabean-1.0"&amp;gt;&lt;br /&gt;           &amp;lt;ns:property name="username"&amp;gt;system&amp;lt;/ns:property&amp;gt;&lt;br /&gt;           &amp;lt;ns:property name="password"&amp;gt;manager&amp;lt;/ns:property&amp;gt;&lt;br /&gt;           &amp;lt;ns:property name="protocol"&amp;gt;rmi&amp;lt;/ns:property&amp;gt;&lt;br /&gt;           &amp;lt;ns:property name="host"&amp;gt;&lt;span style="font-weight: bold;"&gt;server2&lt;/span&gt;&amp;lt;/ns:property&amp;gt;&lt;br /&gt;           &amp;lt;ns:property name="port"&amp;gt;1099&amp;lt;/ns:property&amp;gt;&lt;br /&gt;           &amp;lt;ns:property name="urlPath"&amp;gt;JMXConnector&amp;lt;/ns:property&amp;gt;&lt;br /&gt;           &amp;lt;ns:property name="local"&amp;gt;false&amp;lt;/ns:property&amp;gt;&lt;br /&gt;        &amp;lt;/ns:javabean&amp;gt;&lt;br /&gt;     &amp;lt;/attribute&amp;gt;&lt;br /&gt;  &amp;lt;/gbean&amp;gt;&lt;br /&gt;&amp;lt;/module&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;NOTE: On the other hand, for our server2's configuration the &lt;span style=";font-family:courier new;font-size:100%;"  &gt;&amp;lt;attribute name="name"&amp;gt;&lt;/span&gt; tag's value would be "node1", and the &lt;span style="font-family:courier new;"&gt;&amp;lt;ns:property name="host"&amp;gt;&lt;/span&gt; tag's value would be "server1".&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Starting the cluster&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Once the node configuration is done, start the cluster nodes as you usually would if they were stand alone. In order to verify that they are clustered, on the console screen of the first running node will appear the following notification when the second node would had started:&lt;br /&gt;&lt;pre&gt;Dec 12, 2012 11:11:53 AM org.codehaus.wadi.tribes.WadiMemberInterceptor memberAdded&lt;br /&gt;INFO: memberAdded:tcp://{-84, 16, 2, 16}:4000&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Application configuration&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Add a &lt;span style="font-family:courier new;"&gt;&amp;lt;distributable/&amp;gt;&lt;/span&gt; tag in your application's web.xml file.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Check inside your deployment plan xml file, at the war definition, and add the &lt;span style="font-family:courier new;"&gt;&amp;lt;dep:tomcat-clustering-wadi&amp;gt;&lt;/span&gt; tag so it would look like this:&lt;pre&gt;&amp;lt;dep:environment&amp;gt;&lt;br /&gt;  &amp;lt;dep:moduleId&amp;gt;&lt;br /&gt;     &amp;lt;dep:groupId&amp;gt;com.javaxcross.tests&amp;lt;/dep:groupId&amp;gt;&lt;br /&gt;     &amp;lt;dep:artifactId&amp;gt;WarTest-war&amp;lt;/dep:artifactId&amp;gt;&lt;br /&gt;     &amp;lt;dep:version&amp;gt;1.0.0.0&amp;lt;/dep:version&amp;gt;&lt;br /&gt;     &amp;lt;dep:type&amp;gt;war&amp;lt;/dep:type&amp;gt;&lt;br /&gt;  &amp;lt;/dep:moduleId&amp;gt;&lt;br /&gt;&amp;lt;/dep:environment&amp;gt;&lt;br /&gt;&amp;lt;dep:tomcat-clustering-wadi&amp;gt;&amp;lt;/dep:tomcat-clustering-wadi&amp;gt;&lt;br /&gt;&lt;/pre&gt;where, of course, you should replace the groupId, artifactId and version tags with you own app's data.&lt;/li&gt;&lt;/ul&gt;&lt;span class="mw-headline"&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Application Deployment&lt;/span&gt;&lt;br /&gt;&lt;/span&gt; &lt;p&gt;In order to deploy an application on the cluster, the web console does not have the necessary options, so you must open a command console window and execute the following instruction:&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;deploy.bat --user &amp;lt;name&amp;gt; --password &amp;lt;word&amp;gt; &amp;lt;command&amp;gt; --targets &amp;lt;target&amp;gt; &amp;lt;module&amp;gt; &amp;lt;plan&amp;gt;&lt;/pre&gt;&lt;p&gt;where...&lt;br /&gt;&lt;/p&gt;    &lt;p&gt; &lt;/p&gt;       &lt;ul&gt;&lt;li&gt; you'll find deploy.bat (or deploy.sh for unix like o.s.) at &lt;span style="font-family:courier new;"&gt;&amp;lt;WASCE_HOME&amp;gt;&lt;/span&gt;&lt;wasce_home&gt;&lt;span style="font-family:courier new;"&gt;/bin/deploy.bat&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/wasce_home&gt;&lt;/li&gt;&lt;li&gt;&amp;lt;name&amp;gt; &lt;name&gt; is the username and &lt;/name&gt;&amp;lt;word&amp;gt;&lt;name&gt; &lt;word&gt; is the password you use to login the web console. Default values are: system/manager.&lt;/word&gt;&lt;/name&gt;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&amp;lt;command&amp;gt; &lt;command&gt;is the required instruction to execute, in this case could be &lt;b&gt;deploy&lt;/b&gt; or &lt;b&gt;distribute&lt;/b&gt;. The difference relies on &lt;span style="font-weight: bold;"&gt;deploy &lt;/span&gt;starting the application after the distribution, while &lt;span style="font-weight: bold;"&gt;distribute &lt;/span&gt;doesn't.&lt;br /&gt;&lt;br /&gt;&lt;/command&gt;&lt;/li&gt;&lt;li&gt;Replace &amp;lt;target&amp;gt;&lt;target&gt; with the destination repository. which must be MasterConfigurationStore, because of the cluster. If you need to know the exact data you should use on the &lt;target&gt; &lt;/target&gt;&lt;/target&gt;&amp;lt;target&amp;gt; &lt;target&gt;&lt;target&gt;tag, run GShell (&lt;wasce_home&gt;&lt;/wasce_home&gt;&lt;/target&gt;&lt;/target&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;WASCE_HOME&amp;gt;&lt;/span&gt;&lt;target&gt;&lt;target&gt;&lt;wasce_home&gt;&lt;span style="font-family:courier new;"&gt;/bin/gsh.bat&lt;/span&gt;), provided by WAS CE installation, and run the following command&lt;pre&gt;deploy/list-targets&lt;/pre&gt;to list all the posible destination repositories. Just in case you don't find MasterConfigurationStore, execute on GShell the following command&lt;pre&gt;deploy/start org.apache.geronimo.configs/farming//car&lt;/pre&gt;copy the whole MasterConfigurationStore value and add it to the command replacing the &lt;/wasce_home&gt;&lt;/target&gt;&lt;/target&gt;&amp;lt;target&amp;gt;&lt;target&gt;&lt;target&gt;&lt;wasce_home&gt;&lt;target&gt; tag&lt;target&gt;, the default value is:&lt;pre&gt;org.apache.geronimo.configs/farming/2.1.1/car?ServiceModule=org.apache.geronimo.configs/farming/2.1.1/car,j2eeType=ConfigurationStore,name=MasterConfigurationStore&lt;/pre&gt;The fist command used on GShell will ask for username and password, use the username/password combination you usually use for connecting through the web console.&lt;br /&gt;&lt;br /&gt;&lt;/target&gt;&lt;/target&gt;&lt;/wasce_home&gt;&lt;/target&gt;&lt;/target&gt;&lt;/li&gt;&lt;li&gt;&amp;lt;module&amp;gt; &lt;module&gt;is the application (ear, war or jar) you want to deploy on the cluster.&lt;br /&gt;&lt;br /&gt;&lt;/module&gt;&lt;/li&gt;&lt;li&gt; &amp;lt;plan&amp;gt; &lt;plan&gt;is the xml file with the deployment plan.&lt;/plan&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Verification of the application deployment on cluster.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Once the application has been deployed, you may check if the process ended successfully verifying the following items:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Check the virtual repository MasterConfigurationStore for the application in the machine where the deploy command was executed on, what means, look for the application in the &amp;lt;WASCE_HOME&amp;gt;/master-repository/ directory.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Check the actual repository ClusterStore for the application in &lt;span style="font-weight: bold;"&gt;all&lt;/span&gt; of the cluster nodes including the one where the deploy command was executed on, in other words, look for the application in the &amp;lt;WASCE_HOME&amp;gt;/cluster-repository/ directory&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Starting/stopping the application&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Using the web console you can start the application on each node separately. But if you want to start the application on all nodes of the cluster at the same time, you must open a command console window and execute:&lt;pre&gt;deploy.bat --user &amp;lt;name&amp;gt; --password &amp;lt;word&amp;gt; &amp;lt;command&amp;gt; &amp;lt;module&amp;gt;&lt;/pre&gt;Where...&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt; you'll find deploy.bat (or deploy.sh for unix like o.s.) at &lt;span style="font-family:courier new;"&gt;&amp;lt;WASCE_HOME&amp;gt;&lt;/span&gt;&lt;wasce_home&gt;&lt;span style="font-family:courier new;"&gt;/bin/deploy.bat&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/wasce_home&gt;&lt;/li&gt;&lt;li&gt;&amp;lt;name&amp;gt; &lt;name&gt; is the username and &lt;/name&gt;&amp;lt;word&amp;gt;&lt;name&gt; &lt;word&gt; is the password you use to login the web console. Default values are: system/manager.&lt;br /&gt;&lt;br /&gt;&lt;/word&gt;&lt;/name&gt;&lt;/li&gt;&lt;li&gt;&amp;lt;command&amp;gt; is the required instruction to execute, in this case could be &lt;span style="font-weight: bold;"&gt;start&lt;/span&gt; or &lt;b&gt;stop&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;wasce_home&gt;&lt;wasce_home&gt;&lt;name&gt;&lt;word&gt;&lt;command&gt;&lt;module&gt;&amp;lt;module&amp;gt; is the name wich the application was registered with when deployed on the master repository, for instance, com.javaxcross.tests.WASCEtest/1219953325295/car&lt;/module&gt;&lt;/command&gt;&lt;/word&gt;&lt;/name&gt;&lt;/wasce_home&gt;&lt;/wasce_home&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1664614986140858201-4953249491151245958?l=javaxcross.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaxcross.blogspot.com/feeds/4953249491151245958/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1664614986140858201&amp;postID=4953249491151245958' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1664614986140858201/posts/default/4953249491151245958'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1664614986140858201/posts/default/4953249491151245958'/><link rel='alternate' type='text/html' href='http://javaxcross.blogspot.com/2008/09/websphere-application-server-community.html' title='Websphere Application Server Community Edition (WAS CE) Clustering using WADI'/><author><name>Cross</name><uri>http://www.blogger.com/profile/17985383212473053331</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1664614986140858201.post-6428520307966613970</id><published>2008-06-20T16:27:00.000-07:00</published><updated>2008-11-18T13:40:52.618-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='TimeOut'/><category scheme='http://www.blogger.com/atom/ns#' term='JMS TemporaryQueue createTemporaryQueue Send/Response Asynchronous Synchronous TimeOut'/><category scheme='http://www.blogger.com/atom/ns#' term='JMS'/><category scheme='http://www.blogger.com/atom/ns#' term='Response'/><category scheme='http://www.blogger.com/atom/ns#' term='Asynchronous'/><category scheme='http://www.blogger.com/atom/ns#' term='createTemporaryQueue'/><category scheme='http://www.blogger.com/atom/ns#' term='Synchronous'/><category scheme='http://www.blogger.com/atom/ns#' term='TemporaryQueue'/><title type='text'>JMS Send/Response implementation</title><content type='html'>In this article I want to talk about how you will create a send/response service using JMS.&lt;br /&gt;&lt;br /&gt;There're several reasons to turn an asynchronous thing into a synchronous process, one of them is the following problem: What if you need to call an external service and you will not know how much time that will takes, but you don't want your user seat in front of the page forever? That's one of the problems I faced up some days ago, and because of that I'm writing this.&lt;br /&gt;&lt;br /&gt;Not all the JEE implementations provide a timeout for a method transaction, some of them does and you can put a timeout for a method in the vendor specific deployment descriptor, but it's not required by the EJB spec and, if you want a JEE compliant application, you should work with the specification. There's an annotation "@TimeOut" you could use, and it's a standard supported annotation, but this will not help you at all to solve this problem, but explaining the uses of timers is not the focus of this article (if you need clarification on this, just post a comment...)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;JMS Background&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The sample below uses some JMS basic concepts you need to know about, so If you surf through Internet you will find a lot of tutorials about how to write a client/server JMS stuff, and I will not copy them. In order to fully understand this article I suggest you to take a bird view of Java Sun tutorial for JEE &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/"&gt;http://java.sun.com/javaee/5/docs/tutorial/doc/&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;In the "normal" samples found in Internet you will find a typical solution, a simple java client and a simple java listener, but how everything works if the sender is an EJB Session bean and the JMS receiver is a MessageListener bean?&lt;br /&gt;&lt;br /&gt;ok, lets start with the normal sample, a client sends a message to a MessageDrivenBean and the client continues with its life.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;&lt;pre&gt;@MessageDriven(mappedName = "jms/MyQueue", activationConfig =  {&lt;br /&gt;@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),&lt;br /&gt;@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")&lt;br /&gt;})&lt;br /&gt;public class MyMessageDrivenBeanBean implements MessageListener {&lt;br /&gt;&lt;br /&gt;  public MyMessageDrivenBeanBean() {&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public void onMessage(Message message) {&lt;br /&gt;     System.out.println("Received");&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/span&gt;&lt;br /&gt;Here the server just gets the message and does nothing with it. The Client code is inside a Session bean method:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;@Resource(name = "jms/MyQueue")&lt;br /&gt;private Queue myQueue;&lt;br /&gt;@Resource(name = "jms/MyQueueFactory")&lt;br /&gt;private ConnectionFactory myQueueFactory;&lt;br /&gt;&lt;br /&gt;public void sendReceiveMessage() {&lt;br /&gt;   try {&lt;br /&gt;       Connection conn = myQueueFactory.createConnection();&lt;br /&gt;       Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);&lt;br /&gt;       TextMessage textMessage = session.createTextMessage("Test");&lt;br /&gt;       MessageProducer producer = session.createProducer(myQueue);&lt;br /&gt;       producer.send(textMessage);&lt;br /&gt;       producer.close();&lt;br /&gt;       session.close();&lt;br /&gt;       conn.close();&lt;br /&gt;   } catch (JMSException ex) {&lt;br /&gt;       Logger.getLogger(ClientBean.class.getName()).log(Level.SEVERE, null, ex);&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The client code does not have anything new; it just creates a connection, a jms session with this connection, a Text Message and sends it to the JMS pool.&lt;br /&gt;&lt;br /&gt;What's next? We will send a callback in the client message and it'll try to listen for a response on it.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;JMS Callback&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;        // Creates a callback queue&lt;br /&gt;       TemporaryQueue tempQueue = session.createTemporaryQueue();&lt;br /&gt;       textMessage.setJMSReplyTo(tempQueue);&lt;br /&gt;       producer.send(textMessage);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;With this simple code we created a new Queue that will exists only for the current Connection, and will let us receive the response message, and here is the code to receive that message:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;        conn.start();&lt;br /&gt;       MessageConsumer consumer = session.createConsumer(tempQueue);&lt;br /&gt;       Message response = consumer.receive(10000);&lt;br /&gt;       if (response != null) {&lt;br /&gt;           System.out.println("Response received");&lt;br /&gt;       } else {&lt;br /&gt;           System.out.println("Response not received due to timeout");&lt;br /&gt;       }&lt;br /&gt;       consumer.close();&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;We created a message consumer using the temporal queue and listen for a response on it for 10 seconds (10000 milliseconds), if the message response is null we will know the time out was reached.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;JMS Callback sender&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In the code above we created a Temporal Queue and assigned it to our message, so we will be able to get it from the server side and use it to send the response.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;public void onMessage(Message message) {&lt;br /&gt;   try {&lt;br /&gt;       System.out.println("Received");&lt;br /&gt;&lt;br /&gt;       if (message.getJMSReplyTo() != null) {&lt;br /&gt;           Connection conn = myQueueFactory.createConnection();&lt;br /&gt;           Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);&lt;br /&gt;           MessageProducer producer = session.createProducer(message.getJMSReplyTo());&lt;br /&gt;           producer.send(session.createTextMessage("Response message"));&lt;br /&gt;           producer.close();&lt;br /&gt;           session.close();&lt;br /&gt;           conn.close();&lt;br /&gt;       }&lt;br /&gt;   } catch (JMSException ex) {&lt;br /&gt;       Logger.getLogger(MyMessageDrivenBeanBean.class.getName()).log(Level.SEVERE, null, ex);&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Note: the connection factory was injected using the @Resource annotation.&lt;br /&gt;&lt;br /&gt;Ok, you will get the JMSReplyTo and you'll send a message to that queue, this destination will be the temporally queue you created in the client side.&lt;br /&gt;&lt;br /&gt;And that's it.... but... is not!, you must take care of two things to work this out, the first and most important... if your session bean (the sender) is in a transaction the message will not be send until the end of the transaction is reached, so the consumer will wait for the 10 secs and will always write the message "Timeout....", how can we fix this? just put the annotation   "@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)" in the caller method. And second... if you don't put the line "conn.start()" just before the consumer receive method call the consumer will not start listening... and you will get a "Timeout" message again. So beware of this two lines, they drove me crazy until I figured out what was going on the first time.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;Full code of the application is downloadable from &lt;a href="http://www.4shared.com/file/72114517/344a910e/JMSSendResponse.html"&gt;Full project download&lt;/a&gt; it's a netbeans project so you will be able to open it with that IDE, or just browse for the code in the subprojects JMSSendResponse-ejb and JMSSendResponse-war (actually it does not nothing but calling the sessionbean).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1664614986140858201-6428520307966613970?l=javaxcross.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaxcross.blogspot.com/feeds/6428520307966613970/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1664614986140858201&amp;postID=6428520307966613970' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1664614986140858201/posts/default/6428520307966613970'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1664614986140858201/posts/default/6428520307966613970'/><link rel='alternate' type='text/html' href='http://javaxcross.blogspot.com/2008/06/jms-sendreponse-implementation.html' title='JMS Send/Response implementation'/><author><name>Cross</name><uri>http://www.blogger.com/profile/17985383212473053331</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1664614986140858201.post-1808664001785615251</id><published>2008-04-09T12:24:00.000-07:00</published><updated>2008-04-14T16:06:08.096-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><category scheme='http://www.blogger.com/atom/ns#' term='Enterprise Applications'/><category scheme='http://www.blogger.com/atom/ns#' term='Swing'/><category scheme='http://www.blogger.com/atom/ns#' term='slow'/><title type='text'>Is Swing slow?</title><content type='html'>&lt;p&gt;The main problem with this question is the question itself, is a Windows application slow? is the minesweeper slow? are the legacy applications slow?&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Everything depends on how you use it, if you have a car, lets say Ferrari, if you use it in the first gear all the time the answer will be "YES THE FERRARI IS THE SLOWEST CAR IN THE WORLD", but is it true? is the Ferrari slow? or is the driver the main problem? you would agree that the driver will have to take some lessons... ok... now let me do the question again: "Is Swing slow?" the answer: NO, Swing is as slow as the architect and developers are, if the swing applications have problems then we will not change the Framework, we need to change the Driver!&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;P&gt;The architect and the developer must consider how the platform works under some circumstances and take care of the details, that's true even if you work on a windows application. Swing provides some advantages that you could not have in other languages, but it comes with responsibilities.&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;&lt;P&gt;But, the theory could say something different from the experience, so lets put hands on and measure some times from the sample posted in the last article &lt;a href="http://javaxcross.blogspot.com/2008/04/swing-fast-sample.html"&gt;Swing Fast sample&lt;/a&gt;.&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;.NET vs Swing Time measure&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;P&gt;I created a very simple class to measure the loading time in both applications, the following is the class I used in Java:&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;public class Timer {&lt;br /&gt; private static long startTime;&lt;br /&gt;&lt;br /&gt; public static void registerStartTime() {&lt;br /&gt;     startTime = Calendar.getInstance().getTimeInMillis();&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; public static long getElapsedTime() {&lt;br /&gt;     long currentTime = Calendar.getInstance().getTimeInMillis();&lt;br /&gt;  &lt;br /&gt;     return currentTime - startTime;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;P&gt;and here's the .NET version:&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;public class Timer&lt;br /&gt;{&lt;br /&gt;private static long startTime;&lt;br /&gt;&lt;br /&gt;public Timer()&lt;br /&gt;{&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public static void registerStartTime()&lt;br /&gt;{&lt;br /&gt;startTime = DateTime.Now.Ticks;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public static long getElapsedTime()&lt;br /&gt;{&lt;br /&gt;long currentTime = DateTime.Now.Ticks;&lt;br /&gt;return currentTime - startTime;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;P&gt;ok, I put the statement &lt;code&gt;Timer.registerStartTime();&lt;/code&gt; in the main code just before the invocation of the screen, and the &lt;code&gt;Message.show("Time: " + Timer.getElapsedTime());&lt;/code&gt; just after the screen loaded. These are the results:&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;&lt;P&gt;&lt;table&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;Java ms.&lt;/td&gt;&lt;td&gt;.NET ms.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td&gt;187&lt;/td&gt;&lt;td&gt;156&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td&gt;125&lt;/td&gt;&lt;td&gt;156&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td&gt;125&lt;/td&gt;&lt;td&gt;156&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td&gt;125&lt;/td&gt;&lt;td&gt;156&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td&gt;125&lt;/td&gt;&lt;td&gt;156&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;(sorry for the extra space, I don't know why the blogger added this :s)&lt;br /&gt;&lt;br /&gt;The average time for Java is: 137.5ms and 156ms for .NET, off course... I will not say at this moment that java is faster than .net, this is just the simplest sample, we need to do more tests and more complex scenarios. But the point is... if the starting time is pretty close, why the application will be slower in java than in .net? again, everything depends on how you use the technology.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;New Scenario&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Ok, what if we increase the number of components and the data on them? the new scenario has 4 new combos, each one with the letters from "a" to "z" as items, so what's now?&lt;br /&gt;&lt;br /&gt;&lt;table&gt;&lt;br /&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;Java ms.&lt;/td&gt;&lt;td&gt;.NET ms.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td&gt;156&lt;/td&gt;&lt;td&gt;156&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td&gt;157&lt;/td&gt;&lt;td&gt;156&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td&gt;156&lt;/td&gt;&lt;td&gt;156&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td&gt;156&lt;/td&gt;&lt;td&gt;156&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td&gt;156&lt;/td&gt;&lt;td&gt;156&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td&gt;157&lt;/td&gt;&lt;td&gt;156&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;So, now the times are very close, right? ok, still too easy right?, I added a JTable in the swing application with 3 Columns and 20 Rows and the time is still the same 156ms!!!.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Conclusion&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Most of the problems with the Client applications are not related with the platform or the framework, most of them are because of the abuse of the code, some developers (and also the architects) believe that the code in the client could do whatever they want and do a lot of rookie mistakes (I will talk about that in a new article). The main idea of this article is to prove you that Swing is not slower than other languages, most of the problems with the Swing applications are related with some of the following problems:&lt;br /&gt;&lt;br /&gt;- Misunderstanding of the caching systems in the jndi lookups.&lt;br /&gt;- Abuse of the workload in the Constructor of the class&lt;br /&gt;- Abuse of the round trips to the server (when the screen gets the data for combos, tables, etc.)&lt;br /&gt;- Coding problems because the Notepad coding technique.&lt;br /&gt;- Performance problems in the JDK 1.4&lt;br /&gt;&lt;br /&gt;and some others I will work on later, with their solutions.&lt;br /&gt;&lt;br /&gt;We're close to the main topic of this series, how to build an enterprise applications with Swing as front-end and EJB as backend.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1664614986140858201-1808664001785615251?l=javaxcross.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaxcross.blogspot.com/feeds/1808664001785615251/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1664614986140858201&amp;postID=1808664001785615251' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1664614986140858201/posts/default/1808664001785615251'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1664614986140858201/posts/default/1808664001785615251'/><link rel='alternate' type='text/html' href='http://javaxcross.blogspot.com/2008/04/is-swing-slow.html' title='Is Swing slow?'/><author><name>Cross</name><uri>http://www.blogger.com/profile/17985383212473053331</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1664614986140858201.post-4009913718461673323</id><published>2008-04-04T10:06:00.000-07:00</published><updated>2008-04-09T09:17:57.079-07:00</updated><title type='text'>Swing - Fast Sample</title><content type='html'>In a previous article I promised to show you how to create a simple interface in an easy way using Netbeans and .NET, I will create a simple screen with some simple code, and I will do the same using .NET and Java.&lt;br /&gt;&lt;br /&gt;Both applications (Java and .NET) will create a toolbar with two buttons, and two text boxes with their labels. The buttons will show the typical "Hello" message using the input from the text boxes. This is a very easy sample but the main idea is not to show you the architecture and complex of a big application in swing, the idea in here is to show you the point: "Swing is as easy to develop as other IDEs".&lt;br /&gt;&lt;br /&gt;Ok, here is the .NET sample:&lt;br /&gt;&lt;div align="center"&gt;&lt;br /&gt;&lt;object width="425" height="350"&gt; &lt;param name="movie" value="http://www.youtube.com/v/BDbaVecS8Tg"&gt; &lt;/param&gt; &lt;embed src="http://www.youtube.com/v/BDbaVecS8Tg" type="application/x-shockwave-flash" width="425" height="350"&gt; &lt;/embed&gt; &lt;/object&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;An here is the Java version of the same thing:&lt;br /&gt;&lt;object width="425" height="350"&gt; &lt;param name="movie" value="http://www.youtube.com/v/nc8a6rnv4Vw"&gt; &lt;/param&gt; &lt;embed src="http://www.youtube.com/v/nc8a6rnv4Vw" type="application/x-shockwave-flash" width="425" height="350"&gt; &lt;/embed&gt; &lt;/object&gt;&lt;br /&gt;&lt;br /&gt;As you can see the steps are very similar, later I will show you a powerful applications using Swing without sweating your shirt. In Addition I will show you how to create enterprise applications with this technology.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1664614986140858201-4009913718461673323?l=javaxcross.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaxcross.blogspot.com/feeds/4009913718461673323/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1664614986140858201&amp;postID=4009913718461673323' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1664614986140858201/posts/default/4009913718461673323'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1664614986140858201/posts/default/4009913718461673323'/><link rel='alternate' type='text/html' href='http://javaxcross.blogspot.com/2008/04/swing-fast-sample.html' title='Swing - Fast Sample'/><author><name>Cross</name><uri>http://www.blogger.com/profile/17985383212473053331</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1664614986140858201.post-1876883592175440098</id><published>2008-03-27T09:20:00.000-07:00</published><updated>2008-04-09T09:23:35.615-07:00</updated><title type='text'>Swing... why not?</title><content type='html'>Customer: "Can you create a desktop application quick please?"&lt;br /&gt;Developer: "ohhhh I desktop application, sure... I will use MS Forms"&lt;br /&gt;Customer: "But why not java? you told me you feel more comfortable with java"&lt;br /&gt;Developer: "Shh... Swing is a pain in the ass, its hard to develop and slower than other technologies, I suggest..."&lt;br /&gt;&lt;br /&gt;I've heard this several times, and this led me to start this post.&lt;br /&gt;&lt;br /&gt;The common concerns about Swing are as follows (if you know other ones, just let me know and I will include them):&lt;br /&gt;1. Swing is hard to develop.&lt;br /&gt;2. Swing is slow&lt;br /&gt;3. Swing is not suitable for Enterprise applications&lt;br /&gt;4. The user feels more comfortable if the look and feel is similar to other desktop applications like MS Office, or calc... etc. And Swing looks very different, this might confuse most of the final Users.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Swing is hard to develop.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This can not be more far from true, the main problem with the Java Technology is the lack of tools, everytime Sun releases a new JDK or specification, the users need to suffer this problem, so they must implement everything from scratch using a plain text tool application, just because the IDEs does not have support to this new feature, but... Swing is not new!!!! Swing was released a long time ago, if you use Netbeans or Eclipse you will find that creating a Swing form (class) is just like .NET, even better. (btw, I'm a netbeans lover and they are working very hard to keep the IDE as much up to date as possible.)&lt;br /&gt;&lt;br /&gt;Using Netbeans, you can drag and drop controls, use code templates, doble-click to create code for events, etc. It's very easy to create a swing form from scratch. You can create your own controls very easy and use them as normal controls with drag and drop. In a future post I will write an example of how to create an interface swing in 5 minutes... maybe less, and How to do the same using .NET, I think you would not notice the difference between these approaches (ok, well... maybe you will notice it just because the interface in java will be auto-resizable, and some other improvements).&lt;br /&gt;&lt;br /&gt;Take a look of this: &lt;a href="http://javaxcross.blogspot.com/2008/04/swing-fast-sample.html"&gt;Swing fast sample&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Swing is slow&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This is another lack of knowledge, the JDK 5 and 6 have a lot of improvements in this way, and there's a lot of techniques to improve your Swing code in order to have a better user experience. I will do a post with some of this techniques.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Swing is not suitable for Enterprise applications&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The Swing applications could also have a good connectivity with the EJBs, and everything will depends on how you solve this interaction from the design and architecture. If you use a SessionBean to execute a work and then uses a new Session bean to retrieve data then you will have some remoting problems, but you can create a Session Bean at server side to work as Model in the MVC pattern, in this way you will be able to use this model to execute the task and retrieve the required data in one or more calls from the server side, so, as I said... everything depends on your ability as architect, create JSPs and HTML application requires a lot of work, so I think Swing will reduce the amount of work to create Enterprise applications. In a 3rd post I will compare how to do the same from a Web Application and a Swing application, then I will compare which one best suits your needs.&lt;br /&gt;&lt;br /&gt;One of the arguments used by some people about this point is because Swing is not flexible, so everytime you change a "page" you will need to redeploy the whole jar in the client machine. Ok, here is JavaFX to solve this, so there's no excuses now. :D&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Look and Feel&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you say that the look and feel is a problem... think again, the pluggable look and feel of swing will let you change everything in an application, you could even put a look and feel just like Mac even if you work on windows.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Conclusion&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Swing is a very powerful framework and you won't believe how easy is. This is a starter post in a series of articles about the uses of swing in a "serious" environments.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1664614986140858201-1876883592175440098?l=javaxcross.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaxcross.blogspot.com/feeds/1876883592175440098/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1664614986140858201&amp;postID=1876883592175440098' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1664614986140858201/posts/default/1876883592175440098'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1664614986140858201/posts/default/1876883592175440098'/><link rel='alternate' type='text/html' href='http://javaxcross.blogspot.com/2008/03/swing-why-not.html' title='Swing... why not?'/><author><name>Cross</name><uri>http://www.blogger.com/profile/17985383212473053331</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1664614986140858201.post-4175314440420285618</id><published>2008-03-18T13:36:00.000-07:00</published><updated>2008-03-19T14:13:28.696-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CMP'/><category scheme='http://www.blogger.com/atom/ns#' term='JDO'/><category scheme='http://www.blogger.com/atom/ns#' term='BMP'/><category scheme='http://www.blogger.com/atom/ns#' term='scalable'/><category scheme='http://www.blogger.com/atom/ns#' term='persistence'/><category scheme='http://www.blogger.com/atom/ns#' term='SCEA'/><category scheme='http://www.blogger.com/atom/ns#' term='Hibernate'/><category scheme='http://www.blogger.com/atom/ns#' term='extensibility'/><category scheme='http://www.blogger.com/atom/ns#' term='ORM'/><title type='text'>Analysis of the persistence layer from the SCEA 5 perspective</title><content type='html'>The technology grew up too fast and there's a lot of different ways to perform data persistence in an Enterprise application, you can do a simple INSERT sql, like:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #99ddff; font-style: italic;"&gt;INSERT INTO Customer VALUES  (1, 'Isaac', 'Newton')&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;or you could use a more sophisticated way to do that, with some ORMs frameworks, but... before to talk about the benefits of one over the other, and which one should you pick in the real life or in the SCEA, lets explain every word.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;ORM (stands for Object relationship management):&lt;/span&gt; The definition from wikipedia says:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;"&lt;/span&gt;&lt;span style="font-style: italic;"&gt;Object-Relational Mapping&lt;/span&gt;&lt;span style="font-style: italic;"&gt; (aka &lt;/span&gt;&lt;span style="font-style: italic;"&gt;ORM&lt;/span&gt;&lt;span style="font-style: italic;"&gt;, &lt;/span&gt;&lt;span style="font-style: italic;"&gt;O/RM&lt;/span&gt;&lt;span style="font-style: italic;"&gt;, and &lt;/span&gt;&lt;span style="font-style: italic;"&gt;O/R mapping&lt;/span&gt;&lt;span style="font-style: italic;"&gt;) is a &lt;/span&gt;&lt;a style="font-style: italic;" href="http://en.wikipedia.org/wiki/Programming" class="mw-redirect" title="Programming"&gt;programming&lt;/a&gt; technique for converting data between incompatible &lt;a style="font-style: italic;" href="http://en.wikipedia.org/wiki/Type_system" title="Type system"&gt;type systems&lt;/a&gt;&lt;span style="font-style: italic;"&gt; in &lt;/span&gt;&lt;a style="font-style: italic;" href="http://en.wikipedia.org/wiki/Relational_database" title="Relational database"&gt;relational databases&lt;/a&gt;&lt;span style="font-style: italic;"&gt; and &lt;/span&gt;&lt;a style="font-style: italic;" href="http://en.wikipedia.org/wiki/Object-oriented" class="mw-redirect" title="Object-oriented"&gt;object-oriented&lt;/a&gt;&lt;span style="font-style: italic;"&gt; programming languages. This creates, in effect, a "virtual &lt;/span&gt;&lt;a style="font-style: italic;" href="http://en.wikipedia.org/wiki/Object_database" title="Object database"&gt;object database&lt;/a&gt;&lt;span style="font-style: italic;"&gt;" which can be used from within the programming language."&lt;/span&gt;&lt;br /&gt;but what does this means in the real life of an application?, ok... this is really simple, instead of doing this:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #99ddff; font-style: italic;"&gt;INSERT INTO Customer VALUES (1, 'Isaac', 'Newton')&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;you will do:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #99ddff; font-style: italic;"&gt;    Customer cust = new Customer();&lt;br /&gt;cust.setName('Isaac');&lt;br /&gt;cust.setLastName('Newton');&lt;br /&gt;&lt;br /&gt;somepersistenceframework.doPersist(cust);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;its very clear in the second sample that the LastName is Newton and the First name is 'Issac', futhermore you don't have to care about the type mapping. What will happen if your customer has a birthday and you want to save it? lets see:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #99ddff; font-style: italic;"&gt;INSERT INTO Customer VALUES (1, 'Isaac', 'Newton', '1642/Dec/25');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;but... will be the '1642/Dec/25' a valid SQL format? I don't think so... ok, lets fix it:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #99ddff; font-style: italic;"&gt;INSERT INTO Customer VALUES (1, 'Isaac', 'Newton', '1642/12/25');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now... will this gone a work? it depends on which database you are working on, if the DB is SQL Server then it will, but if this is an Oracle DB then... nope... why? in Oracle you must specified the Date format as: "TO_DATE('YYYY/MM/DD', '1642/12/25')", then you will need to hard code your formatting options in your code if you want to create a good application.&lt;br /&gt;&lt;br /&gt;But, what if you use ORM? then your application should look like:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #99ddff; font-style: italic;"&gt;Customer cust = new Customer();&lt;br /&gt;cust.setName('Isaac');&lt;br /&gt;cust.setLastName('Newton');&lt;br /&gt;cust.setBirthDate(new java.util.Date(1642, 11, 25)); // or use a java.util.Calendar to get a Date&lt;br /&gt;&lt;br /&gt;somepersistenceframework.doPersist(cust);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;its easier right? ok, this is what ORM means, create objects and let the framework (or container) do the work of synchronize the object with the underlying DB. (this will be done in two ways, to persist the data like INSERTS, UPDATEs or DELETEs and also will be done to retrieve the data).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Note here: btw, I don't forget the use of Named parameters in the javax sql statements (that will fix the date format problem), I just put it as an example, but if you will judge me... ok, lets change the problem, what if the problem is with the identities? in SQL you have it but in Oracle you must implement it as Sequence in a dual table, then you will need code a different method for SQL and Oracle... or what will you say about the BLOB datas? or... I think I made my point in here :D&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;The evolution of the concept&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;One of the earliest implementation of this ORM was JDO as a framework and EJB 1.1 as a J2EE standard, in the EJB 1.0 the first approach of this was something called BPM (Bean Persistence Management), which means: "Separate all the SQLs from the Data and the container will let the object know when to synchronize"... so... what's the difference with the DAO Pattern? the main difference is that the server will do all the caching work and will let you know when the data must be saved or retrieved, this will ensure that your application will be scalable, and it will have a good performance (off course, everything depends on the quality of your SQL statements), also it's easily maintained. Then, how this works in our previous sample? here its is:&lt;br /&gt;&lt;br /&gt;the Customer class will implement a two new methods named "ejbStore" and "ejbLoad", with these new methods your class should call a DAO class which will implement the persistence.&lt;br /&gt;&lt;br /&gt;The only advantage here is the separation of concerns and, off course, the scalability, etc. But the developers quickly hated it, just because it was a lot of work and seems not to powerful. (but it was!)&lt;br /&gt;&lt;br /&gt;With this problems in EJB 1.0 the JDO was a good start point for a really ORM framework, the main idea in here is that you will create the objects and an XML which will tell the framework how it will persist this object. JDO could work as a standalone framework, this will able your simple applications to use a persistence framework and forget the behaviour of the persistence layer, this was one of the biggest advantages over EJB.&lt;br /&gt;&lt;br /&gt;The big disadvantage in EJB was that the developer should care about the implementation issues I talked about (the problem with formats like Oracle and SQL Server dates), so the developers were angry about that.&lt;br /&gt;&lt;br /&gt;Then Sun came out with the CMP (Container Management persistence Entities) which has the advantage that it will take care of the SQL stuff and you will only need to create the entities, the promised land came to earth... but was not the best thing in the world, in fact Sun recommended that if you will need performance then you need to go back to the BMP because the algorithm was not the best and so the performance. That changed in EJB 2.0 and 2.1, were the new Entities had a very good performance (even better than if you write your own code), but they were too complex and the people still had in mind the poor performance in the earlier version.&lt;br /&gt;&lt;br /&gt;Recently Sun launched EJB 3.0 based on a new ORM framework (JPA) and a new specification (mainly based over the current persistence frameworks like hibernate and JDO).&lt;br /&gt;&lt;br /&gt;Ok, that was the quick flash back, lets move to the main of this discussion, comparison between the different persistence approaches. (maybe I miss some points in the history or omitted some details)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Analysis of the persistence layer from the SCEA 5 perspective&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Ok, first of all... let me tell you something... the test will rely on the new JEE specification, so you will not need to be worried about CMP or BMP (why? just because they disappeared and were replaced by JPA). So the question will be, what is the best for my application: JPA, DAOs, JDBC, etc. in front of this topics: ease of development, performance, scalability, extensibility, and security?&lt;br /&gt;&lt;br /&gt;The JPA is a framework based on the idea of POJOs (Plain Old JavaObjects) which means: "Leave the Customer class as you have it and the container (or framework) will take care of the persistence", the only thing you need to do its to provide some information about your object to the container, how you do that? if you're using JPA you will do that using Annotations, if you're using Hibernate then you will have the option to put it in a mapping xml file. Lets see how the Customer class will be if you put the JPA annotations:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: courier new;" align="center"&gt;&lt;br /&gt;&lt;table style="width: 436px; height: 777px; color: #99ddff; font-style: italic;" border="1"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;br /&gt;import java.util.Date;&lt;br /&gt;import javax.persistence.Entity;&lt;br /&gt;import javax.persistence.Id;&lt;br /&gt;&lt;br /&gt;@Entity&lt;br /&gt;public class Customer implements java.io.Serializable {&lt;br /&gt;@Id&lt;br /&gt;private int id;&lt;br /&gt;&lt;br /&gt;private String name;&lt;br /&gt;private String lastName;&lt;br /&gt;private Date birthDate;&lt;br /&gt;&lt;br /&gt;public int getId() {&lt;br /&gt;return id;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void setId(int id) {&lt;br /&gt;this.id = id;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public String getName() {&lt;br /&gt;return name;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void setName(String name) {&lt;br /&gt;this.name = name;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public String getLastName() {&lt;br /&gt;return lastName;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void setLastName(String lastName) {&lt;br /&gt;this.lastName = lastName;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public Date getBirthDate() {&lt;br /&gt;return birthDate;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void setBirthDate(Date birthDate) {&lt;br /&gt;this.birthDate = birthDate;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;and how can you retrieve and save a Customer? just doing a minimum work:&lt;br /&gt;&lt;br /&gt;put this as a variable in your Session Bean:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #99ddff; font-style: italic;"&gt;  @PersistenceContext(unitName="BizAgi.RenderPU")&lt;br /&gt;private EntityManager em;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;and the persist the Customer using:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #99ddff; font-style: italic;"&gt;  em.persist(c);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;so, if you ask me what will be the easier method for development be my guess... the EJB 3.0 its really easy and far more maintainable than the previous EJB 2.1, what about the performance? the performance its not really a problem of one Entity or the way you access your db, I think its a problem of how did you solve your design issues before start the development, but from the SCEA perspective... again EJB 3.0 its faster because it has a lot of improves in performance, cache things and reuse, unless you create your own framework to persist and take care of all the cache issues and object queries EJB 3.0 will be faster every time. Off course, if you compare a simple statement over EJB 3.0 the statement will be faster than the entities, but... that's not the normal behaviour in an Enterprise application, you will have several tables, and several rows on them.&lt;br /&gt;&lt;br /&gt;What about scalability? ok, the container ensures that your data will be replicated over all the nodes in the cluster, so you will not need to add anything else to keep the clusters up to date, in this way you could add new nodes to the array and made your application more scalable writing zero code lines, what about JDBC? it is not scalable? mmm scalable relies on how you would add new customers, the jdbc protocol will not be a limitation, the JDBC problem relies on the data cache, with the JDBC aproximation you will need to be in touch with your db to keep synchronization between the nodes, and this will be very expensive. In this way, the JDBC its scalable yes, but will lead you to a performance problem because the lack of cache. And JDO? well JDO and EJB 3 are pretty much the same thing (in the approach concepts) the difference relies again in the cache service, the framework will not replicate the changes and this will generate some problems. DAO will solve any of this? really... it does not, why? just because DAO its an implementation pattern and it will be implemented using JDBC, EJB 3 or JDO as the persistence layer.&lt;br /&gt;&lt;br /&gt;In the extensibility context which one is best? all of the approaches are extensibles, but which one will needs more time? I think JDBC, just because the addition of new fields will need a lot of changes, UPDATE, INSERT, FIND and DELETE statements could change, in the EJB 3 you will need to add a new variable to the class and create its accessors (getters and setters) and thats it. Again EJB 3 wins the battle over JDBC, but what about JDO or hibernate? in terms of extensibility JDO and hibernate has a disadvantage, the mapping xml file, you need to do one more step over EJB 3, put the mapping data in that file (beware, hibernate has a new implementation that will get the entity information from the annotations, so hibernate will be as extensible as EJB 3 is).&lt;br /&gt;&lt;br /&gt;And Security? ok, let me define security... do you need a user and password to create a connection with the db? for all the approaches the answer will be YES, so where is the difference? as far as I see none.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Conclusion&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In the SCEA you will not be answered to choose between EJB 3, EJB 2.1 (CMP or BMP), JDO or Hibernate, it will assume if you are doing the SCEA test you will be approach your answers with his framework JPA, so you will be asked about how to ensure transactions or change things, you will not be asked about which one is the best solution. (From Sun's perspective EJB 3 is the best... off course... I do either :D)&lt;br /&gt;&lt;br /&gt;Hope this article solves all the questions about the persistence you could have in order to pass the test, if you have any further questions about it please let me know and I will edit this article to solve some of them.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1664614986140858201-4175314440420285618?l=javaxcross.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaxcross.blogspot.com/feeds/4175314440420285618/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1664614986140858201&amp;postID=4175314440420285618' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1664614986140858201/posts/default/4175314440420285618'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1664614986140858201/posts/default/4175314440420285618'/><link rel='alternate' type='text/html' href='http://javaxcross.blogspot.com/2008/03/analysis-of-persistence-layer-from-scea.html' title='Analysis of the persistence layer from the SCEA 5 perspective'/><author><name>Cross</name><uri>http://www.blogger.com/profile/17985383212473053331</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1664614986140858201.post-2034468329094827026</id><published>2008-03-12T13:56:00.000-07:00</published><updated>2008-03-12T15:51:55.315-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JEE'/><category scheme='http://www.blogger.com/atom/ns#' term='n-tier'/><category scheme='http://www.blogger.com/atom/ns#' term='3 tier'/><category scheme='http://www.blogger.com/atom/ns#' term='Client-server'/><category scheme='http://www.blogger.com/atom/ns#' term='SCEA'/><title type='text'>Two, Three, N-tier which one should I pick?</title><content type='html'>Jeff asked me (in the Post &lt;a href="http://javaxcross.blogspot.com/2008/03/how-to-pass-scea-5.html"&gt;How to pass SCEA 5&lt;/a&gt;) about the following:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Explain the advantages and disadvantages of two-tier architectures when examined under the following topics: scalability, maintainability, reliability, availability, extensibility, performance, manageability, and security.&lt;/li&gt;&lt;li&gt;Explain the advantages and disadvantages of three-tier architectures when examined under the following topics: scalability, maintainability, reliability, availability, extensibility, performance, manageability, and security&lt;/li&gt;&lt;li&gt;Explain the advantages and disadvantages of multi-tier architectures when examined under the following topics: scalability, maintainability, reliability, availability, extensibility, performance, manageability, and security.&lt;/li&gt;&lt;/ul&gt;I will try to put my thoughts in here about this and I will use the following example to illustrate the case of study: Your assignment is to create a check in application for a counter in an airport. so it will show the current flights, allowing you to pick one, then lists the customers for that flight and assign the passenger's seat. (use your imagination here)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Two Tiers:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;First a brief description of the situation, a two tier application its mainly a client application which has everything in one layer and connects to a repository (a database if you prefer), this is also known as Client-server architecture. (this is just a brief introduction, you could go &lt;a href="http://en.wikipedia.org/wiki/Client-server_architecture"&gt;client-server architecture&lt;/a&gt; to get more detail.&lt;br /&gt;&lt;br /&gt;Lets ask first, if all the code is in one place (the client... like a swing application) the client will have all the power force and everything depends on its machine, is it an scalable solution? what will happen if you add new clients? the network overload will be a problem, because these type of application uses it a lot.&lt;br /&gt;&lt;br /&gt;In the example the work flow will be as follows:&lt;br /&gt;&lt;br /&gt;1. Executes a SQL to get all the current flights (between some date range)&lt;br /&gt;2. shows the flights, and select the one using the ticket information&lt;br /&gt;3. Executes a SQL to get the customers on that flight&lt;br /&gt;4. Shows the list and select the passenger&lt;br /&gt;5. Executes a SQL to verify the status of the ticket.&lt;br /&gt;6. and so on.&lt;br /&gt;&lt;br /&gt;The DB connections are very expensive and very slow, so, if you put new customers your application will have serious problems in bandwidth, overload, etc. So your application is not easily scalable. But... if you have only 3 clients (maybe three counters) this will be a very fast solution, the client application will do all the work and will be very effective. The troubles will come if you want to export this to Internet, because the clients will not have access to your internal network, you will need to spread the user and password for the db, etc.&lt;br /&gt;&lt;br /&gt;Is this application maintainable? Think of this, if all the code is in the client will be easy to find an error? I don't think so.&lt;br /&gt;&lt;br /&gt;What about reliability? the reliability states: "the ability of a system or component to perform its required functions under stated conditions for a specified period of time." so will the client-server be reliability? its hard to figure it out. If the system could be easily break down (because the code is in the client side) someone could change its reliability changing a part of the code. If the network configuration change the client might have problems to establish the connection to the DB, so the reliability will be affected, but as the definition states, everything depends on the conditions not the architecture.&lt;br /&gt;&lt;br /&gt;The system will have a high availability? because all the code will run on the client this configuration will not react to a fail over problems, because everything is in one machine if that machine fails the system will not work, so the availability will decrease with this architecture.&lt;br /&gt;&lt;br /&gt;Extensibility, mmm... I think no, its hard to maintain and extend a Client-server application, just because everything is in one place.&lt;br /&gt;&lt;br /&gt;Performance, ok, here is the big question, the performance in a Client-server application relies on how it will work, if it has several calculations everything depends on the client, there's no way to distribute the work between several machines, all the work will be running in one PC, but... the client-server applications runs fast if you do some tricks. In the example above the performance could be an issue in here, just because it has a lot of DB queries dependencies.&lt;br /&gt;&lt;br /&gt;Manageability, think if you are able to change some parameters and your application will run fast or will have a better reliability, the answer will be no, just because everything runs in the client and you will have absolutely no control over it.&lt;br /&gt;&lt;br /&gt;In general I would say that increasing the tiers will ensure extensibility, maintainability, security but will decrease performance.&lt;br /&gt;&lt;br /&gt;Remember, tiers refers to the layers in which your system could split off, if your application have a lot of classes but works in a single machine which connects to a DB then it's a client-server application.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Three Tiers&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In the three tiers your application will have some logic in the client (usually the presentation and some validations), the business tier will have the 80% of the application logic (lets say this will have most of the business code)  and the DB which could have some Stored Procedures in it.&lt;br /&gt;&lt;br /&gt;What will be different from the previous approach? you will have a lot of things running in one machine, so its easier to maintain, you will increase security because the client will not have the user/password pair to access to the DB, and will be more extensible than the client-server application. But what will you gain or lose? the answer is not easy, I would say It's relative, If the application is a calculation centric then you might lose performance (because the server will do a lot of work for several clients at the same time) or you could gain performance if the application is mainly a db application, just because you could place the DB server near (referring to the network topology not the physical distance) to the business server in order to avoid the network overload.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In comparison with the Client-server you will have:&lt;br /&gt;&lt;br /&gt;- better scalability, you could increase the hardware in the business machine and could have more clients.&lt;br /&gt;- better maintainability, everything is in one place so you can replace a component and fix a bug quickly&lt;br /&gt;- better reliability, because you have a better control of the environment in which the business code runs.&lt;br /&gt;- better availability, if the business machine has problems you can easily replace it by a new machine a your client will be running in a blink of an eye&lt;br /&gt;- better extensibility, you could add new functionality in a better way&lt;br /&gt;- decrease or increase in performance, this depends on the application, if its a db application its 90% to get a better performance.&lt;br /&gt;- Better manageability, its easy to control the environment in the business tier, so you can change configuration settings, improve connections etc&lt;br /&gt;- Better security (I think this does not need further explanation...)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;N-Tier&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I think N-tier and 3-tier are pretty much the same thing, if you have a good security in 3-tier you will have even better security with N-tier and this applies to all the statements. (Even to the performance thing, a bad decision could lead to a poor performance if you choose N-Tier over the others and you don't pay attention on the specific requirements)&lt;br /&gt;&lt;br /&gt;Why will you prefer N-Tier over 3-tier, you could distribute the work in several machines, so if you are working in a collaborative application (I loan application which will need a CRM, ERP etc then will be distribute its responsabilities over several machines and will have a better performance because of it)&lt;br /&gt;&lt;br /&gt;In JEE you could easily use some patterns like Service Locator to change a N-Tier to a 3-Tier application (or, at least, behave as a 3-tier application), just changing the uses of the EJBs from Remote to Local. So if I need a tiered application I will choose N-tier over 3-tier every day of the week (and twice in Sunday)&lt;br /&gt;&lt;br /&gt;(Please let me know if you need further explanation and I will add more information on N-Tiers)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1664614986140858201-2034468329094827026?l=javaxcross.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaxcross.blogspot.com/feeds/2034468329094827026/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1664614986140858201&amp;postID=2034468329094827026' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1664614986140858201/posts/default/2034468329094827026'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1664614986140858201/posts/default/2034468329094827026'/><link rel='alternate' type='text/html' href='http://javaxcross.blogspot.com/2008/03/two-three-n-tier-which-one-should-i.html' title='Two, Three, N-tier which one should I pick?'/><author><name>Cross</name><uri>http://www.blogger.com/profile/17985383212473053331</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1664614986140858201.post-8895114172921230576</id><published>2008-03-05T11:51:00.000-08:00</published><updated>2008-03-17T13:43:38.487-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='javaxcross'/><category scheme='http://www.blogger.com/atom/ns#' term='Certification'/><category scheme='http://www.blogger.com/atom/ns#' term='How to pass SCEA 5'/><title type='text'>How to pass SCEA 5</title><content type='html'>I'm MCP, SCJP, SCBCD and now SCEA 5, when I took the SCEA 5 Beta, I was wondering if this will be as difficult or easy as the other ones, and it was very interesting just because Beta means "you will not have any help on, nobody took this test before and you will have only your knowledge with you".&lt;br /&gt;&lt;br /&gt;Because of this I started this blog, to share my experience in this test and let you know the key elements you must be aware to pass this out.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Certification description&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The certification is compound by 3 parts.&lt;br /&gt;&lt;br /&gt;1. The first part is a multi choice exam just like the others, it will test your knowledge about JEE and Design patterns&lt;br /&gt;2. The assignation is the second part, you will get an assignation which will be similar to a real life assignation, this means that you will face it as a real application should be faced.&lt;br /&gt;3. The third part is the easy one if you did the assignation, they will ask you about some common decisions made during design time, like Authentication, authorization issues, security, scalability, maintainability, and so on. This part will be evaluated as part of the assignation, so you will not have to wait to pass the second part in order to start this one.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;General Advice&lt;/span&gt;&lt;br /&gt;If you think you are ready to pass this test, just ask yourself:&lt;br /&gt;&lt;br /&gt;- Did I worked enough with Case Use , Sequence Diagrams, Class Diagrams, Deployment Diagrams, etc? if the answer is no, go and take some practice on this, I'm pretty sure you will not pass it if you don't have some experience about these topics. (you don't need to be a guru)&lt;br /&gt;- Did you architect some solutions? were they successful solutions? scalable, maintainable, etc?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Part 1&lt;/span&gt;&lt;br /&gt;The first part is easy, you must know the following topics (these are from the java certification page):&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Scalability, maintainability, reliability, availability, extensibility, performance, manageability, and security.&lt;/span&gt; These are very important and will be asked through all the test, you will have problems like: "How can you add new customers and keep the availability?" or "If you add a new layer you will lose in security, reliability, scalability or manageability?" (those are not exactly the answers, I'm not able to put the real ones in here)&lt;br /&gt;&lt;br /&gt;Security. You will be asked for firewalls, protocols, etc. Its easy if you read about it.&lt;br /&gt;&lt;br /&gt;Tiers. You will be asked about the advantages and disadvantages about two tier, three tier, n-tier, client-server. Remember, not always the n-tier is the best option, imagine you have a simple hello world application, will you create this with ejbs, db etc? be sure to take a look of this new post &lt;a href="http://javaxcross.blogspot.com/2008/03/two-three-n-tier-which-one-should-i.html"&gt;Two, Three, N-tier which one should I pick?&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Messaging. You need to know how the JMS works, you will be asked for this, that's sure.&lt;br /&gt;&lt;br /&gt;EJB. this test will be easy if you know EJBs and you already worked with them, GOOD NEWS: YOU WILL NOT SEE CODE IN HERE, yes... you will be asked about the life cycle, advantages, when to use Stateless, Stateful, CMT, BMT, etc, questions like: "will you use persistence to save the data in a Stateless or Stateful bean?", so be sure you create almost any JEE component in a sample and be sure how it works.&lt;br /&gt;&lt;br /&gt;Web Tier. Here is the tricky part, you will be asked for JSF, JSP, Servlets, and will be little bit difficult if you didn't develop a web page, so... go and open your netbeans (or Eclipse) and start working in these concepts. I'm not sure why they ask the details of this, but they will. You will not find answers like: "Find the error in here ...", but you will be asked how can you use those technologies to solve some problems.&lt;br /&gt;&lt;br /&gt;Patterns. Ok, here is the core of the test, you need to know the patterns described in the Blueprints guide, also the ones in the GoF, etc. The test does not ask too many questions about patterns, but its sure you will find some of them.&lt;br /&gt;&lt;br /&gt;In addition, you can find some questions referring to CORBA, RMI, etc, so be sure to understand every term. If you have any further questions about the questions please let me know in the comments, I will try to answer it keeping care of the test disclosure.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Second Part&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Once you get the result of the first part you will be ready for the practice test, so how it works?&lt;br /&gt;&lt;br /&gt;You will get an assignment which you will download from a page Sun gives you, this assignment is private and its very difficult that somebody have the same (I think they must have a hundred of different assignments, but I'm guessing).&lt;br /&gt;&lt;br /&gt;The assignment is compound by a description and a sort of Case Use you must solve, as the real life assignments it has description, domain model, requirements, and Case Use and its possible they have some errors, your job as architect is to detect those and write it down in your assumptions, for example if you get an assignment to do a check in a system for a hotel and you see that the case of use says something like: "The customer could ask for the check" you could assume the check will be in dollars, in this way you will not have to do a currency conversion. Or you could find something like: "The cat eats the dog at breakfast", and you will say "What a hell?, I think this is wrong my assumption is somebody did a mistake in here and it must be 'the dog eats the cat...' "&lt;br /&gt;&lt;br /&gt;You must read very carefully the assignment, go to the bathroom, take a shower and go back on it, read it again and try to be sure you understood all the requirements of the system, if you fail to detect a requirement you will fail the test. Use your imagination to figure out how the steps in the Case Use  works and how will your system is going to address these.&lt;br /&gt;&lt;br /&gt;You will need to provide Class Diagram, Component Diagram, Deployment Diagram and your assumption list, also you will need to provide the sequence or collaboration diagrams (this will not influence your score, but will be a good way to get the other diagrams). Also you will need to provide a list of the top three risks you detected and how you managed them.&lt;br /&gt;&lt;br /&gt;While you are trying to figure out how to solve your problem keep in mind the following: Scalability, maintainability, reliability, availability, extensibility, performance, manageability, and security. These are the key points in the test, if your system architecture could lead to a performance problems then you will need to address that in your design.&lt;br /&gt;&lt;br /&gt;Remember, Sun is asking you for the architectural design, not the detailed design, so keep in mind that to avoid any unnecessary detail. How do you know if your design is too detailed, I think you should be able to explain your design to your team in a 30 minutes meeting, if you went in too much detail the designers will not have any work to do.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The third part&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Ok, this is the easy one, you will be asked for some of the decisions made in the previous step, how did you address the security, the scalability, etc. What is the tricky part in here?, take a look of all the questions before begin, when I took it I tried to answer the best I can, so I put all that comes to my mind, then when I moved to the next question... puff... they are asking for something I already answered in the previous question (and you don't have the copy/cut/paste option), so I needed to move back remove the unnecessary answer in the previous one and rewrite it in the next. The time flew and I only had 5 minutes to do a full review. So, go and read all the questions before begin.&lt;br /&gt;&lt;br /&gt;If you have any further questions please let me know in the comments section, I will try to do another blog with those questions and answers.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1664614986140858201-8895114172921230576?l=javaxcross.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaxcross.blogspot.com/feeds/8895114172921230576/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1664614986140858201&amp;postID=8895114172921230576' title='66 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1664614986140858201/posts/default/8895114172921230576'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1664614986140858201/posts/default/8895114172921230576'/><link rel='alternate' type='text/html' href='http://javaxcross.blogspot.com/2008/03/how-to-pass-scea-5.html' title='How to pass SCEA 5'/><author><name>Cross</name><uri>http://www.blogger.com/profile/17985383212473053331</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>66</thr:total></entry></feed>
