Author Archives: tmarthal

Spring Framework Sample Main Method

So my desk-mate* and I were having a conversation about an upcoming coding project, and he remarked how nice it was for someone, somewhere to post a complete sample on their blog for the spiders to index, so that he can find it. So I thought I would also, pay it forward and hopefully someone in like 2012 comes by and needs a sample main method using the spring spring framework for application level dependency injection.

Everyone out there seems to have used the MVC and deploying spring based apps in a web server WAR file. Except for this link: Levarage Spring Web development with Offspring. [Offtopic: it uses classes in the com.offspring.* package, like the band’s website!] It uses a simple bean file and a main method really close to the following snippet to instantiate (that’s my new favorite word) the application using the spring context**:

import org.springframework.context.ApplicationContext;
import com.blogger.tmarthal.listener.SampleListenerInterface;

 * simple class showing the a listener interface
 * starting listening
public class simpleParserAndStorage
   * The spring context main method
   * @param args
  public static void main(String[] args)
    if (args.length != 1) {
      System.out.println("Usage: java ");

    String springContextFile = args[0];
    ApplicationContext context = new ClassPathXmlApplicationContext(springContextFile);

    // the listener just starts listening
    SampleListenerInterface listener = (SampleListenerInterface) context.getBean("listener");

Now, the wiring, or what sort of implementation is the SampleListenerInterface? This is where dependency injection comes in. Depending on the type of thing you are listening for (or what the example is doing) the implementation class is going to change. The main method is going to remain the same, the bean wiring takes place in the xml file, rather than in the application logic.



So, assuming that there is a Interface implementation of SampleListenerInterfaceImpl and SampleListenerHelperInterfaceImpl in the classpath, then the spring framework will call the listen method of the SampleListenerInterfaceImpl class!

Pretty neat. Hopefully someone, sometime stumbles upon this example trying to get into writing a non-WAR spring framework application, and this post will be helpful to them. I wish I found something like this first. 🙂

* no, not my office mate: we share a desk
** i know the code formatting sucks

Dolphins Make Me Happy

Lately, I’m not sure if its part of a seasonal migration or something, but there seems to be a lot more dolphins in the water. And they seem to be a lot more playful. Meaning, they swim under/close to us when we are surfing and jump and twist out of the water pretty frequently. I should get pictures. They also seem to show up when we are surfing right when a huge set is about to roll in, and the dolphins always seem to ride the set waves while I try to survive the overhead+ sets.

So anyways, read this today:

Basically dolphins showing altruistic tendencies towards a surf and protecting him while in the ocean. So they know we’re out there. I wonder if they hear me when I jump in the water and screech back to them. 🙂

double-tap it

So, oftentimes on my iphone I would unlock it and my ipod controls would come up. I thought it was a bug for a long time, since the controls went away so fast… but it is a feature!

It turns out you can access the iphone ipod controls while the phone is locked or in a different menu than the ipod interface by double-tapping the home button! So, double tapping to wake goes directly to the ipod interface pause button… handy when people are trying to talk to you and you’re listening to music! You can also double tap from any interface and the ability to fast-forward/rewind/pause comes up. Neat-o.

Are undocumented features like this a reason to upgrade your firmware? This is only a iphone 1.1.1 September 2007 update feature or something.

I’ve got the whole internet in my hands

Following up the “comic”, a sweet idea to map the IP address range and their owners into a 2d map (where all adjacent values are grouped together), some bored people over at an email consulting company mapped out the IP addresses and activities using actual CAIDA ‘whois’ data in a scalable google map. CAIDA (The Cooperative Association for Internet Data Analysis) collected the data as seen in the huge png:


The scalable ‘google maps’ like viewing of the Hilbert Table is here:

I should be all Blog2.0 and post this as a trackback, but they don’t have the option.

It is pretty neat to take data that you normally don’t visualize, in this case the assigned DNS IP ranges of organizations and put them together in a way that can make the lay-person understand something new. In this case, you can see the companies that ‘formed’, or at least were the first to embrace, the internet and register whole top level domains! Meaning, of the 4-256 values in a typical IPv4 these companies have a whole first number to themselves.

For example, The Computer Science Corporation ‘CSC’ owns the whole 20.*.*.* address range. Crazy.

updated blog license

i know that i’m not a major player in the content creation business (I just know those kids in Japan are stealing my blogs, translating them, and calling them their own!!) but I put the license at the bottom here, the Creative Commons Attribution 3.0 United States License. That’s what the Creative Commons tells me when I select Yes to “Allow commercial uses of your work?” and “Allow modifications of your work?”. So, all of you people re-mashing my sweet blog via your Pipes or Mashups, then feel free. =)

