Samstag, 31. Dezember 2011

GwtGL 0.9 released

We recently released GwtGL 0.9. GwtGL is a WebGL binding for GWT (Google Web Toolkit).
GwtGL 0.9 provides an improved binding for the WebGL 1.0 spec, support for the GWT 2.2 Canvas widget and support for the current Typed Arrays
spec.

The work areas of this version in detail:

  • Improvements for the WebGLRenderingContext and WebGlCanvas
    • GWT 2.2 Canvas Support
    • WebGLRenderingContext is now a JavaScriptObject
    • Generator for accessing the WebGL constants was removed
  • Basic Tests for the Typed Arrays binding
  • Binding of the current Typed Arays specification
    • Bugfixing of the existing binding (set methods were partially broken)
    • Binding of new functionality (new class Uint8ClampedArray)
  • Improved handling of Java Arrays using the JsArrayUtil

Please note: this release breaks the existing APIs in some parts.

Donnerstag, 13. Mai 2010

Using Spring AOP with Grails Services

If you try to work with Spring AOP and service classes in a Grails application, you will probably end up with an exception like:

Error executing script TestApp: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'testService':
Invocation of init method failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class $Proxy11]: Common causes of this problem include using a final class or a non-visible class;
nested exception is java.lang.IllegalArgumentException: Cannot subclass final class class $Proxy11


To solve this problem you have to add the following line to your resources.xml (in grails-app/conf/spring):
<aop:aspectj-autoproxy proxy-target-class="true"/>

Your final resources.xml will look like this:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

 <aop:aspectj-autoproxy proxy-target-class="true"/> 
 
</beans>


This was tested with Grails 1.2.2 and Grails 1.3.0.

Mittwoch, 24. Februar 2010

First official release of GwtGL - a WebGL binding for GWT

We recently released the first version of GwtGL.
GwtGL offers a GWT binding to enable developers to code WebGL apps using the Java language and toolset.

WebGL is a new web standard for hardware accelerated 3D graphics in web browsers. Soon all major web browsers (Firefox, Safari, Chrome, IE) will support WebGL - at the moment most of these browsers offer preview version that can be used to experience WebGL powered apps.
WebGL is based on OpenGL ES, so porting apps and games to the web is quite easy.

So, why do you need GwtGL when you could use WebGL directly?
WebGL is a javascript API, so you would have to program your application using Javascript. IMHO, this is a real pain for apps that are more complex than simple examples.
This is where GwtGL comes into play. Using GwtGL, which is Open Source and free to use, you can develop WebGL apps using the Java language, using your favorite Java IDE (e.g. Eclipse), using powerful Java tools.
GWT, GwtGLs underlying technology, uses a cross-compiler to compile your Java code to Javascript that can be run in the web browser. The compiler optimizes your code, so your app will probably run faster than it would if you coded it in Javascript directly.



The first release of GwtGL offers a complete binding for WebGL, so everything that is possible with WebGL directly is also possible using GwtGL. Besides that, GwtGL offers a wrapper layer on top of the binding to allow the developer to program in an object oriented, easier way. We also released a documentation with explanations and tutorials, and some examples that you can use as a starting point for your own apps.

I hope you enjoy using GwtGL!

Freitag, 29. Mai 2009

Debugging Grails Integration Tests

Running all unit/integration tests consumes a lot of time, so most of the time during development, you probably run single integration tests from the command line:

grails test-app -integration ClassUnderTest

If you want to debug an integration test to find out why a test is failing, follow the steps described below:

In IntelliJ, do the following:

  • Create new run configuration (Edit configurations -> Add new configuration -> Remote)
  • Enter name for the configuration
  • Deselect "Make"
  • Set brakepoint in your test class to make the debugger stop at this point.

Using the command line, run the single integration test using "grails-debug" instead of "grails". This will start grails in debugging mode (it will open a remote debug port).

grails-debug test-app -integration ClassUnderTest

Run your remote debugging session in IntelliJ by pressing on the debug button next to your run config...

If you use a different IDE like Eclipse or Netbeans, remote debugging should be as easy as described above.

Montag, 18. Mai 2009

Custom Webtest steps for the Grails Webtest Plugin

Since version 0.6 of the grails webtest plugin, it is possible to create custom steps (http://www.leebutts.com/2009/01/grails-webtest-plugin-06-released.html):
"You can now extend com.canoo.webtest.steps.Step by placing groovy classes in webtest/tests/step. They will be automatically loaded at runtime and allow for easy testing of complicated scenarios such as JSON interfaces and email integration"
Unfortunately, there is no description or example how to actually create a custom step.

So here is what you have to do:
  • Create directory webtest/tests/step
  • Create Step Class. It is important that the class name ends with 'Step', otherwise it will not be picked up.
  • Class must extend com.canoo.webtest.steps.Step
  • Class must override void doExecute()
  • Put the step's execution logic into the doExecute() method.
  • To pass parameters to the step, define the step's arguments as properties of the step class.
  • To validate the parameters, override void verifyParameters() and check the properties you defined. If property is not valid, throw IllegalArgumentException.

Here is an example of a custom step. The step will log a greeting message. Our goal is to create a step that can be called in a webtest test class as shown below:
def testGreeting() {
 greeting(param:'grails')
}

The implementation of the step is quite simple:
import org.apache.log4j.Logger

class GreetingStep extends com.canoo.webtest.steps.Step {
 private static Logger log = Logger.getLogger(GreetingStep)
 String param

 @Override
 void doExecute(){
  log.info "Hello $param"
 }

 @Override
 protected void verifyParameters(){
  if(!param) {
   throw new IllegalArgumentException('param not set')
  }
 }
}

Place GreetingStep class in directory webtest/tests/step.

Samstag, 21. März 2009

My Java & Grails Blog has finally come to life!

This is the first post in my new blog. I'm going to blog on Groovy and Grails related stuff, as well as interesting Java EE technologies.