Welcome!
I'm Gediminas and you are in my sandbox, grab your favorite tool and come join me in the game!

Archive for the ‘java’ Category

Kaziukas from a new smile angle

Monday, March 7th, 2011

“<...>Kaziuko mugė (English: Kaziukas Fair, Polish: Kaziuk) is a large annual folk arts and crafts fair dating to the beginning of the 17th century. It was originally held at the two main markets in Vilnius, Lithuania, as well as in the city streets.” – (c) wikpedia

This year I took a different angle of view and photo-freezed all those little miracles:

Smile with us a little bit longer: http://goo.gl/XdMVz

GameJam2011

Sunday, February 6th, 2011

GameJam event comes in place and sprint of non-stop development begins. The theme for this year was “EXTINCTION”. Event location in Lithuania was POV office.
24 games were created. ~30 participants in Vilnius.

The list of games this year:
Colorful Greedy Populations – http://globalgamejam.org/2011/colorful-greedy-populations
Pigeons – http://globalgamejam.org/2011/pigeons
Supersize Exctinction – http://globalgamejam.org/2011/supersize-extinction
Dodopult – http://globalgamejam.org/2011/dodopult
Brain Extinction: Zombie… – http://globalgamejam.org/2011/brain-extinction-zombie-zombie-zombie
Detective – http://globalgamejam.org/2011/detective
Blooming Island – http://globalgamejam.org/2011/blooming-island
Extinct-O-Tanic – http://globalgamejam.org/2011/extinct-o-tanic
Multiply or Extinct – http://globalgamejam.org/2011/multiply-or-extinct
Slots of Death – http://globalgamejam.org/2011/slots-death
Snake Extinction – http://globalgamejam.org/2011/snake-extinction
Breedpong – http://globalgamejam.org/2011/breedpong

Photos from the event:

Also can be accessed at: http://goo.gl/rq3dR
Photos by M.P. at: http://goo.gl/VYWZO

Spring, lets Mock!

Tuesday, January 11th, 2011

How would you mock your services which are not mock-friendly?
Let’s introduce a real case (the bad one) with some preconditions:

1. You have a service where DAOs are wired at runtime based on the some conditions.

2. DAOs lookup API is private and not exposed to the caller.

In this case you will be blocked from mocking those DAOs because of such approach.
The solution I came up with was to tweak the Spring context by unregistering the target bean (service/dao or whatever), creating the mock and registering to the context back by aliasing, to make it retrievable as regular target bean. The concept code snippet from my routine by mocking DAO’s would be:

  1. protected <T extends IDao<?>> void mockDAO(Class<T> mockDaoClass) {
  2.         String mockedDaoClassName = mockDaoClass.getName();
  3.         GenericApplicationContext appContext = (GenericApplicationContext) applicationContext;
  4.         DefaultListableBeanFactory defaultBeanFactory = ((DefaultListableBeanFactory) appContext.getBeanFactory());
  5.  
  6.         T originalDAO = (T) appContext.getBean(mockedDaoClassName);
  7.         T mockedDao = EasyMock.createNiceMock(mockDaoClass);
  8.  
  9.         try {
  10.             appContext.removeBeanDefinition(mockedDaoClassName);
  11.             defaultBeanFactory.registerSingleton(mockedDaoClassName + DAO_ALIAS_ORIGINAL, originalDAO);
  12.             defaultBeanFactory.registerSingleton(mockedDaoClassName + DAO_ALIAS_MOCKED, mockedDao);
  13.         } catch (Exception e) {
  14.             fail(e.getMessage());
  15.         }
  16.  
  17.         defaultBeanFactory.registerAlias(mockedDaoClassName + DAO_ALIAS_MOCKED, mockedDaoClassName);
  18.         mockedDAOGroup.add(mockedDaoClassName);
  19.     }

And after you finish, restore the bean alias to the original one:

  1. @After
  2. public void revertMockedDAOInAppContext() {
  3.        for (String mockedDAOClassName : mockedDAOGroup) {
  4.           GenericApplicationContext appContext = (GenericApplicationContext) applicationContext;
  5.           DefaultListableBeanFactory defaultBeanFactory = ((DefaultListableBeanFactory) appContext
  6.                         .getBeanFactory());
  7.  
  8.           defaultBeanFactory.registerAlias(mockedDAOClassName + DAO_ALIAS_ORIGINAL, mockedDAOClassName);
  9.       }
  10.  
  11.           mockedDAOGroup.clear();
  12.     }

Yet another solution is to wrap the application context and override the #getBean operation. >> Check this out too <<.

Weekly Project: HudsonLifeSupport

Sunday, December 5th, 2010

In short

Arduino based box is connected through the USB with the software module which periodically checks the Hudson job status and triggers the appropriate LED on the box. Software module is based on Java and use RXTX module for communication with the Arduino board.

What is the Hudson CI server?

“<...>Hudson monitors executions of repeated jobs, such as building a software project or jobs run by cron.” More details about Hudson can be found on Hudson WIKI

Hardware Required

1. Arduino Board
2. 10-kilohm Potentiometer
3. 7 segments LED
4. Blue, Yellow, Red LED’s
5. Few meters of wire

Circuit

schema

Build story

This is a simple project to provide detailed build story steps. In short: potentiometer is connected to HudsonLifeSupport box to configure the timeout between the the status retrieval from Hudson server. While rotating the potentiometer 7 segment LED shows the number of time units to countdown. Moreover, during potentiometer rotation the HudsonBuildBox turns to the configuration mode. In case the potentiometer value stays the same for 5 seconds, countdown clock starts. When the countdown is close to zero HudsonBuildBox sends a signal to the software module to retrieve the build status for a configured target in Hudson CI server. Software module retrieves the build status thanks to Hudson XML API.

In case build is successful the BLUE light is triggered.
In case there’s failing unitests YELLOW light is triggered.
In case the build is failed due to compilation errors RED light is triggered.
In case Hudson server is not reachable for some reason (no connecion, server is down) all the LED’s turns to blinking mode until the Hudson server is up.

Code base & Arduino firmware will be posted to GoogleCode next week. Or if you can’t wait drop me an email with your question ;)

Photo story

Similar project: “Ultimate CI Visual feedback” from the “The Ultimate Wallboard” contest”.
Also a similar idea just more in style:

Gosling Unleashes on .NET, IBM, Glen Beck, iPads, Oracle & Others

Friday, October 29th, 2010

“<...>James Gosling sat down and did a really casual, off-the-cuff interview with the guys at basementcoders.com. You can head over to their siteto download the entire interview. We’ll have the transcript of the whole thing up post-haste. But if you don’t have the time to listen to the entire hour long interview, here are a few quotable gems that will tide you over until the complete transcript is up on TheServerSide.com” (c)Cameron McKenzie

Feedflow

Saturday, October 2nd, 2010

Facebook, twitter, your home page, your online albums ant etc.. All of those are reflections of your life in many formats. Some of them are published to social media, some of them are left in a shadow.
My mission here is to accumulate all those flows to the singular point and make it self living organism.
Twitter, home page, online albums like Picasa have a rss feed. By using rss feed and online service http://twitterfeed.com you can setup an automatic rss feed re-publisher to a few services like twitter, facebook, statusnet, ping.fm, hellotxt.
http://twitterfeed.com was my choice of the simplicity & free of charge service. Alternative would be to use http://feedburner.google.com, but this one does not have a facebook connector.
The draft concept would be something similar to:
feedflow

Main feed flow from picasaweb, own pages (home page), vimeo account are published to twitter account. Twitter account feed is published to Facebook. Also Linked in account is connected to the my own home page through the Linked in wordpress connector.