JNDI学习(1)

以下是InitContext过程中要做的。

String getJndiProperty( final int i) {
   return (String) AccessController.doPrivileged(
         new PrivilegedAction() {
     public Object run() {
             try {
       return System.getProperty(PROPS[i]);
            } catch (SecurityException e) {
       return null;
            }
                 }
         }
  );
        }

        String[] getJndiProperties() {
   if (getSystemPropsFailed) {
         return null;   // after one failure, don't bother trying again
  }
  Properties sysProps = (Properties) AccessController.doPrivileged(
         new PrivilegedAction() {
     public Object run() {
             try {
       return System.getProperties();
            } catch (SecurityException e) {
      getSystemPropsFailed = true;
       return null;
            }
    }
         }
  );
   if (sysProps == null) {
         return null;
  }
  String[] jProps = new String[PROPS.length];
   for ( int i = 0; i < PROPS.length; i++) {
         jProps[i] = sysProps.getProperty(PROPS[i]);
  }
   return jProps;
        }


本文出自 “辽源大火的奋斗历程” 博客,谢绝转载!

你可能感兴趣的:(JNDI,学习,职场,休闲)