11 December 2005

RCP vs. Thin-Client

I think the strongest argument for the justification of thin-clients or web applications is the cost of deployment and management problems that are related to rich-clients especially those that are written in Visual Basic, Visual C++ etc. This argument became popular due to shared library problems, user's often tweak their installation resulting in undesirable setup, but the thin-client is actually a step back in functionality and capability even when there's AJAX around.




Due to the complexity of the domains today, users and problems are driving back to rich clients. An observation that I agree with the book above. The demand for rich client goes beyond the desire for rich user interface. Users need to be mobile, must be able to work offline, integrate, collaborate and maximize the power of their hardware. But how about the deployment and updates management? That's where Eclipse RCP is coming in.

10 December 2005

Mining for Ruby?

It has been more than one year when I declared that the time is ripe to mine for Ruby. But until now, I am still asking myself, if this is what a software should be then what's the Value Proposition? Ruby is great, I have a hard copy of Dr. Dobb's issue to prove that it's even older than Java. But again what is the Value Proposition?

I have used Ruby briefly, got some fun from it too. But let's not get carried away, fun is not part of the Value Proposition. Will I risk using it for a highly-critical application? Will other Ruby users be able to relate on my unique business or operational problems? I don't think so. Ruby is great, but to me it's no great deal. It's just another scripting language that happens to be object-oriented. Why other languages are popular and "acceptable" in the majority of the programming community? First, most of them are conceived in order to solve a problem(e.g. C/C++, LISP, Fortran), most of them have something in common in their history, they are designed initially for the purpose of building The One Great Product(e.g. SmallTalk, Java). Ruby was conceived from none of these reasons, it was made out of hobby, for the labor of love. My customers doesn't care about my labor of love.

08 December 2005

Patriot Update

The Patriot project site has been updated an we have added an informational diagram on its value proposition. Currently, I will be finishing the Serial Comm API as part of the selectable protocol drivers.

01 December 2005

SWT vs. JDIC

So much fuzz I thought JDIC will going to solve my desktop integration problems. I ended up, still, using SWT, "The one code to bind them all". From System Tray to GUI application itself, everything was bolted together that looks so natural in their host operating environment. And launching my SWT app like a native Windows application was made easy by Marner Java Launcher, which I would say more flexible than JSmooth. Marner Java Launcher respects my folder structure by providing a launcher.cfg file to specify my JVM arguments.

Most likely, Swing is going to suck even more these days.

29 November 2005

Need for Speed - Singapore Edition

