template for java factory