Archive for the “Software development” Category


I recently have been tasked with writing Java code to insert records into a SharePoint list, and I have been mildly successful, so I thought I’d share some of my experiences.

First, the important thing to know is that SharePoint’s API to stuff that’s not .NET is through Web Services.  SharePoint exposes a large number of Web Services for doing stuff with their tool, but for this particular assignment there were two of primary interest:  Lists and Views.

I’m a CXF guy (Axis2 works the same way), so to get started you get the WSDL, run WSDL2JAVA to generate a client and JAXB classes for the data types defined in the WSDL, and start going.

But here’s one part that really sucks:  The schema in the WSDL defines many of the objects as type ANY, so when you access their JAXB objects, they contain exactly one member called “content” of type List<Object>.  That’s right, you get back DOM nodes which you get to parse yourself.  If you thought you’d get some rich object model for marshalling and unmarshalling your requests to the web service, think again.   And not only do you get back lists of nodes as results — you get to build up a DOM for your requests too.

As I get more done, I will add more.  Stay tuned.

Comments 2 Comments »

I was recently writing a program to find classes that had a certain annotation on them:

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * This annotation works similarly to the @WebMethod
 * annotation. It is used to indicate that the annotated method is allowed to be
 * made visible on a generated facade, and how to do it.
 *
 */
@Target(ElementType.METHOD)
@Documented
@Retention(RetentionPolicy.RUNTIME)
public @interface FacadeMethod
{
	/**
	 * This is the operation name that the annotated object will have on the
	 * generated facade. This will be used as the value for
	 * operationName in the @WebMethod
	 * annotation as well as the name of the method in the facade.
	 *
	 * @return the name that the annotated object will have on the generated
	 *         facade
	 */
	String operationName();

	/**
	 * This is a description of the method which will be used to generate
	 * javadoc on the facade.
	 *
	 * @return a description of the method
	 */
	String description() default "";
}

Methods annotated with this method look something like this:

@FacadeMethod(operationName = "effectivelySame",
              description = "Return true if the two strings are identical, both null, "
                            + "or equivalent after converting to same case and trimming")
public static boolean effectivelySame(String s1, String s2) {
...

What I needed to do was look through a whole mess of jar files that weren’t in the classpath, looking for classes with methods annotated with this annotation, so I could read the operationName and the description properties of the annotation.

Read the rest of this entry »

Comments No Comments »

I’ve done something simple, yet cool and useful in our Ant builds to make them work a little nicer with Hudson.  I’ve modified things so our Jars/Wars get stamped with version control information from Hudson.  To do this, I take advantage of the fact that when Hudson starts an Ant build, it puts certain key values in the environment variables, so I grab them and stuff them into the manifests for the jars.

Read the rest of this entry »

Comments No Comments »

Well, this may turn a number of you off and make you think I’m some sort of Luddite or something, but I have come to a considered opinion:  I don’t really like Hibernate.

Before you consider me an ignorant fool, here are some of my reasons for you to consider (and I may add to this list over time): Read the rest of this entry »

Comments No Comments »

I was looking at some of the core language enhancements being considered for JDK 7.  Some of them look pretty good, others, meh.  Here are a few of the ones I’m looking forward to:

Constructor Inference for Generics

Using generics, your currently have to type both sides of an assignment when doing a constructor:

Map<String, List<String>> anagrams = new HashMap<String, List<String>>();

Being considered is the ability to omit the types and infer them, such as:

Map<String, List<String>> anagrams = new HashMap<>();

which would be equivalent to the first line.  I like this - improves readability, loses nothing but typing.

Relational operators for Enums

Currently, the only relational operators that you can use for constants in an Enum are == and !=.  Since all enums implicitly implement Comparable, theres no good reason why you should not be able to use <, >, <= and >= on enums.  As it stands now, you need to explicitly invoke compareTo().

Switches on Strings

Sure would be nice if instead of if-else if-else constructs to branch on string values, you could do

switch(someString) {
   case CONST_1:
      return true;
   case CONST_2:
      return false;
   default:
      throw new IllegalArgumentException("Bad value: " + s);
}

Comments No Comments »

Here is a great article from CIO magazine, in which Grady Booch (among other things, one of the Three Amigos who developed UML) discusses five things he has learned over his career about developing complex software systems.  Definitely worth a read.

Comments No Comments »

Are unit tests and unit testing on the decline?  Here is an interesting blog post that discusses this very question.

My $0.02:  Read the rest of this entry »

Comments No Comments »

This past week I burned up dozens of hours trying to make JBoss AOP work in my .WAR file.  Then I realized that I didn’t have to.

I have this application that is a WAR file full of web services.  What I wanted to do was create an aspect that I could weave in to gather usage statistics on every web service called — the user, the amount of time spent, whether it was successful or not, that sort of thing — and write it to a table for analysis and reporting.  Since we use JBoss as our application and web server (and a paid support contract), I decided to try JBoss AOP which is bundled with the Enterprise Application Platform.

So, I wrote my aspect, and started trying to hook it in.  Man, what an ordeal. Read the rest of this entry »

Comments 2 Comments »

Will Gorman has a post here about adopting Hudson at his place of work…

Comments No Comments »

As a contrast to my previous post regarding securing Subversion, I thought I would go through how to secure a Hudson installation using Active Directory for authentication and authorization.

Steps:

Read the rest of this entry »

Comments 3 Comments »