jdk/src/share/classes/javax/sql/rowset/spi/SyncFactory.java
changeset 22301 43e72ecb53b9
parent 18564 f9db68ff2cbb
child 22332 fba4c66089bb
equal deleted inserted replaced
22300:d669110735f4 22301:43e72ecb53b9
    33 
    33 
    34 import java.io.FileInputStream;
    34 import java.io.FileInputStream;
    35 import java.io.InputStream;
    35 import java.io.InputStream;
    36 import java.io.IOException;
    36 import java.io.IOException;
    37 import java.io.FileNotFoundException;
    37 import java.io.FileNotFoundException;
       
    38 import java.security.AccessController;
       
    39 import java.security.PrivilegedAction;
    38 
    40 
    39 import javax.naming.*;
    41 import javax.naming.*;
    40 
    42 
    41 /**
    43 /**
    42  * The Service Provider Interface (SPI) mechanism that generates <code>SyncProvider</code>
    44  * The Service Provider Interface (SPI) mechanism that generates <code>SyncProvider</code>
   346                 // keys will over-write
   348                 // keys will over-write
   347 
   349 
   348                 /*
   350                 /*
   349                  * Dependent on application
   351                  * Dependent on application
   350                  */
   352                  */
   351                 String strRowsetProperties = System.getProperty("rowset.properties");
   353                 String strRowsetProperties;
       
   354                 try {
       
   355                     strRowsetProperties = AccessController.doPrivileged(new PrivilegedAction<String>() {
       
   356                         public String run() {
       
   357                             return System.getProperty("rowset.properties");
       
   358                         }
       
   359                     }, null, new PropertyPermission("rowset.properties","read"));
       
   360                 } catch (Exception ex) {
       
   361                     strRowsetProperties = null;
       
   362                 }
       
   363 
   352                 if (strRowsetProperties != null) {
   364                 if (strRowsetProperties != null) {
   353                     // Load user's implementation of SyncProvider
   365                     // Load user's implementation of SyncProvider
   354                     // here. -Drowset.properties=/abc/def/pqr.txt
   366                     // here. -Drowset.properties=/abc/def/pqr.txt
   355                     ROWSET_PROPERTIES = strRowsetProperties;
   367                     ROWSET_PROPERTIES = strRowsetProperties;
   356                     try (FileInputStream fis = new FileInputStream(ROWSET_PROPERTIES)) {
   368                     try (FileInputStream fis = new FileInputStream(ROWSET_PROPERTIES)) {
   391             /*
   403             /*
   392              * Now deal with -Drowset.provider.classname
   404              * Now deal with -Drowset.provider.classname
   393              * load additional properties from -D command line
   405              * load additional properties from -D command line
   394              */
   406              */
   395             properties.clear();
   407             properties.clear();
   396             String providerImpls = System.getProperty(ROWSET_SYNC_PROVIDER);
   408             String providerImpls;
       
   409             try {
       
   410                 providerImpls = AccessController.doPrivileged(new PrivilegedAction<String>() {
       
   411                     public String run() {
       
   412                         return System.getProperty(ROWSET_SYNC_PROVIDER);
       
   413                     }
       
   414                 }, null, new PropertyPermission(ROWSET_SYNC_PROVIDER,"read"));
       
   415             } catch (Exception ex) {
       
   416                 providerImpls = null;
       
   417             }
   397 
   418 
   398             if (providerImpls != null) {
   419             if (providerImpls != null) {
   399                 int i = 0;
   420                 int i = 0;
   400                 if (providerImpls.indexOf(colon) > 0) {
   421                 if (providerImpls.indexOf(colon) > 0) {
   401                     StringTokenizer tokenizer = new StringTokenizer(providerImpls, colon);
   422                     StringTokenizer tokenizer = new StringTokenizer(providerImpls, colon);