Monday 28 July 2014

Java 7 : Exception handling

Highlights:

- Performs more precise and intelligent analysis while re-throwing the exception
- Improved type checking while throwing exception
- Simpler handling for more then one type of exceptions


Examples:

Please find below examples for exception handling for more clarification:

    /* Very generic exception handling in catch block , but precise handling in throws statement*/
     public void rethrowException(boolean flag) throws IOException,
    FileNotFoundException {
        try {
            if (flag) {
                throw new IOException();
            } else {
                throw new FileNotFoundException();
            }
        } catch (Exception e) {
            throw e;
        }
    }

/* No throw required for method , because it can analyze no exception thrown*/
    public void rethrowException() {
        try {
            try {
                throw new Exception();
            } catch (Exception e) {
            }
        } catch (Exception e1) {
            throw e1;
        }
    }
  

    /* Very generic exception handling in catch block , but precise handling in throws statement*/
    public static void rethrow() throws ParseException{
        try {
            new SimpleDateFormat("yyyyMMdd").parse("1");
        } catch (Exception e) {
            throw e;
        }
    }

Tuesday 7 January 2014

Minimize EXT framework download time on browser


EXT framework library(ext-all.js) was around 1.5MB and was taking around 30 seconds for first browser request to download the file which was freezing screen.

Even after enabling the gzip on tomcat server it was not making any effect.
The workaround is to create minimal footprint build using sencha commands.

Example:
sencha compile -classpath=my.js,../src concat -yui ext.js


More details on sencha command @ http://docs.sencha.com/extjs/4.2.2/#!/guide/command