After passing my Basic Theory Test and eventually got my PDL (Provisional Driving License), the next step is to hire a driving instructor and drive, not to learn how to drive, because I've been doing that for fifteen years back in the Philippines, I want to familiarize myself with the right-hand drive cars and a left-side traffic. Hence, I have to go to that process. The basic part is easy, the driving is even easier. A Class 3 QDL (Qualified Driving License) allows you to drive cars in Singapore with manual and automatic transmission, So I called up a driving instructor, the cheapest I can afford at S$45 per 90 minutes. In a matter of minutes he came to my place at 9pm and got a pre-drive briefing and told him briefly that I have been driving before. And he said "OK, take me to Shenton Way", "No Problem" I replied. I sunk the stick to the first gear, signal to the right, look at the cabin mirror, look at the side mirror, glance at the blind spot and off from Lorong 34 Geylang! "You have to keep left", "Yeah right" I remembered, After negotiating the traffic from Geylang to Guillemard, we headed towards Nicoll Highway. Being behind the wheel is no freaking effort. The Kompressors, Diablos, Testarossas, Carreras that you usually watch pathetically at some bus stop while they pass by are cruising alongside with me. "PDL dwayvez must keep a maximum of 60kph" my instructor hinted. I looked on my speedometer and it's pointing at 80kph, at Nicoll Highway(my bad sorry, sorry, I'll remember it next time)! Finally we're at Shenton Way in less than ten minutes, I asked the instructor "What now?". After giving me all his pocketful of challenges from negotiating narrow alleyways, humps or uneven roads, roundabouts, u-turns, clutch-hanging on steep roads, merging traffics, etc. etc. after 90 minutes we covered almost everything that he might want to do for the next 25 lessons. Too bad he's not going to make too much money out of me.

Local software development community is like Singapore traffic, right-hand drive, while seventy percent of the world's roads are in left-hand drive. It's not being right or wrong. It's even a bad taste to talk about profitability. It's like "Hey wake up guys, next year is RCP year! Why are you wasting time with expensive, shitty webby stuff?".

18 November 2005

Product-based vs. Project-based

"If you know the enemy and know yourself, you need not fear the result of a hundred battles. If you know yourself but not the enemy, for every victory gained you will also suffer a defeat. If you know neither the enemy nor yourself, you will succumb in every battle." -Sun Tzu

I am not a sales person, but the reason for my uncanny ability to seal deal is the quote above. It's real and simple, If I can't do it then I will not push myself with all my faith to do it, because I am already aware that I lost the battle before it even started. So there's no sense in wasting my effort and money. The Art of War is a *thousand-year* old value proposition. I am not charismatic, smooth-talking salesman, that is never me. And some sales people in the IT industry has much to learn with Sun Tzu. Take for example a consulting company that has evolved into a project-based model and runs into customer's "quagmire" and will repeatedly run into it again and again and again because the company has only knew itself and not the adversities that it will going to face. Either they don't know it or choose to ignore it for the sake of profitability. Project-based ventures are so risky, the majority of "70% failed software projects" falls on this category. Leaders cannot afford to be conservative as well as this kind of trait will chip away their resources little by little. This kind of venture is so exhausting that there's nothing left to earn when the project is "done". That is if you got paid in the end.

Product-based venture on the other is much simpler and less riskier. There's not much concept to prove. Customers "knows" what they want; it's usually what others have. So there isn't really much effort in selling a product, rather than a project whose derivative is yet to exist. And since the product already exists, it doesn't have to be a hard sell I don't think so, not in my experience. Most of the times a demonstration can already sell by itself. The fun part in product-based venture is that all the painstaking tasks are only in the initial part of the product development. And the best thing about product-based venture is being paid promptly for a delivery well done. Then repeat business comes next. Such is an Art of War.

14 November 2005

Of Music and Software Development

Musicians and Software Developers have some few interesting things in common. There are musicians that performs well and plays well but does not know the conventions of notes, staff and tempos, they can only play well with chords and tablatures. These musicians are parties' and funerals' life, but the problem with them is that they can only play music that they have heard and memorized before and they rehearse specific titles of songs.

On the other hand, there are musicians that are called "sightreaders". Sightreaders knows their instruments and every intrinsic formalities of music very well, they rehearse with scales and exercises more than specific song titles. On the eve of performance they can play musical pieces that they never heard before without rehearsal and by just reading through a given musical piece, and will play along well on it without the audience noticing that they didn't actually rehearsed.

In software development, especially in Java. There are developers that knows BEA Weblogic and can deliver results with it but does not know the whole sense of the J2EE architecture. There are those who knows messaging with Fiorano, but that don't understand the standard interfaces of the JMS specifications. These crops are basically the "Funerals'" cream. A lot on the list can go on. This kind of developers are very limited to delivering results with limited options and they are expensive(salary and the tools of their trade).

The "sightreaders" in this area are obviously different. They are mindful of the whole "Process" instead of specific tools, they are very comfortable with any application servers regardless of vendor as long as it honestly complies with the J2EE spec. They can write high-performance codes in any SQL-based relational database without being tied with the poor Hibernate syntax. They understand the "Process" and "Patterns" and they know the "Fundamentals". They not only deliver results, they deliver lasting results.

09 November 2005

Replacing backslash with double backslash

This is a juvenile problem and too Microsofty. The problem is when Windows-based file names has been stored in a properties file in this way:

my.file=C:\Windows\Kamote


When retrieving that value, the backslashes will be dropped during Properties.load() execution so the resulting string will be:

C:WindowsKamote


Sometimes we have GUI-based configuration managers that we like to be able to store in a properties file or an XML file but want to retrieve the file names with desirable results. Therefore our configuration should look like this:

my.file=C:\\Windows\\Kamote


In order to achieve that, we can use a 2-liner code with JDK's Regular Expression API like this one:



String path = "C:\Windows\Kamote";
String newPath = path.replaceAll("\\\\", "\\\\\\\\");


The code above will yield C:\\Windows\\Kamote. This code is not really necessary, it's just a convenience fix for Windows dummies.

08 November 2005

Open Source Everywhere

Several links of indicating an iminent Open Source onslaught in the years to come.



There's more actually, but one interesting thing was one day while I am at a coffee shop I overheard two locals talking about Open Source and they were quite old I think their ages range from 40-45 years, the conversation was so funny I almost want to butt in because the words that were coming out of their mouths was the oldest, most stale Microsoft argument on Open Source that has been debunked years ago and yet they fear for it. Such misguided perception is abundant here. So now is the time to take a serious look at this viable alternative.

31 October 2005

Windows 2000/XP Password Recovery with Linux

My Window-based laptop was backdoored allegedly by a China-based site, it locked and disabled my account and the administrator's account. Therefore it rendered my system useless for a mean time since I can't login to my two most important accounts in the system. I looked into a lot of Password recovery tools out there and most are so expensive, unbelievably expensive and practically useless. Until I stumbled into this Linux-based password recovery tool. In fact, it cannot be called a password recovery tool because it can't recover a password. What it does however is it allows you to reset password including the Administrator so you can login again.

This little nifty tool is called Austrumi. It is a Slacware-based business card sized bootable Live CD Linux distribution. Unlike any Windows bootable disk, Austrumi is a fully-functional operating system by itself. This tool is so simple, you only to insert the CD and reboot and at the boot prompt just type:





boot: nt_pass



That's it! and you're on your way to recovering and regaining your system from those nasty script kiddies. But before I forgot, the working version that I've used is the Austrumi 0.8.4

27 October 2005

7 months after

Time flies as they say. So far it's a pretty interesting year. So I am going to go for a round down on how things has became in my Singapore Adventure.


  • First month - Is always exciting everything seems to smell like a fresh box out of an airplane that just landed at Changi Airport. Everyday technologies are fun like tapping the EZ-Link card when going places, buying movie tickets online, getting used to the Windows Non-Operating System, still mesmerized by the users' acceptance that virus will always be in their PC's forever, little did they know that Linux is now as equally or even more than capable in the Desktop area as WinBlows can cut off their dependencies from companies such as McAfee, Norton and even Microsoft. That could translate into millions of dollars in savings. Oh what the heck, what savings am I talking about? It doesn't exist here. A dollar saved is a dollar earned.

  • Second month - Almost everyone is so in love with BEA Weblogic, it's almost like buzzword, but try asking those jerks(BEA Consultants) what is an Avalon Framework they will give you a dead stare, little did they know(again) that this is the soul of that shitty application server.

  • Third month - Nothing like the sound of "Watercooler employees" buzzing in conversation, this time it's Chinese version but the substance is still the same, the subject always drills down to the politics of laziness.

  • Fourth month - I made a prediction this month that will happen on the seventh month, and it did.

  • Fifth month - Finally I am reunited with Linux! Not just any Linux, it's Slackware 10.1, I just wish Patrick Volderking good health in the next years to come because I am not worthy to take over his work but I wish I could. After getting used to Singapore's everyday technologies, it has became so boring. Local retailers still manifests very poor customer relations/service, but Auntie who cooks the best Chao Fan in Guillemard is nice but some are so fucking arrogant as if they can speak good English and they think they are the center of the world(literally they are, since this island is in the Equator), oh sheez "Fuck them leh!"

  • Sixth month - Here, typical career path is Programmer->Team Leader->Project Manager->CIO, mostly are 9-5 until 95 types. which is like the Industrial Revolution of the 20's. I know the motto here is "whatever works", a 1979 Toyota Starlet can be as functional as the 2005 Mercedes Benz E320, take your pick. I remember one of my former boss said "In the Philippines there's a lot of ideas but there are no investors, while in Singapore there are a lot of investors but no ideas". Necessity is the mother of all inventions, here it's hard to get a necessity going, that explains the "no idea" thing.

  • Seventh month - Huh! This time we have an idea! Eureka! But what's that? Clue: it's open source. Start the engine, we're on our way.


07 October 2005

Slackware Rules!

After trying several distros from the past and latest being Ubuntu, I still come home to Slackware. First I consider this as a developer's distro. The only people I respect as kick-ass, power-developers(especially in Java) are those who have been using Slackware as their primary operating environment. Suprisingly, a Slackware Skill can really go a long way. First is versatility, although not really unique in Slackware but a Slackware user can easily adapt to any other Unix/Linux/BSD flavors around.

From previous experiences, my Slackware Skill has got me around AIX, Solaris, HP-UX with zero or minimal adjustments. Frustratingly, some local profiles I see around here mostly just have Windows/Java, Windows/Java, Windows/Java...WTF'ing skill sets! Yeah, I understand what users want and what users are asking. I also foresee the troubles they will be facing about the things they are asking today. I know the "ease-of-use" issues, we've been there. In the enterprise, only muggles should have Windows. Developers should be able to switch from one operating environment to another with little trouble.

Second is reliability. My PC, after just 72 hours of continous operation has to be rebooted due to lags, CPU hogs and sudden unknown memory spikes probably due to SpyWares, problems that never existed on my Slackware box even on a continious operation, currently in Singapore my longest uptime for Slackware is 28 days.

Last but not the least is simplicity. Slacware is so simple, on a decent hardware it can boot completely in less than 10 secs. with all the GUIs and necessary services loaded. Most command-line tasks are much shorter than its point-and-click counterpart.

06 October 2005

The JDIC

Also known as the Java Desktop Integration Components. You know, those girlie stuff you put on your Windows. Although I've been itching to write one about JDIC long ago. And the much distraction the XBox Live is putting on me. Now I got a time to do so. At least it's good to know that Java isn't completely isolating itself from its host environment. With JDIC, you don't need to write JNI codes by yourself in order to make wonders with your Java applications on your desktop especially on Windows. In short, that saves a lot of time and effort.

More on this coming up.

29 September 2005

The Halo 2 Fever

Admittedly, I had so much fun with my XBox Blue and my XBox Live subscription. Ironically, this is the only thing that has came out good from Microsoft, instead of Windows. But if PS2 and the upcoming PS3 has this "Live" thing, I would happily switch or add it to my gaming system. Technically, Playstation is better. It's just that it "doesn't put value to the business", no one can just always play alone or with someone on a split screen forever. So what if you have great hardware that can be possibly tweaked to launch missiles but sucks in marketing value? The sad thing about XBox is [I think that] it's selling below cost. Which is ok if you really want to put M$ out of business.

Going to Halo 2, I am skeptical why some people has touted it as "redefining the FPS genre". Until I played "Live", I realized it is very much different than other FPS like Counter-Strike. Now Battlefield 2 is following the same success with their "USMC vs. MEC" where you can fly Blackhawks, drive tanks etc. but that's too "American".

22 September 2005

XBoxing...Live!!!

I officially stopped playing games on my PC. For one, to me it's very unprofessional. Basically, I gave in to the temptation of the dark side, I got an XBox Blue Limited Edition from a recently concluded COMEX computer expo at SGD$288 with free Halo 2. And I got a Starter Kit 12-month XBox Live Subscription which I got at SGD$75 that comes with a free headset. Playstation 2 should have a something like the "Live" thing! Right now, I have Full Spectrum Warrior 1 which I just had finished, Halo 2, NFSU2. I don't have any playmates around yet but I am will be online this weekend. My gamertag is "jaredlinux".

20 September 2005

Open Source Business Readiness Ratings

What's this? Business Readiness Ratings is basically used to determine if an open source tool is mature enough for corporate use. Really? Or maybe corporations should be mature enough for open source use. :))

It's a good and bad thing, like how would you rate vi, grep, awk, ssh etc. for business readiness? I think BRR has the same stench as CMM and may be less "corruptible". It's like this, lets take for example, India.

India, the country that took away a lot of American programming jobs has something there to deserve the luck they are getting now, It's the CMM-decorated companies that sprawl in their landscape. And of course with that and a cheap job market it's a bullet for America ready to backfire. CMM is a buzzword and CMM is just a buzzword. Using a funny analogy, An alleged mentally deranged employee(MDE) who's been acting weird noticed that his co-workers are mocking and laughing at him because they know he's crazy, so his boss tells him to take a leave and get professional help. So this MDE did what his boss said. He went to a psychiatrist to check him up. In short, he was diagnosed as normal and doesn't have any mental disorders so the psychiatrist certifies that and issue him the certification so he could go back to work. Back at work, he chanced upon everyone talking about him and his weirdness, upon seeing him everyone was stunned and kept quiet. He gave them a stern look, and said "So you people think I am crazy? You're damn wrong!" And then he flashed a paper in front of them... "'coz I got a certificate that says I am not. DO YOU HAVE THE SAME CERTIFICATE?". Now everyone's crazy and he's not. ;)

CMM is just some shit-brick's concept from what school is that? CMU? Does CMM assures your company is mature enough and it's capable of bringing back home a space shuttle that's has been dinged a little? Maybe that's too exaggerated, or maybe that same shit-brick is involved in designing a space pen that will push ink at zero-gravity while Russian cosmonauts are happy scribbling notes using pencil and are very productive.

On the other hand, open source applications like GNUEnterprise can benefit from BRR. Since GNUEnterprise is more on the "operational" side of things rather than "technical" as many open source tools are. A BRR rating for GNUEnterprise can have a great impact on the ERP market.

YourSQL not mine

I have been a PostgreSQL user for quite some time and it hasn't failed me on most of the basic and advance features that I expect to get from it, whether I write client software in Java or in C, the results are consistent. Before then, I have a "weak" argument that MySQL is weak. Because I only scratched the surface of it and didn't do a lot of thorough testing. This MySQL, by default, has failed on a lot of things compared to Postgresql point by point even on some minor things. Some of the things I noticed are:


  • Lousy way of granting permissions

  • The autocommit functionality can break the most generic JDBC code that is supposed to support multiple databases

  • Tables are case-sensitive, unless you're a diehard Windows genius, you're not going to notice this.

  • The interactive command-line interface is so crude. It's nothing compares to PostgreSQL

  • So some silly asshats will ask me "Why would you use a CLI when there's a lot of GUI tools for MySQL?", even that sucks too. And what if the only available thing to you is an SSH access without X? Then you're dead in the middle.

  • The PreparedStatement.executeUpdate() does not return the right value for the rows affected, I am wondering what's the big deal why this thing can't be fixed since Postgresql, Oracle and other "production-grade" databases can handle it. Just simply returning the right value is very important for debugging and information purposes.


  • These are just a few things that I can remember after my fury died out. I am not going to the argument of "you don't know shit" or "read the fucking manual" stuff. By all virtues of a good database, out of the box, everything must work fine, just like Postgresql or even Thunderbird. In the end, I have deduced so far, that those who are so in love with this database are merely Windows users, that are writing apps which are even simpler than a candy store application.

14 September 2005

What ESB? What SOA?

What Web Services? What Asynchronous Messaging? Where JMS fails, Jabber/XMPP succeeds. Of course, not all solutions to problems are obvious, to the muggles, Jabber is used by people to chat with each other just like Yahoo! or MSN. But machines can be made to "talk" to each other using this protocol too and in the most reliable, lightweight conditions. There's no need for fragile JNDI lookups, uncannily resolving IIOP hostname which is Sun MQ's sickness with the "JMS over Internet" thing. No more complex WSDL, even if it's transparent to developers nowadays, it still packs some unnecessary weight. And can be a relief from the aweful RMI too. And when these heavyweight solutions fails, recovery is not always as easy as what they claim in their manuals. With the exception of ActiveMQ. But most of the time, Acegi+WW2+ActiveMQ+Spring+SJSAS doesn't work as expected.

Jabber on the other hand, is straightforward, as long as the client machines has access to the network in whatever setup, will work. Doesn't care on what container the application is running with. Jabber-based services are rare, because in order to take advantage of those services the user has to sign up to whatever jabber server the service is signed on, and understand their "lingo". But on availability and reliability, the Jabber can walk the walk.

Nutch

Before Nutch has become a sub-project of Lucene. There's a niche opportunity for the raw power of this unbiased search engine. Now that Knowledge Management has slowly, clearly defining itself not only in the "intelligence" community but for corporate uses as well. With Nutch and some little imagination, one can create, for one, is a Verity-style "federated" searches and indexing that is "C:drive" mountable or thru Samba or NFS, depending on the "federation", information can be presented in a folder structure, as a web portal and so forth. Tools can be built on top of Nutch to aggregate RSS Feeds, IMs, Blogs and even password-protected filesystems.

In fact, "knowledge"-snooping systems such as this, is very attractive to a lot people for very obvious reasons.

01 September 2005

So it's called Age of Participation

To the OSS-phobics, Age of Participation is a more subtle term. That really boils down to either two things, Adapt or Die. The other side of that is Age of Elimination which is rather timeless. Age of Participation is one of the key topics Sun Microsystem's Scott McNealy will be discussing here in Singapore with the local industrialists on September 12(?).

Speaking of locals, specially some developers, are big "ji bai". Every time they hear the word "Open Source" their chorus would be "NO SUP-PAWT", it's like getting a job that involves an automatic weapon and saying "No Danger". It's an understandable dilemma for a user but not for a developer! These people are pollutants to the local developers who want to learn and build products on top of their favorite Open Source tools that can spread the use of OSS to several industries such as the much-hyped biotech industry.

It's very interesting that big companies are having their own campaigns to promote Open Source in this Last Stronghold of the Proprietary Software Colony. Get Some!

31 August 2005

Webwork 2.2 has now JSR-168 Portlet Support!

Yes! A JSR-168 Portlet support for Webwork 2.2. WWPortlet is Webwork, Velocity, Spring, Hibernate MVC Portal Framework. With this coming to life, rapid development of portlets will soon become a reality. But right now, I just want to nail my excitement so I can compare this versus InfoGlue which is another Webwork-based JSR-168 Portal Framework. These stuff put their expensive counterparts like the non-compliant BEA Portal Framework into shame. Webwork2's architecture makes it so natural to "slide" things like this into its framework.

Makes me wonder, there's just so much buzz with portlets these days.

23 August 2005

Sun Developer Days 2005

Today the Sun Developer Days here in Singapore has just been concluded. Quite an event, Treos has been raffled off, everyone got some Duke T-shirts. Of course not all seminars and conferences are perfect. There are some good and bad stuff that comes out from there.

To make a rundown of what came in that event let's start with the good stuff:


  • The opening salvo of the event talks about nothing but Open Source, it's Open Source here and there. Matt Thompson, Sun's Director of Technology Outreach and Open Source Programs Office, I remembered(hope my memory serves me right) quoted him on saying "...for the Singapore IT industry to 'continue' to move [forward]...", Why? Is the Singapore IT industry moving otherwise? His radar is quite powerful. I would partly agree, maybe around 70%. Of course, offshore and institutionalized companies like IBM, Sun, SAP etc. that has operations here doesn't fall on the reverse direction. Practically all the speakers uttered the word "Open Source" with different levels of boldness or shall I say wake up calls. Yes, most of the local IT players are moving on the wrong direction.


  • Again, it's about Open Source. It rules. Project Glassfish, Project Peabody, OpenSolaris are some of the highlights of this event. It's both open source Java SE(Mustang) and Java EE. And all the virtues of openness. Pretty frustrating when the speakers are attempting to get a consensus like "Who's using open source tools?", "Who's involved in open source?", "Who has a java.net user id?" etc. etc., from the look of their faces they seem to always get disappointing results. That's understandable, there will be some effort of pushing needed in this part of the world.


  • SAP the Platinum sponsor, has long been an Open source advocate. Well that's nothing new.


  • So it's open source and open source so forth. The Information Age is over, it's now the dawning of the Participation Age.


  • Going to Netbeans 4.1, Matt Thompson admits that Eclipse has a huge leadership in the open source IDE arena. For the reason that during circa Netbeans 3 and JDK 1.3 Swing with all its beauty and madness has been lagging in performance. I will admit that Netbeans 4.1 is now much faster than the previous versions which is a great improvement. The integration with Sun Java System Application Server 8.1 also rocks, the Java EE demos are not your typical nonsense "Hello world" demos, And if you insist that AppFuse is awesome, you're making a huge joke on yourself.


  • Going to NetBeans Mobility Pack, there's nothing like it elsewhere.


  • So far, I think IntelliJ has to really open up. Or it will really be left behind.


  • The speakers are great, they're all evangelists, of course, whatever that means


  • The DTrace discussion is also interesting, as of now Linux does not implement this kind of instrumentation. The stack traces, core dumps and panics are more understandable than the typical barrage of memory addresses etc. etc.




Going to the sleep-inducing stuff:

  • The JSF and Creator Studio, the yawnful JSF, It's good to have a nice "visual" way of doing things, personally, I still prefer to have full control of my codes, I still want to have the final decision on-the-fly where to put my validators, whether client-side or server-side, edit things with the IDE getting on the way, things like that. But all in all I will not give it a second look.


  • Java Generics, personally I don't feel like using this. It's like being forced to learn English the George Bush way. Gives me a lot of eye strains during the length of the discussion, is that the reason they put a Latina babe to present this so there will be minimal eye strain?


  • Java and .Net Interoperability, why bother? Being sensitive to the local needs? :)) I could say, Adapt or Die!


  • Netbeans' JUnit is crude, needs some improvement, I sat down with Chuk Munn Lee about this and showed him how JUnit works with Eclipse and compared it with Netbeans. It's understandable that this feature is also a work in progress.


  • Some clueless guests, BEA consultants which I knew by the face, may be they are now considering switching to Netbeans :)) , some asshat programmer from a state university who claims to know what he's talking about e.g. JSF rocks, Shale is going to change the world(Shale on him), Spring is just an MVC pattern(good thing I realized my shoes are made for walking), I wished he knew who he sits with. By the way, he gave me his business card.




