With the recent introduction of the Nintendo Wii and the great iPhone demo on Macworld, I became really curious on how these new gesture-based UIs can be programmed.

Event-driven UI programming is fairly straight-forward. When the user clicks a button, moves a joystick, or presses the pen down on the surface, your component or event handler receives a message, and usually its type and parameters will be quite straight forward to describe the actual user intention.

I'm sure it's much more difficult with both the Wii controller, which has a large number of sensors to capture your arm gestures in 3d space and time, and with the iPhone, which has a multi-touch interface, which must have a much more varied event model than a straight pen-based touch interface.

On a sensor-level, there's nothing particularly complex, these sensors will produce some sort of digital reading that's ready to be analyzed. However there must be some sort of abstraction layer to make it easier to consume than the raw sensor readings. After all, these input devices (the Wiimote and the iPhone multi-touch digitizer) want to capture gestures, not just a particular change on a sensor. The Wii game developer is interested if the player performed a proper throw in the Baseball game, with the proper aim and force, and the iPhone developer wants to know if the user "pinched" an image on the screen to make it appear smaller.

Relying on individual sensor readings would be horrific in development time, on the other hand just providing a number of simplified events, like "THROW_TO_SCREEN" on the Wii, or "LOWER_CORNER_PINCHED" events on the iPhone would limit what developers can do to take advantage of the new controls.

So I guess Nintendo and Apple has some sort of abstract gesture descriptions that can be mapped to sensor readings, combining the output of the individual sensors (Wiimote held upwards, facing the screen), the changes over time (controller swung within a 2-second range), and the threshold to accommodate small differences (like a kid with smaller hands will produce smaller motion on the controller).

I have no doubt that these gesture-driven user interfaces work well in this context, in fact I absolutely love to play with the Nintendo Wii, and I will likely not be able to resist the iPhone when it comes out. As a developer, I wonder how these new, more complex user input paradigms are available for the developer.

I just went through tons of articles and documents and howtos to implement a simple web application authorization, so I thought I should save the effort for other impatient people like me. Read through the extensive JBoss documentation for detailed specifications and such, if you're in the mood.

Basic concept:
I want a set of pages to require username-password authentication.

  • The username-password combination should be stored in a database
  • I am not concerned about EJB security right now, just the webapp
  • I don't want to write my own code for this
  • I'm using MySQL

