BibleGateway.com Verse Of The Day

Thursday, February 23, 2006

Some CSS Resources

Today, instead of just using CSS (cascading style sheet) elements that others in the group have already built, I had to make my own for a cruddy little user-requested feature of our flagship app.

There was one little feature I needed help with so I did a Google search, and came up with two resources that were helpful and cool.

One is a 2-page PDF file that when printed is a tri-fold quick reference card for CSS. The link to that puppy is: http://142.104.48.20/Benjamin.Jung/uploads/Download.QuickReferences/CSS-2.0.pdf

The other tidbit of info is cool because it is setup to be readable on your iPod. Most iPod since the 3rd gen and iPod mini have had the ability to store text notes and contacts. You unzip this directory and drop it in your iPod’s “notes” directory. Then you can scroll through the menus and pick the elements you need more info on. You never know when you might have to whip up some CSS style sheets and you don’t have your handy reference card. You can rock out to Killswitch Engage while building the next great web portal. Link is: http://www.westciv.com/news/podguide.html

As a side note about CSS, it’s a lot more powerful and useful than just fonts and colors, as I have found out. As a programmer it is nice to see presentation and information separated as much as possible, which is why I kind of like XML and XSLT (as much of a pain as it is).

Friday, February 17, 2006

OpenLaslo And Java RPC

