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
          主站蜘蛛池模板: 遵义市| 曲沃县| 钦州市| 栾城县| 普定县| 北安市| 尼勒克县| 舟曲县| 英德市| 陇川县| 武功县| 扶余县| 四子王旗| 汶上县| 会昌县| 延寿县| 大同县| 万全县| 应用必备| 兴海县| 惠水县| 清远市| 黎川县| 乌海市| 深泽县| 云阳县| 上虞市| 兴仁县| 永泰县| 安泽县| 康定县| 武乡县| 南漳县| 诸暨市| 化州市| 洛南县| 集安市| 延津县| 龙川县| 美姑县| 镇康县|