Refactoring Ideas: inline method with flag parameter

Check all calls to see if the value of the flag can be analysed, if so inline everywhere (otherwise tell the developer where it is ambiguous):

   public static String pad(final String string, final int length, final char character, final boolean before)
   {
      if(before)
      {
         return leftPad(string, length, character);
      }
      else
      {
         return rightPad(string, length, character);
      }
   }

Webhooks – event driven REST

From the site:

The concept of a Webhook is simple. A WebHook is an HTTP callback: an HTTP POST that occurs when something happens; a simple event-notification via HTTP POST.

A web application implementing WebHooks will POST a message to a URL when certain things happen. When a web application enables users to register their own URLs, the users can then extend, customize, and integrate that application with their own custom extensions or even with other applications around the web. For the user, WebHooks are a way to receive valuable information when it happens, rather than continually polling for that data and receiving nothing valuable most of the time.

Testing using FEST Swing in Jenkins

You can use the same trick as with cruise control (which actually originated from the hudson website)

java -DJENKINS_HOME=C:\Jenkins -jar C:\Jenkins\jenkins.war
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\AutoAdminLogon=1
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName=testuser
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultPassword=secret

Apache VFS Files Cache implemented using Guava CacheBuilder

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
 
import java.util.concurrent.TimeUnit;
 
import org.apache.commons.vfs2.FileName;
import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.FileSystem;
import org.apache.commons.vfs2.cache.AbstractFilesCache;
 
class GuavaFilesCache extends AbstractFilesCache
{
   static class CacheOfFilesystem
   {
      private final Cache<FileName, FileObject> files = CacheBuilder.newBuilder()
               .concurrencyLevel(4)
               .maximumSize(10000)
               .expireAfterWrite(10, TimeUnit.MINUTES)
               .build();
 
      public FileObject getFile(final FileName name)
      {
         return files.getIfPresent(name);
      }
 
      public void putFile(final FileObject file)
      {
         files.put(file.getName(), file);
      }
 
      public boolean putFileIfAbsent(final FileObject file)
      {
         return files.asMap().putIfAbsent(file.getName(), file) == null;
      }
 
      public void removeFile(final FileName name)
      {
         files.invalidate(name);
      }
   }
 
   private final LoadingCache<FileSystem, CacheOfFilesystem> filesystems = CacheBuilder.newBuilder()
         .concurrencyLevel(4)
         .maximumSize(10000)
         .expireAfterWrite(10, TimeUnit.MINUTES)
         .build(new CacheLoader<FileSystem, CacheOfFilesystem>(){
            @Override
            public CacheOfFilesystem load(@SuppressWarnings("unused") final FileSystem key) throws Exception
            {
               return new CacheOfFilesystem();
            }});
 
   @Override
   public void putFile(final FileObject file)
   {
      filesystems.getUnchecked(file.getFileSystem()).putFile(file);
   }
 
   @Override
   public boolean putFileIfAbsent(final FileObject file)
   {
      return filesystems.getUnchecked(file.getFileSystem()).putFileIfAbsent(file);
   }
 
   @Override
   public FileObject getFile(final FileSystem filesystem, final FileName name)
   {
      return filesystems.getUnchecked(filesystem).getFile(name);
   }
 
   @Override
   public void clear(final FileSystem filesystem)
   {
      filesystems.invalidate(filesystem);
   }
 
   @Override
   public void removeFile(final FileSystem filesystem, final FileName name)
   {
      filesystems.getUnchecked(filesystem).removeFile(name);
   }
}

Creating a Glassfish domain and run it as a Windows service

So, my on-going saga of ways to run glassfish as a service progresses to glassfish 3.1.1.

Here are the ant snippets I am using to create the glassfish domain and set it up to run as a windows service:

<exec executable="${glassfish.home}/bin/asadmin.bat" 
      failonerror="true" 
      output="${glassfish.home}/glassfish-create-domain.log"
      inputstring="AS_ADMIN_PASSWORD=${glassfish.admin.password}">   
   <arg value="--user"/>
   <arg value="${glassfish.admin.username}"/>
   <arg value="--passwordfile"/>
   <arg value="-"/>
   <arg value="create-domain"/>
   <arg value="--savelogin"/>
   <arg value="--checkports=false"/>
   <arg value="--adminport"/>
   <arg value="${glassfish.admin.port}"/>
   <arg value="--instanceport"/>
   <arg value="${glassfish.http.port}"/>
   <arg value="--domainproperties=jms.port=7676:domain.jmxPort=8686:orb.listener.port=3700:http.ssl.port=8181:orb.ssl.port=3820:orb.mutualauth.port=3920"/>
   <arg value="myDomain"/>
</exec>
<exec executable="${glassfish.home}/bin/asadmin.bat" 
      failonerror="true"
      output="${glassfish.home}/glassfish-create-service.log">
   <arg value="create-service"/>
   <arg value="--name"/>
   <arg value="MyServiceName"/>
   <arg value="myDomain"/>
</exec>