Tuesday, December 20, 2005
Free Icons
> Need icons for your new website or web application, at the best price there is (free!)?
Monday, December 19, 2005
CSS-Only, Table-less Forms
> Most of the CSS-only, table-less forms available suck. So, not wanting to stoop to mediocrity, I decided to take on the task of coming up with something better. This is the result of my efforts. It works in Win/IE6, Firefox v1.0 , Win/Opera v8.0, has minor layout differences in Mac/Safari v1.0.3 and Mac/Safari v1.2, and is usable but fairly buggered in Mac/IE5.2.
File Uploads with Rails
> This library makes handling of uploaded files in Ruby on Rails as easy as it should be. It helps you to not repeat yourself and write the same file handling code all over the place while providing you with nice features like keeping uploads during form redisplays, nice looking URLs for your uploaded files and easy integration with RMagick to resize uploaded images and create thumb-nails. Files are stored in the filesystem and the filename in the database.
Rails Petstore
> an implementation of Clinton Begin's JPetstore that has been developed with the Rails web framework. The aim of this project is to develop a reference application that demonstrates the capabilities of the framework and the best practices that should be followed when developing an application.
This is for all you Java people out there who have seen the Petstore application in one form or another over the years. The Petstore is a common Java application implementation used to show how a framework is used "in the real world". It's been implemented many times, and comparing a Java Petstore to a Rails Petstore is very useful.
Sunday, December 18, 2005
Ruby off the Rails
> Ruby on Rails is just one facet of what makes Ruby great, just like EJB is only part of the Java™ enterprise platform. Andrew Glover digs beneath the hype for a look at what Java developers can do with Ruby, all by itself.
Saturday, December 17, 2005
Steal These Buttons
All these links stolen from MeFi.
SwitchTower: Automating Application Deployment
> SwitchTower is a standalone utility that can also integrate nicely with Rails. You simply provide SwitchTower with a deployment “recipe” that describes your various servers and their roles, and voila! You magically have single-command deployment. It even allows you to roll a bad version out of production and revert back to the previous release.
Question now is, can this even be done in the Java world? Even if it could, would it ever take hold? I almost think that a common deploy script and procedure would not be widely accepted in the Java world, because of the mentality of the common Java developer. A Java developer wants to built it himself (see the insane number of web frameworks out there for evidence of that). Of course, one size doesn't fit all, but in the limited scope of web applications, one size fits most.
Friday, December 16, 2005
IM, meet AJAX
Call me when I'm running an AJAX browser inside my browser.
On the Rails Again
> A lot of presentations I saw, about Java EE 5 (GlassFish) but also for instance about Spring, stressed that everyone now focusses on EoD(Ease of Development) and ‘code by exception’, meaning: only having to code the exceptions to the default behaviour.
Having just come back from The Spring Experience myself, and having written Ruby on Rails applications for the two weeks prior, I can attest to what Danny experienced. Programming in Rails certainly opens up your eyes to what else is possible in the web programming world. Not all of it is good, mind you. You immediately miss the power of your Java IDE, for one thing.
I recommend that every Java web developer go code a quick application in Rails, even if they will never use Rails again. It's so easy to get caught up in a language's constraints, both physical and mental. By programming an application in something not Rails, you take a breath of fresh air. Rails is cutting edge because of what it doesn't try to do. I'm certain that a Java developer can learn a thing or two from what Rails attempts.
Writing Mixins using AspectJ
>Aspect-oriented programming complements object-oriented programming in many ways. One interesting complementary feature is behavior composability. This means that it should be possible to compose a class by adding behavior from different classes. OO uses inheritance and many patterns to add behavior to existing classes. AOP allows us to use mixins without changing the class inheritance hierarchy or otherwise changing the code.
>Mixins enable us to uniformly extend a set of classes with a set of fields and methods. Java does not support mixin-based programming. This article shows what mixins are and explains how AOP constructs in AspectJ allow us to use this technique to isolate crosscutting concerns, with an example. It starts with a plain Java implementation and ends with an AspectJ 5 implementation.
Tutorial on Semantic Web Technologies
Accessible, stylish form layout
> Yes, HTML forms are the worst things known to web designers. Yes, HTML forms have to be accessible and usable. No, HTML forms do not have to be an eyesore.
Thursday, December 15, 2005
W3’s CSS Activity
> 2005-12-16: The CSS Working Group has released a First Public Working Draft of the CSS3 Advanced Layout Module defining grid layout. The draft's features could be used to define visual order independent of document order, position and alignment of user interface "widgets," and page and window grids. Also published are Working Drafts of Multi-Column Layout and Cascading and Inheritance. Visit the CSS home page.
Ten Rules for Web Startups
To avoid the suspense:
1. Be Narrow
1. Be Different
1. Be Casual
1. Be Picky
1. Be User-Centric
1. Be Self-Centered
1. Be Greedy
1. Be Tiny
1. Be Agile
1. Be Balanced
1. Be Wary (bonus!)
Russell Beatie wanted to add a #12, Be Mobile.
More on Splitting Hibernate Jars from Spring
> It's not about splitting it out just to split it out. The problem is
that having both the Hibernate 2 and Hibernate 3 code together leads to
a lot of confusion. People end up importing the wrong classes all the
time. The actual class names are identical, and the packages as
identical except for one extra char, so it's easy to import the wrong
one when you do an auto import in Eclipse. I see this over and over
during trainings, among other places. So back in the summer I suggested
we split things out to separate jars and have people just include
whichever one they wanted, but it didn't make sense (for drop in
compatibility reasons) to do this in a 1.2 point release, but rather
only now with 2.0...
Wednesday, December 14, 2005
Project Aardvark
> Four interns are brought into Manhattan and given 12 weeks to design, develop, debug and ship a program that will change the way computer geeks around the world fix their friends' computers. Boondoggle Films presents a journey through the world of software development from the perspective of a unique upstart, four quirky interns, and the world of The Geek.
Spring 2.0 Jar Missing Hibernate Classes
> I stopped Rob, Rod, and Juergen in the lobby on the last day of TSE and asked the same question. It seems that Juergen has split out most of the vendor-specific ORM stuff into independent JARs (spring-hibernate.jar or spring-hibernate3.jar for instance). It's my understanding that the decision was made because (1) the main JAR was getting quite large and (2)
Hibernate/iBATIS/OJB/etc-specific stuff is not central to Spring and thus should not be in the main JAR.
> So, yes, from a JAR dependency perspective, backwards compatibility is broken. But fixing it is simply a matter of including an addition JAR file in the classpath. Code-wise, backwards compatibility is still intact.
JavaPolis Spring Web Tier slides
>Yesterday, Erwin Vervaet and me did a 3-hour session on Spring in the Web Tier. We mainly focused on Spring MVC and Web Flow. The sample is online; you can get to it from the Spring Framework site.
>The slides are here, in PDF format.
Tuesday, December 13, 2005
Ruby to JMS Bindings
Monday, December 12, 2005
Removing Commons-Logging Once and For All
> I lurk on a bunch of mailing lists via Gmane and recently came across this message in which Henri Yandell asks if it would be possible to write a tool using bytecode manipulation which strips out any dependency on commons-logging.
> After getting in touch with Henri he suggested making it a generic tool that could strip out any dependency. That's pretty much right up my alley, and since I've had a few logging headaches of my own I figured it was worth a try. So I've checked in some experimental code to the Jar Jar Links project, which has similar dependency-reducing goals.
Saturday, December 10, 2005
Pragmatic AOP with Spring and AspectJ
Aspects are modular, enhancing the value of the software overall. Aspects lead to DRY SOCs (Don't Repeat Yourself, Separation of Concerns).
Join points are well defined points in the execution of the program.
Pointcuts are expressions that match join points.
Advice is action to take at those join points. Advice is not explicitly called, unlike methods.
Typical applications are Spring managed for data access, services, web controllers, transactions, etc. Up to now, the Domain Model has not been managed by Spring.
Spring AOP is a good fit for Spring managed beans, execution based join points, or coarser-grained service application. Or any time where the aspect is slower than the impact of the proxy itself (ie, transactions).
In Domain Driven Design, another separation of concern (SOC) is the Technical Concerns (transactions, auditing, etc) from the Business Concerns (the Ubiquitous Language, language of the business domain experts).
AspectJ is perfect for integration with the Domain Model, in contrast to Spring AOP which is good for advising the service layer.
What makes a good aspect? Does the aspect reduce coupling?
Friday, December 9, 2005
Practical Quick Start with Acegi Security and Spring
The important thing to know about Acegi Security is it is more of a model and lexicon instead of pre-built security implementation. Because security varies across each application so widely, Acegi provides interfaces and extension points to make building a security framework much easier.
Acegi is much more than a replacement for Servlet API security. While it does fully replace the Servlet security features, it also provides fine grained ACLs on a per-object instance which is a huge feature. J2EE security does not support that at all. Other features include CAPTCHA, channel security, switch user, prohibit concurrent logins, and many others.
It's important to note that Acegi Security is not specific to web applications. It's perfectly viable as a security framework for your Rich Client project, too.
There are an insane amount of Authentican mechanisms, including Form, HTTP Basic, HTTP Digest, RMI X509, Yale CAS, SiteMinder, Remember-Me, Anonymous, and others.
Thursday, December 8, 2005
Spring.NET Introduction
So the first question is Why Spring.NET? Simply, the IoC container transends platforms. Also, a lack of similar toolsets and libraries on the .NET platform required a Spring.NET.
However, it's not a direct port, as the two environments have quite different practices and conventions.
One benefit to the Spring Community is a bigger core development team, and a good cross-pollination of ideas. For instance, the new XML Namespaces and XSD configurations originally came from Spring.NET.
A similarity between Spring.JAVA and Spring.NET is the transaction handling. AOP exists in Spring.NET, but implemented differently. One difficulty with aspects in .NET is methods are by default marked as
final.You'll find there are naming differences between the two environments. Object vs bean, type vs class, dictionary vs map. In .NET all exceptions are unchecked. Configuration is more formal in .NET, something that is ad hoc in Java (ie, just putting some file into META-INF).
With Spring.Web, you can now Dependency Inject your ASP.NET pages.
Jurgen Holler and JMS and JCA
JmsTemplate, useful when you're not running an asynchronous JMS listener.Spring 2.0 has full support for asynchronous message receiving with POJOs. This is the elusive Message Driven POJO, important when Message Driven Beans (MDBs) aren't available.
An important note about the
JmsTemplate is that it fetches a Connection for every request. In a managed environment, this is OK, because the container will pool Connections. However, in a non-managed environment, be sure that the ConnectionFactory is pooling connections.For asynchronous message handling, you can either use
MessageListener and manually register it with the Session, or use J2EE's Message Driven Beans. In either case, you are using a framework interface (MessageListener) which is not POJO compliant. Also, typically if you want XA and asynchronous message reception, you need to use MDBs.Enter Spring 2.0's new message listener container. You have the option of implementing
MessageListener, or the Spring specific SessionAwareMessageListener. As it sounds, you get a onMessage(Message, Session) method. This is useful for sending reply messages, and you're able to thrown JMSException.The Spring provided message container is the
DefaultMessageListenerContainer. It supports XA message reception, works with all JMS providers, simply uses MessageListener and MessageConsumer facilities. However, it does create one thread per consumer, which is forbidden by the J2EE contract. However, you may still do this and usually doesn't harm much.Note that XA transaction handling provided by the container starts the transaction with message reception. That is, the message reception is within a transaction.
SimpleMessageListenerContainer is an alternative container, but does not support XA message reception and does not create custom threads. This is useful outside of a container.ServerSessionMessageListenerContainer uses JMS's ServerSessionPool, which is a SPI into the JMS Server. However, not very useful in J2EE containers, as the spec forbids the use of ServerSessionPool. Also does not use XA transactions.Much of this is possible through the new
TaskExecutor abstraction, for creation of custom threads. Three different implementations including a ConcurrentTaskExecutor which uses JDK1.5's ThreadPoolExecutor or WorkManagerTaskExecutor which is for modern J2EE containers like BEA WebLogic 9 or IBM WebSphere 6. This executor uses the CommonJ WorkManager abstraction, allowing J2EE applications to formally and correctly use threads from within the container (forbidden by the spec). However, CommonJ is not a JSR, but is supported by BEA and IBM.DefaultMessageListenerContainer is the recommended container, useful for most needs.
The Aspects Blog: The New Holy Trinity
Aspects Blog: The New Holy Trinity is Adrian Colyer's excellent post about the relationship between aspects, annotations, and POJOs. This is required reading when investigating Spring 2.0's new POJO Dependency Injection, powered by annotations and AspectJ. Essentially, you may now DI your POJOs, even when you use the
new operator. In other words, you can use Spring to Dependency Inject your POJOs without any ApplicationContext in sight, or without the ApplicationContext having even created your POJO.> Dependency injection, annotations, and aspects are the three foundations on which the next generation of world-class POJO-based applications should be built.
Spring, Mule, and the ESB
His talk covered what an ESB is (generally speaking, doing a good job not to do too much arm waving), what Mule is (short answer: an ESB container), and how Spring can be used for tasks like Mule configuration and Mule components.
Justin's style is quite good, and I can recommend you check him out if you happen to be at a conference with him. Or, just corner him and yell, "Hey, it's Justin Gehtland!" He loves that.
I've used Mule once, evaluating it for a project. We needed to shuffle files around, uploaded to us via FTP every night. At that time, Mule's support for file based messages was limited, so we didn't end up using the product. I think it was mainly because Mule didn't natively support the universal workaround for file dumps (place a zero-length "I'm Done!" file to indicate file upload is complete).
However, if your system is message based (where message can be email, web services, TCP, or JMS) then take a look at Mule. It provides the container concept to your messaging architecture. It's actively developed and very flexible.
Get Rocketboom via Tivo
Subscribe to Rocketboom with your Tivo now.
Clustering Spring
The crowd quickly steared the talk to a technical overview of the product, and it was quite interesting once we got them to stop hand waving. The product is not FOSS, but still pretty cheap (mentioned about $2k per node).
The product, named Terracotta Distributed Shared Objects, provides essentially a networked shared heap. This is not a standard object caching thing like Coherence, this product maintains object identity.
Wednesday, December 7, 2005
The Spring Experience Keynote
We're here at The Spring Experience keynote, given by Rod Johnson. It's Wednesday evening, and dinner has finished up. The approx. count for attendance is 275, not a bad number.
His talk is titled Spring Today and Tomorrow. Spring is “the most powerful technology for enabling POJO-based application development.” The majority of Interface 21’s clients are in the backing sector.
The framework is released in Feb 03 as open source, released as Spring 1.0M1 in Aug 03, and finally 1.0 Mar 04. Spring 1.1 arrives in Sept 04, 1.2 in May 05, and Spring 2.0 M1 is released at The Spring Experience.
New features of Spring 2.0 includes:
- Bean Scoping
- CommonJ timer manager
- Portlet MVC
- Message-driven POJOs
- Configuration simplification (XML or Java code)
- SimpleJdbcTemplate – Java 5 features
Still committed to Java 1.3.
Coming up, what will get better?
- Configuration can become simplified – Use XML namespaces, XML schema to reduce code, use custom domain specific tags, and better IDE integration.
- Closer integration of Spring AOP and AspectJ. Spring AOP gains AspectJ pointcut expression language, also gains the @AspectJ syntax. AspectJ gains Spring DI, for instance to DI domain objects.
Spring serves two communities: conservative users and early adopters.
Tuesday, December 6, 2005
Particletree · Quick Guide to Prototype
> JavaScript’s increasing popularity throughout the web makes it more important than ever to make sure our client side code is implemented with a nice mix of stability, speed, and reusability. One of the best ways for accomplishing this is to use a simple library and syntax to use as a foundation for every project. Thankfully, Sam Stephenson created an amazing library of functions that we can rely on called Prototype.js to ease our JavaScript development practices.
Treehouse
>Treehouse is a monthly web development PDF magazine put together by the people behind Particletree.
>Treehouse provides web designers, programmers and entrepreneurs a creative home and outlet for the latest news, trends and techniques from the best in the industry.
Monday, December 5, 2005
Sunday, December 4, 2005
Now with Tagging
Rails and Allowing ID Editing from Forms
Need to allow yours users to directly edit the ID of your model object?
By default, Rails will strip out the ID field from the hash of request parameters. This is a security measure, prohibitings the web interface from altering an object's ID.
Generally, this is a good practice. However, some legacy schemas have IDs that are not simply numbers. In those cases, the ID is created and managed by the user.
To tell Rails to allow the ID to be edited, you can use attr_protected and attr_allowed.
More information is available at http://wiki.rubyonrails.com/rails/pages/HowToEnsureValidAttributesInFormData
Friday, December 2, 2005
Rails, Legacy Schemas, ActiveRecord, and has_and_belongs_to_many
There turns out to be an issue with legacy schemas and ActiveRecord, the ORM layer of Rails when using has_and_belongs_to_many.
Note: This issue might be Oracle specific.
If the join table itself has an id column, and it has the same name as the id column from the association table, then it will override the id from the association table.
This means that instances from the association table will have the wrong id.
The solution looks to be the new :finder_sql parameter of the has_and_belongs_to_many relationship. With :finder_sql, you can override the generated SQL.
How to use :finder_sql? Try:
has_and_belongs_to_many :ksaas, :join_table => "tbl_ksaa_objective",
:foreign_key => "objective_cid", :association_foreign_key => "ksaa_cid",
:finder_sql => "SELECT TBL_KSAA.cid, TBL_KSAA.ksaa_type, TBL_KSAA.ksaa_item, " +
"TBL_KSAA.KSAA_TYPEID, TBL_KSAA.SAMPLE_BEHAVIOR " +
"FROM TBL_KSAA LEFT JOIN TBL_KSAA_OBJECTIVE ON " +
"TBL_KSAA.cid = TBL_KSAA_OBJECTIVE.ksaa_cid WHERE " +
'(TBL_KSAA_OBJECTIVE.objective_cid = #{id} )'
Keep those single quotes in order to lazily interpret the id in the query.
Note that Hibernate does not have this problem, as it aliases all column names, even when not using joins. Therefore it doesn't have the column naming conflicts.
OWLIM Inference Storage Engine
OWLIM is a high-performance semantic repository, packaged as a Storage and Inference Layer (SAIL) for the Sesame RDF database. OWLIM uses the IRRE engine to perform OWL DLP reasoning. The reasoning and query evaluation are performed in-memory, while a reliable persistence strategy assures data preservation, consistency and integrity.
– From the OWLIM Page.
More Ruby Meets the Semantic Web
Here's one of his snippets:
class Person < ActiveOntology::Base
definition "http://xmlns.com/foaf/0.1/index.rdf"
def your_method_here
# methods are pretty much the only thing left to write
# because since you defined it as a foaf:Person, it already has
# all the properties described at http://xmlns.com/foaf/0.1/#term_Person
end
def network_msg
"#{firstName} #{surname} has #{knows.size} people in their network"
end
end
Thursday, December 1, 2005
Ruby, Meet the Semantic Web
Because Ruby is so dymanic, I tend to agree. Plus, my Ruby on Rails work is making me a convert to The Way.
Named Routes in Rails
From Ronny Haryanto via the Rails Mailing List:
Interested in URLs that look something like this?
http://www.example.com/project/submarine
You can tell Rails to parse that URL in order to call the appropriate method on the controller.
You might be interested in Named Routes.
http://wiki.rubyonrails.com/rails/pages/NamedRoutes
In config/routes.rb:
map.project 'project/:projtitle' :controller => 'project',
:action => 'show'
In app/controllers/project_controller.rb:
def show
@project = Project.find(:first,
:conditions => ['title = ?',params[:projtitle]])
...
end
Or something like that. Assuming your project titles are unique. Then
you can also use project_url (since you have map.project in routes.rb)
for urls in your views, e.g.
<% for project in @projects %>
<%= link_to project.title,
project_url(:projtitle => project.title) %>
...
<% end %>
Named Routes is a really cool feature, and one of the best of Rails,
I'd say.
Thanks Ronny!
Using Columns with Reserved Names in Rails
From Rails Mailing List : How to access column with a reserved name?
def new_column
read_attribute 'old_column'
end
def new_column=(value)
write_attribute 'old_column', value
end