But of course, it pays to pack two loaded guns instead of one. So today, it will be Eclipse for work, Netbeans for entertainment. How's that?

21 August 2005

Making D-Link DWL-G650+ AirPlusG+ work on Slackware 10.1


It's not great as others claimed to be or maybe "great" is relative. I spend a whole Saturday trying to make this WiFi card work. Since I lost touch with my Linux hardware buying strategy, for SG$43 I was so compulsive that I picked this stupid thing at Sim Lim Square. The buying strategy that I have adapted when I first learned Linux is the "defective/success" ratio of the hardware. This means getting the pulse of the forums on how many got a device working and how many got persistent problems even if they managed to get one working. And this device falls into the "high defective" rate and it will be a torn in my pride not to get out of that statistic. So I have to wrestle with mid-level stuff of drivers and kernels. In short, I should have took the $55 Linksys or even the $38 Netgear(!!!) that has a higher "success" ratio.

Anyway, the real fault can really be attributed to the Open Source culture of "What documentation?". So let's start with a few things. One of the most helpful sites I went is the House of Craig. Much of what I have done was there. What I am going to add are few points that has not been emphasized specially on building the driver without an alternative internet connection. Here's the brief summary of the steps for building the driver:


  1. Get the latest acx1xx*.tar.bz2, what I have is the pf51 from acx100.sourceforge.net. Of course, since the target machine to be build on does not have an internet connection, do this from other workstation

  2. Get the latest firmware driver from D-Link website, yeah we know it's for Windows but that's what you're going to use

  3. Referring from the House of Craig, do everything as necessary



Now if everything looks fine and you didn't have errors that says something like "bailing..." in the end of the steps but no IP was assigned or there's no internet connection. Here are some few checks that you can do:


  1. Make sure to turn on LED options in the start_net script, then re-run start_net

  2. if no LED went on, check the /usr/share/acx directory if all firmwares including the Windows firmware are there

  3. Rename TIACX111.BIN to TIACX111.BIN.org

  4. Create a symbolic link from the Windows driver e.g. ln -s FwRad16.bin TIACX111.BIN, then run start_net, this time the LED will light up.

  5. do a tail -f /var/log/syslog to check if the card is actually associating to the Access Point

  6. If association is successful but you got an error that looks like: Error: wlan0 failed to associate, can't use DHCP for IP Address, try iwconfig.
  7. If everything looks normal, this is the last and dirty resort: dhcpcd wlan0, if you're Linux kernel is properly compiled and installed and you are actually associated to the Access Point, an IP address will be provided automatically.

  8. Start surfing wirelessly and enjoy!



For some reasons, the start_net script has to be tweaked for it to properly recognize that DHCP is being used and there's no WEP security enabled. But I am have no time to do it yet. For now, I have the ./start_net && dhcpcd wlan0 everyday. So far I am happy with how things are coming along and this blog was submitted thru D-Link DWL-G650+. Hope this helps.

18 August 2005

Now a "bonfide" publication

After waiting for a couple of days The National Library Board of Singapore has granted me my ISSN(International Standard Serial Number). Which means this blog is now a "bonafide" publication.

What's the big deal about ISSN? An ISSN is an internationally accepted code that provides a unique numerical identification for a serial publication. It takes the form of the acronym "ISSN" followed by two groups of four digits, separated by a hyphen, for example, ISSN 0217-4634 or ISSN 0218-401X. The first seven digits are unique to the title, while the last digit provides an automatic check on the accuracy of an ISSN. The last digit may be an X (for 10); otherwise the ISSN is fully numeric.

So what's the benefit of an ISSN? An ISSN uniquely identifies a serial publication. Publishers, suppliers and libraries worldwide use ISSN as a reference number for selection and acquisitions.

Serials with assigned ISSNs are easily identifiable and retrievable. In addition, ISSN acts as an access point to the ISSN Register published by the International Centre in Paris. The Register lists serial titles published all over the world, and is available in microfiche, magnetic tape and CD-ROM.

In addition to that, ISSN is important for this blog because not all the rants here are "rants". When stuff are reviewed on this space, it's not just a piece of software or hardware lent to me over the weekend and have my opinion on it then post and rate it. It's about actual usage, actual consumption that has been done over and over again.

My apologies for the aggregators where I am listed if all my old posts are being reposted. I am just making a backup of my entire blog to the CD as a Legal Deposit in exchange for the ISSN.

16 August 2005

Java Card Communications Access Layer

Also known as JACCAL or sounds like "j@k07" is a smart card API for Java. I am not really into Smart Cards, but basically anything that passes thru I/O should have one thing in common -bytes, it's just a matter of learning the communications protocol like how the streams are parsed and read, how the data are build and transmitted. JACCAL uses the PCSC or Personal Computer Smart Card protocol. Anyone who's interested in writing an application in Smart Cards especially in Java should be familiar with the Java Communications API.

I remember that I have to promote my SerialFTP from Planning stage to Beta, but I have to find my backup code back home. SerialFTP also uses Java Communications API, it implements a simplified ZMODEM protocol, jokingly named as JMODEM and has stuck since then. Even funnier is, this protocol has been used as a non-standard firewall too. Who? Well, that information is not open source :) Eventually I will write a hyperterminal-style functionality there when I get the time.

Audacity addiction

It's really like magic, I don't want to bother about the underlying reasons why ALSA produces better sound than any other Windows-based audio architecture. But there's really a distinctive difference. Even our resurrected now-Slackware-souled Dell Latitude CPx sounds better than its siblings that are still running Winblows.

Anyway, in relation to chiseling sounds. I used to do audio editing with SoundForge years ago and its a nice tool and now it has improved a lot, I hope they can release something for Linux soon. But since I don't have the budget allocated for it yet, I will settle for a cheapo(just kidding) Audacity, I've been watching the progress of this tool and it has improved a lot although not as intituitive as SoundForge, still, I can get the quality of sound I want with just a little perseverance and patience. A few months more hopefully.

And finally, this is my first post written on a Linux machine since I landed in Singapore! Purifying experience.

15 August 2005

Stuff that keeps my biological clock broken

And the stuff they don't give medals for. Of course, the next best thing to orgasm is having an environment that you put up yourself. For example, installing Linux from scratch, from building the right drivers, compiling the kernel to setting up of your favorite Window Manager. The fun part is doing that to an old machine(a laptop for this matter) where all the devices are almost obsolete. It's like giving an initial drift to an old Shelby. After several months of no Linux-as-a-development-operating-system, my long Linux itch has been finally scratched. But that doesn't stop there. More fun is about to come.

The rig that I resurrected into a drifting machine is a Dell Latitude Cpx, with Pentium III 650Mhz CPU, 256 RAM, 10GB HD. From what I heard around, this is one of the most Linux-hostile machine. But it has been very cooperative so far, boots in an average of 15 secs, faster than when it was running WinBlows(of course) before. Taking advantage of the Linux 2.6's HyperThreading features, Java apps like Eclipse are snappy as well. But of course given the skimpy hardware configuration, it has limits too. And feels good squeezing every drop of juice from it.

Another thing that will keep me up at night is this. The Linux Guitar apps, I believe there are many more but I'll be taking those stuff one by one. I remember back in my college days listening to NU107, the Philippine's only rock radio station(hey Singapore should have a dedicated rock radio too), There's an intermission message that say's something like this:

"If I were to choose between losing sight and losing hearing, I will choose sight. For if I lose my hearing, that will be the end of me".

These are the stuff of the revived nocturnal creature. Linux, Java, jazz, rock and...did I forgot salsa?


Darkstar, Signing on.

14 August 2005

Another one on Intellectual Property Rights

Snipped from a hard copy of The Strait Times' Review Section, August 13, 2005, entitled "Intellectual Property rights: Why they are so wrong". Written by Joseph E. Stiglitz, a Nobel laureate in economics. It's about his takes on why intellectual property rights are so wrong. Some interesting points I would like to share if you failed to grab a copy from the newsstands. Sorry URL link requires registration and I am too lazy to do that ;)

