Saturday, August 21, 2010

frickjack.com DNS forwarding to Google Sites

Today I finally wired up my frickjack.com domain configuration with GoDaddy to just redirect (via domain forwarding) to pages hosted on Google Sites. I bought the frickjack.com domain a few years ago with the idea that I'd get a static IP address, and run a web server from home with a bLog, code repostiory, and some demonstration littleware web applications.

I actually did run my own server on an old laptop for a while, but I always felt bad leaving my old laptop running in the corner just to host a site no one looked at anyway. I tried to manage my own bLog with XML and XSL, but Blogger and other hosted solutions are free and easy to use. Similarly, I've been very happy letting Google Code host my littleware project.

Anyway, Google Sites gives me an easy way to put frickjack.com back online as the root node of the graph that connects my disembodied web presence across blogger, facebook, google code, and other sites.

Sunday, June 13, 2010

Bootstrap Bonanza

This post is a copy of this google doc describing littleware's bootstrap process.

I recently reworked the littleware bootstrap and dependency injection process. In the new system Guice manages dependency injection; java's ServiceLoader utility discovers the littleware modules available in the classpath, and OSGi manages startup and shutdown of subsystems. The new bootstrap code also supports different runtime profiles similar in spirit to java EE6 profiles or configurations in Apache Ivy. The new code both simplifies the process an application follows to configure, startup, and shutdown a littleware application; and also simplifies the artifacts that a littleware extension module must provide to register itself with littleware's runtime to expose its functionality to the application.

Littleware has a multi-step bootstrap process. The parent application determines whether to start littleware in a "server", "client", or "app" configuration. With the "client" configuration littleware's bootstrap establishes and authenticates a user session with a remote littleware server (which is another application running a "server" configuration). The "app" configuration allows applications that do not interact with a littleware server to still take advantage of littleware tools that support generic standalone GUI and CLI applications.

The "server", "client", and "app" systems have similar bootstrap processes. A "client" application begins by allocating a ClientBootstrap.ClientBuilder type object:

       final ClientBootstrap.ClientBuilder builder =           
             ClientBootstrap.clientProvider.get();

The ClientBuilder automatically loads the ClientModuleFactory service providers registered in the application class path, and gives the application the opportunity to add or remove modules from the bootstrap module set. The ClientBuilder also allows the application to specify a a profile from the AppBootstrap.AppProfile enumeration. The available profiles include AppProfile.SwingApp (the default), AppProfile.JNDI, AppProfile.CliApp, and AppProfile.WebApp.

The ClientBuilder constructs a LoginSetup object that provides methods to manage user authentication including an automatic method that prompts the user for his credentials in a way appropriate to the AppProfile, and returns a ClientBootstrap object. The ClientBootstrap bootstrap method injects and returns an application supplied type.

        final ClientBootstrap boot = 
               builder.addModuleFactory( new MyModuleFactory() 
                         ).profile( AppBootstrap.AppProfile.CliApp 
                         ).automatic();
        final MyTool tool = boot.bootstrap(MyTool.class);