I also reduced the number of posts on the front page (soon my xmlrpc blogpost will have scrolled off) and added the archival links at the bottom. Enjoy.

iphone news

What this post boils down to is $100 for 2 months of sweet iphone usage. =)

I can’t say that I’m disappointed, my $499 4GB iPhone purchase was a sunk cost, and I expected some ‘early adopter’ problems. I did not expect news that apple would cost them so aggressively so soon. Today apple released news that they are getting rid of the 4GB iphone models and dropping the price of the 8GB version to $399.

Pretty crazy. But the last two months were worth the hundo! We do throw them out of windows, you know.

And in a suprising move, jobs offers $100 credit back to early iPhone adopters! There is a first time for everything, I guess.

My First iPhone Problem and Post: Google Maps Hardlocking

I had been using my iPhone without a problem since I got it opening day, June 29th at the Manhattan Beach Apple Store. [Thanks fulk dog for waiting in line!] Everything was awesome; contacts, pictures, youtube, Safari integration, everything. No problem activating it, like others have reported.

I didn’t usually let people handle it, I’m crazy like that, because they would have no idea where to start. So I would show them around all of the features; usually open up my Boards of Canada video to display the screen, surf the contacts and show them how to put their number into the phone, and/or show them Safari and my friend Deward’s blog (since it looks super nice in the iPhone browser) depending on if I was on a wireless network or AT&T’s EDGE. Take a picture, show them some pictures from that bar crawl from mid-June. Normal things that you would do with an integrated device that bills itself as a revolution!

So, fast forward to last Saturday night. I let my friend’s sister borrow my iphone just to play around with everything. He is technically apt, so I thought he could navigate the menu with minimal advice (“Just hit the Home button to reset any interface.”). I was wrong. This was in Manhattan Beach, which has notoriously bad network coverage between Highland Ave. and the beach (due to the housing height and density, called “The Beach District”). He hands it back to me after like 5 minutes with “I think I broke it.” No problem I thought, he just couldn’t get back to the home screen. Well, that wasn’t the case.

The iPhone was stuck in the Google Maps application with the /Manhattan Beach, CAirvine/ text, which is an obvious mistyped search into the search bar of Google Maps. I’m not sure if it was the maps application or the lowsy EDGE connection, but it was frozen, half-dimmed with neither of the buttons working: holding down the Home key, or the On/Off toggle at the top did not seem to do anything**. Even plugging the phone into iTunes did not remove the lock. I had to do a Factory Reset via the iTunes interface to remove the Google Maps hardlocked screen. Sucks.

‘Cause after using the phone for 2 weeks, I already had multiple pictures, Wireless settings, and histories built up that were cleared. All of the pictures taken with the camera that were not emailed off the phone are lost, my long ass password for my WPA account had to be re-typed, and my Youtube and Safari bookmarks and history were gone. Luckily, it sync’ed my contacts and everything else. (installing gcaldemon now to test it out…)

I guess that is what you get when you are an early iphone adopter. It is worth it though. 😉

** Supposedly holding down both buttons at once will hardboot the iphone. 20/20 hindsight