"...Without intellectual property protection, incentives to engage in certain types of creative endeavours will be weakened. But there are high costs associated with intellectual property..."

Correct. Continuing on...

"...and if intellectual property slows down the ability to use others' ideas, scientific and technological progress will suffer..."

"...the mathematics that underlies modern computer -are not protected by intellectual property..."

This is undisputable. Now let's hit the G-spot.

"...The growth of the "open source" movement on the Internet shows that not just the most basic ideas, but even products of enormous immediate commercial value, can be produced without intellectual property protection..."

"...By contrast, an intellectual property regime rewards innovators by creating a temporary monopoly power allowing them to charge far higher prices than they could if there were competition...In the process, ideas are dessiminated and used less than they would be otherwise...Modern research has shown that the great economist Joseph Schumpeter was wrong that competition in innovation leads to a succession of firms..."

Stiglitz also added how Microsoft demonstrated its abuse of market power to discourage innovation.

Take note, these words are not from a zealot's mouth like RMS or ESR. This is a third-party opinion concerning intellectual property and how it hampers innovation. Even for sustaining a developed economy, open source will still play an essential, semi-obvious roles.

13 August 2005

Sun Acquired SeeBeyond

Nodding sideways with a chuckle was my reaction when I read this news. Sun Microsystems, lacking a decent product to compete in the SOA arena, bought somewhat a decripit company call SeeBeyond. I remembered seeing the life and death(yes, being witness to the slaughter) of ICAN when I was working for one of the top Philippine's telecoms companies. While we were developing our Webwork+Velocity+Spring+ActiveMQ+SJSAS+JNI+CORBA combo of systems along side ICAN. I can't help but pity that ICAN thing because it can't take up the load of the Philippine's SMS-savvy networks so every now and then it conks out. We even flew in consultants from Australia and Singapore and the only words they can spew out was "That's strange", the phrase I found very famous here actually.

Yes, ICAN might have helped in launching space shuttles, but it failed to handle the world's biggest SMS chunk or junk for that matter. That SOA thing failed miserably in the 20,000,000 messages/day business(and I am referring only to one telco handling that, we have 3). And eventually, I saw that thing decommissioned and spent the good value of money rewriting things on our own. I just hoped the money paid for that shit was used to jack-up my salary.

Hopefully, Sun can improve some things about it like performance and memory optimization. But honestly still, I am not willing to pay a premium for that.

11 August 2005

Building The Empire: The Singapore Takedown!

The storm troopers of Business Software Alliance are stealthily creeping the city. And I am surprised in a developed country who as I heard on the streets and teh tarik breaks boasts of not maximizing the power of open source because it is a cheapo, yet still has symptoms of a third-world software piracy. At least in the Philippines, after an infamous raid on a very reputable world-renowned Japanese company around 5 years ago, businesses started to clean up since then, that's why technologies that really make sense(those that will help uptick your stocks, upgrade your salary, strengthen your skills) are flourishing up there.

As a support to the storm troopers actions and part of the empire building, I have cleansed two offending workstations(a desktop and a notebook) of its unnecessary evils. These two are both from Dell and has surrendered themselves to Slackware 10.1 with recompiled Linux kernel 2.6.12, all the old Xircoms(PCMCIA) heeded to the recompilation smoothly. One local Linux user asked me, "why recompile"? I had an empty stare at him and asked back, "why not"? This is what Linux is all about, freedom, the chance to play with the "engines". What's the point of owning a hotrod if you can't open the hood?

Another local who is outside of the paying-members-only Singapore Linux Users' Group got the chance to compile a MySQL 4.1 source in our Slackware notebook and got it working under my watch. My wild guess is, he's the first local to do it in a such noob-hostile environment here. :)) So I told him to put it in his resume and if he enters a Poly or Uni, asks his major class professors if they had done such things, before they teach the "undervalue" of open source.

Building The Empire: Mule vs. OpenAdaptor

I am revisiting these two EAI implementations(whatever you may call it e.g. SOA, ESB etc. whatever). I have once played with OpenAdaptor before, it was really nice but it doesn't fit what we were trying to do two years ago. OpenAdaptor has been around before these marketing buzzwords such as SOA, ESB etc. etc. were coined. Mule on the other hand, tries to achieve the same thing, this time it is a bus, a looong bus, a double-decker bus, a triple-decker bus. Whatever. Since there's just so much fuzz about a lot of crappy technologies these days both coming from commercial and open source(e.g. AppFuse, Weblogic, etc. etc.), the commercial ones are even too hard to swallow, so much eye candy, so much 'surface value'. It's time to revisit technologies that really make sense!

The streets are so much buzzed with knowledge management, content management systems, portal management that really contributes so little to the value of a business. Some thought it's useful because a sweet-talking salesman has told them so. Businesses are more concerned to the value of what they are doing; getting results done in the most effective way, because this is how businesses can maximize profits.

The lack of appeal of these products are due to the absence of a tantalizing, hypnotic UI. I realized that UI is one of the best tools to fool a customer. But with OpenAdaptor or Mule, it's really the actions, especially the unattended ones, that matters.

08 August 2005

Blog DeathMatch: Hani vs. Paul

Choose sides or run for your unmentionables :)) This is going to be fun! We have a wet dreamer and a wanker, what more could you ask for? "Hiring is Obselete?", maybe in an ideal world, and I don't think Microsoft is one of the three big powers of the Internet, that thing is a sleeper. It's MS that tries to debunk the potential power of Internet in the mid-90s and claimed CD-ROMs are the way to go. In fact, they were hit titsup by the dotcom wave eating up their own shorts. Paul Graham might be a PR man on the M$ payroll.

And Hani on the other hand, is a real wanker. Who desperately plays Twister(TM) alone, naked and trying not to get aroused in the process. I don't mind if he's a sucker for IntelliJ maybe that's his source of inspiration(and wisdom) for all his writings. His open source hypocrisy is also one of his ticklers.

Both came from a programming career. The one become an investor and the one become the invested or fornicated. It seems there are two trends a programming career will be heading, either become a funder or become funded. Interesting. Hey, bring more mud in the ring!

07 August 2005

What you don't know about XP will hurt you

Just like what you don't know about sniping without an observer can kill you. Maybe that is the most appropriate analogy, Sniper/Observer pairing, in XP, it can be coder/observer pairing. Like an observer in a sniper duty, he/she is not only focused on the target at sight, he/she has to observe the surroundings ask questions like "is our position compromised?", "did the enemy spotted us?". He/she also has to provide cover for the sniper when things goes awfully wrong.

In XP's pair programming, almost an equivalent scenario applies. Observers does not only watch the coder type away. The observer has to consider how that particular piece of code currently being written will affect the whole application, is the code style correct? Are the use of patterns correct? Are the singletons should be where they are? Will it become a bottleneck if we integrate with X Team's API? In a looming deadline, the observer can also sit down side by side with the coder, he/she can build some urgent test cases, prototype user interfaces while the coder continue writing the business modules and data objects needed(this is like providing cover fire).

Just like in combat, snipers/observers are not the only elements/operators you need to win the war. They only make fighting easier, "safer" and faster for the regular infantry. And their utilization is "as-per-needed" basis only. No general will order a full regiment of snipers/observers to the front, that's ridiculous. Only missions that requires speed and clean extraction such resource will be employed, and will come out as if nothing happened.

That's what corporate developers find difficult to swallow, the "as if nothing happened" part. Most of them always needs recognition for every efforts, individual recognitions. And XP efforts are one of the most difficult to appraise especially in a traditional brick-and-mortar company.But pair programming isn't the silver bullet in every SDLC, just like snipers/observers they're used in special situations anywhere in the SDLC phase.

06 August 2005

Fast Infosets, How are they coming along?

The last time I read and played little about Fast Infosets was a year and half ago when I am still developing "highly-intelligent crawling" stuffs for the telecommunications and broadcasting industry. As the name implies...

Fast Infoset specifies a binary encoding for the XML Information Set. An XML infoset (such as a DOM tree, StAX events or SAX events in programmatic representations) may be serialized to an XML 1.x document or, as specified by Fast Infoset, may be serialized to a fast infoset document. Fast infoset documents are generally smaller in size and faster to parse and serialize than equivalent XML documents.

Sun Microsystem has one project going on. This is really cool stuff since plain XML, which is really one of the necessary evils when it comes to performance bottlenecks. Most developers, just to say they have used XML in their resumes, will really do stupid things at the expense of performance, to any type of 'XMLing' in their apps. In effect, we have a lot of heavily XML dependent frameworks. On the other hand, a lot of things won't be possible without XML. Adaptation will be one of the challenges Fast Infoset will have to tackle. Imagine if we want Spring to be more bouncy then there's a lot of work to be done in making context bean factories work with Fast Infosets. Web Services especially, the WSDL has to be modified if we to have a faster SOAP XML interoperability. Apache will also have a lot of refactoring to do make Fast Infosets really work for them.

But if we want to break the barrier of XML-burdened performance, then Fast Infosets needs to be adapted as soon as possible.

05 August 2005

Webwork+Velocity+Acegi config

Honestly, it's really a no-brainer. As what other Acegi's advocates are talking about, that Acegi should work with any frameworks. That's correct and adding to that, there's isn't much to code. I experienced getting some surprisingly erratic redirection behaviours after login. But I know there's nothing wrong with controller(action) classes so I was firm about my suspicion that what was happening was just a misconfiguration on my context files. The assumption was right. After following tightly the Contacts example, there's something that needs to be modified in the redirection if anyone intends to use Webwork+Velocity with Acegi Security framework.

Listing 1: applicationContext-acegi-security.xml



<!-- ===================== HTTP REQUEST SECURITY ==================== -->

<bean id="securityEnforcementFilter"
class="net.sf.acegisecurity.intercept.web.SecurityEnforcementFilter">
<property name="filterSecurityInterceptor"><ref
local="filterInvocationInterceptor"/>
</property>
<property name="authenticationEntryPoint"><ref
local="authenticationProcessingFilterEntryPoint"/></property>
</bean>

<bean id="authenticationProcessingFilter"
class="net.sf.acegisecurity.ui.webapp.AuthenticationProcessingFilter">
<property name="authenticationManager">
<ref bean="authenticationManager"/>
</property>
<property name="authenticationFailureUrl">
<value>/showlogin.action?loginerror=true</value></property>
<property name="defaultTargetUrl"><value>/readuser.action</value></property>
<property name="filterProcessesUrl"><value>/j_acegi_security_check</value></property>
<property name="rememberMeServices"><ref local="rememberMeServices"/></property>
</bean>

<bean id="authenticationProcessingFilterEntryPoint"
class="net.sf.acegisecurity.ui.webapp.AuthenticationProcessingFilterEntryPoint">
<!--<property name="loginFormUrl"><value>/acegilogin.jsp</value></property>-->
<property name="loginFormUrl"><value>/login.vm</value></property>
<property name="forceHttps"><value>false</value></property>
</bean>

<bean id="httpRequestAccessDecisionManager"
class="net.sf.acegisecurity.vote.AffirmativeBased">
<property name="allowIfAllAbstainDecisions"><value>false</value></property>
<property name="decisionVoters">
<list>
<ref bean="roleVoter"/>
</list>
</property>
</bean>