Continuing on my evaluation of the OpenLaszlo 3.1.1 web application development environment (http://www.laszlosystems.com ), I’ve got the Java RPC stuff working. You can build POJO Java classes and put them in the Laszlo’s WEB-INF classes or lib directory, and then call them from your LZX code.

Last night I built a simple class with a method that returns an XML snippet. Easy enough, it took maybe a half hour to get it all perfect. Today, I got a little more complex and made a class that talks to a WebSphere MQ server, getting queue depths, and putting and getting messages from queues.

I tied that into my little sample LZX app, and have buttons that get queue depths and put messages on a queue. Still simple, but I’m starting to see how this can be very powerful. I still need to get better with the front-end LZX language and events handling to make the GUI more robust, but for now I am happy to be able to talk to server-side classes that tie into existing business logic and applications.

To let your LZX code know about a class and allow it to be called, you drop it in the WEB-INF/classes or WEB-INF/lib for JAR files, and then add this snippet of code to the LZX. This explicitly allows the class to be run from LZX via RPC, all others are implicitly denied:

<security>
<allow>
<pattern>BaseRpcAdapter</pattern>
</allow>
</security>

The pattern can be a regular expression, for example to allow everything with a certain package. You could also specify each class individually by putting in multiple <pattern> elements.

To create an instance (or really client side stubs), a chunk of code would look something like this:

<javarpc name="rpcadapter" scope="none" classname="BaseRpcAdapter">

<remotecall funcname="getMqQueueDepth">
<param value="'RAN.TEST.QUEUE'" />
</remotecall>

<remotecall funcname="putMqMsg">
<param value="'RAN.TEST.QUEUE'" />
<param value="'blah blah'" />
</remotecall>

</javarpc>

And then to call the methods, you could do something like this to create a button and tie it to the method:

<button onclick="rpcadapter.getMqQueueDepth.invoke()">
Get Queue Depth
</button>


So far it’s impressive, even with the lack of direct DB support. To make this viable in the enterprise, I also have to figure out the security models, and how to lock everything down better.

Side note from yesterday’s post: Still no direct database access. The options right now as I see them are to front-end your persistence and business logic layers with either an RPC adapter like I’ve done here, or expose them via Servlets, JSP, or web services (Session EJB & Apache AXIS is what we generally use).

Thursday, February 16, 2006

OpenLaszlow And Persistence

I’ve been evaluating the OpenLaszlow rich web application framework, and it seems really cool at first glance. It is very easy to build a very rich and interactive GUI using their LZX language (XML based). Your LZX code gets compiled into SWF shockwave code that runs in the browser window, and the whole thing is served out of a Tomcat servlet container.

But is it ready for enterprise applications? I wanted to say yes, but I’m not so sure yet. Yes, it has the ability to talk SOAP and XML via HTTP. It also has the ability to run POJO Java classes using RPC (I haven’t tested this yet, but the docs say it’s so, and the demos seemed to work OK).

But what about databases? Persistence? The data-binding demos look impressive, how you point it at a datasource and it can list out the data, or put the data in an Excel-like grid, etc. If your data is XML. Let me repeat, If your data is XML. I have been looking and searching for the database API’s, and the reason I haven’t found them is they are not there. They assume your datasource is XML, either from a static XML file or from a JSP or web service that serves XML-based content. Then it used XPath to do searches and binding. Nice for XML, but what about databases?

Almost all of my development involves talking to a database. Basic CRUD functionality is assumed in most enterprise applications. It’s not here. No ODBC, no JDBC, no “Laszlow-QL”, etc.

So the front end is now easy and pretty, but your back end application ends up being a bunch of servlets or POJO classes that serve up XML. It’s possible, but the expected tie-in just isn’t there – you must now build servlets, JSP’s, or web services that front-end a database, and then with the source code of the LZX being visible to the end user, you have potential security concerns as they can see how to manually call your services.

Maybe I’m just missing something, and need to read more of the docs and dig deeper into the language.

I guess my next step is to build a serious prototype of an application to see how my concerns can be addressed in the “real world”.  I’ll post my progress and any tips or pitfalls I encounter.

Monday, February 13, 2006

Software Development Tools

Here's a quick list of some of the tools I use for various aspects of software development and debugging. Some of these I use all the time (daily), and others fill a niche need that arises once in a while.
  • Notepad++ - Free Source code editor, with a lot of nice features, but a lot smaller and faster than a full-blown IDE. Link

  • NetBean - Open Source Java IDE (and development framework)Link

  • Eclipse  - Open Source IDE (and development framework) Link

  • MyEclipse Enterprise Workbench - Set of commercial plugins to add a lot of J2EE functionality to Eclipse Link

  • Vim (gvim) - Nice GUI version of of an "improved" vi editor clone Link

  • Ethereal - Network Protocol analyzer Link

  • MQJExplorer - Websphere MQ management tool. Simple but powerful Link

  • TortoiseCVS - Open Source CVS client that features integration with Windows Explorer. Link

  • MC4J - GUI tool for remote JMX administration Link

  • JProbe Profiler - Java Profiler tool from Quest Link

  • DJ Java Decompiler - Java Decompiler. Used to be free, now it seems to be shareware. Link

  • Jboss - Open Source J2EE Application Server and more Link

  • TOAD - Tool For Oracle Application Developers. Also versions for SQL Server, MySQL. There's a free version and commercial version. A lot nicer than the SQL Plus command line. Link

  • PuTTY - A Free SSH and Telnet client for Windows Link

  • Cygwin - Unix-like environment for Windows, complete with all the command line favorites and XFree86 support. Link

  • SysInternals Utilities - This site has a lot of useful utilities for Windows, like TCPView, Process Explorer, etc Link

  • ArgoUML - Free open source UML editor that can be downloaded or run via Java Web Start Link

  • Cooktop XML - Free XML editor for Windows Link

  • Butterfly XML - Another free XML editor, very simple and stripped down. Link

  • MarrowSoft Xselerator - A very nice commercial tool for working with XML and especialy XSL stylesheets and transformations, and FOP.Link

TAO of Regular Expressions

Another quick software development link for y’all. I found this link to the “TAO of Regular Expressions”, and have found it to be extremely handy, and definitely worth sharing.  It’s a good reference, concise and informative, without a bunch of crap. http://sitescooper.org/tao_regexps.html

Quick vi Editor Reference

Looking for a quick no-nonsense reference for the vi editor? Look no further than http://www.cis.ksu.edu/~bhoward/vi/vi60.html. It’s concise and to the point, without a bunch of crappy pop-ups or annoying graphics.

Friday, February 03, 2006

Re-Synching Oracle Sequence With PL/SQL

Sometimes an Oracle Sequence can get out of sync. For instance, if a sequence gets dropped or wraps around to zero while there is data in the table, or if data is loaded while the sequence is disabled. Here is a quick PL/SQL block to reset the sequence to 1 more than the max id in the data.

Replace column_name, table_name, sequence_name below and then run it.



declare
max_id number;
tmp number;
begin
max_id := 0;
select max(column_name) into max_id from table_name;
if max_id > 0 then
for i in 1..max_id loop
select sequence_name.nextval into tmp from dual;
exit when tmp > max_id;
end loop;
end if;
end;
/

Basic Linux Troubleshooting Commands

The following commands are useful when trying to troubleshoot issues on our J2EE servers. This is for Red Hat Linux, but some of these commands are generally applicable to other versions of Linux and Unix as well. This is by no means a full tutorial on Linux administration, just some quick stuff for a guy doing basic troubleshooting.

top - memory and CPU utilization of various processes.
lsof - List open file descriptors
file – shows what type a file is
ps – shows processes and their id’s, children and parent id’s
netstat – shows ports and connections status, e.g. netstat –a to show all connections.
ipcs – show shared memory info
nice, renice – change the run priority for a process
sudo – run a process as the root or other privileged user
who –r – shows current run-level of machine
kill - everyone knows the basics of kill, interupts a process with a signal you specify. kill -l to list the signals, kill –3 for instance is stack trace, kill –9 really kills the process dead.

ran488>kill -l
1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL
5) SIGTRAP      6) SIGABRT      7) SIGEMT       8) SIGFPE
9) SIGKILL     10) SIGBUS      11) SIGSEGV     12) SIGSYS
13) SIGPIPE     14) SIGALRM     15) SIGTERM     16) SIGURG
17) SIGSTOP     18) SIGTSTP     19) SIGCONT     20) SIGCHLD
21) SIGTTIN     22) SIGTTOU     23) SIGIO       24) SIGXCPU
25) SIGXFSZ     26) SIGVTALRM   27) SIGPROF     28) SIGWINCH
29) SIGLOST     30) SIGUSR1     31) SIGUSR2

