Avatar
😀

Organizations

  • Note to self, here are some code coverage tools for .NET that are free to use… and therefore good candidates for having the Coverage plugin for Hudson support off the shelf:

    Jenkins Created Wed, 07 Nov 2007 00:00:00 +0000
  • Created Mon, 08 Oct 2007 00:00:00 +0000
  • I am sick of the fun that is getting JAX-WS 2.1 to work on JVM 1.6.

    Oh, copy these four jars into the endorsed directory and then you can use JAX-WS 2.1… oh but sometimes it won’t work for some unknown reason and then it will work again.

    How you are supposed to explain this to end users, I don’t know.

    So next you need a platform specific installer to put those jars into the correct location, or a platform specific start script to tell the JVM about my alternate endorsed lib folder… or do I write a self-extracting jar file that exctracts the libs and forks a second JVM… no that won’t work for people wanting to use my library..

    Java JavaEE Created Wed, 05 Sep 2007 00:00:00 +0000
  • Not perfect, but enough to get you going.

    To build with this pom:

    Then you can install away to your hearts content.

    <?xml version="1.0"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>net.sf.jsf-comp</groupId>
      <artifactId>chartcreator</artifactId>
      <version>1.2.0-mavenized</version>
      <packaging>jar</packaging>
      <name>ChartCreator</name>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
              <source>1.4</source>
              <target>1.4</target>
            </configuration>
          </plugin>
        </plugins>
      </build>
      <dependencies>
        <dependency>
          <groupId>javax.faces</groupId>
          <artifactId>jsf-api</artifactId>
          <version>1.2-b19</version>
          <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>javax.faces</groupId>
          <artifactId>jsf-impl</artifactId>
          <version>1.2-b19</version>
          <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>com.sun.facelets</groupId>
          <artifactId>jsf-facelets</artifactId>
          <version>1.1.11</version>
          <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>javax.servlet.jsp</groupId>
          <artifactId>jsp-api</artifactId>
          <version>2.1</version>
          <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>javax.portlet</groupId>
          <artifactId>portlet-api</artifactId>
          <version>1.0</version>
          <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>javax.servlet</groupId>
          <artifactId>servlet-api</artifactId>
          <version>2.5</version>
          <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>jfree</groupId>
          <artifactId>jfreechart</artifactId>
          <version>1.0.5</version>
        </dependency>
      </dependencies>
    </project>
    
    Maven Created Thu, 23 Aug 2007 01:00:00 +0000
  • Spent ages trying to get close to this… gave up looking at what others had done, here is my version from scratch:

    <?xml version="1.0"?> 
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    	<modelVersion>4.0.0</modelVersion>
    	<groupId>....</groupId>
    	<artifactId>....</artifactId>
    	<version>1.0-SNAPSHOT</version>
    	<packaging>war</packaging>
    	<name>....</name>
    	<build>
            <plugins>
            	<plugin>
            		<groupId>org.apache.maven.plugins</groupId>
            		<artifactId>maven-compiler-plugin</artifactId>
            		<configuration>
            			<source>1.5</source>
            			<target>1.5</target> 
            		</configuration>
            	</plugin>
            	<plugin>
            		<groupId>org.mortbay.jetty</groupId>
            		<artifactId>maven-jetty-plugin</artifactId>
            		<version>6.1H.5-beta</version>
            		<configuration>
            			<contextPath>/</contextPath>
                        <scanIntervalSeconds>10</scanIntervalSeconds>                 
                    </configuration>
               </plugin>
           </plugins>
        </build>
        <dependencies>
            <dependency>
                <groupId>javax.faces</groupId>             
                <artifactId>jsf-api</artifactId>             
                <version>1.2-b19</version>         
            </dependency>         
            <dependency>             
                <groupId>javax.faces</groupId>             
                <artifactId>jsf-impl</artifactId>             
                <version>1.2-b19</version>         
            </dependency>         
            <dependency>             
                <groupId>com.sun.facelets</groupId>             
                <artifactId>jsf-facelets</artifactId>             
                <version>1.1.11</version>         
            </dependency>         
            <dependency>             
                <groupId>commons-digester</groupId>             
                <artifactId>commons-digester</artifactId>             
                <version>1.7</version>         
            </dependency>         
            <dependency>             
                <groupId>commons-beanutils</groupId>             
                <artifactId>commons-beanutils</artifactId>             
                <version>1.7.0</version>         
            </dependency>         
            <dependency>             
                <groupId>commons-collections</groupId>             
                <artifactId>commons-collections</artifactId>             
                <version>3.2</version>         
            </dependency>         
            <dependency>             
                <groupId>javax.servlet</groupId>             
                <artifactId>jstl</artifactId>             
                <version>1.1.0</version>         
            </dependency>         
            <dependency>             
                <groupId>javax.servlet</groupId>             
                <artifactId>servlet-api</artifactId>                 
                <version>2.5</version>             
                <scope>provided</scope>         
            </dependency>     
        </dependencies> 
    </project>
    
    Maven Created Thu, 23 Aug 2007 00:00:00 +0000
  • Working on this to add to EasyGloss.

    There are a number of rules that JPA entities must obey:

    • equals and hashCode must only be based on the persistent fields that are @Id annotated.
    • annotations must be applied to either fields or getters, no mix & match (although future versions of the spec may provide for such)
    • In general, getters and setters should be simple methods (i.e. no complex processing)

    I want to have a JPA Entity excerciser that will check these rules for you (and can be included in your unit tests)

    Java JavaEE Created Fri, 20 Jul 2007 00:00:00 +0000
  • I have been reading a book on C# recently, and it got me thinking about Java’s hashCode() in a little bit more detail than I had before.

    Consider the following Java class.

    public class Person {  
    	private String firstName;  
    	private String surname;  
    
    	public Person(String firstName, String surname) {    
    		this.firstName = firstName;    
    		this.surname = surname;  
    	}  
    
    	public boolean equals(Object other) {
    		/* proper equals checking firstName and surname */  
    	}  
    
    	public int hashCode() {
    		int code = surname.hashCode();
    		code = 31 * code + firstName.hashCode();    
    		return code; 
    	}  
    
    	public String getFirstName() { /* getter */ }  
    	public void setFirstName(String firstName) { /* setter */ } 
    	public String getSurname() { /* getter */ } 
    	public void setSurname(String surname) { /* setter */ }
    }
    

    What is wrong with the above? Ignore that the hash code may not be well designed given that names are usually A-Z only and the prime factor may not be the most efficient algorithm for calculating hash codes for our data set.

    Created Mon, 26 Feb 2007 00:00:00 +0000
  • Let’s have a look at some em.merge related fun.

    From discussions on a number of forums, here is my explanation for what goes on when you call em.merge.

    We will use the following classes as an example:

    @Entity
    public class Parent {
        // ...
        private List<Child> children;
        // ...    
        public List<Child> getChildren() { return this.children; }
        public void setChildren(List<Child> children) { this.children = children; }
        // ...
    }
    
    @Entity
    public class Child {
        // ...    
        private Parent parent;    
        // ...    
        public Parent getParent() { return this.parent; }    
        public void setParent(Parent parent) { this.parent = parent; }    
        // ...
    }
    

    To aid in understanding, we will assume that our client has a UserTransaction ut (this is to allow us to force entity instances to become detached. Entity instances can becomedetached without using a UserTransaction, however, we want to show what happens to the entities;

    Created Fri, 16 Jun 2006 00:00:00 +0000
  • Borys Burnayev has an interesting article with some useful ideas on testing annotated entities and EJB3 classes requiring injection to work.

    http://www-128.ibm.com/developerworks/java/library/j-ejb3jpa.html

    Created Thu, 13 Apr 2006 00:00:00 +0000
  • EasyGloss has been accepted as an incubator project on dev.java.net https://easygloss.dev.java.net/

    Created Wed, 12 Apr 2006 00:00:00 +0000