<!-- Note the order that entries are placed against the objectDefinitionSource is critical.
The FilterSecurityInterceptor will work from the top of the list down to the FIRST pattern that matches the request URL.
Accordingly, you should place MOST SPECIFIC (ie a/b/c/d.*) expressions first, with LEAST SPECIFIC (ie a/.*) expressions last -->
<bean id="filterInvocationInterceptor" class="net.sf.acegisecurity.intercept.web.FilterSecurityInterceptor">
<property name="authenticationManager"><ref bean="authenticationManager"/></property>
<property name="accessDecisionManager"><ref local="httpRequestAccessDecisionManager"/></property>
<property name="objectDefinitionSource">
<value>
CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
PATTERN_TYPE_APACHE_ANT
/index.vm=ROLE_ANONYMOUS,ROLE_USER
/login.vm*=ROLE_ANONYMOUS,ROLE_USER
/readuser.action*=ROLE_USER
</value>

</property>
</bean>




From the "filterInvocationInterceptor" id, I removed the "/**=ROLE_USER" and replace it with my actual pattern based that is also the default redirection URL if authentication is successful. This reduces the "candidates" within the filter invocation interception to be matched.

Acegi Security is a very comprehensive security framework that is usable to almost any applications including non-web apps(Swing, SWT etc.) and is straightforward to customize. I don't see any reason why would anyone build an authentication and ACL framework from scratch again.

04 August 2005

A little fix for the fart-addicts

As not to spoil so much of your fun. I know that most Hibernate+WhateverWebFramework+WhateverPattern+AlwaysInTomcat junkies out there sure will make things work fine. You have a shiny, bubbly web application bouncing like a squash ball. This addicts will claim they have over a thousand users on that application, no shit man this is what you call hallucination, it's truly a fucking lie, I don't buy that, I can bend over with pants down on this people and for sure they can't tell the difference between kissing Britney Spears and my ass.

Ok here it is, if you happen to be a developer who belonged to the companies with deep pockets, most likely you're playing with IBM Websphere, SJSAS that has really have a fine security policy. Also, this will prevent that pitiful Weblogic from shutting down. And with some dickhead even upgraded your Hibernate to Version 3 then your hibernate.cfg.xml should have something like this:


<property name="hibernate.query.factory_class">
org.hibernate.hql.classic.ClassicQueryTranslatorFactory
</property>


Otherwise you don't need that since you're awfully poor and you can't afford a decent application server.

Oh yeah, it's good to be back

So some people do remember me as The Darkstar Blogger, hehehehe. Darkstar is really the name of my PC back in the Philippines where I hastily installed Slackware 9.1. So the name stuck.

So let's see what has happened in the Java Blogging Community during the moments of lull. First, how's J2ME? Yeah, it's now Java ME, a couple of years back there's too much buzz about it, some predictions says new Java jobs will be created from this and that was made a couple of years ago. But so far, only games are making noise on this side of Java. The everyday Java ME apps are from usable. I still use my phone for talking, SMS, trying out some 3Gs but the latter won't stick like talking and texting. The lack of standards is really killing this platform. There isn't much any catchy hype like Spring and Groovy. It's more like rants and raves from wannabes and wannados.

In between these times I also happened to watch Hani's interview at TSS, yes that guy at Fornicary (did I spell it right?) and Rod Johnson's "Why J2EE Projects Fail", hope some tough nuts here have learned something from him especially the "corporate developers". There are no new heroes lately like Rod Johnson or Josh Bloch. No new hyped patterns. I guess most of us has peaked the technical side of our Java careers and started looking at the leadership aspect of the whole thing which is totally a different skillset at all. I didn't use "management" as it may imply PHBs (Pointy-Haired Bosses). Most of us right now is in the stage of balancing zeal and profits(dual-licensing still rocks). Of course, not to forget, IBM and Sun is carrying their own brand of open source these days too.

Again, there were days that will never be complete without bashing Hibernate, EJB and now there's an additional toy to fool around with, BEA Weblogic. While the new versions are up, new bugs are there too and surprisingly even the old ones are still alive! But I think those are fundamental flaws or permanent damage in other words symptomatic to the brains of their creators :)), use-at-your-own-risk.

At least now JavaBlogs has been fixed and its intelligent enough to recognize atom.xml. Silly, of all blog aggregators this the last one that knows there's such thing as atom.xml.


And yeah, it feels good to strike back again.

JSR-220/243 The Dream Project

Get out of the way Hibernate, go to sleep. According to Eclipse.org, "... The goal of the project is to provide tooling integrated with the Eclipse platform that generates artifacts for runtime implementations of the JSR 220 persistence and JSR 243 specifications..." Which means the Eclipse team is getting serious about JDO. The politics of persistence has kept JDO from the limelight not because of technological merits, in fact it's really far more superior than anything else. It's just some people from Hibernate, the CMP-loving JBoss and other rotting persistence groups just really^9999999 love to fart from their mouths. Naturally, farts like that can truly get some attention.

But with this JSR-220/ORM coming along, at least some of us could breath easier. Hopefully, some of those fart-addicts could be rehabilitated. Persistence is the name of the game, instead of sending letter, why not let just let JDO prevail ok? That letter does not even have a clear direction on how to unify, it only talks about how to improve the technically inferior side. Anyway, with the increasingly popular Eclipse, things will change in the near future.

03 August 2005

1 shitty container + 1 shitty persistence framework = ???

Of course, a cakeful of shitty applications. This is a funny experience, well I consider this funny so let me consider this two shitty things as the two stooges chasing a gopher but eventually hitting each others head in the process. I tried to run a sample application using Hibernate 3 on Weblogic 8.1, Hibernate is using ANTLR for some reasons maybe to process it's HQL dynamically, whatever that means. There is some sort of a query factory class that H3 has started using and for some reasons it causes a CharScanner.panic() in the ANTLR which by default will shutdown the JVM. I don't have anything against ANTLR, that is a very good tool written by a very good programmer who deserves to be really in "front of the keyboard", not these goofy jerks from Hibernate and Weblogic.

So here it is, I encountered this panic() that is configured normally as per instructions, believe it or not it actually shutsdown the Weblogic Server! Weblogic, by default, allows itself to be shutdown!!! Of course some goofy there will tell me, "you should modify the policy file" yeah you're right as if they're really going to do that if this pest didn't bite them. And I tried replicating the same error on Sun Java System Application Server PE 8.1 and it disallowed the process without me having to tweak anything for the first time. Imagine of you have several 24/7 applications sitting on the server, that is nightmare!

14 Marines just died recently in Iraq, it may be more if these two shitty products are running some show over there.

Effectiveness vs. Efficiency

I asked one candidate before what's the difference between effictiveness and efficiency. Take note this candidate has all the "SC" prefix on his certifications, he technically knows almost everything. But that is a clincher question and after throwing that question many times already, it is not surprising that 2 out of 10 will give an answer that makes sense. These few individuals, from the less obvious ways, knows the difference between doing things right and doing things quickly. Seldom these two mix, seldom you meet people who knows the difference.

You'll notice, only software marketing bullshit promotes efficiency. While the true successful ones really emphasize more on the how to be highly effective, one even came up with a 7-habits for it :)) Even some digital cameras measure pixels in "Million Effective Pixels" rather than "Million Efficient Pixels".

31 July 2005

Why I hate going to Funan IT Mall

Yesterday, I went to Funan IT Mall and my intention is to just look for this book called Java Puzzlers, I already know where to look at it's called The Computer Book Centre. But before I went there, a lot of distractions has come my way. Now I have changed my dream developer laptop from Fujitsu E8020 to Toshiba Tecra M3. So I ticked it to my To-Buy List. Although the review about this product is not-so-good since it's just about all those relative things like speed, lack of multimedia buttons, lack of anti-asthma-inhaler and lack of other girly stuff. My point is not about it, it's about development. When I saw it, it already looks worth the price, Toshiba's reputation on TFTs is unbeatable, they have the best screen displays ever. Put it side by side with ThinkPad, Vaio(all with dedicated VRAMs) or what have you, the M3 stands out. Of course since I am an nVidia fan, that's another thing that attracts to this machine, it has an nVidia GeForce 6600 thingy in it. As of this writing, it's priced at SGD$3,299. Not bad. Now where's my credit card?

That's not the point of me being in there in the first place. So I walked with some few paces. Store after store seems to have a life of its own uttering in my ears "M3...M3...M3". Finally, I am heading to where I want to go, The Computer Book Centre. Upon arriving, there's a bunch of books on sale, tempting. O'Reilly has their SWT Developer's Notebook(not the laptop ok!) series at SGD$20 and O'Reilly's Sping Developer's Notebook at $47(?). The O'Reilly Notebook series are another interesting series aside from the Head First series because the book looks like a college math notebook where sample codes has written on it. Again, that's not what I am looking for. I headed to the Java Section there are books of interests about JDO, another JCA, JavaSpaces/Jini. I sat on the floor to scour the bottom, nothing. So I went to the Publishers section then to the Addison-Wesley shelf and...NOTHING! I asked the sales clerk if there's a Java Puzzlers and said that book is still to arrive and asked if I want to advance my order, I refused. Not to put to waste the efforts of going there, I went back to the A-W shelf, now there are three books of interests I am looking at; "Open Source Licensing", "Succeeding with Open Source" and this. I opened the last book and the page that pop on me is p.213 and I quote:

"...Let's say you have a module of legacy code that's in a real mess, and you want to rewrite it rather than keep trying to live with it. You have to involve your boss because it will require significant investment resources.

You could present this choice to your boss:


  1. Do nothing new, keep fixing bugs as they appear.

  2. Total rewrite.



Your boss may choose option 1 outright..."


And I keep on reading the whole page. Damnit! I am sold. I am buying this book now! That's SGD$55 by the way.

29 July 2005

Bug on Acegi's "debug.jsp" Contact example

I notice from the debug.jsp code of Acegi's Contacts sample application that this code snippet:



<%@ page import="net.sf.acegisecurity.context.SecurityContextHolder" %>
<%@ page import="net.sf.acegisecurity.Authentication" %>
<%@ page import="net.sf.acegisecurity.GrantedAuthority" %>
<%@ page import="net.sf.acegisecurity.adapters.AuthByAdapter" %>

