Warning: simplexml_load_file(http://api.twitter.com/1/statuses/user_timeline/cleversoap.xml) [function.simplexml-load-file]: failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request in /home/mclever/webapps/blag/wp-content/themes/Starkers/header.php on line 56

Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "http://api.twitter.com/1/statuses/user_timeline/cleversoap.xml" in /home/mclever/webapps/blag/wp-content/themes/Starkers/header.php on line 56

Easy Java Reflection & Interface Implementations

Penned by Cleversoap at precisely 10:32 on the morning of November 2nd, 2010

Reflection is one of those features that is severely underused when it comes to flexible coding. The Java language has an excellent means of handling the creation of objects based purely on class names. To start with, let’s just grab everything java needs to do reflection.

import java.lang.reflect.*

Now say we have an interface called ISomething and we want to allow people to write and compile their own implementations without actually having our packages in source form. This is useful when you want to ship a jar for example.

public interface ISomething
{
      void doSomething();
}

We still aren’t actually using reflection yet. In terms of the interface you don’t have to do anything extra. Once it’s implemented and instantiated it’s exactly the same as if the implementation was hard coded in.

Now lets move on to creating our reflection based implementation.
Continue thusly

Spider.bat Instance Launcher

Penned by Cleversoap at precisely 10:32 on the morning of November 2nd, 2010

I test client/server structures quite frequently so I need a mechanism to start up several client instances at once sometimes to test concurrency features etc…

Most of my clients are actually Windows based so I created this short batch file to startup a specific program n times. For example to start “program.exe” 8 times you would simply type:

spider.bat program.exe 8

Source:

@echo off
set /a max=%2
set /a count=1
:LOOP
start %1
set /a count+=1
if not %count%==%max% goto LOOP