There is a great article over at Ajaxian on programming for the Nintendo Wii. I bought a Wii myself a few weeks back and have been having great fun with Tiger Woods golf. (It is actually my first game console) Up until down the idea of playing a game console alone did not appeal to me but the Nintendo Wii experience is amazing.
The Wii console connects to the controller or Wiimote via bluethooth and uses an accelerometer built into the wiimote to detect the location of the wiimote as well as it’s acceleration. This leads to a really interactive experience for the user.
I have been amazed by responsiveness of the Wiimote and now Dion Almaer and Ben Galbraith over at Ajaxian have developed an Ajax app that uses Wiiusej to interact with the Wiimote. The Wiiusej API is a java wrapper for the C based Wiiuse library.
We then wrote a Java class that acts as a state machine for what the remote is doing. It understands the movements, which buttons are pushed, how fast you are moving the device. With this data we could build a simple darts game. With the state machine Java code, and an Applet wrapper that exposed the information, we were ready to get to the Ajax side of the house.
I came across this great site via DZone. The site provides a great overview of the Gang of Four patterns as well as J2EE patterns with UML diagrams and sample code for each one. Here what the author, Andre Mare wants to get from the blog.
Java Design Concepts will provide information on how to design, implement and deploy system in a high availability enterprise environment. The design concepts include design patterns, and Object Oriented Programming (OO). Java technologies include J2EE, EJB, JAF, JMS, JSP, JSTL, JDBC etc..
As the site is still in development some of the J2EE patterns are not complete yet but this is definitely one for your RSS reader.
Google just launched a preview of their app enigne. You can read all about it here.
With Google App Engine, developers can write web applications based on the same building blocks that Google uses, like GFS and Bigtable. Google App Engine packages those building blocks and provides access to scalable infrastructure that we hope will make it easier for developers to scale their applications automatically as they grow. This means they can spend less time dealing with system administration and maintenance, and more time building and improving their applications. (There’s more detail on the new App Engine Blog.)
I tried to sign up but it looks like the first 10,000 have already applied. You can still download the API from here in the mean time if you want.
I came across this framework during the week via Ajaxian. It provides an end to end solution with all of the plumbing in place for DWR, Dojo, Spring and Hibernate/JPA. This is a great place to start for someone that wants to get up and running fast with inner plumbing in place for these frameworks. Here is what the developer Jose Noheda said he was looking for from the project:
Nonetheless, in my mind what I really needed was a platform that:
Is based on Java
Although supporting Grooy / JRuby is a plus
Helps me to kick start a project
But simplifying the process by giving me the best (and this can be tricky) set of frameworks for each task
Integrates both server and client sides
And it’s lightweight, robust and extensible. Read enterprise quality.
Supports all the common tasks a web app has to handle
I include here: User Management, CRUD operations, i18n support (both framework & data), AJAX and astounding visuals
The project is only at the preview stage so it does come with caveats. When you start up the app you get a sample app showing some of the Dojo widgets in action as well as some screens demonstrating basic CRUD operations.
If you want find out more you can download the project from here or check out Jose’s blog here.
I have used the Checkstyle plugin for a few years now and found it extremely useful. In a nutshell, checkstyle will check your code against coding standards and issue a warning if you code something that is not in the correct format. This has always been a real bone of contention with fellow developers. One developer I worked with in the past felt that everyone should be free to code in whatever style they prefer. I would not agree with this at all. It can lead to code that is very hard to maintain and read.
With a plugin like Checkstyle you don't need "Code Police" checking the code and informing people that they are using the wrong style. If you want to push it one step further you can set up your automatic build (We used Cruisecontrol in the past) to mark a build as broken when it comes across a Checkstyle error. This ensures that a code base is readable and maintainable. Here is an example of bad coding style:
if (testBoolean) myNum++;
Many developers leave out the parenthesis as the compiler will not complain, this can often lead to confusion when you expect a line below to run when the statement is true but of course it won't because the myNum++ is going to run. The correct way to write this would be as follows:
if (testBoolean) { myNum++; }
A new developer that comes across this code will know exactly what statement is run when the if statement is true. It is also possible to change the change the Checkstyle configuration for situations where a company has their own coding convention.
I have not used the other plugins yet but have a look at the article for how to install them. I am interested to see how good the code duplication plugin is. I hate when I come across "Cut and paste" coding because someone is too lazy to abstract the functionality into a base class.
I came across an interesting article by Masayuki Otoshi via Java World that discusses how to execute process definitions on the client side rather than the server side. This can come into play when making AJAX calls. As AJAX is Asynchronous, it is not possible to predict the order that your callback methods will be called in. Masayuki uses J-SOFA (Java/JavaScript Services Orchestration for Actions) to overcome this.
I haven't come across J-SOFA before but it looks like it might be worth looking at for situations where the order of callback methods is important.
I came across this interesting article by Matjaz B. Juric on how to integrate BPEL(Business Process Execution Language) into an SOA environment. Juric discusses the core concepts involved with BPEL and why BPEL is so important. He uses a business travel system as an example.
Juric concludes by stating:
We have seen that BPEL is one of the most important cornerstones of SOA. It differs from common programming languages, such as Java, and is relatively easy to learn and use. Because BPEL has been designed specifically for definition of business processes, it provides good support for various specifics of business processes, such as support for long running transactions, compensation, event management, correlation, etc. BPEL is well suited for use with the Java EE platform, and many BPEL servers build on top of it. Java developers, particularly those who are involved in the development of enterprise applications and SOA, should therefore take a closer look at BPEL and start using the benefits it provides.
I have not used BPEL in any of the projects that I have been involved with but it certainly looks like something that should be seriously considered.
Does anybody have any Caveats from their experiences of using BPEL? If so please leave a comment as I would be interested to hear any real world experiences.
Here is an interesting artice from Jeff Friesen discussing how to interact with a USB device using java:
Java and USB by Jeff Friesen — Want to use a USB device in Java? Some with native abstractions, like mass-storage drives, work as you'd expect, but many devices like webcams and game controllers are simply invisible to the Java programmer. Jeff Friesen looks at two APIs that expose USB devices to Java, then shows how to build a Java USB implementation of your own.
Currently, Java does not officially support USB but Jeff discusses how you can use thirdparty APIs as well as his own API. Readers may also be interested in the Bluetooth JSR.
There are often times when you need to call a method but you do not know the name of the method until runtime. I came across this issue during my Thesis. Our problem was as follows: How do we dynamically map between an object type and a method in the sub class of PublishableServer that processes that type?
Here is some background to the problem: PublishableServer is an abstract class that can connects to our distributed system and receives requests for lists of PublishedData objects. A subclasses of PublishableServer must implement methods to process various PublishedData objects it receives.
If we look at the JDBCServer illustrated above. This class must implement methods to search for PublishedData objects in the database that it is connected to. Each method must map between attributes of the PublishedData object and the columns in the database. As the getPublishedList(PublishedData publishedData) method of PublishableServer is called we must map this publishedData object to the correct method in the sub class.
One option could be to declare the methods as abstract in the PublishableServer class and then use the instanceof operator to select the correct method.
public ArrayList getPublishedList(PublishedData publishedData) { if (publishedData instanceof Student) { return getPublishedList((Student) publishedData); } else if (publishedData instanceof Course) { return getPublishedList((Course) publishedData); } return new ArrayList(0); }
public abstract ArrayList getPublishedList(Course publishedCourse); public abstract ArrayList getPublishedList(Student publishedStudent);
The issue with using this approach is that we need to update the PublishableServer class every time a new type of PublishedData is added to the framework. All PublishableServer implementations would also have to implement all the search methods, even if they did not want to.
The solution to this issue is to use Reflection to dynamically call the methods in the sub class. To allow this, the methods in the subclass must have a known name. We prepend "getPublished" to the name of the PublishedData class that was passed to the getPublishedList() method. So all we need to do is get the name of the class that has been passed, append that to "getPublished" and we have the name of the method that implements that search. The publishedData object implements a mehtod called getClassName() that will return the name of a class without the package name. To create a method to search for Student objects we simple implement the following method in the JDBCServer class that extends PublishableServer.
public ArrayList getPublishedStudent(PublishedData publishedData)
The body of this method should implement a search for Student objects in the servers persistent store using the properties of the Student object passed to narrow the search results.
So how do we call this method once we have its name?
The getClass() method that all java objects inherit will return the runtime class of the current object. In our case when we call this method inside the PublishableServer class we will get the runtime class that extended our PublishableServer class. The Class object contains a method called getMethod() which takes the name of the method and an array of Class objects which represents the list of parameters for the method. If the method does not exist a NoSuchMethodException is thrown. If this is thrown in our server we simple return an empty ArrayList as this server does implement that search.
If the method does exist then we call invoke() passing the current object and PublishedData parameter. This will dynamically call our method and return an Object class. We must cast this to an ArrayList and return it. The implementation of this can be seen below.
public ArrayList getPublishedList(PublishedData publishedData) { ArrayList result = new ArrayList(0); String className = publishedData.getClassName(); String methodName = "getPublished" + className; Class[] argTypes = new Class[] { PublishedData.class }; Object[] args = new Object[] { publishedData }; try { Method m = this.getClass().getMethod(methodName, argTypes); result = (ArrayList) m.invoke(this, args); } catch (NoSuchMethodException noSuchMethod) { logger.error("ERROR: " + serverName + " does not support searches of type: " + publishedData.getClass().getName()); logger.error("ERROR:" + this.getClass().getName() + " needs to implement the follwing method to preform search:"); logger.error("public ArrayList " + methodName + "(PublishedData publishedData){"); logger.error(" ArrayList result = new ArrayList();"); logger.error(" //Preform Search"); logger.error(" return result;"); logger.error("}"); } catch (IllegalAccessException illegalAccess) { logger.error(serverName + " Does not support searches of type" + publishedData.getClass().getName(), illegalAccess); } catch (InvocationTargetException invocTarget) { logger.error(serverName + " Does not support searches of type" + publishedData.getClass().getName(), invocTarget); } catch (Exception general) { logger.error(serverName + " Does not support searches of type" + publishedData.getClass().getName(), general); }
Exadel have just released a JSF editor with AJAX support.
JSF, a Web component framework, is the only standard Java Web framework,” said Richard Monson-Haefel, senior analyst for Burton Group. “AJAX, which makes Web sites more responsive, is enjoying an avalanche of grass roots support because of its portability and seamless integration with HTML. Together, JSF and AJAX offer the benefits of standardization with a rich internet experience; a combination that will be attractive to many organizations
Unfortunately, it is a bit pricey at $799 per annual subscription license. I am going to download the trial at the weekend and have a look. I have been using the exadel Studio for eclipse and found the it very good. (Thanks Colin for the recommendation on this one.) I had been looking for a good JSP visual editor plugin for eclipse for quiet a while and this seems to be one of the better ones.
On a different note, I have decided to change my hosting service to InterAdvantage. I have got a pretty good package and will be transferring over this blog to Wordpress as soon as the domain transfer goes through. I will post all new RSS feeds here before the change over.