<%
Authentication auth = SecurityContextHolder.getAuthentication();
if (auth != null) { %>
Authentication object is of type: <%= auth.getClass().getName() %>


Authentication object as a String: <%= auth.toString() %>




Is wrong, there is no such thing as getAuthentication() within the SecurityContextHolder, it has to be fixed with something like this:


<%@ page import="net.sf.acegisecurity.context.SecurityContextHolder" %>
<%@ page import="net.sf.acegisecurity.context.SecurityContext" %>
<%@ page import="net.sf.acegisecurity.Authentication" %>
<%@ page import="net.sf.acegisecurity.GrantedAuthority" %>
<%@ page import="net.sf.acegisecurity.adapters.AuthByAdapter" %>

<%
SecurityContext securityContext =
SecurityContextHolder.getContext();
Authentication auth =
securityContext.getAuthentication();
if (auth != null) { %>
Authentication object is of type: <%= auth.getClass().getName() %>



Authentication object as a String: <%= auth.toString() %>





No wonder the Contacts sample with every instructions followed can't work. And this file has been sleeping in the CVS for months. Calling Ben Alex, yoohoo!

28 July 2005

Dude, it's called Java Job Interview

I pity the owner or stakeholders of companies who hires god-like asshats in their Software Engineering section. Those uber-coder-turned-CTO or whatever who doesn't know how to pick their own in just 3 hours or less. These high-IQ individuals tend to overlook EQs, which effectively push them downwards to the intellectual echelon.

For technical jobs especially Java-related ones, any type of on-the-spot exam barely proves anything. Whether it's online or written and be subjected to batteries of technical interviews if the candidates happen to pass their so-high-standard tests. I observed that these kind of tests are simply more of intimidation contests rather than getting the right person for the job. These techniques are top time-wasters and outdated, it was formulated by men with fragile egos to protect. They will say these are standard company procedures, WELL, FUCK YOU! Some of it was written by morons who has nothing better to do, and definitely wasting company resources by missing the right people who are truly capable.

I can always get a good guy, not necessarily great ones but capable, in just a three-hour or less semi-technical-behavioural one-on-one interaction. Ok, I will not call it an interview because when I do conduct such things I make sure I don't make the candidate feel he/she is somewhere in Guantanamo. The secret to this selection process is PREPARATION. Every candidates has a unique sets of questions prepared for them based on what they claim to know in their CVs. So making standardized interview questions is a big NO-NO! Preparation will always pay off. My interview sequence always goes this way:


  • Introduction of myself and what am I to the organization I represent

  • Asking the candidate how to address him/her.

  • Then the "can opener" questions



What are the "can opener" questions? These are some of the example questions that I usually starts with, let's say the candidate has extensively wrote about Spring in his CV:


  • "So what do you do in your current job?"


  • At this point, the candidate will express vaguely about what he/she does. And take note, almost everyone in this position will almost, always be honest.

  • "So you've mentioned in your CV that you have used Spring, What's good about it?"


  • Please listen carefully on this part and stop being a zealot for a while, if you tend not to like what the candidate will going to say. This is where your own EQ will be tested. Do not confront the candidate. Give brownie points on keywords like IoC, DI, etc. etc.

  • "What's your most difficult problem in using Spring?"


  • Case-to-case basis, you will know that the candidate is better than you when you hear something new and makes sense.

  • "When do you prefer not to use IoC?"


  • Again, listen and you will get some points for yourself here as well. But stupidity will show it's obvious head. You will find out how easy it is.

  • "Tell me about your experience in working on a team"


  • Never ask "Have you worked on a team?". Because that is answerable by yes/no and you will find yourself in a deadlock, you'll have a hard time getting the information you need to evaluate the candidate.

  • "Tell me about your most difficult teammate"


  • Scrutinize the candidate's behaviour. The way he solves problems, he may have solved it in a technical or smart(insidious) way.

  • "Tell me about your most challenging design problems"


  • Here, buzzwords like Singleton, encapsulation etc. will fly out anywhere and if the candidate really knows what he/she's talking about, smile. This part you will hear with enthusiastic elaboration how the candidate tackled the problems using a pattern and how they mixed patterns to come up with a solution or sets of solutions.
    How one tool sucks from the other, that x database is better than y database for a particular task. OR you'll see an empty stare and a hum here and a hum there.




At this part, while you're still browsing halfway of the candidate's CV. You know if he/she's a go or no go. And can immediately write your recommendations. Potentially save your company some money etc. etc.

I have mastered this skill during my days on the Dark Side. You can formulate your own questions too. But the real key is preparation.

The Falcon Pirate now online

There's a Darth Vader's blog, now it's Han Solo's blogs at The Falcon Pirate. Now I don't know if this has something to do with software development. We'll see.

27 July 2005

Inconsistency on Acegi's Reference Guide

Quoting the intstruction from Acegi Reference Guide, this is what it tells.

"1.11.3. Catalina (Tomcat) Installation

The following was tested with Jakarta Tomcat 4.1.30 and 5.0.19.

$CATALINA_HOME refers to the root of your Catalina (Tomcat) installation.

Edit your $CATALINA_HOME/conf/server.xml file so the section contains only one active entry. An example realm entry:

appContextLocation="conf/acegisecurity.xml"
key="my_password" />

Be sure to remove any other entry from your section.

Copy acegisecurity.xml into $CATALINA_HOME/conf.

Copy acegi-security-catalina-XX.jar into $CATALINA_HOME/server/lib.

Copy the following files into $CATALINA_HOME/common/lib:

*

aopalliance.jar
*

spring.jar
*

commons-codec.jar
*

burlap.jar
*

hessian.jar

None of the above JAR files (or acegi-security-XX.jar) should be in your application's WEB-INF/lib. The realm name indicated in your web.xml does not matter with Catalina."


But building the "Contacts" example and following their Maven(which really^1000000 sucks) build instructions will give a most likely erroneous war file that will cause "IncompatibleClassChangeError, IllegalStateException: No WebApplicationContext found" etc. etc., which leaves the hapless developer gasping for breathe where to go, and most likely be shooed away in the forums to just READ THE FUCKING MANUALS(what manuals?!?). While the cause of these problems are just overlapping of jar files from the common classloaders and webapp classloaders.

So here's my take, don't follow the freaking instructions above and you have a higher chance of making things work. I successfully did it on GlassFish.

Hey Spring/Acegi guys, you made a good job creating this hype, but why can't you agree on what's the right thing to do?

26 July 2005

Of Salsa and Protocol-agnosticism

It's like JavaSpaces. When everybody got to implement the Space interface except me. This is what I felt when I went to Union Square at Tanjong Pagar last Friday night. My Singaporean-American friend happened to be going there and I told her I could drop by and a have a few beers and listen to salsa and other Latin music since I don't can't really dance(and I don't want to). But upon the entrance to the door I saw the dance floor jampacked with every guys and babes doing salsa. My jaw dropped and my chic-magnet points seems to diminish every minute, guys who knows(implements) salsa can dance around with anybody. Feeling like boy in the candy store, I told my friend "this is amazing", never felt like a loser before I really am that night.

My friend told me to join her class, but I am still in self-denial. Anyway, the empire will strike back next time.

25 July 2005

Working Hard(ska Working Stupid) vs. Working Smart

A lot of developers not only in the Java Community, complains a lot about crap-related work, I mean work-related crap. There are developers who were agonized by long painful experiences that it has in-growned to their minds that if you haven't done the "working-hard" stuff, you haven't done enough or you haven't really feel the real work. F&#k that!

Developers in general who "work hard" has some unique behaviours that are different from the developers who work smart. Developers who work smart knows:


  • When to reinvent the wheel

  • When to say the big "NO"

  • That success is a daily happening and should be taken for granted

  • How not to submit to stress

  • That is fun to smirk at workmates who are really weary of what the fuck is going on with their careers. That listening to the backbiting sessions about their superiors are treated as a joke to themselves.
  • how to look at the big picture, and consciously knows his directions

  • how to think ahead of the competition.

  • and understand the fears of the opponents

  • how to effortlessly negotiate with minimal buzzword, less assertiveness and with full control.
  • when to give up.

  • every risk and how to calculate them.

  • how to be a confident asshat, that honestly tell people what he does and doesn't know

  • that pretending and fooling around has consequences

  • that it is stupid to repeat the same stupid mistake

  • how to party and have fun. While "hard-workers" work at weekends and holidays

  • what the task at hand and what to do about it. If doubtful, smart workers are inquisitive species

  • that it is a bad idea to consult with "hard workers"

  • that an "early bird catches the early worm and fucks the prom queen", while hard-workers whines about how to try their best

  • that lunch and other breaks are not the good times for work-related chats

  • that the most difficult of all is preserving integrity over job security, which is by the way achievable

  • that with integrity, job market is not scarce, which takes away their fears of "starting-over-again" dilemma



Working smart is not a skill that is developed overnight. It takes some level of guts and cockiness, some sacrifices as well. There are prices to be paid in exchange for the lessons learned. Smart workers can be mistaken as slackers in the office because the speed and the scope of possibilities laid out by them are tremendous and overwhelming in any given minute that hard-workers will simply scratch heads in awe.

Patriot Update

After several weeks of inactivity, I have created a new source folder for the drivers. Redefined interfaces that will handle SMS messaging thru GSM Modem. I guess the client APIs and SPI should have separate source folders as well, to be able to build the whole thing properly.

More on the Patriot project here.

Building The Empire: Smaller Steps

Four months of no Linux here in Singapore and I am starting to get some sort of a withdrawal syndrome of a heroine junkie. It's really hard not to work with Linux, missing the CLI, means doing stuff the harder way of point-drag-click dance, where you could accomplish 1-3 steps with one press of the "Enter" button.

Incidentally, My eyes happens to tripped on one of the decent idle boxes in our office. It's a Dell Dimension 4300S with just 256MB RAM(for now), good enough as my second development box. Put up a Slackware 10.1 on it, install Glassfish on it. And behold, I was amazed at the startup speed. I don't how many times, but it's really, really much faster than BEA Weblogic 8.1 running on a SparcServer (Solaris 8) with 512MB of RAM which is, by the way, one of my toys that I want to get rid off pretty soon from the office.

So Slackware 10.1, Welcome to Singapore.

23 July 2005

Anatomy of a Corporate Developer

It's funny to watch these species wander around mazes of endless and monotonic cubicles of the corporate world. But don't be decieved by the crisp suit and tie and clean looks, the neater they are the dumber they get. So let's take a look from the uncanny consultant's view of what is a corporate developer.

First, let's determine where they are in the food chain. A corporate developer looks up at only two kinds of superior in the workplace, a clerk and a glorified clerk. His/her favorite term for open source tools are "freebies", freeware, shareware etc. A corporate developer is not really a programmer by heart, he/she only took the programming course because of its job market demand and is willing to get out of programming as soon as better opportunities pop up like taking up a Nursing course and eventually become a caregiver or better he/she wishes to become a glorified clerk ticking up timelines, gantts and some UML diagrams awefully, wrongly drawn.

At work, he's usually the nicest, sweetest smelling guy you can walk past at complete with designer ties and shoes, he thought he looks genius by putting a "The Geek shall inherit the Earth" wallpaper with Bill Gates' face on it. He/she thinks the meaning of JAVA is "Just Another Vague Acronym". He/she believes that the best solutions are the ones you can always buy. At the start of the day a corporate developer usually checks emails first instead of synchronizing his/her codes against the CVS repository. After updating his code, he will proceed back to checking and answering emails for the rest of the day. Corporate developer worships every author of books that's in his seatmate's bookshelf and every blogs that he shares his personal view regarding corporate development, that he/she even quoutes when arguing some important technical issues.

A corporate developer eats buzzwords for breakfast, lunch and dinner. He/she thinks that wearing a shirt with an IT vendor's logo embroidered in the left chest is awesome and geeky. He/she never touched a linux/unix box in his entire development career and never heard of Gnome. And normally, his/her language of choice is Visual Basic or anything high-level until Java became so hot, he/she jumped the bandwagon. He/she believes that good practices aren't necessary as long as the system is currently working. A corporate developer loves BEA even if he/she has been bitten by it, he/she will insist on using it on the next project rather than be "bitten by an unfamiliar snake". And they think learning while working is a waste of time.

This is sometimes sickening, if the corporate developer especially the male variety has some new cool gadget, he knows very well the intricacies and internal workings of that thing rather than the work he is supposed to do.

20 July 2005

How the Integer-masked permission works

Honestly, it's so simple. Let's say we have the following permissions such as read, write, create, delete and administration permissions. We'll assign it like:



administer = 2^0
read = 2^1
write = 2^2
create = 2^3
delete = 2^4


Using the logical inclusive OR ("|") operator we can come up with a series of logical combinations.


read, write = 2 | 4

0010
0100
====
0110 = 6 (READ,WRITE)

read,write,create = 2 | 4 | 8

0010
0100
====
0110
1000
====
1110 = 14 (READ,WRITE,CREATE)

read,write,create,delete = 2 | 4 | 8 | 16

00010
00100
=====
00110
01000
=====
01110
10000
11110 = 30 (READ,WRITE,CREATE,DELETE)

and the list can go on...


Not perfect, but better than anything else. So the only thing needed on any permission tables are the actual integer permission values.

Building The Empire

I as We, declare this day the start of Building The Empire. This island is white and ripe. Get your ploughs, your shovels and your picks. Take that corner and this corner and I will take mine. It's harvest time. Every minute and every second counts. We will liberate this city from proprietary madness, from fear, uncertainty and deceit. From the handshakes to the sealing of contracts there will be no turning back. Everything counts in large amounts. We have the spoils anyone can't refuse. Our technology is no secret, our weapons-of-choice has been laid out. Our battlefield is open, open to those who are ready to fight. We will change the rule of the game. It will fit like water to our pipes. And this will be everyone's unwritten business law: "Adapt or die".

Say "Open Source is not for us", we say "Adapt or die". Say "The old ways works with us", we say "Adapt or die". Say, "This is what they taught in school", we say "Adapt or die". Adapt and we will support. Oppose and we'll bring the game to the next level. Until submission is achieved. Or else, competition is dead before it even started. Such is an art of war.

Let's Build The Empire. It's for everyone. It's extensible, replicable, "commoditizable". It's not unique. Not even a monopoly. What differs from one to another is the value they bring to the battlefield. Not the technology or the strategy they choose adapt. The days of the proprietary software are numbered. Let's Build The Empire and start counting.

Join us and together we'll rule this part of the galaxy.

19 July 2005

Acegi's Integer-masked ACL

Finally, a permission masking that works like chmod in Linux. This is the kind of ACL that makes sense in every Java EE applications. By using Acegi's Integer-masked ACL, permissions and groupings are not directly wired up together. Which is a common flaw in most Java EE applications past and present. This means it will be easier to implement a "by-group" permission. More on this later.

18 July 2005

Testing Acegi Security's Provider-based Authentication

I am taking down this note as this process is very hard to remember when finalized and has been stabilized. The authentication process is very straightforward because most of the dirty works are handled by authentication providers. We will take the assumption that the reader is already familiar with Spring's application-context XML configurations in Acegi. We'll write a testable code based on JUnit. But first we have to enumerate the steps our authentication method will going to take:


  1. Initialize a ListableBeanFactory instance

  2. Initialize the net.sf.acegisecurity.Authentication interface with a proper reference implementation

  3. Obtain an instance of the from the ListableBeanFactory configuration

  4. Invoke the AuthenticationProvider.authenticate()
  5. Get the instance of the net.sf.acegisecurity.providers.dao.User from the AuthenticationProvider.authenticate().getPrincipal()
  6. Check ALL of the following from the User object: isEnabled(), isAccountNonLocked(), isAccountNonExpired(), isCredentialsNonExpired()
  7. Register the Authentication object to the SecureContext

  8. Register the SecureContext object to ContextHolder.setContext() static method.


In code, this is how it looks like:

Listing 1:


public boolean authenticate(String username, String password) {

Authentication authentication =
new UsernamePasswordAuthenticationToken(username, password);

SecureContext secureContext = new SecureContextImpl();

//have chose daoAuthenticationProvider for this.
AuthenticationProvider provider =
(AuthenticationProvider)beanFactory.getBean("daoAuthenticationProvider");
Authentication auth = provider.authenticate(authentication);
System.out.println(auth.getName());
User user = (User)auth.getPrincipal();

if (user.isAccountNonExpired() && user.isAccountNonLocked() &&
user.isCredentialsNonExpired() && user.isEnabled()){
auth.setAuthenticated(true);
}

secureContext.setAuthentication(auth);
ContextHolder.setContext(secureContext);
return auth.isAuthenticated();

}



The test code should assert for the isAuthenticated() method with something like this:

Listing 1:


public void testAuthenticate() {

String[] contexts = {"applicationContext-acegi-security.xml",
"applicationContext-common-business.xml",
"applicationContext-common-authorization.xml"};

ListableBeanFactory beanFactory =
new ClassPathXmlApplicationContext(contexts);

UserAuthenticate authenticate = new UserAuthenticate(beanFactory);

//we assume that you are familiar with JUnit
assertTrue(authenticate.authenticate("scott", "wombat"));

}



To do this test properly, all the AOP-based interceptors must be disabled since it will not be ran on a web container or application server. From a controller class (such as Webwork2 action classes) the authenticate() method at Listing 2 will be shorter because the ContextHolder already has the security credentials provided by AOP interceptors executed during initialization of UsernamePasswordAuthenticationToken class. But for the sake of making a testable code, I have provided those checks for clarity.

17 July 2005

My Non-tech entries

I've been itching to write non-technical stuff for a while. Since it doesn't have a room here in this URL. And I don't want to be tempted to push non-tech stuff here anymore. I would like to invite my good readers to see my non-tech entries at http://jaredflo.multiply.com/journal. So if the "force" doesn't move anywhere in here, its there ;).

