mvn 3.0.3 + java 7 Datasource fail

11 11 2011

Okay just wanted to mention that if you’ve done a custom Datasource for java 6 and try to compile it with java 7 on maven using backwards compability you get this:


[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on pr
oject wallboard-cisco-drivers: Compilation failure
[ERROR] \nino\develop\eclipseworkspace\projects\internalcomponents\Applications\wallboard\trunk\wallboard-cisco-dri
vers\src\main\java\com\netdesign\dao\cisco\general\DataSourceProvider.java:[149,43] error: is not abstract and does not override abstract method getParentLogger() in
CommonDataSource
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn -rf :wallboard-cisco-drivers
C:\nino\develop\eclipseworkspace\projects\internalcomponents\Applications\wallboard\trunk>

Please notice that i’ve specified this in my pom:

<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>

Only solution are to grab an old jdk 6 and compile it with that.. I was using jdk 1.7.0.

Feel free to correct me if im wrong somehow.

Advertisements




Guice and JDBC #2

4 11 2011

So a little while ago, I wrote about jdbc and guice.. I’ve been using mybatis since then.. And it just came to me yesterday “with mybatis you can do simple jdbc with guice”. Something similar to Spring JDBC templates.

So heres how (integer select), using annotation approach in something called a mapper class.


@Select(value = "select ${sql}")
public Integer updateCustomerEntrance(@Param("sql") String sql);

Thats it the only stuff you need to ensure are that your select will return an integer, and thats it. Mybatis will manage connection pool, connection etc for you.

It’s probably also possible for you to just return a object.. you’ll need at least 3 methods one for each type of sql, select update and delete.

However this approach are not at all utilizing mybatis’s power and are prone to SQL injection.. But it will do the job, and you can then go ahead an convert your legacy code slowly to use mybatis’s full potential.

Heres howto setup guice using it:

http://code.google.com/p/mybatis/wiki/Guice





Connecting to db_cra uccx 8

3 06 2010

So im trying to connect to db_cra on a uccx 8, and it turned out to be a litte harder than expectet. In the cisco documentation the Informix database should be called something like hostname_uccx. In our case our servers are named SERVERNAME-number so the informix name should be SERVERNAME-number_uccx, thats not the case.

Heres the recipe:

Find the real name of the informix server: run this on your uccx CLI:

file dump inactivelog /uccx/log/db/uccx_repl_output_util.log

Go to the last page using SPACE and look for something like this:

2010-05-14 22:00:23,242 - uccxdb.util - DEBUG - getservers processing
2010-05-14 22:00:23,244 - uccxdb.util - DEBUG - getservers: processing line g_poc5_uccx8_uccx group           -               -               i=1
2010-05-14 22:00:23,244 - uccxdb.util - DEBUG - getservers: processing line poc5_uccx8_uccx onsoctcp POC5-UCCX8 poc5_uccx8_uccx g=g_poc5_uccx8_uccx b=32767
2010-05-14 22:00:23,245 - uccxdb.util - DEBUG - The servers are [['poc5_uccx8_uccx'], ['g_poc5_uccx8_uccx']]
2010-05-14 22:00:23,453 - uccxdb.util - DEBUG - Setting property com.cisco.callprocessing.protocolID to CTI-JTAPI on poc5_uccx8_uccx

And that’s it. So in our case our server got lower cased and underscored, “poc5_uccx8_uccx”.

If you want you can use the ibm JDBC driver (http://www14.software.ibm.com/webapp/download/search.jsp?go=y&rs=ifxjdbc) and the SQL squirrel (http://squirrel-sql.sourceforge.net/)





Guice Caching And Interceptors

14 05 2010

A little while ago I wanted to try out Guice 2’s Interceptors. And amazingly enough, I managed to create an integration towards ehcache in a couple of hours and had fun too.

The result is this

// Calculator.java
package org.slurry.cache4guice;

public interface Calculator {

        public int calculateSomethingWild(Integer number) throws InterruptedException ;

        public int calculateSomethingWild(Integer number,Integer number2) throws InterruptedException ;

}

// CalculatorImpl.java
package org.slurry.cache4guice;

import org.slurry.cache4guice.annotation.Cached;

public class CalculatorImpl implements Calculator {

        @Cached
        public int calculateSomethingWild(Integer number)
                        throws InterruptedException {
                Thread.sleep(2000);

                return number;

        }

        @Cached
        public int calculateSomethingWild(Integer number, Integer number2)
                        throws InterruptedException {
                Thread.sleep(2000);

                return number + number2;
        }

}

And bind it in your module

// GuiceModule.java
package org.slurry.cache4guice;

import com.google.inject.AbstractModule;

public class GuiceModule extends AbstractModule {

        @Override
        protected void configure() {
                bind(Calculator.class).to(CalculatorImpl.class);

        }

}

So what’s backing those annotations in line 19 and 28 of the first source code box, whats doing all the magic?
1. An annotation, dada 🙂

package org.slurry.cache4guice.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD)
public @interface Cached {

}

2. An interceptor, more interesting, look at line 18 the most important thing in the interceptor implementation

package org.slurry.cache4guice.aop;

import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Element;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

import com.google.inject.Inject;

public class CacheInterceptor implements MethodInterceptor {

        private CacheManager cacheManager;

        private CacheKeyGenerator cacheKeyGenerator;

        public Object invoke(MethodInvocation invocation) throws Throwable {
                setupCacheIfNecessary(invocation);

                return getResultFromCacheOrMethod(invocation);

        }

...

3. Some Guice setup, in a module look at line 18,19 and 20. And actually line 19 are only needed if you need something injected into your interceptor

package org.slurry.cache4guice.module;

import net.sf.ehcache.CacheManager;

import org.slurry.cache4guice.annotation.Cached;
import org.slurry.cache4guice.aop.CacheInterceptor;
import org.slurry.cache4guice.aop.CacheKeyGenerator;
import org.slurry.cache4guice.cache.StringBasedKeyGenerator;

import com.google.inject.AbstractModule;
import com.google.inject.matcher.Matchers;

public class CacheModule extends AbstractModule {
        protected void configure() {

                bind(CacheManager.class).toInstance(CacheManager.create());
                bind(CacheKeyGenerator.class).to(getCacheKeyGeneratorClass());
                CacheInterceptor cacheInterceptor = new CacheInterceptor();
                requestInjection(cacheInterceptor);
                bindInterceptor(Matchers.any(), Matchers.annotatedWith(Cached.class),
                                cacheInterceptor);
        }

        protected Class getCacheKeyGeneratorClass() {

                return StringBasedKeyGenerator.class;
        }
}

So could it be easier? I mean theres only 3 steps. Now I haven’t shown all the code, only the relevant ones for guice. There’s a little more to it. And I should probably expand the functionality, so there’s a evict from cache annotation, that can evict certain caches. So did you need a cache for guice or did you want to play with interceptors, now you got both 🙂

All hosted here, with source code and tests,  if you have additions please contribute
http://code.google.com/p/slurry/





GeeCon_2010

14 05 2010

So sitting in the hotel, geecon 2010 are over. All in all a nice experience. A little small maybe. But content was great, thats the important thing. And if you look at the price, if probably the best conference for the price, 100 eur… Cant get much cheaper.

The website

http://2010.geecon.org/main/home

And the slides/videos (some, I guess they’ll all come latter) :

http://www.parleys.com/#st=4&id=51713





Rest Guice and JAX-WS

10 03 2010

These days im working on a small rest application, I found these resources to be helpful:

http://docs.sun.com/app/docs/doc/820-7627/giqdq (archetypes)

http://blog.curran.in/2010/02/creating-restful-service-with-jersey.html (setting up jax-ws with guice)

https://jersey.dev.java.net/nonav/documentation/latest/user-guide.html#d4e1111 (a little more info, but the article above are enough)

http://xstream.codehaus.org/ (framework for creating xml fragments)

So for unit tests im using dbuit to seed the hsql database and grizzly to run the application, jersey client acts as client.

I’ll probably add code examples to this article when I get time.





WicketStuff Artwork new release

26 05 2009

Ever tired of using endless hours of css’ing just to find out that what you did breaks in IE.. WicketStuff Artwork is all about making your wicket site turn into art, easy. It’s a package consisting of two modules

  1. Liquid
  2. NiftyCornersCube

Both modules will let you do round corners on containers simple and easy, just add a behavior to your wicket component or your page and thats it.
Liquid will let you do all sorts of advanced stuff with your markup containers, for example add a shadowed border, see this screenshot:

Liquid Examples

Liquid Examples

NiftyCornersCube are really quick to render and requires less cpu processing so it has some advantages but are also very limited in effects. See here:

Nifty Examples

Nifty Examples

You can grab the latest snapshot release here:
http://wicketstuff.org/maven/repository/org/wicketstuff/artwork/1.4-SNAPSHOT/

And see howto checkout the examples here:
http://wicketstuff.org/confluence/display/STUFFWIKI/Wiki

Basically it’s just this svn url:
http://wicket-stuff.svn.sourceforge.net/svnroot/wicket-stuff/trunk/wicketstuff-core/artwork-parent/artwork-examples
But you should check out the whole wicketstuff core in order to build dependencies.

Now please come with more ideas and JS libs to add to the Artwork package 🙂 I want to see some comments on how to improve it 🙂

Regards Nino