You don’t know what you’ve got till it’s gone

A lot has changed since I last wrote a blog post. One of the biggest changes career-wise has been a decision by the company I work for to move away from IBM Domino and switch to a different platform for all future and new development. We had already started the process of switching all our users to Office365 for email so keeping Domino around just didn’t make a lot of sense.

Thankfully I was given the reigns in deciding what direction we should move to in a post Domino world and given our skills in using Java because of XPages the decision was easy, or was it?

You really don’t know what you have got till it is gone, as the song lyrics go, because Domino provides so many capabilities out of the box, you have directory and security, you have application deployment via templates, automatic code building in the designer, a backend data store, a server to run it all on, containerized applications, pretty much everything you needed to build applications is available in Domino and replacing it is not an easy task.

I’ve decided to try and start blogging against so that I can share some of the journey and hopefully make it easier for anybody else facing the same road.

Tagged with: ,
Posted in Domino To Spring, Uncategorized

Hello… Hello… Is this thing still on?

Testing, Testing, One Two Three…

Posted in Uncategorized

Getting To The Java Roots of XPages – Part 14

Adding additional methods to an existing class by extending it is not the only thing that you can do with Extends. You can also override existing methods in the extended class. In our StaffInfo class the getInternetAddress will return a simple internet email address like jbloggs@somecorp.xyz but for your application you need it to look like ‘Joe Bloggs ‘.

Now you COULD create a new method just like the getReversedName() method in the last part but then you would have to go back to the application and change all the calls to getInternetAddress() to your new method name. Instead, however, you can create your own getInternetAddress() method in StaffInfoPlus.

    @Override
    public String getInternetAddress() {
	return getCommonName() + " ";
    }

The @Override is called a compiler annotation. It is not strictly needed and the above would work perfectly without it but it does help the compiler to know that we are overriding a method in the extended class ( and an warning will show if it comes to an @Override on a method that doesn’t exist in the extended class ).

After the annotation is our new version of the getInternetAddress() method. It is returning a string made up of the users common name, a space, an opening angle bracket, the users internet address and then a closing angle bracket.

Look closely at how we get the users internet address. I’m overriding the getInternetAddress() method but I also need to get the users internet address. To do this I use a special keyword called ‘super’. This tells the compiler that I want to call the version of this method in the class that I’m extending and not the version in this class.

So my StaffInfoPlus class has all the methods that exist in the StaffInfo class, plus my reversedName method and now, any call to getInternetAddress() will use the version in this class rather then the StaffInfo class that I’m extending.

This java stuff is not so scary after all…

Tagged with: ,
Posted in None

Getting To The Java Roots of XPages – Part 13

In todays part I’m going to talk about Extending a class in Java.

The concept is very simple, There is an existing class that does 90% of what you need it to do but your application needs some extra functionality to get it to 100%. If you have access to the code for the original class you could just add some additional methods to it to get that extra 10% but in a lot of cases you may not have that access or maybe you do have the access but that code is on a different update cycle and you need to get your application out the door quicker.

In this case we can create a new java class and tell it to extend the class that has the 90% of the code we need. The new class will inherit all of the methods of the extended class and then we can add our own methods as required.

Lets take a look at the following example

package scary.java.demo;

public class StaffInfoPlus extends StaffInfo {

    private static final long serialVersionUID = 1L;
    private String reversedName;
    
    public StaffInfoPlus() {
	
    }

    public String getReversedName() {
	if (reversedName == null) {
	    reversedName = getLastName() + " " + getFirstName();
 	}
        return reversedName;
    }

}

I’m creating a new class called StaffInfoPlus and I’m telling it to extend the previous class that we worked on called StaffInfo. In this class I’ve added one method called getReversedName which is very simply taking the person’s last name and first name and putting them into a simple string with a space between them and returning the value.

But where is it getting the last name and first name and how does it know what person we are dealing with? That is the beauty of extending a class. Our new class StaffInfoPlus has all the methods that StaffInfo has so I can call staffInfoPlus.load(employeename) and while the method doesn’t directly exist in StaffInfoPlus it does exist in StaffInfo and it will be run and all the variables loaded just like before. If I call StaffinfoPlus.getFirstName() then I’ll get the loaded employees first name. Therefore the calls to getlastName() and getFirstname() in the getReversedName() method are just calling those methods in StaffInfoPlus but because they don’t exist directly in that class they are really calling them the extended StaffInfo class.

Tagged with: ,
Posted in None
Archives