Thanks for your patronage.

15 July 2005

Implementing Embedded Database for Corporate Developers

There are some corporate developers who would claim they were able to build "massive" distributed systems that were able to serve 100,000 users or so(I could imagine them now flapping their ears). But if you ask them what if someone/SOMETHING suddenly pulls the network cables behind the asses of their servers or a sudden power outage that no UPS can handle left some part of the data center dead and most of the clusters crippled? Huge chances are these morons will give you a blank stare and will argue that those things are absurd and will never happen.

To make it easy for corporate developers to understand some aspects of "mission-critical" elements of an application. First, we look at the RDBMS/JMS application and how to maintain its data integrity in times of any untoward crisis. Suppose we had a transaction that has to be committed across some distant SQL database when all of a sudden the JMS Provider and the remote DB went down probably due to a nuclear attack leaving only less reliable lines available. Nonetheless, data has still to be transmitted to the other end. So the requirements to perform that has to be streamlined as well which means the absence of using SQL databases is inevitable because the transaction due to its emergency nature has to be fast and stable so therefore the use of JDBC is definitely a big minus also, and the only available transmission is via HTTP. Likewise, we should not forget the RDBMS are all down as well, this is the worst possible scenario. And since the JMS is also down transmission to queues will be impossible.

Now, here's one solution for free. Let's introduce the use of SleepyCat's BerkeleDB Java Edition 1.5. There's no need to tell who uses BerkeleyDB because this article is intended to help corporate developer understands the nature of what they're suppose to be doing in times of crisis.

Let's now look at the code (AlarmLogDBEnv.java)that initializes a BerkeleyDB Database Environment. The nature of this code is to write an Alarm message to BerkeleyDB when RDBMS is not available.



import java.io.File;

import org.apache.log4j.Logger;

import com.sleepycat.bind.serial.StoredClassCatalog;
import com.sleepycat.je.Cursor;
import com.sleepycat.je.Database;
import com.sleepycat.je.DatabaseConfig;
import com.sleepycat.je.DatabaseEntry;
import com.sleepycat.je.DatabaseException;
import com.sleepycat.je.Environment;
import com.sleepycat.je.EnvironmentConfig;

/**
* Description:
*
* This is the helper class for utilizing sleepycat embedded db.
*
* @author Jared Odulio
*
*/
public class AlarmLogDBEnv {

private Database alarmlogDB;
private DatabaseConfig dbConfig;
private Environment env;
private EnvironmentConfig envConfig;
private StoredClassCatalog alarmsCatalog;
private Cursor cursor;
private String dbEnv;
private String key;
private DatabaseEntry alarmKey;
private DatabaseEntry alarmData;
private Logger logger;
private File fileEnv;

/**
*
*/
public AlarmLogDBEnv(String dbEnv) {

super();
this.dbEnv = dbEnv;
initialize();

}

/**
* Copy constructor that takes a File object as an
* argument.
*
* @param fileEnv
*/
public AlarmLogDBEnv(File fileEnv){

this.fileEnv = fileEnv;
initWithFile();

}

private void initWithFile(){

logger = Logger.getLogger(this.getClass());

envConfig = new EnvironmentConfig();
envConfig.setAllowCreate(true);
//envConfig.setTransactional(true);

try {

env = new Environment(fileEnv, envConfig);
dbConfig = new DatabaseConfig();
dbConfig.setAllowCreate(true);
//dbConfig.setTransactional(true);
alarmlogDB = env.openDatabase(null, "AlarmLogDB", dbConfig);

} catch (DatabaseException e) {

logger.error(e.toString(), e);

}

}

/**
* Initialize this class with only the String value of the Database
* Environment path as argument.
*
*/
private void initialize(){

logger = Logger.getLogger(this.getClass());

envConfig = new EnvironmentConfig();
envConfig.setAllowCreate(true);
//envConfig.setTransactional(true);

try {

env = new Environment(new File(dbEnv), envConfig);
dbConfig = new DatabaseConfig();
dbConfig.setAllowCreate(true);
//dbConfig.setTransactional(true);
alarmlogDB = env.openDatabase(null, "AlarmLogDB", dbConfig);

} catch (DatabaseException e) {

logger.error(e.toString(), e);

}

}

/**
* @param string
*/
public void setKey(String string) {
key = string;
}


/**
* @return
*/
public Environment getEnv() {
return env;
}

/**
* @return
*/
public Database getAlarmlogDB() {
return alarmlogDB;
}

public void close(){

if (env != null){

try {

alarmlogDB.close();
env.close();

} catch (DatabaseException e) {

logger.error(e.toString(), e);

}
}

}
}


Of course we will need to create a DAO-Pattern-style value object and call it EmbeddedAlarm.java


/**
* Description:
* This is the model used for storing and retrieving alarm log data into the
* Berkeley Embedded DB.
*
* @author Jared Odulio
*
*/
public class EmbeddedAlarm {

private int alarmID;
private int errorID;
private int agentID;
private int moduleID;
private String instanceID;
private String hostAddress;
private int severity;
private String remarks;
private String status;
private long entryDate;
private String userID;
private long clearDate;

/**
* @return
*/
public int getAgentID() {
return agentID;
}

/**
* @return
*/
public int getAlarmID() {
return alarmID;
}

/**
* @return
*/
public long getClearDate() {
return clearDate;
}

/**
* @return
*/
public long getEntryDate() {
return entryDate;
}

/**
* @return
*/
public int getErrorID() {
return errorID;
}

/**
* @return
*/
public String getHostAddress() {
return hostAddress;
}

/**
* @return
*/
public String getInstanceID() {
return instanceID;
}

/**
* @return
*/
public int getModuleID() {
return moduleID;
}

/**
* @return
*/
public String getRemarks() {
return remarks;
}

/**
* @return
*/
public int getSeverity() {
return severity;
}

/**
* @return
*/
public String getUserID() {
return userID;
}

/**
* @param i
*/
public void setAgentID(int i) {
agentID = i;
}

/**
* @param i
*/
public void setAlarmID(int i) {
alarmID = i;
}

/**
* @param l
*/
public void setClearDate(long l) {
clearDate = l;
}

/**
* @param l
*/
public void setEntryDate(long l) {
entryDate = l;
}

/**
* @param i
*/
public void setErrorID(int i) {
errorID = i;
}

/**
* @param string
*/
public void setHostAddress(String string) {
hostAddress = string;
}

/**
* @param i
*/
public void setInstanceID(String string) {
instanceID = string;
}

/**
* @param i
*/
public void setModuleID(int i) {
moduleID = i;
}

/**
* @param string
*/
public void setRemarks(String string) {
remarks = string;
}

/**
* @param i
*/
public void setSeverity(int i) {
severity = i;
}

/**
* @param string
*/
public void setUserID(String string) {
userID = string;
}

/**
* @return
*/
public String getStatus() {
return status;
}

/**
* @param string
*/
public void setStatus(String string) {
status = string;
}

}






