Featured FREE Whitepapers

What's New Here?


Analysis of software developer’s competency – Choosing a right team member

In this post I shall try to explain an approach for estimating developer’s skills. The approach is still as a concept, which lacks some concrete decisions, but you can choose the thing which suits your case best. There are number of methods for estimation of developers skills, my favourite being the developer competency matrix. This method is very good, and it prooved to be useful for general estimation of different skills, for example as a part of a general employment assesment. But here it is relevant to estimate competency with relation to specific project, for example when choosing a right team members for a specific project, assuming we have a list of potential candidates to choose from. I would also like to automate this process, so the approach excludes the personal qualities for that reason – being not quantitative. This is no easy task due to vast space of different skills one might have, so I shall restrict myself only to most common types of software development, which are web and app development for the most common platforms. Additionally, most developers I work with are also involved in organizational activities, such as team management, customer relations, communication… I shall try to isolate these qualities out of this analysis and focus on pure technical skills. We shall try to represent this software developer skill space with different dimensions:programming language tools and libraries platform application type experience (lenght) role (depth)These dimensions are basically factors which are taken into account for the competency analysis. There may be other relevant dimensions added. Programming language dimension is pretty obvious, it is a distinct list of items such as c, c++, java… Tools and libraries dimension represents various IDE tools, compilers, editors, frameworks, and libraries which are used when developing software. Platform dimension is representing the environment in which application is deployed, and encapsulates both hardware and software environment. It is also a distinct list of items, such as windows, linux, iphone, desktop, silverlight, flash… Application type dimension represents the domain in which the software is being used, and it is also a distinct list of items such as “information system”, “online sales”, “banking”, “medical device”, “web portal”, “social network”… Experience dimension represents simply the length of experience for particular development which has already happened in the past. Role dimension represents level of the development activity and may contain items such as “apprentice developer”, “medior developer”, “senior developer”, “software architect”, “platform architect”… With these dimensions one should be able to define a metrics system for measurement of general competencies, or a measurement system for a specific project. Simplest thing to do is to represent the metrics as a linear combination of the dimensions, but there may be other useful methods as well. For a specific project different weights are given to any value in each dimension. This way, basically, we define what are we looking for in a candidate. If we accept only Java developer for a position, we would give other programming languages a zero weight. If we need a candidate to be a senior, but also accept medior developer, we assign appropriate weights to these values. Our candidates need to fill their values for every relevant dimension, or we extract that from the CV or an interview, giving us values we can work with. Then, for each candidate we calculate the metrics, and choose the one with the highest score! It would be interesting to create a web app which would allow online calculation of the competency based on a given criterion. Not to be forgotten, there are other – more human factors which need to be considered. I shall reflect on that in a separate post. Reference: Analysis of software developer’s competency – Choosing a right team member from our JCG partner Nenad Sabo at the Software thoughts blog....

ADF Declarative Component example

In my previous post I promised to show  how to create ADF Declarative Component for Smart List Of Values. So, I’m going to create a component consisting of three elements: a label, an input text and a combobox list of values. That’s very easy. I created a separate ADF ViewController project in my work space:                                In this project open the Create JSF Declarative Component wizard:The new declarative component smartLovDef should have at least three attributes: some string for label, attribute binding for input text and LOV binding for combobox list of values:The wizard creates metadata file declarativecomp-metadata.xml and smartLovDef.jspx file where we can put the content of our component:The source code of smartLovDef.jspx looks like this: <?xml version='1.0' encoding='UTF-8'?> <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"           xmlns:f="http://java.sun.com/jsf/core"           xmlns:h="http://java.sun.com/jsf/html"           xmlns:af="http://xmlns.oracle.com/adf/faces/rich">   <jsp:directive.page contentType="text/html;charset=UTF-8"/>   <af:componentDef var="attrs" componentVar="component">         <af:panelLabelAndMessage label="#{attrs.label}" id="plam1">   <af:panelGroupLayout id="pgl1" layout="horizontal">     <af:inputText value="#{attrs.attrBinding.inputValue}"                   required="#{attrs.attrBinding.hints.mandatory}"                   columns="#{attrs.attrBinding.hints.displayWidth}"                   id="deptid" partialTriggers="departmentNameId"                  autoSubmit="true" simple="true"/>    <af:inputComboboxListOfValues id="departmentNameId"                 popupTitle="Search and Select: #{attrs.lovBinding.hints.label}"                 value="#{attrs.lovBinding.inputValue}"                 model="#{attrs.lovBinding.listOfValuesModel}"                 columns="#{attrs.lovBinding.hints.displayWidth}"                 shortDesc="#{attrs.lovBinding.hints.tooltip}"                 partialTriggers="deptid"                simple="true">   </af:inputComboboxListOfValues> </af:panelGroupLayout> </af:panelLabelAndMessage>    <af:xmlContent>       <component xmlns="http://xmlns.oracle.com/adf/faces/rich/component">         <display-name>smartLovDef</display-name>         <attribute>           <attribute-name>label</attribute-name>           <attribute-class>java.lang.String</attribute-class>           <required>true</required>         </attribute>         <attribute>           <attribute-name>attrBinding</attribute-name>           <attribute-class>java.lang.Object</attribute-class>           <required>true</required>         </attribute>         <attribute>           <attribute-name>lovBinding</attribute-name>           <attribute-class>java.lang.Object</attribute-class>           <required>true</required>         </attribute>         <component-extension>           <component-tag-namespace>cscomponent</component-tag-namespace>           <component-taglib-uri>/componentLib</component-taglib-uri>         </component-extension>       </component>     </af:xmlContent>   </af:componentDef> </jsp:root>The next step is to deploy the component into ADF Library. We have to add new deployment profile for the CSComponents project:And let’s deploy the project into library:The following step is to define File System connection in the resource palette to the deployment path of CSComponents project:After that we have to choose the project where we’re going to use the new component (in my case ViewConroller) and add CSComponents.jar library to it:Now we can use smartLovDef  component in our page and drag it from the component palette:In our jspx page the source code is going to look like this:     <cscompLib:smartLovDef label="#{bindings.DepartmentId.label}"                         attrBinding="#{bindings.DepartmentId}"                         lovBinding="#{bindings.DepartmentName}"                         id="sld1"/>Reference: ADF Declarative Component example from our JCG partner Eugene Fedorenko at the ADF Practice blog....

