Pages

    Monday, November 24, 2008

    Architecting Things Out

    I'm now going down the path of fleshing out the architecture for our project. We're working with the concept of "gadgets" coupled with a "platform" as the basis for our architecture.

    A gadget is simply an object (in a conceptual sense, not a programmatic sense) which takes an input, processes that input and produces an output. The platform will coordinate the gadgets in such a way that you can string gadgets together in order to get a chain of information, or a work flow, that you like.

    Those are the concepts, but how does that play out in an application?

    Well, the first idea that comes to mind is a service oriented architecture. Here, the gadgets have two components: a webservice that takes the input, does the processing and then gives an output; a component that plugs into the platform, interfaces with the webservice and provides any UI. A good example of a gadget is one that takes input and provides a visualization dependent on the input.

    The platform would ideally be a flexible piece of software that would allow you to "wire together" different gadgets into the work flow that you want, among other things. I'd like to take a page out of Spring's book and make the wiring together of gadgets by the platform be definable in XML. This would allow for dynamic wiring at run time which would mean you could build an "application" out of gadgets as you saw fit, ad hoc.

    I like the idea of using webserivces because it provides such flexibility. It also means that you could create a gadget out of an existing web service (assuming that it was all right with you that you don't control webservice).

    All in all, it's a rather web 2.0 concept that I think we're developing here, and I really like it. I'd like to get to a place where someone could wire together their own version of the application and then run it, change things and then rerun it to see if the output changed. Remember, this software is in support of research, so the ability to prototype a system is incredibly useful.

    Monday, November 17, 2008

    Hibernate Musings

    So, I'm working my way through this tutorial on hibernate. It basically takes you through creating a basic (and trivial) Hibernate project, all the way to the point where you create the database and put info into it, then take it out.

    Wait, did I just say "create the database"? That I did. I think this is the coolest feature in Hibernate that I've come across so far. The work flow basically works like this: First, you create your POJO bean which will hold a record. Then, you create a mapping file which will map the properties of the bean onto a table in the database. Next, you set a special property in your hibernate.cfg.xml file (called hbm2ddl.auto) to "create". Finally, you create some utility classes that drive Hibernate.

    Set up an ant task to do something (in my case, I stored a record) with the database and run it.

    On start up Hibernate will create the database using the mapping files. The more mapping files you have, the more tables will be created. I still don't know if you can create multiple tables from one mapping, but the ability to create a database based off of POJO beans is some kind of powerful and is a feature that I will hopefully use to a great degree in order to get around some of my relative inexperience with database design.

    Wednesday, November 12, 2008

    1 Year

    Today marks the one year anniversary of when we checked into the hospital to begin Cole's treatment for ALL. In many ways, this has been the longest year of my life. But, in many ways the time has flown by.

    You guys have read the long part in my blog (if you haven't, I especially recommend the beginning, around the middle of November, through mid January, that was probably the toughest time). Let me tell you about why it has been so short.

    Personally, I have been stretched and moved in ways that I never thought were possible. Never did I think that I could endure something like this. The challenges have been physical as well as mental and emotional. It's required more patience of me than I thought I had, more stamina of me than I thought I had and more perseverance of me than I thought I had. In all the ways except one (Cole is still alive, praise God) this has been a true tragedy, but my, these things have a way of shaping and changing you which I do not regret.

    Mine and Dalynn's marriage has also grown. We had no choice but to pull together as a team in order to ride this thing out. But, in that process, we have done more than ride it out, we have thrived. If you consider that just over two and a half years ago we were separated you begin to see how amazingly God can work things out. I feel that we are now stronger than we have ever been and being forced to pull together has a lot to do with that. She is my teammate and my partner in all that we do now. I don't often consider how I will respond to a situation, I consider how we will respond to a situation. I like where we are now, and I look forward to all the years that we have in which we can figure more of this out.

    As is quite obvious, our family has continued to grow. We're now expecting our 3rd, a little girl. While we know that it will be difficult, being a team gives me confidence that we can handle the challenges that having 3 under 4 will present (and one of those in treatment for cancer). I'm also blessed with perspective now, as far as my family goes. I can often look at one of my boys and think "How blessed am I that he can walk?" Seeing either of my boys running around is a joy, and that joy has a lot to do with the perspective that cancer has brought to our lives.

    I've seen Cole grow. Physically, he's about twice the size he was when he started treatment. Especially recently, he's really started to shoot up. He no longer looks like a baby, but instead looks like a little boy (much to his Grammy's lamentation). I'm also seeing his full personality emerge, and while I know that cancer will play a role in shaping that (such as making him innately more cautious than a lot of his peers), I can see how cancer has not stunted his spirit. From Cole's perspective, everything is a mystery, and the questions "Why?" and "What kind?" are going to unlock that mystery for him! I certainly hear them enough during the day to convince me of that! His cheerfulness is infective if not a little exhausting and I love the way that I can see things new through his eyes as he witnesses things for the first time.

    Then there's Logan. If it can be studied, he will. If it can be climbed, all the better! If it thwarts him, he'll definitely let you know and generally in a very vocal and foot stomping manner. He's a sheer delight and I look forward to seeing his personality come out, as well. He doesn't have much to say, but he communicates loudly.

    Cancer has visited this family but it has not left us distraught or destitute. It has left us stronger and more fully capable of enjoying every precious second of life. While I never would have chosen this for our family I find it satisfying that we can thrive even in the midst of all of this.

    I would like to thank all of you for the support that you have offered. Having this outlet in which to express my thoughts has been invaluable, especially during the difficult times. Then there's the support both in prayer and monetarily that you have offered. Without prayer I don't believe we would be thriving and without the monetary support things would be very difficult indeed on our family. So, thank you all for all that you've done.

    I'd like to leave you with this thought from Romans 8:28:

    And we know that for those who love God all things work together for good, for those who are called according to his purpose.

    Thursday, November 6, 2008

    Spring!

    I'm reading a book right now by Rod Johnson, called "J2EE Design and Development". It's a fabulous book which conveys all kinds of refinements on the architecture of a J2EE application.

    In the book, Johnson puts forth his own novel framework for managing various aspects of the application. This framework became know as Spring and can be found here.

    Of particular interest to me is the MVC framework that can be used to create a thin and clean front end for your web app. After reading a bit about this in the book I went and got Spring and ran through a tutorial that helps you create a non-trivial but simple front end for an inventory system. It's all included in the Spring download, if you're interested.

    So, what are the highlights? First off, anything that can be configured in XML is configured in XML, allowing for dynamic shifting of classes at run-time! Further, one of the big Spring tenants is to program to interfaces (which is simply a sound principal and one I'm finding myself adopting quickly). These two things taken together means that Spring is incredibly non-invasive. You can use the Spring framework without having to write a bunch of code aimed at the Spring framework.

    Let me walk you through a request flow to give you an example of how this works in the MVC framework.

    To start off with, I have set up an index.jsp that redirects to hello.htm so that you can easily enter the application. I've set up a servlet-mapping in my web.xml which intercepts any and all .htm pages and redirects them to the Spring master controller.

    So, enter the Spring master controller (which I use right out of the jar). The master controller will process the request, then hand off the request to a sub-controller which you define. All of this is configured in an XML file as well. I called my application springapp, so I created an XML file called springapp-servlet.xml.

    I have a bean definition in springapp-servlet.xml for /hello.htm:

    <bean name="/hello.htm" class="springapp.web.InventoryController">
    <property name="productManager" ref="productManager"/>
    </bean>

    The master controller sees the class that is attached to /hello.htm and interprets this as the sub-controller which it should forward the request to. So, off the request goes.

    My InventoryController does some logic processing and data gathering (for instance, it gathers a list of items to show in the inventory view) and puts all of this into a model which, in this instance, is a Map which contains a list of Products as well as a Date object. The InventoryController forwards the model and the name of a view back to the master controller and the master controller then forwards the model to the view specified which, in this case, is a jsp called hello.jsp.

    The jsp page loops through the products list (which is model.products) and displays the products.

    We also have a link on hello.jsp which will take us to the price increase page (called priceincrease.jsp). This page allows you to implement a price increase by percentage over all the products.

    Here's where things really get cool. Spring ships with a tag library, called form. It adds on to some normal HTML tags, such as form or input. The specific design, though, is to allow you to map a form or input back to a specific class. So, to enter in the price increase, I use an input defined by the form tag library:

    <form:input path="percentage"/>

    I also define a form which this input sits in:

    <form:form method="post" commandName="priceIncrease">

    The command name maps back to a bean in the springapp-servlet.xml file. That bean has a controller class specified (PriceIncreaseFormController) with it as well as a name (/priceincrease.htm). You see how the pattern is forming up? In that controller, there is a mapping to several things. First off is a mapping which corresponds with the commandName. This is mapped to a class (called PriceIncrease in this instance). PriceIncrease has a field called percentage. So, when the form is submitted, a new object of class PriceIncrease is created with the value in the input attached to the field percentage. PriceIncrease is considered a command, as it provides direction on what the ProductManager should do with the Products.

    Further, a validator is specified for PriceIncrease and is automatically run. All of this is then passed into the PriceIncreaseFormController. The controller evaluates the results of the validator, does any processing necessary, builds a model if necessary, and then forwards everything to a view (which is hello.jsp in this case).

    So, that's the basic workflow. I think it's pretty awesome that so much can be specified in XML. That gives you an amazing amount of flexibility at run-time.

    All in all, I think I'm going to benefit a lot from Spring. It has more than just an MVC component. It provides an abstraction for almost every level of J2EE applications, from the database level (a JDBC abstraction) to a replacement for the EJB tier.

    Monday, November 3, 2008

    New Pictures of the Boys

    Here they are!

    Cole Turns 3

    On Saturday, November 1, Cole turned 3!

    As I write this I thank God that I'm not saying "Cole would have turned 3". Dalynn and I have been thanking the Lord for the fact that we've had one more year with our precious son.

    Thank you all for your prayers and help. They have seen us through such a difficult time but days like Saturday continue to drive home to us just how blessed we are. Blessed that we can still celebrate the life of our sweet son.

    I'll try to get some pictures posted soon. If you haven't seen a picture of Cole recently (and only have pictures from his initial treatment to go on) then you may thoroughly enjoy some new pictures. He looks like a typical (if somewhat chubby) 3 year old.

    We had a party for Cole and invited some friends over. Unfortunately, as is normally the case with us trying to plan birthday parties (we seem to suffer from a birthday party curse), something happened that prevented a lot of folks from coming (that being that half of the folks that were supposed to come, including my mom, got sick). Despite that, though, we had a rousing good time! Cole received many fun toys and he and Rayanna (sorry if I butchered her name, Camille!) played until about 9 that night (having started at 3).

    It was so much fun to see Cole interacting with another 3 year old. At one point, they were running around trying to rescue pretend animals from a pretend tiger and dragon all the while calling Diego and Dora on their cell phones. It was quite cute.

    All in all, we had a really good weekend and I'm so thankful that we got to throw a party for Cole.