Wednesday, February 01, 2006

iTunes Library.xml, Meet XSLT

If you've looked at the iTunes Library.xml file, you were probably shocked at how cryptic XML can be. You have a list of songs and playlists, with attributes such as song name, album, band, etc. Seems simple, but that XML is UGLY.I found this XSL sniipet on the web somewhere and started to play with it. I'm not an XSL guru by any means, but I've hacked together a couple XSL transformations to make some sense of the Library. In this case, it is a two step process (I'm sure it could be boiled down to 1, but I'm not XSL guru, remember?). This creates a simple HTML table with song, album, band, genre, etc.

Step 1: Flatten out the relations a little to make it look more like you expected in the first place:



<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<tracks>
<xsl:apply-templates select="plist/dict/dict/dict"/>
</tracks>
</xsl:template>

<xsl:template match="dict">
<track>
<xsl:apply-templates select="key"/>
</track>
</xsl:template>

<xsl:template match="key">
<xsl:element name="{translate(text(), ' ', '_')}">
<xsl:value-of select="following-sibling::node()[1]"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>



STEP 2: Render the output the way you want it, simple example shown below:



<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body bgcolor="navy">
<table border="1" align="center" bgcolor="silver" width="90%">
<tr>
<th bgcolor="#8b9ffe">Artist</th>
<th bgcolor="#8b9ffe">Album</th>
<th bgcolor="#8b9ffe">Year</th>
<th bgcolor="#8b9ffe">Track</th>
<th bgcolor="#8b9ffe">Song</th>
<th bgcolor="#8b9ffe">Genre</th>
</tr>
<xsl:for-each select="/tracks/track">
<xsl:sort data-type="text" order="ascending" select="Artist"/>
<xsl:sort data-type="text" order="ascending" select="Year"/>
<xsl:sort data-type="text" order="ascending" select="Album"/>
<xsl:sort data-type="number" order="ascending" select="Disc_Number"/>
<xsl:sort data-type="number" order="ascending" select="Track_Number"/>
<tr>
<td><xsl:value-of select="Artist"/></td>
<td> <xsl:value-of select="Album"/></td>
<td> <xsl:value-of select="Year"/></td>
<td>
<xsl:value-of select="Disc_Number"/>
<xsl:text> </xsl:text>
<xsl:value-of select="Track_Number"/>
</td>
<td> <xsl:value-of select="Name"/> </td>
<td> <xsl:value-of select="Genre"/> </td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>