161 views

Loading ...
18.04.13
Posted in Blogroll, Tech at 2:23 pm by Liv 
I’ve talked before on this blog about Apache Commons CLI project and showcased how easy it is to use it to build a rather complex command-line syntax for your Java application. If you find yourself at any point writing an application which needs more than one command line switch, I strongly recommend Commons CLI is the way to go: it takes care of basic “syntax” validation, missing command-line parameters, help screens and so on, and all of this in exchange of pretty much providing a structured set of options describing the parameters expected / accepted by your application.
One of the problems when dealing with command-line arguments is that in a lot of cases the application needs to interpret these not as simple strings but parse them in some different data types and interpret them as numbers, file names, url’s etc. A classic example is specifying the max heap space when starting a Java process:
Java -Xmx512m ...
In the above case, the Java process needs to interpret the argument after -Xmx as a number followed by a “denominator” (e.g. kilobytes, megabytes etc) — as such will employ a process of extracting the digits in a separate string, parsing them, ensure they are a valid number, then separately identify the denominator (“m” in this case), ensure it’s a valid one and find the multiplier (megabytes in this case – i.e. 1024 X 1Kb) and based on these 2 finally compute the final result.
Read the rest of this entry »
Permalink
Disclaimer
1,502 views

Loading ...
26.10.12
Posted in Blogroll, News, Random Thoughts, Tech at 2:40 am by Liv 
If at any point in your coding life you had to measure some component performance, chances are that you came across Perf4J at some point. To quote from their own website:
Perf4J is to System.currentTimeMillis() as log4j is to System.out.println()
There are of course other ways to measure timings of components execution, however, I found Perf4J to be rather neat as it plugs into Log4J, Apache Logging, JDK Logging and a whole bunch of others. It also has a bunch of tools you can use to analyze the output and generate some interesting stats analysis or even graphs. Basically, if you haven’t looked into it by now, do so! 
Read the rest of this entry »
Permalink
Disclaimer
300 views

Loading ...
20.10.12
Posted in Blogroll, Fun Time, Random Thoughts, Tech at 12:37 am by Liv 
I found myself recently using the Buffer class in the Apache Commons Collections framework — and realised that the Buffer-related classes don’t get enough coverage as they probably should, since they can actually provide out-of-the-box solutions to common development problems. So I started this little exercise partly to demonstrate some of the powerful Buffer-based classes in Commons Collections and partly for my sheer amusement
So here it is — if you didn’t know too much about Buffer‘s previously, you might find out a useful thing or two; failing that, you would definitely be amused about how much one can complicate a simple problem 
Read the rest of this entry »
Permalink
Disclaimer
377 views

Loading ...
28.07.12
Posted in Blogroll, Tech at 1:40 am by Liv 
Not sure if it’s just me who’s been digging around this issue for a while, maybe it’s common knowledge to the maven community, but I found this very frustrated dealing with this and researching it on the net, so having finally found the solution to this I thought I’d post it here. If nothing else, it would make it easier for me to find the answer to this issue every time I come across it in the future 
So my main “beef” with maven site plugin (aka DOXIA) in this case was when using bookmarks in the page in the link — which as you know, involves the usage of the hash symbol (#) — e.g. http://liviutudor.com/javadoc/some/package/ClassName.HTML#methodName(Parameter,Parameter). It turns out that running the xml file through mvn site I get this link: http://liviutudor.com/javadoc/some/package/ClassName.HTML#methodNameParameter,Parameter — needless to say that’s a broken link and would only end up confusing the user!
Read the rest of this entry »
Permalink
Disclaimer
542 views

Loading ...
16.07.12
Posted in Blogroll, Tech at 4:35 am by Liv 
If you have done any code that needs some sort of pooling of resources (which is some sort of caching, let’s face it), you would have no doubt come across Apache Commons Pool. (In fact the DBCP pool is used as a standard in applications which require database connection pooling.) The framework offers most of the things needed to pool objects of any kind and provide the management required around pooling.
I’m going to look in this post at how to use this framework to create a “cache ahead” pool — a cache/pool where a certain number of instances are created ahead and are ready to use when requested. This might sound odd, since the idea of pooling means that once an object is created is returned back to the pool and ready to use again — however, you will find out that the pool classes don’t pre-populate the pool, that’s one thing and secondly, there are cases where objects created store stateful information and as such cannot be returned to the pool and recycled. In such cases, you really have to continuously create new instances on demand — and the pool classes are not designed for that out-of-the-box.
Read the rest of this entry »
Permalink
Disclaimer
« Previous entries Next Page » Next Page »