Solution:

  1. Secure the protected URLs in your web.xml. Put the following lines into the web.xml file in your WEB-INF directory:
    <security-constraint>
    <web-resource-collection>

    <web-resource-name>Secure Content</web-resource-name>
    <url-pattern>/restricted/*</url-pattern>

    </web-resource-collection>
    <auth-constraint>

    <role-name>AuthorizedUser</role-name>
    </auth-constraint>

    </security-constraint>


    <login-config>
    <auth-method>BASIC</auth-method>

    <realm-name>The Restricted Zone</realm-name>
    </login-config>


    <security-role>

    <description>The role required to access restricted content</description>
    <role-name>AuthorizedUser</role-name>

    </security-role>

    This means that any page that's within the /restricted URL will get protected, the authentication mechanism will be BASIC (ugly popup screen which requests the credentials), and anyone who is in the AuthorizedUser role will be able to see it. See the login-config documentation about how to configure a JSP page with form based authentication instead of this.

  2. Make the database accessible for JBoss. Drop the mysql client jar into your JBoss domain's lib folder, and customize the mysql-ds.xml file, which you can find in the JBoss docs/examples/jca directory, using your own database's URL, login, etc. Drop the modified file into your JBoss domain's deploy folder. This is a great feature for datasource configuration!

  3. Create a Users and Roles table in mysql, with the following structure:
    - Users should have an username and password field
    - Roles table should have a username field, and a roles and role_group field.

  4. Configure JBoss to use your new table for the JBoss-provided DatabaseServerLoginModule. This is configured in your JBoss domain's conf folder, in the login-config.xml file. Basically you need to provide the datasource, and the SQL selects you would use to return these values.


    <application-policy name="myOwnDomain">

    <authentication>
    <login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule\"

    flag="required">
    <module-option name="dsJndiName">java:/MySqlDS</module-option>

    <module-option name="principalsQuery">
    select passwd from Users where username=?</module-option>

    <module-option name="rolesQuery">
    select role, role_group from Roles where username=?</module-option>

    </login-module>
    </authentication>

    </application-policy>

    Make sure your Datasource name matches the one you configured in the Mysql DS xml file.

  5. Connect your webapp's J2EE standard authorization settings with the JBoss-specific provider implementation. The place for this is the jboss-web.xml file in your webapp's WEB-INF directory.


    <jboss-web>

    <security-domain>java:/jaas/myOwnDomain</security-domain>
    </jboss-web>

    This will make JBoss look up the myOwnDomain settings in the login-config.xml file, which will use the JDBC based module to query your database for authentication.

It is quite straight forward to use hashed passwords as well, this is documented in the DatabaseServerLoginModule provider's documentation. Enjoy!

EJB3 is going to kick ass, even though the current beta implementations are inconsistent and not there yet.

Example: Oracle JDeveloper has EJB3 support (very basic as there are no wizards and things that are available for EJB2). It uses TopLink as its persistency provider. Unfortunately it is not updated to the latest spec versions, for example I have found that the @GeneratedValue annotation does not work, I had to use the @Id (generated=AUTO) notation.
The documentation is also not updated, and sometimes points to non-existent configuration options and such.

To my great surprise, Sun's beta Application Server also uses TopLink as the embedded EJB3 persistency provider, but a newer build which supports generatedvalue! On the other hand, I saw from the startup process, that it also uses Hibernate for something, as it logs stuff to the console.

Another Sun AppServer quirk: I saw hssqldb dumping stuff on the console, on the other hand it uses Apache Derby to persist the entities as a default embedded db...I don't even dare to look at what jarfest is in there. Still, props to the Netbeans 5.5/Sun app server beta, as I managed to code and deploy my first EJB3 package with entities and session beans in it without much struggle.

I wasn't able to run the EJB3 enabled JBoss beta on my PowerBook, I suspect it is unhappy with my Apple 1.5 JDK.

Anyways, the standard itself is pretty much all we can hope for in Javaland. I am quite willing to accept the current beta stuff to be able to play with the features. The persistency API is a joy, and the dependency injection stuff makes it easy to work with the beans. The new 1.5 language features do make it even more clean.

Interesting thought - if someone starts to learn and work with Java EE next year, the lucky bastard will probably never have to understand what we had to work with in current J2EE versions. It's just a well thought out, clean and consistent set of APIs, based on plain Java objects. I am not so enthusiastic about the web layer yet, but stuff like the Stripes framework is quite non-threatening, and should be easy to pick up for web developers.

Most of the drudgery is going to be gone, soon, and we can point to Java EE's strong localization features, the undeniable strength of integration APIs, BPEL engines, refactoring IDEs, and so on, the next time a kid from a Scandinavian country comes in and tells Java people us to pack up shop :-)

Competition is fantastic. Just look at how much Netbeans or even JDeveloper strenghtened under the highly competitive situation, and how much the Java Web frameworks are focusing now on simplicity and ease of use, no doubt at least partially because of Rails' relentless push and undeniable attractiveness as a Web development framework.

I'm in love with web applications.

I use multiple computers, running multiple operating systems. so I find it extremely convenient to access my mail through the GMail web interface, I do all my blog reading through NewsGator online, and I am in awe of Writely, which could be my single content repository for all my articles and writings once they fix a couple of things. I am keen on sharing my photos with my family through .MAC and iPhoto's photocasting feed. I use Yahoo Unlimited for my music needs, it's great to be able to stream and download my music through the web, from anywhere.

The thing is, I am starting to feel the limit of free usage, and now that I am thinking about subscribing to all the services I'd like to use, it would just cost too much.

I enjoy Backpack, it is convenient that I can store my notes online, securely, sharing it only with trusted people. I have lost my local OneNote notes, my Palm notes, primarily because I am retarded when it comes to migration between PCs and I am sloppy with backup. The "Pro" account which I would need would cost me 9$ per month, 108$ per year. Let's assume that I want to use this webapp for 3 years, this is reasonable for most of my desktop apps. To host these 100 note pages, it would cost me more than 300$ for 3 years.

I am really keen on iPhoto's sharing features, it would be a great way to share my kids' photos with the grandparents privately - a .mac account would cost me 100$ per year, or 300$ for the 3 years timeframe.

I am sure Writely.com will have pricing similar to Backpack, so I expect that it'd run me again 300$ for that service. Yahoo Music is about 60$ per year. Actually I think given the value it provides, its pricing is the most realistic from all these services I am using.

So a full "Web 2.0" lifestyle, with web-based apps instead of desktop-bound applications would cost me more than let's say an iBook with some cheap software per 2-3 years, for sure.

Now I am totally accepting the fact that I will have to pay for someone's effort to implement all the RoR-AJAX apps, run the services, provide reliable backups, and so on. I don't mind paying for value. I think what needs to be done though, to make it actually feasible to choose the Web instead of the desktop, is to bundle these services as affordable packages rather than paying to 10 different sources for services.

Now some of that is already happening, as Yahoo! and Google is buying up services, and many startups are working towards the goal of this happening with them as well. However, there should be a way to provide lower cost bundles of independently operated "Web 2.0" services as well. Maybe Internet providers, maybe media companies, maybe even payment providers like PayPal should step in, and provide this aggregation and provisioning services to new startups.

This would drive more users to the new services. I would be more keen on trying new stuff, if I would know that my low cost "gLife" subscription would cover 10 different services, and I don't have to commit one more item to my monthly service charges. Keeping the overall costs low and bundled would also mean that I don't have to be worried about being cut off from my documents, photos, websites, if I have a bad month financially.

I don't want to see a "Walmart of Web based services" that would totally suck out the revenue from the little guys really, I want a convenient mall where service providers could rent space - and I could shop around without too much hassle.

TurboGears seems to be a very nice alternative to Ruby On Rails. It shares the appeal of the end-to-end Web Application framework, with a modern, productive language, but it is much more modest in terms of hype and world domination plans.
Although I do prefer Ruby as a programming language, Python (used by TurboGears) is a fine choice as well. I totally dig that it has a specific template language, I don't particularly like the native Ruby approach to the web pages on RoR. The persistency framework (SQLObjects) seems to be a nice choice, it has support for the usual suspects (MySQL, PostgreSQL, even the little embedded SQLite package). Although I was very impressed with RoR implementing all the required frameworks (DB, MVC, etc.) from scratch, TurboGears seems to be well integrated from the existing components.
As a beginner OSX user I had an moderately easy time getting it up and running, I attribute most of the work to my lack of Mac skills. There is a brief help page on TurboGears.org, but I needed to play around to get the expected results.

The fist step for me was to install MacPython. By default Apple ships Python 2.3.5 with Tiger, so this is needed to get Python 2.4 installed. The MacPython website is not very good in terms of documentation, but this is how I managed to get it running.
  1. I've installed the distribution from the .dmg file
  2. I've installed the TigerPython fix as well
  3. Now I needed to have the new MacPython as the default Python interpreter in the shell, so I needed to edit the ".bash_profile" file in my home directory. I've used TextWrangler's hidden file mode, as by default this file does not show up in the Finder or in the File Open dialogs
  4. I've added this line to my bash profile: PATH=/usr/local/bin:$PATH
  5. I've closed my shell and opened it again - apparently the "source .bash_profile" does the same trick
  6. Now, when you run "python -V" to get the python version in the shell, it should display 2.4.1 instead of 2.3.5. If you still see 2.3.5, check your path with "echo $PATH", as the "/usr/local/bin" location should precede the "/usr/bin" one, where old python shortcuts live
  7. While I was dicking around on the macpython website, I've also downloaded and installed the pysqlite package from http://pythonmac.org/packages/
  8. Next I've downloaded the ez_setup.py file from the TurboGears site
  9. Then I've run the ez_setup script as instructed on the TurboGears site: sudo python ez_setup.py -f http://www.turbogears.org/download/index.html --script-dir /usr/local/bin TurboGears

After this, I've created a project folder in my home directory, and used the "tg-admin quickstart" command to create the default web app structure, which completed successfully. Then I've started the web app with the generated Python script, and it showed up on the http://localhost:8080 address, to my great pleasure.

Now I only need to complete the code for the application...

As you might know from some of my previous posts here, I work for EPAM Systems, the largest software outsourcing company in Central & Eastern Europe. I lead the Pre-sales department.
As our plans for World Domination start to fall in place, I am looking for 2 engineers to join my team of tech experts.
These are the key responsibilities for the position:

  • Review, research, understand the needs of our new prospects
  • As part of the proposals, design a candidate architecture for the new opportunity
  • With the help of our project managers, plan out the project for the proposal
  • Implement prototypes, perform small proof-of-concept projects (on-site and off-site) to prove the candidate architecture
  • Work with the project team to kick off the project, transitioning the responsibilities to the PM and Lead Architect after the first iteration

We are looking for people with extensive architecture design experience either in J2EE or .NET, preferably with project management experience as well, who are willing to move to Budapest, Hungary (the location of our European Headquarters).
I think this is a great opportunity for people who are excited about technology, software development, but are looking for more varied responsibilities, instead of day-in day-out project work.
Send your CV (with focus on tech skills, team leadership, development process experience) to fbalazs -at- gmail.com.

<< 1 2 3 4 5 6 >>

September 2010
Sun Mon Tue Wed Thu Fri Sat
 << <   > >>
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    

Search

Random photo

XML Feeds

powered by b2evolution free blog software