VIRGIN FOREST OF JAVA
          不要埋頭苦干,要學習,學習,再學習。。。。。
          powered by R.Zeus
          PropertiesHelper.resolvePlaceHolders( copy );

          public static String resolvePlaceHolder(String property) {
          ??if ( property.indexOf( PLACEHOLDER_START ) < 0 ) {
          ???return property;
          ??}
          ??StringBuffer buff = new StringBuffer();
          ??char[] chars = property.toCharArray();
          ??for ( int pos = 0; pos < chars.length; pos++ ) {
          ???if ( chars[pos] == '$' ) {
          ????// peek ahead
          ????if ( chars[pos+1] == '{' ) {
          ?????// we have a placeholder, spin forward till we find the end
          ?????String systemPropertyName = "";
          ?????int x = pos + 2;
          ?????for (? ; x < chars.length && chars[x] != '}'; x++ ) {
          ??????systemPropertyName += chars[x];
          ??????// if we reach the end of the string w/o finding the
          ??????// matching end, that is an exception
          ??????if ( x == chars.length - 1 ) {
          ???????throw new IllegalArgumentException( "unmatched placeholder start [" + property + "]" );
          ??????}
          ?????}
          ?????String systemProperty = extractFromSystem( systemPropertyName );
          ?????buff.append( systemProperty == null ? "" : systemProperty );
          ?????pos = x + 1;
          ?????// make sure spinning forward did not put us past the end of the buffer...
          ?????if ( pos >= chars.length ) {
          ??????break;
          ?????}
          ????}
          ???}
          ???buff.append( chars[pos] );
          ??}
          ??String rtn = buff.toString();
          ??return StringHelper.isEmpty( rtn ) ? null : rtn;

          extractFromSystem( systemPropertyName )

          private static String extractFromSystem(String systemPropertyName) {
          ??try {
          ???return System.getProperty( systemPropertyName );
          ??}
          ??catch( Throwable t ) {
          ???return null;
          ??}
          ?}


          this properties can use in hibernate.cfg.xml
          posted on 2006-11-07 17:25 R.Zeus 閱讀(494) 評論(0)  編輯  收藏 所屬分類: Hibernate
          主站蜘蛛池模板: 怀仁县| 尉氏县| 渝中区| 策勒县| 阜宁县| 类乌齐县| 凤山市| 稻城县| 诏安县| 兴海县| 伊金霍洛旗| 宿松县| 遂川县| 新兴县| 许昌市| 阳新县| 赣榆县| 高阳县| 突泉县| 邯郸市| 吴忠市| 安乡县| 五河县| 邢台县| 西吉县| 广昌县| 新晃| 新野县| 伊金霍洛旗| 子洲县| 如东县| 射洪县| 碌曲县| 阳泉市| 乐山市| 桐梓县| 达州市| 都江堰市| 瑞丽市| 芦山县| 安宁市|