Thursday, September 4, 2008

Adding LinkedIn to Your Blogspot

Ok here's how to get it done

1. Go to the Layout Tab, and open 'Edit HTML' section

2.Find for the <data:post.body/> tag

3.Paste this just above the tag

<div style='float:right; margin-left:10px;'>

<a href='http://www.linkedin.com/in/yourprofile'><img alt='View Your Profile's profile on LinkedIn' border='0' height='15' src='http://www.linkedin.com/img/webpromo/btn_profile_greytxt_80x15.gif' width='80'/></a>

</div>
<data:post.body/>

You have different image formats available at linked in so you can pic the one of your choice and put it instead of the one I have used (between the <div> and </div> tags).
Of course you have to change your profile to your name :-D

Tuesday, August 26, 2008

More on Maven

Well if you don't really like ant for some reason

Quick Facts


Adding Plugin to Project

Add the following to your POM


<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<hibernate>
<configurationFile>
src/main/resources/hibernate.cfg.xml
</configurationFile>
</hibernate>
<outputDirectory>
<hbm2cfgxml>src/main/resources</hbm2cfgxml>
</outputDirectory>
<componentProperties>
<outputfilename>schema.sql</outputfilename>
</componentProperties>
</configuration>
<dependencies>
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.1.2</version>
</dependency>
</dependencies>
</plugin>
<plugin>


Adding Extensions

This is requiered to ensure the correct driver for the databse you are using is available to the plugin. I am using MySQL for example for other databses you have to mention there respective driver jar.


<build>

........

<extensions>

<extension>

<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.0.8</version>

</extension>

</extensions>

</build>


Plugin Goals

  • hibernate3:hbmtemplate Generic exporter that can be controlled by a user provided template or class.
  • hibernate3:hbm2cfgxml Generates hibernate.cfg.xml
  • hibernate3:hbm2dao Base class for the different hibernate3 goals based on the Ant tasks of hibernate tools.
  • hibernate3:hbm2ddl Generates database schema.
  • hibernate3:hbm2doc Generates HTML documentation for the database schema.
  • hibernate3:hbm2hbmxml Generates a set of hbm.xml files.
  • hibernate3:hbm2java Generates Java classes from set of *.hbm.xml files.

Usage

Run the following command from command line(ensure you use the complete plugin name)

mvn org.codehaus.mojo:hibernate3-maven-plugin:2.1:hbm2ddl

Jetty-Maven-Eclipse ... mmmmm nice

Here's on how to setup jetty:run goal for a maven project, and to run it from eclipse.

Configure Jetty in project's pom.xml

The first step is to add maven-jetty-plugin to you project's pom.xml. Here is n extract from my sample project.



<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.10</version>
<configuration>
<scanIntervalSeconds>5</scanIntervalSeconds>
<jettyEnvXml>src/main/resources/jetty-env.xml</jettyEnvXml>
<webApp>target/webmeet-1.0</webApp>
</configuration>
</plugin>


No rocket science here, the configuration tag defines the configuration for your specific needs i will elaborate it a little later.

  • <scanIntervalSeconds> tag defines the interval after which the plugin will 'scan' all resources in 'webb-application' base directory for changes. Good option if you will be editing your JSPs or VMs(velocity!) on the fly while developing and want to see immediate results.
  • <jettyEnvXml> tag defines the XML where you configure environment properties for Jetty. For example 'propertyhosts' and JNDI data-sources etc
  • <webApp> tag points to the 'exploded' webapp created by maven install goal in your eclipse project.

Adding Dependencies

If needed you can add dependencies 'selectively' toyour pom so that they apply only on the jetty configuration. Here's how to do that


<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1</version>
<type>jar</type>
</dependency>
.....

</dependencies>

The dependencies tag should be nested within the plugin tag.

The Jetty Environmental Config

Environmental resources such as JNDI names etc for datasources can be configured in a file pointed by the < jettyEnv > tag. In my sample I configure a propertyhost and a datasource. Following is the complete xml file


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
<New class="org.mortbay.jetty.plus.naming.EnvEntry">
<Arg>propertyhost</Arg>
<Arg type="java.lang.String">localhost:22081/</Arg>
</New>

<New id="webmeet" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>jdbc/webmeet</Arg>
<Arg>
<New class="oracle.jdbc.pool.OracleConnectionPoolDataSource">
<Set name="Password">password</Set>
<Set name="User">appuser</Set>
<Set name="URL">
jdbc:oracle:thin:@127.0.0.1:1521:XE
</Set>
</New>
</Arg>
</New>
</Configure>

To run this from command line run following command from the maven project root

mvn jetty:run  

Running from Eclipse

Eclipse 3.3.X Europa

  • Choose Run > Open Run Dialog.
  • Select Maven Build and click on add new configuration button
  • Give the configuration a name
  • Add goal jetty:run
  • If you want to use log4j instead of the sl4j provided by jetty add the following in the WM argson the JRE tab
    -Dslf4j=false -Dlog4j.configuration=file:path/to/your.log4j.properties
  • Click 'Apply' and click 'Run' to run the webapp in Jetty.

Eclipse 3.2.X Callisto

The steps are same as above except that you have to choose Run > External Tools > Open External Tool Dialog in the first step.