Skip to main content

GlassFish : Java EE Service Engine is now called sun-javaee-engine

Posted by bhavanishankar on June 2, 2007 at 10:36 PM PDT

 

Recently, the component name of the Java EE service engine is changed from "JavaEEServiceEngine" to "sun-javaee-engine". It is very easy for the end users to migrate their applications to the new name. All that is required is to open your existing JBI project in NetBeans, build and deploy.

These are the detailed steps:

1. Go to http://www.netbeans.org/community/releases/60/index.html
2. Click "Download Preview"
3. Select your platform and download "Full" version.
4. Open your JBI project with this new NetBeans, do a "Clean and Build Project" and "Deploy Project".

If you have Non-NetBeans projects, then the following program can be used to migrate your projects to the new name. You just need to compile it and run it. You can also modify this utility to server your purpose.

JBICompNameChangeUtil.java

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileFilter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class JBICompNameChangeUtil {
   
    private void printUsage() {
        System.err.println("Usage: java JBICompNameChangeUtil " +
                "");
        System.err.println("For example: java JBICompNameChangeUtil" +
                " /space/projects/jbi");
    }
   
    private void changeName(String... args) {
        if(args.length != 1) {
            printUsage();
            System.exit(1);
        }
       
        File root = new File(args[0]);
        if(!root.exists() || !root.isDirectory()) {
            printUsage();
            System.exit(1);
        }
        List fileList = new ArrayList();
        getAllImpactedFiles(root, fileList);
        for(Iterator i = fileList.iterator(); i.hasNext();) {
            File file = (File)i.next();
            try {
                updateFile(file);
            } catch(FileNotFoundException ex) {
                ex.printStackTrace();
            } catch(IOException ex) {
                ex.printStackTrace();
            }
        }
    }
   
    private void getAllImpactedFiles(File root, List fileList) {
        FileFilter myFileFilter = new FileFilter() {
            public boolean accept(File file) {
                if(file.isDirectory()) {
                    return true;
                } else {
                    String fileName = file.getName();
                    return fileName.equals("jbi.xml");
                }
            }
        };
        File files[] = root.listFiles(myFileFilter);
        File arr[] = files;
        int len = arr.length;
        for(int i = 0; i < len; i++) {
            File file = arr[i];
            if(file.isDirectory())
                getAllImpactedFiles(file, fileList);
            else
                fileList.add(file);
        }
    }
   
    private void updateFile(File file)
            throws FileNotFoundException, IOException {
        System.out.println((new StringBuilder()).append("Updating ").
                append(file.getPath()).append("...").toString());
        String fileName = file.getName();
        BufferedReader reader = new BufferedReader(new FileReader(file));
        File tempFile = File.createTempFile(fileName, "tmp");
        BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile));
        String line;
        if(fileName.equals("jbi.xml")) {
            while((line = reader.readLine()) != null) {
                line = updateSEName(line);
                writer.write((new StringBuilder()).append(line).
                        append(LINE_SEPARATOR).toString());
            }
        }
        writer.close();
        reader = new BufferedReader(new FileReader(tempFile));
        writer = new BufferedWriter(new FileWriter(file));
        while((line = reader.readLine()) != null)
            writer.write((new StringBuilder()).append(line).
                    append(LINE_SEPARATOR).toString());
        reader.close();
        writer.close();
        tempFile.delete();
    }
   
    private String updateSEName(String line) {
        if(line.indexOf("JavaEEServiceEngine") != -1)
            line = line.replace("JavaEEServiceEngine", "sun-javaee-engine");
        return line;
    }
   
    private static final String LINE_SEPARATOR =
            System.getProperty("line.separator");
   
    public static void main(String args[]) {
        JBICompNameChangeUtil instance =
                new JBICompNameChangeUtil();
        instance.changeName(args);
    }
   
}