ToString: Hexadecimal Representation of Identity Hash Codes

I have blogged before on the handy Apache Commons ToStringBuilder and I was recently asked what the seemingly cryptic text appearing in the generated String output constitutes. The colleague asking the question correctly surmised that what he was looking at was a hash code, but it did not match his instance’s hash code. I explained that ToStringBuilder adds the identity hash code in hexadecimal format to its output. In this post, I look in more depth at ToStringBuilder‘s use of the identity hash code presented in hexadecimal format. Even those not using ToStringBuilder might find this information useful as Java’s standard Object.toString() also uses a hexadecimal representation of what is effectively its identity hash code. I’ll begin with a very simple Java example using ToStringBuilder. This example uses three Java classes (Person.java, Employee.java, and Main.java) that are shown next. Person.java package dustin.examples;import org.apache.commons.lang.builder.ToStringBuilder;/** * A simple representation of a Person intended only to demonstrate Apache * Commons ToStringBuilder. * * @author Dustin */ public class Person { /** Person's last name (surname). */ protected final String lastName;/** Person's first name. */ protected final String firstName;/** * Parameterized constructor for obtaining an instance of Person. * * @param newLastName Last name of new Person instance. * @param newFirstName First name of new Person instance. */ public Person(final String newLastName, final String newFirstName) { this.lastName = newLastName; this.firstName = newFirstName; }/** * Provide String representation of this Person instance. * @return My String representation. */ @Override public String toString() { final ToStringBuilder builder = new ToStringBuilder(this); builder.append("First Name", this.firstName); builder.append("Last Name", this.lastName); return builder.toString(); } }Employee.java package dustin.examples;import java.util.Objects; import org.apache.commons.lang.builder.ToStringBuilder;/** * Simple class intended to demonstrate ToStringBuilder. * * @author Dustin */ public class Employee extends Person { /** Employee ID. */ private final String employeeId;/** * Parameterized constructor for obtaining an instance of Employee. * * @param newLastName Last name of the employee. * @param newFirstName First name of the employee. * @param newId Employee's employee ID. */ public Employee( final String newLastName, final String newFirstName, final String newId) { super(newLastName, newFirstName); this.employeeId = newId; }/** * Provide String representation of me. * * @return My String representation. */ @Override public String toString() { final ToStringBuilder builder = new ToStringBuilder(this); builder.appendSuper(super.toString()); builder.append("Employee ID", this.employeeId); return builder.toString(); }/** * Simple object equality comparison method. * * @param obj Object to be compared to me for equality. * @return {@code true} if the provided object and I are considered equal. */ @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Employee other = (Employee) obj; if (!Objects.equals(this.employeeId, other.employeeId)) { return false; } return true; }/** * Hash code for this instance. * * @return My hash code. */ @Override public int hashCode() { int hash = 3; hash = 19 * hash + Objects.hashCode(this.employeeId); return hash; } }Main.java (Version 1) package dustin.examples;import static java.lang.System.out;/** * Simple class enabling demonstration of ToStringBuilder. * * @author Dustin */ public class Main { /** * Main function for running Java examples with ToStringBuilder. * * @param args the command line arguments */ public static void main(String[] args) { final Person person = new Person("Washington", "Willow"); out.println(person); final Employee employee = new Employee("Lazentroph", "Frank", "56"); out.println(employee); } }The above example is simple and its output is shown next:The output depicted above shows the String in question printed for both instance’s output generated by ToStringBuilder. The String representation of the instance of Person class includes the String “1f5d386″ and the String representation of the instance of Employee class includes the String “1c9b9ca”. These strings are the hexadecimal representation of each object’s identity hash code. The strings “1f5d386″ and “1c9b9ca” do not look like the integer hash codes many of us are used to seeing because of their hexadecimal representation. The Integer.toHexString(int) methods [available since JDK 1.0.2] is a convenience method for printing an integer in hexadecimal format and can be used to convert “normal” hash codes to see if they match those generated by ToStringBuilder. I have added calls to this method on the instances’ hash codes in the new version of the Main class. Main.java (Version 2) package dustin.examples;import static java.lang.System.out;/** * Simple class enabling demonstration of ToStringBuilder. * * @author Dustin */ public class Main { /** * Main function for running Java examples with ToStringBuilder. * * @param args the command line arguments */ public static void main(String[] args) { final Person person = new Person("Washington", "Willow"); out.println(person); out.println("\tHash Code (ten): " + person.hashCode()); out.println("\tHash Code (hex): " + Integer.toHexString(person.hashCode()));final Employee employee = new Employee("Lazentroph", "Frank", "56"); out.println(employee); out.println("\tHash Code (ten): " + employee.hashCode()); out.println("\tHash Code (hex): " + Integer.toHexString(employee.hashCode())); } }Executing the above leads to the following output:As the output indicates, the hexadecimal representation of the hash code for the Person instance does indeed match that shown in the ToStringBuilder-generated String for that instance. However, the same cannot be said for the Employee instance. The difference is that the Person class does not override the hashCode() method and so uses the identity hash code by default while the Employee class does override its own hashCode() (and therefore being different than the identity hash code). The third version of Main outputs the identity hash code using System.identityHashCode(Object) [discussed in further detail in my blog post Java's System.identityHashCode]. Main.java (Version 3) package dustin.examples;import static java.lang.System.out;/** * Simple class enabling demonstration of ToStringBuilder. * * @author Dustin */ public class Main { /** * Main function for running Java examples with ToStringBuilder. * * @param args the command line arguments */ public static void main(String[] args) { final Person person = new Person("Washington", "Willow"); out.println(person); out.println("\tHash Code (ten): " + person.hashCode()); out.println("\tHash Code (hex): " + Integer.toHexString(person.hashCode())); out.println("\t\tIdentity Hash (ten): " + System.identityHashCode(person)); out.println("\t\tIdentity Hash (hex): " + Integer.toHexString(System.identityHashCode(person)));final Employee employee = new Employee("Lazentroph", "Frank", "56"); out.println(employee); out.println("\tHash Code (ten): " + employee.hashCode()); out.println("\tHash Code (hex): " + Integer.toHexString(employee.hashCode())); out.println("\t\tIdentity Hash (ten): " + System.identityHashCode(employee)); out.println("\t\tIdentity Hash (hex): " + Integer.toHexString(System.identityHashCode(employee))); }With this in place, we can now compare the the identity hash code to the string generated by ToStringBuilder.The last example definitively demonstrates that ToStringBuilder includes the hexadecimal representation of the system identity hash code in its generated output. If one wants to use the hexadecimal representation of the overridden hash code rather than of the identity hash code, an instance of ToStringStyle (typically an instance of StandardToStringStyle) can be used and the method setUseIdentityHashCode(boolean) can be invoked with a false parameter. This instance of ToStringStyle can then be passed to the ToStringBuilder.setDefaultStyle(ToStringStyle) method. As a side note, the equals(Object) and hashCode() methods in the Employee class shown above were generated automatically by NetBeans 7.1. I was happy to see that, with my source version of Java for that project specified as JDK 1.7, this automatic generation of these two methods took advantage of the Objects class. I have used ToStringBuilder-generated output throughout this post to facilitate discussion of hexadecimal representations of identity hash codes, but I could have simply used the JDK’s own built-in “default” Object.toString() implementation for the same purpose. In fact, the Javadoc even advertises this: The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@’, and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode()) The only reason I did not use this example to begin with is that I almost always override the toString() method in my classes and do not get this “default” implementation. However, when I use ToStringBuilder to implement my overridden toString() methods, I do see these hexadecimal representations. I am likely to reduce my use of ToStringBuilder as I increase my use of Objects.toString(). Many of us don’t think about hexadecimal representations or identity hash codes in our daily Java work. In this blog post, I have used ToStringBuilder‘s output as an excuse for looking a little closer at these two concepts. Along the way, I also briefly looked at the Integer.toHexString(Object) method, which is useful for printing numbers in their hexadecimal representation. Knowing about Java’s support for hexadecimal representation is important because it does show up in toString() output, in labeling of colors, memory addresses, and in other places. Reference: ToString: Hexadecimal Representation of Identity Hash Codes from our JCG partner Dustin Marx at the Inspired by Actual Events blog....

Quotes relating to System Design

There are a few quotes I think of when thinking about computer design. These are not specifically about computers, but I think they are appropriate. Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. — Antoine de Saint-Exupery, French writer (1900 – 1944) “Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it’s worth it in the end because once you get there, you can move mountains.” Steve Jobs -[BusinessWeek, May 25, 1998,] Often contentious topics can labour under the assumption that it makes any difference in the first place. DEVENTER (n) A decision that’s very hard to make because so little depends on it, such as which way to walk around a park — The Deeper Meaning of Liff by Douglas Adams and John Lloyd. Everyone can learn something from your mistakes Mistakes – It could be that the purpose of your life is only to serve as a warning to others. — Ashleigh Brilliant on on Despair.com Remember to keep what you are doing relevant Computers make it easier to do a lot of things, but most of the things they make it easier to do don’t need to be done. ~Andy Rooney Information technology and business are becoming inextricably interwoven. I don’t think anybody can talk meaningfully about one without the talking about the other. ~Bill Gates Making things simple and clear should be much of the design effort. Not just something which works. A computer will do what you tell it to do, but that may be much different from what you had in mind. ~Joseph Weizenbaum Doing very little, often enough, can quickly add up. The inside of a computer is as dumb as hell but it goes like mad! ~Richard Feynman   Reference: Quotes relating to System Design from our JCG partner Peter Lawrey at the Vanilla Java blog. ...

The complex (event) world

This blog entry attempts to summarize the technologies in the CEP domain, touching over their prime feature(s) as well as their lackings.  It seems sometimes that the term CEP is being overused (as did happen with ‘ESB’) and the write-up below reflects our perception and version of it. ESPER (http://esper.codehaus.org/) is a popular open source component for complex event processing (CEP) available for java. It includes rich support for pattern matching and stream processing based on sliding time or length windows. Despite the fervent discussion over the term ‘CEP’ (http://www.dbms2.com/2011/08/25/renaming-cep-or-not/), ESPER seem to be a good fit for the term CEP, as it appears to be able to really identify “complex events” from a stream of simple events, thanks to ESPER’s EPL (Event Processing Language).Recently, while searching for an open source solution for real time CEP, our group stumbled across Twitter’s Storm project (https://github.com/nathanmarz/storm). It claims to be most comparable to Yahoo’s S4, while being in the same space as “Complex Event Processing” systems like Esper and Streambase. I am not sure about Streambase, but digging deeper into the Storm project made it look much different from CEP and from the ESPER solution. Ditto with S4 (http://incubator.apache.org/s4/). While S4 and Storm seem to be good at real time stream processing in a distributed mode and they appeared (as they claim) to be the “Hadoop for Real Time”, they didn’t seem to have provisions to match patterns (and thus to indicate complex events).Searching for a definition for CEP (that our study can relate to) led to the following bullets, (http://colinclark.sys-con.com/node/1985400) which include the below four as prerequisite for a system/solution to be called a CEP component/project/solution:Domain Specific Language  Continuous Query  Time or Length Windows Temporal Pattern MatchingThe lack of continuous query supporting time/length windows and temporal pattern matching seem to altogether missing in current versions of the S4 and Storm projects. Probably, it is due to their infancy and they will mature up to include such features in future. As of now, they only seem fit for pre-processing the event stream before passing it over to a CEP engine like ESPER. Their ability to do distributed processing (a la map-reduce mode) can help to speed up the pre-processing where events can be filtered off, or enriched via some lookup/computation etc. There have also been some attempts to integrate Storm with Esper (http://tomdzk.wordpress.com/2011/09/28/storm-esper/). While the processing systems like S4 and Storm lack important features of CEP, ESPER based systems have the disadvantage of being memory bound. Having too many events or having a large time windows can potentially cause ESPER to run out of memory. If ESPER is used to process real time streams, for e.g. from a social media, there will be lot of data accumulating in the ESPER memory. On a high level, the problem statement is to invent a CEP solution for big data. On a finer level, the problem statement include architecting a CEP solution for handling on-board (batched) as well as in-flight (Real-Time) data. In DarkStar’s terminology (http://www.eventprocessing-communityofpractice.org/EPS-presentations/Clark_EP.pdf), the requirement is “having matched a registered pattern in real time, discover similar patterns in the database”. Since being memory bound is a limitation, it may prove useful if some mechanism to condense the in-memory events can be arrived at. The condensed data however should still be meaningful and retain the context of the original stream.DarkStar does this using Symbolic Aggregate Approximation (http://www.cs.ucr.edu/~eamonn/SAX.htm), and they claim to address the aforementioned requirements by using SAX together with AsterData’s nCluster which is a mpp (massively parallel processing) database with an embedded analytics engine based on SQL/MapReduce (http://www.asterdata.com/resources/mapreduce.php). to be continued (as we research further) … Reference: The complex (event) world from our JCG partner Abhishek Jain at the NS.Infra blog....

Git vs. SVN – Commandline Syntax Reference

Learning the git workflow takes a bit of brain retraining, but since I’ve been using SVN almost entirely via commandline (because Subversive sucks and locks up my Eclipse when I try to use it for anything beyond synching/updating/committing a handful of files), adopting git’s commandline syntax is reasonably similar. Consider these simple operations:Initial checkout from existing repo for a given branch git clone http://github.com/sonatype/sonatype-tycho.git; cd sonatype-tycho; git checkout origin/tycho-0.10.x svn checkout http://anonsvn.jboss.org/repos/jbosstools/branches/jbosstools-3.2.0.Beta1/Update locally checked out files from central repo git pull svn updateList locally changes files/folders git status svn statDiff locally changed file git diff somefile.txt svn diff somefile.txtRevert locally changed file* git checkout somefile.txt svn revert somefile.txtRevert ALL local changes (except untracked files)* git reset –hard HEAD svn revert . -RAdd new file git add file.txt svn add file.txtAdd new folder recursively git add folder svn add folderDelete file git rm file.txt svn rm file.txtDelete folder git rm -r folder (non-recursive by default; use -r to recurse) svn rm folder (recursive by default; use -N to not recurse)Commit changed file to central repo git commit -m “message” file.txt; git push svn ci -m “message” file.txtIgnore files/folders (in the current folder) echo “target *.class bin” > .gitignore; \ git ci -m “gitignore” .gitignore svn propset svn:ignore “target *.class bin” .; \ svn ci -N -m “svn:ignore” .Obviously you can do a lot more w/ Git than with SVN (like stashing local changes temporarily), but for the sake of simply moving from a VCS to a DVCS and being able to continue to work the same way you already do, the above table should provide a good introduction. Reference: Git vs. SVN – Basic Commandline Syntax Reference from our JCG partner Nick Boldt at the DivByZero blog....

Camel: Now with Twitter and Websocket

The upcoming Apache Camel 2.10 is well underway. A lot of new components is being added, and two really exiting new components is twitter and websocket. Its yet another kick ass contributions from the community that makes this possible. James Strachan and I gave a talk last month at the JFokus conference in Stockholm. And for that conference I had prepared a little example using these new components. Unfortunately there was a problem with the projector and James laptop, so we had to give the presentation with slides only. So this weekend I found some time again, to polish the example, prepare documentation, and donate the example to the Apache Camel project. The example is demonstrating how to poll a constant feed of twitter searches and publish results in real time using web socket to a web page. As usual the code in Camel is very simple. All it takes is roughly   from(“twitter://search?…”)     .setHeader(“websocket.sendToAll”, “true”)     .to(“websocket:camel-tweet”) To use twitter, you need a twitter account which have setup an application to be used. For twitter users, you may be familiar that twitter requires you to grant applications access to your twitter account, such as twitter for iphone etc. The same applies for this example. We have described this in more details at the Camel twitter documentation. When you have created an application, you get a number of details back from twitter which you need to use the twitter component. We will get back to this later. This example is located in the examples directory of Apache Camel 2.10, in the camel-example-twitter-websocket. To run the example you use Maven with the following command: mvn compile exec:java The example will report error if you have not setup your twitter application. To do that edit the source code in the src/main/java/org/apache/camel/example/websocket/CamelTwitterWebSocketMain.java class. When successfully setup the applications starts, and you can open a web browser on page http://localhost:9090/ By default we do a twitter search every 2nd second for the word “gaga”. There is usually a lot of people tweeting about Lady gaga :). You can of course change this in the aforementioned source file. Below is a screenshot of the example in action.Live feeds of gaga tweets using Camel in a web browserThe client is a web browser, so we need to setup this in a .html page using JavaScript. See the src/main/resources/index.html for the source code. The interesting piece in the source code is that its very easy to setup a websocket client   var location = “ws://localhost:9090/camel-tweet”;   this._ws=new WebSocket(location);   this._ws.onmessage=this._onmessage;   this._ws.onclose=this._onclose; Notice that all it requires is an url to pass into the WebSocket constructor. And then setup two functions for callbacks.Have fun, and I tried using Metallica as the search term, but I must admit that there are more frequent tweets about Gaga.Metallica tweetsAnyone its time to end this blog, and get the code committed. And to enjoy some Metallica music, and have a nice weekend. Reference: Camel now with twitter and websocket from our JCG partner Claus Ibsen at the Claus Ibsen riding the Apache Camel blog....

WebSphere Application Server Performance Tuning Toolkit

IBM has released the WebSphere Application Server Performance Tuning Toolkit that gives the ability to monitor multiple WebSphere Application Servers from an eclipse workspace*. This tools uses WAS Performance Monitoring statistics to get and chart statistics that indicate the health and well being of your server. * Please note that the tool has been released on an as-is basis with no support. http://www.ibm.com/developerworks/websphere/downloads/peformtuning.html Why this tool instead of the other monitoring solutions 1. Its free :-) 2. No agents needed on the server 2. Monitor multiple servers3. This tool provides a standalone viewer for PMI and mbean statistics. It has a RCP GUI which uses the WebSphere application server admin thin client to call a JMX proxy, the JMX proxy will communicate with the WAS via the SOAP/RMI. 4, Predefined alerts and actions. · If the heapsize reaches the maximum heap size, it will generate a runtime alert. · If the thread pool reaches the threshold, it will generate a threadpool alert. · If the CPU usage reaches 90%, it will generate a runtime alert. · If some servlet error occur, it will generate a servlet alert. · If some connection timeout occurs, it will generate a connection alert · If there are some thread waiting for connection, it will generate a connection alert · If there are more then 1000 prepared statement discarded, it will generate a connection alert · If application try to use some invalidated session, it will generate a session alert · If there is no room for new session, it will generate a session alert · If some hung thread decleared, it will generate a threadpool alert · If some transactions rolled back, it will generate a transaction alert · If some transactions timeout, it will generate a transaction alert · You can define your own rules. 5. Monitoring The monitor panel presents performance data (Servlet Response Time, Transaction Response Time, Jdbc Response Time, Servlet Throughput, Transaction Throughput, Jdbc Throughput, Concurrency) in a classified views to help you with correlation and provide a comprehensive view of the state of the server. you analyze the performance problems in your environment.Response Time page The response time page presents the response time of a server. It collects data from four components i.e. servlet, transaction, EjbMethod and JDBC.Throughoutput page The throughoutput page presents the throughoutpage of a server. It displays data from four components. i.e. servlet, transaction, EjbMethod and JDBC.Concurrency page The concurrency page presents the concurrency of a server collecting data rom four components transaction, EjbMethod and JDBC.Alert page The alert page presents the alert evens of a server. You can find the alert detail from the alert type and alert description columns. Servlet page The servlet page presents the servlet detail informations of a server. You can find the response time, throughoutput, concurrency and error count in the columns. When you expand the row , you will get the servlet page detail of you application. Transaction page The transaction page presents the transaction information of a server. It displays response time, through output, roll back count, global timeout count, local timout count, global response time, local response time. EJB page The EJB page presents the EJB information of a server. It collects and displays response time, throughput and concurrent invocation data. When you expand the row, you can find the detail contribution of your application. The different colors mean the degree of the contributions. Connection Pool page The connection pool page presents the connection pool information of a server. It collects data from connection use time, connection through output, error count, wait time, JDBC through output, JDBC response time, JDBC concurrency, statement discard. When you expand the row, you can find the detail information of different JDBC connections. Runtime page The runtime page presents the runtime information of a server. It collects data from CPU usage, Max heap size, heap size, used heap size. Session page The session page presents the session information of a server. It collects data from live count, life time, affinity break, time out count, active non-exist count, no room count, cache discard count. When you expand the row, you can find the detail information of your different applications. The different colors mean the different contribution to the whole time. ThreadPool page The Thread pool page presents the thread pool information of a server. It collects data from max size, pool size, use pool, min size, declared thread hung count, concurrent hung thread count, cleared thread hung count. When you expand the row, you can find the detail information of different thread pools. The colors mean the different contributions. For more see http://www.ibm.com/developerworks/websphere/downloads/peformtuning.html Reference: WebSphere Application Server Performance Tuning Toolkit from our JCG partner Rohit Kelapure at the All Things WebSphere blog....

Automaton implementation in Java

This post will address the problem of implementing finite states machines into java. If you don’t know what FSM are or where can be used you may be keen on reading this, this and this. If you ever found yourself in the situation of using a FSM on your design you have probably started to write classes for every state which implemented the same interface. A good design might have been: interface State { } class State_1 implements State {} class State_2 implements State {} ...And you probably had a class that managed these states and the transitions between them, and another that implemented the Context of the FSM (the input band strip) and another interface for the starting states and one more for the end states and so forth. A lot of classes spread out in a lot of files that makes you to quickly lose track of them. There is another way: using enums. Enums are essentially list of classes, and each member of the enum may have a different implementation. suppose we have the following state machine that we want to implement: Init -(‘a’)-> A Init -(else)-> Fail A -(‘b’)-> B A -(‘c’)-> C A -(‘a’)-> A A -(”)-> End A -(else)-> Fail B -(‘c’)-> C B -(‘b’)-> B B -(”)-> End B -(else)-> Fail C -(‘c’)-> C C -(”)-> End C -(else)-> Fail This FSM will validate the following regexp: ^(a+)(b*)(c*)$. We can write the states as elements of the enum State as follows: interface State { public State next(); }class Input { private String input; private int current; public Input(String input) {this.input = input;} char read() { return input.charAt(current++); } } enum States implements State { Init { @Override public State next(Input word) { switch(word.read()) { case 'a': return A; default: return Fail; } } }, A { @Override public State next(Input word) { switch(word.read()) { case 'a': return A; case 'b': return B; case 'c': return C; case '': return null; default: return Fail; } } }, B { @Override public State next(Input word) { switch(word.read()) { case 'b': return B; case 'c': return C; case '': return null; default: return Fail; } } }, C { @Override public State next(Input word) { switch(word.read()) { case 'c': return C; case '': return null; default: return Fail; } } }, Fail { @Override public State next(Input word) { return Fail; } }; public abstract State next(Input word); }What we’ve done is we’ve defined the transitions of every state inside each enum. Each transition returns a new state and as such we can cycle through them more efficiently: State s; Input in = new Input("aabbbc"); for(s = States.Init; s != null || s != States.Fail; s = s.next(in)) {} if(s == null) {System.out.printlin("Valid!");} else {System.out.println("Failed");}At this point, we have either validated the string or failed. It is a simple and elegant design. We could further improve the implementation by separating the final states from the main ones as to simplify the exit condition of the traversal. We will define another interface called FinalState and a second enum that would contain the desired exit states (changing also the States enum accordingly): interface FinalState extends State {} enum FinalStates implements FinalState { Fail { @Override public State next(Input word) { return Fail; } }, Ok { @Override public State next(Input word) { return End; } } }As such, the traversal will be somewhat simplified: for(s = States.Init; !(s instanceof FinalState); s = s.next(in)) {} switch(s) { case Fail: System.out.printlin("Failed"); break; case Ok: System.out.println("Valid!"); break; default: System.out.println("Undefined"); break; }The advantage is that (besides a simpler traversal) we could specify more than two final states. Most of the times, a FSM will have more than one exit point so this last improvement is recommended for the long-term. You can also place all these enums and interfaces inside the same source file and have the whole logic in one place rather than surf through multiple tabs in order to understand how the flow works. As a conclusion, using enums makes for a more compact and meaningful implementation of a FSM. You have all the logic in one file and all traversal is painless. You will also have a much more easier debugging experience since the name of the states in which you’ve translated will appear in the debugger ( the variable s will change its value accordingly, bearing the name of the new state) rather have to figure out what class you have just jumped to. All in all I think it’s a good technique to have in mind. Reference: Automaton implementation in Java from our JCG partner Attila-Mihaly Balazs at the Transylvania JUG blog....

Spring & JSF integration: Navigation

This is the first in what I hope will be a series of blogs about my efforts to provide deep integration between Spring and JavaServer Faces. Everything mentioned here is a “work in progress” so if you checkout the code please be aware that it is a moving target; expect some rough edges and don’t be surprised if it’s sometimes broken. You can already use Spring with JSF pretty happily out of the box, with Spring managing your beans and JSF handling your screens. There is also some really great support for JSF in Spring Web Flow, if you are doing any flow based application you really should be using Web Flow. Web Flow also provides the org.springframework.faces.mvc.JsfView class that will let you render a JSF page from Spring MVC. Unfortunately JsfView only renders transient (stateless) views, if you want to handle postbacks you are out of luck. Allowing Spring MVC to render JSF views that can handle postback has been my primary driver for starting this project. Thanks to the flexibility of both MVC and JSF it is entirely possible to integrate these technologies (although the exact details of how are probably best saved for another post). I want to spend the rest of this post talking about how we can create really nice JSF navigation. If you have used standard JSF navigation you are probably used to the following type of thing in your faces-config.xml: <navigation-rule> <from-view-id>/pages/list.xhtml</from-view-id> <navigation-case> <from-outcome>select</from-outcome> <to-view-id>/pages/details.xhtml</to-view-id> <redirect/> </navigation-case> </navigation-rule>Whilst it is pretty easy to understand, there are some obvious drawbacks of the standard approach, for starters its pretty verbose. Most of the time I want to redirect my users rather than leaving them confused as to why the URL shows something different to their current page. Needing that <redirect/> on virtually every element is really annoying. The amount of XML obviously upset the developers of JSF themselves, and luckily JSF 2.0 has introduced the concept of implicit navigation. This is something we will make use of later. If you want to read a really good article about JSF navigation checkout Fluent Navigation in JSF 2 by Dan Allen. Navigation is really all about destinations, there is not much point in redirecting someone to a 404 page not found error. Creating nice readable URL destinations has always been a bit of a struggle for JSF. Right now, without developing your own code, the best option for creating readable URLs is probably to use PrettyFaces. Of course, with JSF and Spring integrated nicely you don’t need to use anything other than the @RequestMapping annotation to create readable URLs. The example below shows a how you can map a nice readable URL to show hotel details from an ID. @Controller public class HotelsController { @RequestMapping(value = "/hotels/{id}", method = RequestMethod.GET) public String show(@PathVariable Long id, Model model) { model.addAttribute(bookingService.findHotelById(id)); return "hotels/show"; } }With @RequestMapping annotations in place we can think again about the navigation. Usually the <h:commandButton>, <h:button>, <h:commandLink> or <h:link> components will be used to trigger navigation, for example: <h:commandButton value="Go" action="select">Here when the user clicks on the "Go" button the "select" action kicks in and the navigation rules are used to find a destination. As we want to move away from defining navigation XML we need an alternative approach to find MVC destinations. Slightly subverting JSFs support for implicit navigation gives us quite a nice way to do this. With a bit of integration code we can support a special "spring:" prefix that tells JSF to resolve destinations using Spring MVC. <h:commandButton value="Go" action="spring:redirect:/spring/hotels/123"/>The example above will resolve "redirect:/spring/hotel/123" using the ViewResolvers registered with Spring MVC. In this case UrlBasedViewResolver will pick up "redirect:" and a RedirectView will be used. That’s quite nice, but hard-coding the hotel ID "123" into the view name is not all that practical. Luckily there is an answer: <h:commandButton value="Go" action="spring:redirect:/spring/hotels/{id}"> <f:param name="id" value="#{resultItem.id}/> </h:commandButton>All <f:param> child tags of the commandButton will be used to construct a model for the MVC view. In this case we get a model containing “id=#{resultItem.id}“. The EL value expression #{resultItem.id} will be resolved before the view is rendered. The RedirectView class in Spring 3.1 will deal with URL template variables, so “/spring/hotels/{id}” will pick up “id” to render the complete URL. One slight irritation with the above method is that you need to define your URLs inside your XHTML files as well as in your @RequestMapping annotations. As an alternative to this you can use a special “@bean.method” notation to indicate that you want to navigate to the value of the @RequestMapping on the specified controller bean method: <h:commandButton value="Go" action="spring:@hotelsController.show"> <f:param name="id" value="#{resultItem.id}/> </h:commandButton>If you have more than one @RequestMapping method on your controller bean you can navigate between them using the even shorter syntax “@method” (here the bean is assumed to be the current handler). Of course not every type of @RequestMapping can be reversed into a URL, for example if you use wildcards then this will not work. The advice is to keep your mappings as simple as possible. One final benefit of this method is that we can also reverse the DataBinder process. For example: public class SearchCriteria implements Serializable { private String searchString; private int page; // ... getters / setters }@RequestMapping(value = "/hotels") public String list(SearchCriteria criteria, Model model) { // ... }<h:link outcome="spring:@list"> <f:param name="sc" value="#{searchCriteria}"/> </h:link>Assuming the #{searchCriteria} EL expression resolves to a SearchCriteria object containing the string "California" and the integer 10 the URL built would be "/spring/hotels?searchString=California&page=10". If you would like to have a look at code for this project it is currently available at http://github.com/philwebb/springfaces. As mentioned at the top of the post this code is a work in progress so please expect some problems. My next task on the roadmap is to support a @NavigationMapping annotation that will allow programmatic navigation. Reference: Integrating Spring & JavaServer Faces : Navigation from our JCG partner Phillip Webb at the Phil Webb’s Blog....
Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
Do you want to know how to develop your skillset and become a ...
Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

Get ready to Rock!
You can download the complementary eBooks using the links below: