Muitos de vocês devem conhecer o Arun Gupta, Entusiasta de Glassfish com enfase em consolidação web na Sun. Ele foi um dos condutores da especificação da plataforma Java, está comprometidos com diversos projetos de Código Aberto e Software Livre, participou de vários comites de padronização e participou de releases ddo Java EE e SE. É um blogueiro prolÃfico com várias dicas muito úteis no seu http://blogs.sun.com/arungupta.
Este webinar será conduzido em Inglês e está marcado para o dia 3 de Fevereiro de 2009, as 10:30 am aqui no horário de Fortaleza, e 9:30 am 11:30 em São Paulo e 8:30 am no horário da Califórnia.
Para participar responda o RSVP e pegue o link do Elluminate dentro do site do evento no OSUM.
I won a certificate (seems to be really autographed by Jonathan Schwartz *_* I want to believe) that I will frame and put in my room and a $250 dollars check that I’ll save for a trip next year. \o/
Long urls are difficult to remember or print, usually full of redundancy and low semantic. With short and meaningful urls you can avoid thes problems and even achieve profitable goals with SEO
SEO (search engine optimization) technics.
There are services like Tiny URL, Fancy URL, Moo URL and others. Although they solve part of the problems, they bring several others. Another problem is if you have a web site like example.com and use a third-party service for short urls you are losing part of your mind-share with your users and clients.
As an example, if a example.com company wants to promote a open work position would be preferable spread a example.com/jobs instead of a tinyurl.com/examplejobs, or even worst, a tinyurl.com/3i4i592 (meaningless hash).
2. Solution Approach
I created a little program called xort that can be placed on your own server and provide you own short maintening your base url.
I use a pipe abstraction. Each pipe redirects from a key url to an output url.
The idea is that you have xort installed and associated into your domain (preferably on /x). A pipe inside example.com would be like example.com/x/jobs.
3. Tools
All those tools are multi platform, open source and free.
3.1 Glassfish Application Server
Glassfish is an open source application server project led by Sun Microsystems for the Java Enterprise Edition (Java EE) platform. It’s very easy to install and run and have a very nice administration web interface where you can do from simple tasks like deploy a application to more complexes like clustering.
Glassfish Admin Console
To develop the application I’m using NetBeans 6.5 Beta that comes with Glassfish V3 prelude b15b. Netbeans also provides a integration of project, database and web server.
Nevertheless, Glassfish has no dependencies with any IDE and perfectly works by alone. If you need I wrote this post explaining how to install and deploy a application on Glassfish from scratch.
3.2 MySQL Relational Database
MySQL is a relational database management system and probably the most used database on internet (has more than 11 million installations). It’s also very easy to install and administer, through command line or many gui interfaces.
To install MySQL and JDBC driver on Ubuntu just run as root:
# apt-get install mysql-server libmysql-java
After installing and configuring it you can test the jdbc driver throught this servlet code. You can optionally register the MySQL on NetBeans to have a easier access to it thought the service tab.
At the command line you can invoke mysql command line interface and use MySql commands or SQL queries. I’ll login and create a database called xort:
$ mysql -u username -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.0.51a-3ubuntu5.3 (Ubuntu)
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
You could also create this database by an SQL statement:
CREATEDATABASE xort;
CREATE DATABASE xort;
To select the database xort:
mysql> use xort;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql>
Now we create a database called pipes with fields pin (pipe in) and pout (pipe out). They represent the input url and the output url of our pipe abstraction.
CREATETABLE pipes (
pin VARCHAR(255)NOTNULL,
pout VARCHAR(255));
CREATE TABLE pipes (
pin varchar(255) NOT NULL,
pout varchar(255)
);
As we expect a lot of searches queries on this table, we can optionally create a index for it on pin field. This can reduce ours searches from O(n) to O(logn) (because pin’s will be ordered so don’t need to look all pipes, we can use logn algorithms like binary search).
CREATEINDEX pinindex ON pipes (pin);
CREATE INDEX pinindex ON pipes (pin);
Another trick to improve our speed is recycling connections through connection pools.
Creating a pool of MySQL connections on Glassfish is very easy. There’re two good tutorials on this subject:
Set if users can add new pipes using the web interface.
allowNewPipes
true
JDBC driver to use
driver
com.mysql.jdbc.Driver
Username to login on the database.
username
root
Password for the given username.
password
yourpassword
JDBC path to database.
database
jdbc:mysql://localhost:3306/xort
Set if users can add new pipes using the web interface.
allowNewPipes
true
JDBC driver to use
driver
com.mysql.jdbc.Driver
Username to login on the database.
username
root
Password for the given username.
password
yourpassword
JDBC path to database.
database
jdbc:mysql://localhost:3306/xort
You be asked about the license agreement (CDDL+GPL).
Files will be decompressed in a directory named glassfish.
$ cd glassfish
Now we need to continue the installation. You can have Ant installed in your system or, like I’m doing, use a version that comes the Glassfish package.
Tip: if you have more servers and want to create a cluster for load balancing, see this documentation. After ajust the setup-cluster.xml file you just need to run ant on it.
The default user is admin and password is adminadmin. Log in.
Tip: you be asked for register your version. This register is not mandatory and not doing it will not limit the features of your Glassfish. It’s just a way they use to track the number of users. Aditionaly can have acess to newsletters, tutorials, screencasts, services and support. If you already have a SDN (Sun Developer Network) or Sun Online account you can use it for registration. If you simply doesn’t want to, you can skip this step.
For security reassons, click in the Application Server icon on the left sidebar and so in the Adminstrator Password tab. Chose a new password and click Save.
There other ways less easy but more flexible) to deploy your application, you can take a look on this and others topics on Glassfish Quick Start Guide.
Try to explore the Glassfish admin interface. It’s very easy and intuitive.