This value object needs to be converted in byte arrays so that BerkeleyDB could understand it. So we use our own Custom Binding to do that. AlarmLogBinding.java


import net.smart.umui.logging.model.EmbeddedAlarm;

import com.sleepycat.bind.tuple.TupleBinding;
import com.sleepycat.bind.tuple.TupleInput;
import com.sleepycat.bind.tuple.TupleOutput;

/**
* Description:
*
* This class is used for binding the EmbeddedAlarm class in order to write and read
* complex objects in to BerkeleyDB embedded database.
*
* @author Jared Odulio
*
*/
public class AlarmLogBinding extends TupleBinding {



/* (non-Javadoc)
* @see com.sleepycat.bind.tuple.TupleBinding#entryToObject(com.sleepycat.bind.tuple.TupleInput)
*/
public Object entryToObject(TupleInput ti) {

EmbeddedAlarm alarm = new EmbeddedAlarm();
alarm.setAlarmID(ti.readInt());
alarm.setErrorID(ti.readInt());
alarm.setAgentID(ti.readInt());
alarm.setModuleID(ti.readInt());
alarm.setInstanceID(ti.readString());
alarm.setHostAddress(ti.readString());
alarm.setSeverity(ti.readInt());
alarm.setRemarks(ti.readString());
alarm.setStatus(ti.readString());
alarm.setEntryDate(ti.readLong());
alarm.setUserID(ti.readString());
alarm.setClearDate(ti.readLong());

return alarm;
}

/* (non-Javadoc)
* @see com.sleepycat.bind.tuple.TupleBinding#objectToEntry(java.lang.Object, com.sleepycat.bind.tuple.TupleOutput)
*/
public void objectToEntry(Object obj, TupleOutput to) {

EmbeddedAlarm alarm = (EmbeddedAlarm)obj;

to.writeInt(alarm.getAlarmID());
to.writeInt(alarm.getErrorID());
to.writeInt(alarm.getAgentID());
to.writeInt(alarm.getModuleID());
to.writeString(alarm.getInstanceID());
to.writeString(alarm.getHostAddress());
to.writeInt(alarm.getSeverity());
to.writeString(alarm.getRemarks());
to.writeString(alarm.getStatus());
to.writeLong(alarm.getEntryDate());
to.writeString(alarm.getUserID());
to.writeLong(alarm.getClearDate());


}

}



We also need an enabler class to initialize the Database Environment based on client object's configuration. AlarmLogDB.java



import java.io.File;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;

import net.smart.umui.binding.AlarmLogBinding;
import net.smart.umui.logging.db.exception.AlarmDBException;
import net.smart.umui.logging.model.EmbeddedAlarm;

import org.apache.log4j.Logger;

import com.sleepycat.bind.tuple.TupleBinding;
import com.sleepycat.je.Cursor;
import com.sleepycat.je.Database;
import com.sleepycat.je.DatabaseEntry;
import com.sleepycat.je.DatabaseException;
import com.sleepycat.je.Environment;
import com.sleepycat.je.LockMode;
import com.sleepycat.je.OperationStatus;

/**
* Description:
*
* This is the BerkeleyDB application class that will use the
* AlarmLogDBEnv class.
*
* @author Jared Odulio
*
*/
public class AlarmLogDB {

private Database alarmLogDB;
private Environment env;
private String dbEnv;
private AlarmLogDBEnv alarmEnv;
private Cursor cursor;
private Logger logger;
private EmbeddedAlarm embedAlarm;
private DatabaseEntry dbEntry;
private DatabaseEntry alarmKey;

private String dbKey;
private TupleBinding alarmBinding;

/**
*
*/
public AlarmLogDB() {

logger = Logger.getLogger(this.getClass());

}

/**
* Initialize the DB for writing or reading functions.
* @param dbEnv
*/
public void setup(String dbEnv){

alarmEnv = new AlarmLogDBEnv(dbEnv);
alarmLogDB = alarmEnv.getAlarmlogDB();
alarmBinding = new AlarmLogBinding();

try {

cursor = alarmLogDB.openCursor(null, null);

logger.info("Cursor has been opened");

} catch (DatabaseException e) {

logger.error(e.toString(), e);

}
}

/**
* Use this method if a File object is to be used instead of the
* String value of the Database Environment path.
*
* @param fileEnv
*/
public void setup(File fileEnv){

alarmEnv = new AlarmLogDBEnv(fileEnv);
alarmLogDB = alarmEnv.getAlarmlogDB();
alarmBinding = new AlarmLogBinding();

try {

cursor = alarmLogDB.openCursor(null, null);

logger.info("Cursor has been opened");

} catch (DatabaseException e) {

logger.error(e.toString(), e);

}

}
/**
* Write Alarm log to embedded db.
*
*/
public void writeAlarm(){

try {

dbEntry = new DatabaseEntry();
alarmKey = new DatabaseEntry(dbKey.getBytes("UTF-8"));
//converts the model to database entry
alarmBinding.objectToEntry(embedAlarm, dbEntry);
cursor.put(alarmKey, dbEntry);

logger.info("Alarm recorded");
cursor.close();
alarmEnv.close();

} catch (UnsupportedEncodingException e) {

logger.error(e.toString(), e);

} catch (DatabaseException de){

logger.error(de.toString(), de);

}

}

/**
* Gets the alarm logs from BerkeleyDB
*
* @return
* @throws AlarmDBException
*/
public List getAlarms() throws AlarmDBException{

List alarmList = new ArrayList();
dbEntry = new DatabaseEntry();
alarmKey = new DatabaseEntry();

try {

while (cursor.getNext(alarmKey, dbEntry, LockMode.DEFAULT) == OperationStatus.SUCCESS){

embedAlarm = (EmbeddedAlarm)alarmBinding.entryToObject(dbEntry);
alarmList.add(embedAlarm);

}

} catch (DatabaseException e) {

throw new AlarmDBException(e);

}

return alarmList;
}

public void deleteAlarms() throws AlarmDBException{

try {
alarmLogDB.truncate(null, false);
} catch (DatabaseException e) {

throw new AlarmDBException(e);
}

}

/**
* Sets the key to be used for the database entry.
*
* @param dbKey
*/
public void setDBEntryKey(String dbKey){
this.dbKey = dbKey;
}

/**
* @param alarm
*/
public void setEmbedAlarm(EmbeddedAlarm alarm) {
embedAlarm = alarm;
}

public void close(){

try {
cursor.close();
} catch (DatabaseException e) {

logger.error(e.toString(), e);
}
alarmEnv.close();

}
}



To test those codes we need to write a couple of classes that we will name TestEmbeddedReader.java and TestEmbeddedWriter.java. For TestEmbeddedWriter.java, heres the code snippet.



import java.io.File;
import java.net.URI;

import org.apache.log4j.Logger;

import net.smart.umui.logging.db.AlarmLogDB;
import net.smart.umui.logging.model.EmbeddedAlarm;

/**
* Description:
*
* Testing writer.
*
* @author Jared Odulio
*
*/
public class TestEmbeddedWriter {

private AlarmLogDB alarmDB;
private EmbeddedAlarm alarmModel;
private File dbenv;
private Logger logger = Logger.getLogger(this.getClass());


/**
*
*/
public TestEmbeddedWriter() {

initialize();

}

private void initialize(){

dbenv = new File("dbEnv");
dbenv.mkdir();

alarmDB = new AlarmLogDB();
alarmDB.setup(dbenv);
alarmModel = new EmbeddedAlarm();
alarmModel.setAgentID(0);
alarmModel.setAlarmID(2);
alarmModel.setClearDate(System.currentTimeMillis());
alarmModel.setEntryDate(System.currentTimeMillis());
alarmModel.setErrorID(1);
alarmModel.setHostAddress("10.121.55.105");
alarmModel.setInstanceID("instanceID");
alarmModel.setModuleID(5);
alarmModel.setRemarks("NO REMARKS");
alarmModel.setSeverity(6);
alarmModel.setStatus("NO STATUS");
alarmModel.setUserID("jared");

alarmDB.setEmbedAlarm(alarmModel);

/*
* If you're going to follow this example think of your own
* unique key. The fully qualified name of your class is definitely
* acceptable.
*/
alarmDB.setDBEntryKey("TestKey3");

}

public void writeToDB(){

alarmDB.writeAlarm();
logger.info("Data has been written");

}

public static void main(String[] args) {

new TestEmbeddedWriter().writeToDB();

}
}



For the TestEmbeddedReader.java.


import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import org.apache.log4j.Logger;

import net.smart.umui.logging.db.AlarmLogDB;
import net.smart.umui.logging.db.exception.AlarmDBException;
import net.smart.umui.logging.model.EmbeddedAlarm;

/**
* Description:
*
*
* @author Jared Odulio
*
*/
public class TestEmbeddedReader {

private AlarmLogDB alarmLogDB;
private List logs;
private EmbeddedAlarm alarmModel;
private Logger logger = Logger.getLogger(this.getClass());


/**
*
*/
public TestEmbeddedReader() {

initialize();
}

private void initialize(){

File dbenv = new File("dbEnv");
alarmLogDB = new AlarmLogDB();
alarmLogDB.setup(dbenv);
alarmModel = new EmbeddedAlarm();
alarmLogDB.setEmbedAlarm(alarmModel);
alarmLogDB.setDBEntryKey("TestKey");

}

public List readLogs(){

try {

logs = alarmLogDB.getAlarms();
alarmLogDB.deleteAlarms();
alarmLogDB.close();

} catch (AlarmDBException e) {

logger.error(e.toString(), e);

}

return logs;

}

public Logger getLog4j(){
return logger;
}

public static void main(String[] args) {

EmbeddedAlarm alarms = null;
List logs = null;
TestEmbeddedReader reader = new TestEmbeddedReader();
logs = reader.readLogs();
Logger logger = reader.getLog4j();
Iterator it = logs.iterator();
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss");

while(it.hasNext()){

alarms = (EmbeddedAlarm)it.next();
logger.info("Host Address: " + alarms.getHostAddress());
logger.info("Remarks: " + alarms.getRemarks());
String date = sdf.format(new Date(alarms.getClearDate()));
logger.info("Clear Date: " + date);

}


}

}



Now this is an instant embedded db! all a corporate developer needs to do is download the BerkeleyDB API implementation, modify a few code above that will cause the data to be re-routed from the normal RDBMS/JMS path to the lightweight and fast route of embedded database.