jakarta-bsf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sanka Samaranayke <ssa...@gmail.com>
Subject Re: [patch] BSFManager see contents...
Date Sat, 02 Sep 2006 18:58:23 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Applied.

Thanks,
Sanka

Kev Jackson wrote:
> Hi,
>
> A small amount of refactoring to conform to the Java coding
> conventions: - } catch () { - use Iterator interface instead of
> get(i) - use : for(Enumeration e = vector.enumeration();
> e.hasMoreElements();)
>
> instead of Enumeration e = vector.enumeration();
> while(e.hasMoreElements()) { [reduces scope of enumeration variable
> to the site where it is used] - remove extraneous newlines - don't
> create a StringTokenizer to extract to strings, use substring +
> indexOf
>
> patch file included
>
> Kev
>
> ----------------------------------------------------------------------
>
>
> Index: .
> ===================================================================
>  --- .    (revision 438751) +++ .    (working copy) @@ -25,6 +25,7 @@
> import java.security.PrivilegedExceptionAction; import
> java.util.Enumeration; import java.util.Hashtable; +import
> java.util.Iterator; import java.util.MissingResourceException;
> import java.util.NoSuchElementException; import
> java.util.Properties; @@ -114,16 +115,13 @@ Properties p = new
> Properties(); p.load(is);
>
> -                Enumeration keys = p.propertyNames(); -
> while (keys.hasMoreElements()) { +                for (Enumeration
> keys = p.propertyNames(); keys.hasMoreElements();) { String key =
> (String) keys.nextElement(); String value = p.getProperty(key); - -
> StringTokenizer tokens = new StringTokenizer(value, ","); -
> String className = (String) tokens.nextToken(); +
> String className = value.substring(0, value.indexOf(","));
>
> // get the extensions for this language -                    String
> exts = (String) tokens.nextToken(); +                    String
> exts = value.substring(value.indexOf(",")+1, value.length());
> StringTokenizer st = new StringTokenizer(exts, "|"); String[]
> extensions = new String[st.countTokens()]; for (int i = 0;
> st.hasMoreTokens(); i++) { @@ -133,16 +131,13 @@
> registerScriptingEngine(key, className, extensions); } } -        }
>  -        catch (IOException ex) { +        } catch (IOException
> ex) { ex.printStackTrace(); System.err.println("Error reading
> Languages file " + ex); -        } -        catch
> (NoSuchElementException nsee) { +        } catch
> (NoSuchElementException nsee) { nsee.printStackTrace();
> System.err.println("Syntax error in Languages resource bundle"); -
> } -        catch (MissingResourceException mre) { +        } catch
> (MissingResourceException mre) { mre.printStackTrace();
> System.err.println("Initialization error: " + mre.toString()); } @@
> -163,8 +158,7 @@ *      &quot;dd&quot; two digit day. * @since
> 2006-01-17 */ -    public static String getVersion() -    { +
> public static String getVersion() { return version; }
>
> @@ -210,8 +204,7 @@ } }); result = resultf; -        } -
> catch (PrivilegedActionException prive) { +        } catch
> (PrivilegedActionException prive) { logger.error("Exception: ",
> prive); throw (BSFException) prive.getException(); } @@ -263,8
> +256,7 @@ return null; } }); -        } -        catch
> (PrivilegedActionException prive) { +        } catch
> (PrivilegedActionException prive) { logger.error("Exception :",
> prive); throw (BSFException) prive.getException(); } @@ -306,8
> +298,7 @@ return null; } }); -        } -        catch
> (PrivilegedActionException prive) { +        } catch
> (PrivilegedActionException prive) { logger.error("Exception :",
> prive); throw (BSFException) prive.getException(); } @@ -350,8
> +341,7 @@ return null; } }); -        } -        catch
> (PrivilegedActionException prive) { +        } catch
> (PrivilegedActionException prive) { logger.error("Exception :",
> prive); throw (BSFException) prive.getException(); } @@ -439,8
> +429,7 @@ } }); result = resultf; -        } -        catch
> (PrivilegedActionException prive) { +        } catch
> (PrivilegedActionException prive) { logger.error("Exception: ",
> prive); throw (BSFException) prive.getException(); } @@ -487,8
> +476,7 @@ return null; } }); -        } -        catch
> (PrivilegedActionException prive) { +        } catch
> (PrivilegedActionException prive) { logger.error("Exception :",
> prive); throw (BSFException) prive.getException(); } @@ -527,8
> +515,7 @@ return null; } }); -        } -        catch
> (PrivilegedActionException prive) { +        } catch
> (PrivilegedActionException prive) { logger.error("Exception :",
> prive); throw (BSFException) prive.getException(); } @@ -550,8
> +537,7 @@ if (classPath == null) { try { classPath =
> System.getProperty("java.class.path"); -            } -
> catch (Throwable t) { +            } catch (Throwable t) {
> logger.debug("Exception :", t); // prolly a security exception ..
> so no can do } @@ -577,8 +563,9 @@
>
> if (dotIndex != -1) { String extn = fileName.substring(dotIndex +
> 1); -            String langval = (String) extn2Lang.get(extn),
> lang = null; -            int index = 0, loops = 0; +
> String langval = (String) extn2Lang.get(extn); +            String
> lang = null; +            int index, loops = 0;
>
> if (langval != null) { while ((index = langval.indexOf(":", 0)) !=
> -1) { @@ -594,8 +581,7 @@ String engineName = (String)
> registeredEngines.get(lang); Class.forName(engineName); -
> } -                    catch (ClassNotFoundException cnfe) { +
> } catch (ClassNotFoundException cnfe) { // Bummer. lang = langval;
> continue; @@ -604,7 +590,7 @@ // Got past that? Good. break; } -
> if (loops == 0) lang = langval; +                if (loops == 0) {
> lang = langval; } }
>
> if (lang != null && lang != "") { @@ -700,12 +686,10 @@
> loadedEngines.put(lang, eng); pcs.addPropertyChangeListener(eng);
> return eng; -        } -        catch (PrivilegedActionException
> prive) { +        } catch (PrivilegedActionException prive) {
> logger.error("Exception :", prive); throw (BSFException)
> prive.getException(); -        } -        catch (Throwable t) { +
> } catch (Throwable t) { logger.error("Exception :", t); throw new
> BSFException(BSFException.REASON_OTHER_ERROR, "unable to load
> language: " + lang, @@ -726,8 +710,7 @@
>
> try { return
> ((BSFDeclaredBean)objectRegistry.lookup(beanName)).bean; -        }
>  -        catch (IllegalArgumentException e) { +        } catch
> (IllegalArgumentException e) { logger.debug("Exception :", e);
> return null; } @@ -747,8 +730,7 @@
>
> if(bean == null) { tempBean = new BSFDeclaredBean(beanName, null,
> null); -        } -        else { +        } else { tempBean = new
> BSFDeclaredBean(beanName, bean, bean.getClass()); }
> objectRegistry.register(beanName, tempBean); @@ -871,8 +853,8 @@
>
> BSFDeclaredBean tempBean = null; boolean found = false; -
> for (int i = 0; i < declaredBeans.size(); i++) { -
> tempBean = (BSFDeclaredBean) declaredBeans.elementAt(i); +
> for (Iterator i = declaredBeans.iterator(); i.hasNext();) { +
> tempBean = (BSFDeclaredBean) i.next(); if
> (tempBean.name.equals(beanName)) { found = true; break; @@ -900,4
> +882,4 @@
>
> objectRegistry.unregister(beanName); } -} +} \ No newline at end of
> file
>
>
> ----------------------------------------------------------------------
>
>
> ---------------------------------------------------------------------
>  To unsubscribe, e-mail: bsf-dev-unsubscribe@jakarta.apache.org For
> additional commands, e-mail: bsf-dev-help@jakarta.apache.org


- --
Sanka Samaranayake
WSO2 Inc.
T:+94-77-3506382 F:+94-11-2424304

http://sankas.blogspot.com/
http://www.wso2.net/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (GNU/Linux)

iD8DBQFE+dRO/Hd0ETKdgNIRArx6AJ9n31ajmkfzeKeMkfUfK/e18embxQCgmN79
Yh2rCs92oHKTayPD78FHecI=
=Ek0Z
-----END PGP SIGNATURE-----


---------------------------------------------------------------------
To unsubscribe, e-mail: bsf-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bsf-dev-help@jakarta.apache.org


Mime
View raw message