The littleware runtime is up and running at this point. The MyTool class should be annotated so Guice injects whatever dependences the application needs.

         class MyTool {
                 ...
                   @Inject
                    public MyTool( AssetSearchManager search ) {
                           this.search = search;
                    }
                 ...

Under the bootstrap hood ClientBootstrap loops over the ClientModuleFactory service providers to build a ClientModule (a Guice Module subtype) configured :

         factory.build( profile )

ClientBootstrap builds a Guice Injector configured by the resulting collection of ClientModule objects, then loops over the ClientModule collection again to inject the OSGi BundleActivator associated with each module. Next ClientBootstrap launches an OSGi runtime to startup the activators. Finally, ClientBootstrap injects and returns MyTool.class the application passed to the bootstrap() method.

Saturday, May 15, 2010

Stacked Authentication with JAAS

I was happy the other day to find a quick solution to an authentication problem using java's authentication and authorization service ( JAAS). I was configuring JAAS authentication for a littleware based webapp where I wanted most users to authenticate via active directory, but to also have a simple password file to manage authentication for some internal users like "guest". Fortunately, JAAS easily supports this kind of thing. After googling around I stumbled across the JMX com.sun.jmx.remote.security.FileLoginModule which uses a simple password file, and I was already familiar with using the com.sun.security.auth.module.LdapLoginModule for simple authentication against Active Directory. I simply configured the "littleware.login" context in the Glassfish server domain's login.conf file (below) so that authentication via either A.D. LDAP bind or the password file would both be sufficient to certify a user. Works like a charm!

littleware.login {
        com.sun.security.auth.module.LdapLoginModule SUFFICIENT
             userProvider="ldap://xxxxxx/dc=auburn,dc=edu"
             authIdentity="{USERNAME}@auburn.edu"
             userFilter="(cn:dn:={USERNAME})"
             useSSL=false
             debug=true;
        com.sun.jmx.remote.security.FileLoginModule SUFFICIENT
             passwordFile="/home/glassfish/.littleware/jaasPasswordFile.txt";
};

Tuesday, April 20, 2010

Scala dependent method type

Scala dependent type exception

I'm building a simple JSF-3 web application that implements backing beans in Scala 2.8 One bean includes Enumeration properties that a JSF web-form exposes to clients via a combo-box control configured via a key-value map.

    <h:selectOneMenu id="patronType" value="#{sampleBean.patronType}">
        <f:selectItems value="#{sampleBean.patronTypes}" />
    </h:selectOneMenu>

The sampleBean's definition includes patronType and paronTypes properties which are Enumeration subtypes.

object PatronType extends Enumeration {
  val Student, Faculty, Other = Value
}

...

@ManagedBean
@RequestScoped
class SampleBean extends InjectMeBean {
  private def enumToMap( enum:Enumeration ):java.util.Map[String,Enumeration#Value] =
        ((new ImmutableMap.Builder[String,Enumeration#Value]) /: enum.values) (
      (builder,member) => builder.put( member.toString, member )
    ).build

...
  @reflect.BeanProperty
  var patronType:PatronType.Value = PatronType.Student

  @reflect.BeanProperty
  val patronTypes:java.util.Map[String,Enumeration#Value] = enumToMap( PatronType )
}

I originally defined the patronTypes property as a mapping from String to PatronType.Value.

  @reflect.BeanProperty
  val patronTypes:java.util.Map[String,PatronType.Value] =
               ((new ImmutableMap.Builder[String,PatronType.Value]) /: enum.values) (
        (builder,member) => builder.put( member.toString, member )
      ).build

I introduced the enumToMap method to share that code block between several similar properties with different Enumeration types. Unfortunately - a subtype-specific enumToMap implementation has on output type that depends on an input parameter.

scala> def enumToMap( enum:Enumeration ):java.util.Map[String,enum.Value] =
     |         ((new ImmutableMap.Builder[String,enum.Value]) /: enum.values) (
     |       (builder,member) => builder.put( member.toString, member )
     |     ).build
<console>:6: error: illegal dependent method type
       def enumToMap( enum:Enumeration ):java.util.Map[String,enum.Value] =
                      ^    

I tried several variations on this theme, but finally settled on the enumToMap implementation that just leverages the Enumeration#Value base type. I googled around while working on this code, and stumbled across the fact that scala includes limited experimental support for dependent method types - that will be very cool if it evolves to production status.

Scala's instance-attached nested types have advantages, but they feel alien to an experienced java developer like me.

scala> class A {
     | var a = "A"
     | class B {
     | var b = "B"
     | }
     | var b = new B
     | }
defined class A

scala> val a1 = new A
a1: A = A@6489f0

scala> val a2 = new A
a2: A = A@15c44d6

scala> a1.b = a2.b
<console>:9: error: type mismatch;
 found   : a2.B
 required: a1.B
       a1.b = a2.b
                 ^

Friday, March 26, 2010

Wisdom

I sometimes find myself thinking as I look back at life "Man! I was an idiot back then!" where "back then" might be ten years ago or last year or yesterday or the previous paragraph.

As time passes, I'll think again, "I was an idiot back then" remembering my thoughts the last time I thought what an idiot I was. Eventually I realize that even as I'm thinking what an idiot I was in the past, that in the future I'll look back on the present and think, "What an idiot!".

In time I'll think "I was an idiot when I thought I was an idiot before, because what I did before was not so idiotic although I was too much of an idiot to realize it at the time" - sort of like multiplying two negatives. Of course it's possible to multiply three negatives, "I was an idiot when I thought I was an idiot for thinking I was an idiot".

I know I'll eventually find myself in some bed after the ravages of parkinsons, alzheimers, and multiple strokes leave me with half my body frozen in place and the other half constantly shaking violently. I'll be thinking, "Where am I ? Who is this person feeding me oatmeal ? Who am I ? This oatmeal tastes good! Where am I ? What is this in my mouth ? It tastes good!".

Sunday, February 14, 2010

Larry Ellison in the Cloud

I enjoyed the webcasts Oracle published to outline its product strategy upon the approval of Oracle's acquisition of Sun Microsystems. I was impressed with most of the ideas presented, and I think Oracle will have some success selling their integrated stack "from disk to whatever". However, I was surprised by Larry Ellison's criticism of "cloud computing" when responding to a question near the very end of the event.

Cloud service providers like Amazon EC2 allow a software service developer to deploy one or more copies of a virtual machine image that provides some online software service. A "cloud" service may be a natural evolution of standard hosting provider, but the ability to dynamically allocate and deploy compute resources opens doors for a "software as a service" (Saas) developer. A developer of some service can quickly provision and deploy a virtual server dedicated to some new customer, or scale an application horizontally or vertically in response to increased client load.

A developer team that codes for the cloud avoids the cost and complexity of maintaining servers, networking switches, or storage in a data center. Managing data center complexity is where Oracle makes a lot of its money. Furthermore, the cloud is a natural platform for free open technologies like LAMP that are free to the developer, and do not provide a clear business model for a technology infrastructure companies like Oracle.

Oracle has tremendous breadth and depth of resources, and I don't think Larry Ellison's cloud myopia will be a problem of any importance, but it's strange when a technology leader comes late to an important idea.

Wednesday, January 27, 2010

Apple iPad, Oracle-Sun, and the State of the Union

It's a big day for announcements and media. First, Apple launched the iPad; which looks like it nearly lives up to the hype. Next, Oracle finalized its acquisition of Sun. Finally, President Obama will give his State of the Union address tonight. I wonder which event will be remembered as the most important years from now ?

Sunday, January 24, 2010

Multiple RMI Services on a Single Port

I recently learned of a solution to a problem I've struggled with using java remote method invocation (RMI) to implement client-server applications. I've used RMI for several years, and I think it's a great technology. RMI makes it easy to implement fast and secure remote procedure call between java clients and servers. RMI has two disadvantages compared to REST over HTTP or CORBA as a network computing platform. First, RMI is tied to java, so non-java clients cannot directly access network services via RMI. A second disadvantage of RMI is that RMI exports each of a server's remote objects on a separate TCP network port, so it's difficult to setup firewall rules for an RMI server that dynamically exports distributed objects as different clients request different services.

It turns out that there's an easy workaround to configure RMI to export all of a server's remote objects through a single firewall-friendly network port. I've known for some time that RMI allows server code to specify the port on which to export a remote object. For example, the HelloService below can pass a network port number to its UnicastRemoteObject super class constructor. However, I did not realize that multiple remote objects can specify the same network port to the RMI engine as long as a single RMISocketFactory manages every object on that port (which is the default behavior).

A contrived example below shows a simple scenario where an application dynamically exports multiple remote objects. At boot time, the server initializes a DirectoryService object, and registers the object with an RMI name service. The DirectoryService dynamically creates a HelloService object for each client call to login(). Because DirectoryService and HelloService both specify port 12345 in their constructor, clients access every service object via the same network port.


public class DirectoryService extends UnicastRemoteObject implements Directory {
    public DirectoryService() {
        super( 12345 );
    }

   public login( String name ) throws RemoteObject {
        return new HelloService( name );
   }
}

…

public class HelloService extends UnicastRemoteObject implements Hello {
    private  final String name;

    public HelloService ( String name ) {
        super( 12345 );
        this.name = name;
    }

    public String sayHell() {
        return “Hello, “ + name + “!”;
   }
}


Sunday, January 17, 2010

Jython ScriptEngine with WebStart

An embedded script engine is a great way to empower an application's users with the ability to customize and extend tools, and java's JSR223 ScriptEngine framework makes it easy to implement.

I recently embedded a Jython ScriptEngine in a littleware based application that runs in a WebStart environment. Problems always arise when integrating two sophisticated software frameworks like jython and webstart, but the jython ScriptEngine ran with WebStart after addressing two small problems.

First, the application links against the "standalone" jython.jar library which bundles the complete jython script engine. Second, the application includes the following jython-specific code to add jython.jar to the python library search path.

...
final PySystemState engineSys = new PySystemState();
engineSys.path.append( Py.newString( "__pyclasspath__/Lib" ) );
Py.setSystemState(engineSys);
final ScriptEngine jython = new ScriptEngineManager().getEngineByName("jython");
if (null == jython) {
   throw new IllegalStateException("Failed to load jython ScriptEngine");
}
...

Thursday, January 07, 2010

Windows 7 Cross Domain Drive Map Garbage

I tried to map a network drive cross-domain over VPN on my Windows 7 laptop last night, but my laptop failed to authenticate with the file server. Last month I bought a new Dell Studio 15 laptop with Windows 7 64bit, and I've been very happy with it, so I assumed that the map failed due to some random bad setting. I googled around and sent some e-mail to IT support, and eventually found out that I would have to upgrade to Windows 7 Professional to alter the Windows security policy preventing the drive map. The technical details are here in the "catdogboy" posts.

This map drive issue is my first Windows 7 problem that really annoys me. It's upsetting when something works with XP and Vista, but requires extra money and an upgrade with 7.

Library 2020

Let's assume the following technology trends realize their potential over the next ten years.

  • Cloud discovery services like Worldcat, EBSCO, and Serial Solutions successfully federate search across most journals and databases that universities subscribe to.
  • Subscription services from Google and others offer access to most out of print books.
  • Computer tablets like the iSlate with e-reader software become ubiquitous on university campus, and students obtain all their text books electronically.

What would a University Library look like in this world ? The traditional acquisition, cataloging, archiving, and circulation library and librarian roles become anachronisms. The library completes its already begun transition from a student's content provider of books and journals to become a manager of contracts with third party content and service providers that students access directly. Eventually campus IT or some similar organization assumes responsibility for managing the library provider contracts, and the library space itself completes its transition to student union and learning commons.

An academic library may keep vitality as a publisher and archiver of university authored content from research papers to financial statements. It will be fun to see what happens.

Tuesday, December 01, 2009

Library Budget Breakdown

I work part time at a university library, so I think a little bit about the roles the library fulfills for the university and the cost the university pays the library to provide services.

The traditional library roles as cataloger and archiver of scholarly research are anachronistic. Nearly all of our scholarly journal subscriptions are online, and we download catalog records for most of the books we purchase. The library continues to spend a large portion of its budget maintaining its book collection, but it is likely that in the near future services like "Google Books" may offer subscription services for institutions to access e-books online.

Like most research libraries Auburn's has sought out new roles to fill for the university. First, a large part of the main library building's space has been cleared of books to make room for a media and digital resource lab, learning commons, and coffee shop. Second, the library has developed a digital library for online collections of scanned historical material, and university intellectual property like electronic theses and dissertations. Finally, the library web site has evolved to be a better gateway to the online databases we subscribe to.

In many ways the library budget and personnel structure continue to reflect the library's past rather than its future. In 2008-2009 Auburn University Libraries spent a total budget over $12.76 million - about the same as the school of pharmacy, about 10% less than the college of education, and more than human sciences and forestry combined. Over $7 million of the library's $12.76 million budget paid salaries, and only about $5 million paid for books, journals, and database subscriptions. For every $1.00 the university pays for books and journals, Auburn pays the library $1.40 in salaries to take care of that book.

An overhead of $1.40 for every $1.00 of investment in materials gives a sense of the library's finances, but we can achieve a better understanding if we dig a little deeper into the budget. First, the library employs over 12 reference librarians whose primary job is to help students and faculty at the reference desk, so the university invests $1 million or so in salaries to provide a reference desk. Library staff and student employees are also responsible for opening and closing the three campus library buildings, so we can say the university pays at least $1 million a year to manage that space. We can also set aside $1 million for the systems department and software subscriptions to maintain the library web site, MDRL media computer lab, and computer network. Finally, about $1 million in salary goes to the dean's office.

After subtracting $4 million from the salary budget for reference and keeping the library buildings open the library now has $0.60 overhead for every $1.00 spent on books, journals, and databases: $3 million in salaries for $5 million in materials. That looks better at first, till we remember that over 70% of the materials budget pays for online journal and database subscriptions, so $3.5 million of the materials budget pays for online resources, and at most $1.5 million pays for books and other physical materials. The library staff is divided so that approximately $1 million of salary supports the $3.5 million in electronic materials, and $2 million in staff supports the $1.5 million physical material budget.

ServiceAnnual Salaries
Reference Desk $1 million
web site, computer support, and MDRL$1 million
Library Buildings $1 million
Dean's Office $1 million
support for $1.5 million physical material budget $2 million
support for $3.5 million e-resource material budget $1 million

Obviously these numbers are all back of the envelope - I don't have access to the real books.

Monday, November 23, 2009

Water Conservation Starts at Home

I attended a two hour rain barrel workshop hosted by the Alabama Cooperative Extension Service last weekend. The workshop started with a great presentation by Tia Gonzales describing environmental impact of storm water and runoff on watersheds followed by an introduction to rain water harvesting. Tia also sent us a link to this cool map of the watersheds around Auburn, AL.

I walked away from the workshop thinking that the building code ought to include requirements for storm water management in new construction and tax incentives to encourage water harvesting. That idea was re-enforced today by this front page article on the New York Times web site describing how even light rain generates enough storm water to overwhelm many city sewer systems which overflow sewage into watersheds, drinking water sources, and basements.

Mike Rogers Disappoints on Health Care

I was disappointed, but not surprised by Mike Rogers' (Congressional representative for Albama's 3rd district) recent press release opposing health care reform. The health care bills before the House and Senate address the systemic problems in our health system that include fast rising costs for employers and patients, a growing numbers of uninsured, and an insurance system that discriminates against an American with any pre-existing condition.

It is true that the health care legislation involves trade-offs, costs, and risks. Healthy American who do not currently cary health insurance will be required to buy insurance. The wasteful Government subsidies to private insurers for Medicare Advantage programs will decrease. Medicaid expansion will increase financial burdens on federal and state governments.

The financial and humanitarian jeopardy we leave ourselves vulnerable to by not pursuing health care reform far outweighs the risks and imperfections we accept with reform. We can see that the dam will burst if we do not attempt to re-enforce it. There are good sources of information online that describe the costs and benefits in detail including healthreform.gov and Wikipedia.

Sunday, November 08, 2009

Banana Muffins

I prefer muffins to pan cakes - I always burn the pan cakes. This recipe evolved from Fannie Farmer's muffin recipe.

Ingredients:
  • 4 Tbspn melted butter
  • 1/2 cup wheat flour
  • 3/2 cups flour
  • 1 ripe banana
  • 1 egg
  • 1 cup Soy milk
  • 1 Tbspn baking powder
  • 1 tspn cinamon
  • 1/2 cup chopped pecans
  • 1/2 cup sugar
  • 1 Tspn vanilla

Mash the banana with the egg and vanilla and mix everything up, then load into a greased muffin tin and bake 20 minutes at 380 degrees F. Muffins with coffee start the day with a smile!

Thursday, November 05, 2009

Publish javadoc to Google Code via Mercurial

I like Google code more and more the more I use it ... more. Why don't I have a vocabulary ? Anyway, I also like Mercurial, so combine Mercurial with Google Code and you have chocolate with peanut butter.

Here's how I managed to post javadoc to http://code.google.com/p/littleware/.

  • Clone the wiki mercurial repo:
        $ hg clone  https://wiki.littleware.googlecode.com/hg littleWiki
        
  • Copy your javadoc into littleWiki, and add it to the repo
        $ hg add -I 'glob:javadoc/**' 
        $ hg commit
        
  • Push the patch back up to google code
              hg push https://username:hg-password@wiki.littleware.googlecode.com/hg
                

BTW - I just tracked down how to tell blogger not to insert <br /> tags all over my post (http://www.google.com/support/forum/p/blogger/thread?tid=2dae985eba6f8c04&hl=en) in the HTML editor. What a stupid default!

Wednesday, October 21, 2009

The "I am Legend" Pitch

It's like "Castaway", but there are zombies on the island, right? Tom Hanks all alone on this desert island, but with zombies that come out at night.

Yeah - it's like "Castaway" meets "28 Days Later", but instead of Wilson the ball we have Sam the dog, so it's like "Marley and Me" too.

Yeah, I'm afraid Sam doesn't make it, and Tom Hanks probably wouldn't last long too, so it's Will Smith. Really buff Will Smith, and the island is Manhattan - post apocalyptic Manhattan - "Mad Max" style!

No - no women, just Will and the zombies, except there are female zombies - scary hot female zombies, and several scenes with mannequins.

Sure - we could add some flash backs with women, but it's really a cautionary tail about man's hubris and science gone wrong in the near future. Like "Terminator" except Schwartzenegger is a virus that turns people into zombies, and Sarah Connors is Will Smith.

No, I didn't think about that, but it's a good idea - "terminator zombies". Could be a sequel.

That's right - "Castaway" meets "28 Days Later" with "Marley and Me" meets "Terminator" in a "Mad Max" world with Will Smith in every scene and mannequins. It's a guaranteed block buster!

Friday, October 16, 2009

Public Option

I was thinking about arguments for and against the “public option” in health care reform. The argument in favor of a public option is that a non-profit national health insurance option would set an upper bound on premiums and prevent collusion between private insurers. The private health insurance industry has a history of inefficient resource management that spends 30% of premiums on overhead (including high executive salaries). The industry also prioritizes profits over patient well being in its efforts to avoid paying claims and over-pricing coverage for anyone that develops an ongoing health condition.

The argument against the public option reasons that the private insurance industry will not be able to compete with the public option, so the insurance industry will evolve into a single payer system run by the government. From that point public option opponents go on to argue that a government run single payer system is bad.

Spelling out the arguments for and against the public option in this way shows that both sides of the debate actually agree that a public option would more efficiently finance health care than private insurers do currently. The argument then becomes whether or not private insurers will be able to evolve and compete with an opponent that will not collude on price, the costs and benefits if we evolve toward a centralized single payer system; and if the government does not provide a private option, then how can we trust private insurers to change their behavior and become more efficient and more focused on patient well being.

Wednesday, October 07, 2009

Social Networking

I've been playing around with Twitter and Facebook lately. I'm surprised how well these sites work as communication tools. A bunch of people tracked me down on facebook in the last month, and it's fun to keep in touch. Crazy.

I'm now trying to figure out how we can wire up the feeds off some of our blogs and wikis at the Auburn libraries to auto-update the library twitter/facebook accounts. I thought there would be some open source tools we could download, but twitterfeed is the most promising thing I've come across so far. We'll see how it goes.

Sunday, October 04, 2009

Comments on Bill Marre

I watched Bill Marre the other night, and he took his usual jabs at religion and religious for inspiring terrorism, oppressing women and others, and generally doing bad stuff in God's name. I only disagree with Bill to the extent that he believes that the world would be a better place without religion. I rather tend to believe that religion is just a convenient excuse for the bad things that people will find a reason to do anyway. Bad guys like Hitler, Stalin, Mao, and Pol Pot did not need religion to justify their crimes - they just reasoned that their ends justified the means.

Anyway, that's the deep thought for the day.