??xml version="1.0" encoding="utf-8" standalone="yes"?>欧美日韩1区2区,日本一区二区三区在线播放,亚洲缚视频在线观看http://www.aygfsteel.com/yjlongfei/zh-cnSat, 17 May 2025 00:18:42 GMTSat, 17 May 2025 00:18:42 GMT60inotify+rsync+ssh数据实时同步http://www.aygfsteel.com/yjlongfei/archive/2010/01/10/308940.html阳江头夜送客阳江头夜送客Sun, 10 Jan 2010 12:07:00 GMThttp://www.aygfsteel.com/yjlongfei/archive/2010/01/10/308940.htmlhttp://www.aygfsteel.com/yjlongfei/comments/308940.htmlhttp://www.aygfsteel.com/yjlongfei/archive/2010/01/10/308940.html#Feedback0http://www.aygfsteel.com/yjlongfei/comments/commentRss/308940.htmlhttp://www.aygfsteel.com/yjlongfei/services/trackbacks/308940.htmlInotify 是文件系l事件监控机Ӟ计划包含在即发布的 Linux 内核中作?dnotify 的有效替代。dnotify 是较早内核支持的文g监控机制。Inotify一U强大的、细_度的、异步的机制Q它满各种各样的文件监控需要,不仅限于安全和性能。下面让我们一起学习如何安?inotify 和如何构Z个示例用L间应用程序来响应文gpȝ事g?/p>

1.1同步工具安装
1、输入命令:su rootQ切换到用户?br /> 2、先查看linux的内核是否支持inotifyQ支持inotify的内核最ؓ2.6.13Q输入命令:uname –a。如下图所C,内核?.6.27Q支持inotifyQ?br />  
注:如果内核低于2.6.13Q请升内核或重新安装内核版本更高的linuxpȝ?br /> 3、徏立同步ssh信Q关系Q输入命令:cd $HOMEQ进入用h目录?br /> 输入命oQssh-keygen -t rsa (会出现几个提CZ息,一直按回R卛_)?br /> 会在 cd $HOME/.ssh/目录下生?个文件id_rsa、id_rsa.pub?br /> 输入命oQcp  id_rsa.pub  authorized_keysQ将id_rsa.pub拯成authorized_keys?br /> 授权密钥分发到iEPG服务?192.168.100.101)上,输入命oQ?br /> scp  ~/.ssh/authorized_keys root@192.168.100.101:/root/.ssh/
如果有多C载服务器Q每台都运行一ơ上面的密钥下发命o?br /> 4、通过如下命o查看pȝ是否支持inotifyQll /proc/sys/fs/inotify
如果有如下输出,表示pȝ内核已经支持inotifyQ?br /> total 0
-rw-r--r-- 1 root root 0 Feb 21 01:15 max_queued_events
-rw-r--r-- 1 root root 0 Feb 21 01:15 max_user_instances
-rw-r--r-- 1 root root 0 Feb 21 01:15 max_user_watches
5、取得Y件包inotify-tools-3.13.tar.gzQ放?tmp下?br /> 6、输入命令:tar zvxf inotify-tools-3.13.tar.gzQ解压Y件包?br /> 7、输入命令:cd inotify-tools-3.13Q进入解压后的目录?br /> 8、输入命令:./configure
9、输入命令:make
10、输入命令:make install
11、在pȝ下执行命令:man inotify?man inotifywait?man inotifywatch卛_得到相应的帮助信息,表示inotify安装成功?br /> 12、输入命令:rsyncQ查看rsync是否安装?br /> rsync一般是pȝ默认安装Q如果没有安装就取得软g包,安装Ҏ同inotify?/p>

同步脚本使用
1、取得syncapps.sh脚本

#!/bin/sh
    SRC=/root/sys/
    SEND=iEPGService.dat
    PID_FILE=syncapps.pid
    
    function sync_files
    {
       cat $SEND | while read DST 
       do
       rsync -avzq  --delete --exclude '/.version' --exclude '/.bak' $SRC $DST
       done
        
    }
    
    function inotify_func
    {
        inotifywait -mrq -e modify,delete,create ${SRC} | while read D E F;do
            # echo "$D : $E : $F"
            sync_files
        done
    }
    
    function stop
    {
        pkill inotifywait &>/dev/null && rm -f ${PID_FILE} &> /dev/null
    }
    
    case $1 in
        stop)
            echo -n "Stopping sync service"
            if [ -e ${PID_FILE} ]; then
                stop
                echo "Stopped"
                exit 0
            else
                echo "pid file not found"
                exit 2
            fi
            ;;
        start) 
            echo -n "Starting sync service"
            if [ -f ${PID_FILE} ] && ((`ps awux | grep -v grep | grep -c inotifywait`)); then
                echo " already running: pid file found ($PID_FILE) and an inotifywait process is running"
                exit 1
            elif [ -f ${PID_FILE} ]; then
                echo -n "(stale pid file)"
            fi                        
            
            sync_files
            inotify_func&
            
            pid="$!"
            ps --ppid $pid -o pid,cmd | grep inotifywait | awk '{print $1}' > ${PID_FILE}
            
            echo "Started"
            ;;
        restart)
            $0 stop
            $0 start
            exit 0
            ;;
        status)
            echo -n "Getting status for syncer service "
            pid=`cat ${PID_FILE} 2>/dev/null`
            if [ -f ${PID_FILE} ] && ((`ps awux | grep -v grep | egrep -c "$pid.*inotifywait"`)); then
                echo "running (pid $pid)"
                exit 0
            elif [ -f ${PID_FILE} ]; then
                echo "not runing (pid file found $pid)"
                exit 3
            elif ((`ps awux | grep -v grep | egrep -c "$pid.*inotifywait"`)); then
                echo "not running (inotifywait procs found)"
                exit 4
            else
                echo "not running"
                exit 5
            fi
            ;;
                    
        *)
            echo "Usage error"
            echo "Usage: $0 
<start|stop|restart|status>"
            ;;
    esac
2、取得iEPGService.dat脚本?br />   root@10.10.80.76:/root/files/
3、输入命令:chmod  +x  *.shQ给文g赋可执行权限?br /> 4、输入命令:./syncapps.sh startQ启动同步工兗?br /> 启动同步工具的输入命令:./syncapps.sh start
停止同步工具的输入命令:./syncapps.sh stop
重启同步工具的输入命令:./syncapps.sh restart
查看同步工具状态的输入命oQ?/syncapps.sh status
link

]]>
判断文g格式http://www.aygfsteel.com/yjlongfei/archive/2010/01/10/308936.html阳江头夜送客阳江头夜送客Sun, 10 Jan 2010 11:56:00 GMThttp://www.aygfsteel.com/yjlongfei/archive/2010/01/10/308936.htmlhttp://www.aygfsteel.com/yjlongfei/comments/308936.htmlhttp://www.aygfsteel.com/yjlongfei/archive/2010/01/10/308936.html#Feedback0http://www.aygfsteel.com/yjlongfei/comments/commentRss/308936.htmlhttp://www.aygfsteel.com/yjlongfei/services/trackbacks/308936.html首先阅读此文之前Q最好阅?br /> http://hi.baidu.com/maml897/blog/item/324bf86369961ed4e6113a5c.html

http://hi.baidu.com/maml897/blog/item/fa5f0a7e1edef00129388ae2.html

其次q要知道一点常识,是我们在记事本{一些文本工具中 写的都是字符Q没有谁会去写字节(可以写字节,但是要用LD的~辑器)Q但是其实,我们的写的是字符Q但盘上真实存储的是字节?/p>

q里出C转换的问题,当然Q这些问题记事本本n会帮助我们解冟뀂我们打开一个记事本Q然后文?-另存为,你会发现有几U存储格式供您选择Q?br /> ANSI格式Q就是ascii的格?br /> Unicode格式Q采用国际通用的编码存?br /> Unicode big endian格式Q这个和unicode有点区别Q但我也不明太具体的不同
UTF-8Q采用utf-8存储Q看q上面的两篇文章Q你会十分的了解q里介绍的编码。Utf-8Q是unicode的一U实现方式?/p>

例如我们在记事本里面输入“q?#8221;两个字?/p>

1.我们另存C本的时候,采用unicode存储Q那么虽然我们看到的字符q是“q?#8221;Q但是其实存储在盘上的字节 实
8FDEQ连Q?901A Q通)Q这个是规定的,unicode是国际上规定的,l世界上的每个字W分配的唯一~码。获取某个字W的unicode的方法,可以ȝ上查找,最单的ҎQ就是打开word文档Q输入字W,把光标移动到字符后面Q按alt+xQword会自动把字符转换成unicode~码Q这里呢我们也可以看刎ͼ用unicode存储汉字啊,每个汉字占用两个字节?/p>

2.我们另存C本的时候,采用utf-8存储Q虽然我们看到的字符q是“q?#8221;Q但是其实存储在盘上的字节 实已经变化了,q时候存储的?br /> E8 BF 9E Q连QE9 80 9AQ通)。这是utf-8的存储的~码Q至于utf-8Z么这样存储,你可以阅M面的两篇文章来了解,可以看到Qutf-8使用3个字节存储一个汉字?/p>

另外我们q要知道的就是:电脑怎么区分一个记事本是用什么存储的呢?
换句话说Qؓ什么我用unicode存储?FDEQ连Q?901A Q通)Q电脑就知道q是unicode~码Q从而用unicode解码Q还原ؓ“q?#8221;呢?电脑又怎么知道E8 BF 9E Q连QE9 80 9AQ通)q是按照utf-8的存储方式存储的呢?

q里有一Ҏ讎ͼ是在存储字节的时候,C本首先在最前面 标明Q这个记事本下面的存储格?是utf-8Q还是unicode?/p>

例如Q?/p>

1.unicode存储“q?#8221;。磁盘字节真实存储的其实是:

FF FE 8FDE 901A

前两个FF FE是标讎ͼ告诉电脑Q这个文档的存储方式是unicode

2.utf-8存储“q?#8221;。磁盘字节真实存储的其实是:

EF BB BF E8 BF 9E E9 80 9A

前三个EF BB BF 告诉电脑 q个文档是utf-8存储?/p>

Ҏ不同~码的特点和标志,对一个文本文件判断编码方法如?br /> 1  .  UTF7  所有字节的内容不会大于127,也就是不大于&HFF
2  .  UTF8  起始三个字节?0xEF 0xBB 0xBF"
3  .  UTF-16BE 起始三个字节?0xFE  0xFF"
4  .  UTF-16LE 起始三个字节?0xFF  0xFE"


import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;

public class FileEncodeReferee
{
    
private File file;
    
    
public FileEncodeReferee(File file)
    
{
        
this.file = file;
    }

    
    
public FileEncodeReferee(String path)
    
{
        file 
= new File(path);
    }

    
    
public String getCharset()
    
{
        File file 
= this.file;
        
        String charset 
= "GBK";
        
byte[] first3Bytes = new byte[3];
        BufferedInputStream bis 
= null;
        
try
        
{
            
//boolean checked = false;
            bis = new BufferedInputStream(new FileInputStream(file));
            bis.mark(
0);
            
int read = bis.read(first3Bytes, 03);
            
if (read == -1)
            
{
                
return charset;
            }

            
if (first3Bytes[0== (byte0xFF && first3Bytes[1== (byte0xFE)
            
{
                charset 
= "UTF-16LE";
                
//checked = true;
            }

            
else if (first3Bytes[0== (byte0xFE
                    
&& first3Bytes[1== (byte0xFF)
            
{
                charset 
= "UTF-16BE";
                
//checked = true;
            }

            
else if (first3Bytes[0== (byte0xEF
                    
&& first3Bytes[1== (byte0xBB
                    
&& first3Bytes[2== (byte0xBF)
            
{
                charset 
= "UTF-8";
                
//checked = true;
            }

            
/** */
            
/*******************************************************************
            * bis.reset(); if (!checked) { int loc = 0; while ((read =
            * bis.read()) != -1) { loc++; if (read >= 0xF0) { break; } if (0x80 <=
            * read && read <= 0xBF) // 单独出现BF以下的,也算是GBK { break; } if (0xC0 <=
            * read && read <= 0xDF) { read = bis.read(); if (0x80 <= read &&
            * read <= 0xBF)// 双字?nbsp;(0xC0 - 0xDF) { // (0x80 - 0xBF),也可能在GB~码?br />             * continue; } else { break; } } else if (0xE0 <= read && read <=
            * 0xEF) { // 也有可能出错Q但是几率较?nbsp;read = bis.read(); if (0x80 <= read &&
            * read <= 0xBF) { read = bis.read(); if (0x80 <= read && read <=
            * 0xBF) { charset = "UTF-8"; break; } else { break; } } else {
            * break; } } } System.out.println(loc + " " +
            * Integer.toHexString(read)); }
            *****************************************************************
*/

        }

        
catch (Exception e)
        
{
            e.printStackTrace();
        }

        
finally
        
{
            
if (bis != null)
            
{
                
try
                
{
                    bis.close();
                }

                
catch (Exception ex)
                
{
                    ex.printStackTrace();
                }

            }

        }

        
return charset;
    }

    
    
public static void main(String[] args)
    
{
        FileEncodeReferee fer 
= new FileEncodeReferee("F://锁表1.sql");
        System.out.println(fer.getCharset());
    }

}



]]>
net.sf.cglib.beans.BeanMap 重写toString()的用?/title><link>http://www.aygfsteel.com/yjlongfei/archive/2009/10/19/298898.html</link><dc:creator>阳江头夜送客</dc:creator><author>阳江头夜送客</author><pubDate>Mon, 19 Oct 2009 13:41:00 GMT</pubDate><guid>http://www.aygfsteel.com/yjlongfei/archive/2009/10/19/298898.html</guid><wfw:comment>http://www.aygfsteel.com/yjlongfei/comments/298898.html</wfw:comment><comments>http://www.aygfsteel.com/yjlongfei/archive/2009/10/19/298898.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/yjlongfei/comments/commentRss/298898.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/yjlongfei/services/trackbacks/298898.html</trackback:ping><description><![CDATA[在cglib ?BeanMap的用?br /> <br /> 1.导入cglib-nodep-2.1.3.jar<br />   <br /> 2.在javaBean 对象中重写toString()Ҏ  比如是UserManageVo.Java <br />  public String toString(){<br />   return BeanTools.getBeanDesc(UserManageVo.this);<br />  }<br /> java 代码<br /> <div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><span style="color: #008080"> 1</span><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /><span style="color: #0000ff">package</span><span style="color: #000000"> BeanUtils;<br /> </span><span style="color: #008080"> 2</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /><br /> </span><span style="color: #008080"> 3</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> net.sf.cglib.beans.BeanMap;<br /> </span><span style="color: #008080"> 4</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /><br /> </span><span style="color: #008080"> 5</span><span style="color: #000000"><img id="Codehighlighter1_79_1608_Open_Image" onclick="this.style.display='none'; Codehighlighter1_79_1608_Open_Text.style.display='none'; Codehighlighter1_79_1608_Closed_Image.style.display='inline'; Codehighlighter1_79_1608_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_79_1608_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_79_1608_Closed_Text.style.display='none'; Codehighlighter1_79_1608_Open_Image.style.display='inline'; Codehighlighter1_79_1608_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align="top" alt="" /></span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">class</span><span style="color: #000000"> BeanTools </span><span id="Codehighlighter1_79_1608_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_79_1608_Open_Text"><span style="color: #000000">{<br /> </span><span style="color: #008080"> 6</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />    </span><span style="color: #0000ff">private</span><span style="color: #000000"> </span><span style="color: #0000ff">static</span><span style="color: #000000"> String LINE </span><span style="color: #000000">=</span><span style="color: #000000"> System.getProperty(</span><span style="color: #000000">"</span><span style="color: #000000">line.separator</span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">"</span><span style="color: #000000">\r\n</span><span style="color: #000000">"</span><span style="color: #000000">);<br /> </span><span style="color: #008080"> 7</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" /><br /> </span><span style="color: #008080"> 8</span><span style="color: #000000"><img id="Codehighlighter1_161_247_Open_Image" onclick="this.style.display='none'; Codehighlighter1_161_247_Open_Text.style.display='none'; Codehighlighter1_161_247_Closed_Image.style.display='inline'; Codehighlighter1_161_247_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_161_247_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_161_247_Closed_Text.style.display='none'; Codehighlighter1_161_247_Open_Image.style.display='inline'; Codehighlighter1_161_247_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />    </span><span id="Codehighlighter1_161_247_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff">/** */</span><span id="Codehighlighter1_161_247_Open_Text"><span style="color: #008000">/**</span><span style="color: #008000"><br /> </span><span style="color: #008080"> 9</span><span style="color: #008000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />     * 对象中重写toString()Ҏ,在打印日志的时候调?br /> </span><span style="color: #008080">10</span><span style="color: #008000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />     * </span><span style="color: #808080">@param</span><span style="color: #008000"> obj<br /> </span><span style="color: #008080">11</span><span style="color: #008000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />     * </span><span style="color: #808080">@return</span><span style="color: #008000"><br /> </span><span style="color: #008080">12</span><span style="color: #008000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />     * </span><span style="color: #808080">@return</span><span style="color: #008000"> String<br /> </span><span style="color: #008080">13</span><span style="color: #008000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />     </span><span style="color: #008000">*/</span></span><span style="color: #000000"><br /> </span><span style="color: #008080">14</span><span style="color: #000000"><img id="Codehighlighter1_295_1606_Open_Image" onclick="this.style.display='none'; Codehighlighter1_295_1606_Open_Text.style.display='none'; Codehighlighter1_295_1606_Closed_Image.style.display='inline'; Codehighlighter1_295_1606_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_295_1606_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_295_1606_Closed_Text.style.display='none'; Codehighlighter1_295_1606_Open_Image.style.display='inline'; Codehighlighter1_295_1606_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />    </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">static</span><span style="color: #000000"> String getBeanDesc(Object obj) </span><span id="Codehighlighter1_295_1606_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_295_1606_Open_Text"><span style="color: #000000">{<br /> </span><span style="color: #008080">15</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        StringBuffer bf </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> StringBuffer();<br /> </span><span style="color: #008080">16</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        bf.append(LINE </span><span style="color: #000000">+</span><span style="color: #000000"> </span><span style="color: #000000">"</span><span style="color: #000000">{</span><span style="color: #000000">"</span><span style="color: #000000"> </span><span style="color: #000000">+</span><span style="color: #000000"> LINE </span><span style="color: #000000">+</span><span style="color: #000000"> </span><span style="color: #000000">"</span><span style="color: #000000">Class = </span><span style="color: #000000">"</span><span style="color: #000000"> </span><span style="color: #000000">+</span><span style="color: #000000"> obj.getClass().getName()<br /> </span><span style="color: #008080">17</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                </span><span style="color: #000000">+</span><span style="color: #000000"> LINE);<br /> </span><span style="color: #008080">18</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        BeanMap beanMap </span><span style="color: #000000">=</span><span style="color: #000000"> BeanMap.create(obj);<br /> </span><span style="color: #008080">19</span><span style="color: #000000"><img id="Codehighlighter1_502_1561_Open_Image" onclick="this.style.display='none'; Codehighlighter1_502_1561_Open_Text.style.display='none'; Codehighlighter1_502_1561_Closed_Image.style.display='inline'; Codehighlighter1_502_1561_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_502_1561_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_502_1561_Closed_Text.style.display='none'; Codehighlighter1_502_1561_Open_Image.style.display='inline'; Codehighlighter1_502_1561_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">for</span><span style="color: #000000"> (Object object : beanMap.keySet()) </span><span id="Codehighlighter1_502_1561_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_502_1561_Open_Text"><span style="color: #000000">{<br /> </span><span style="color: #008080">20</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />            Object value </span><span style="color: #000000">=</span><span style="color: #000000"> beanMap.get(object);<br /> </span><span style="color: #008080">21</span><span style="color: #000000"><img id="Codehighlighter1_565_1512_Open_Image" onclick="this.style.display='none'; Codehighlighter1_565_1512_Open_Text.style.display='none'; Codehighlighter1_565_1512_Closed_Image.style.display='inline'; Codehighlighter1_565_1512_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_565_1512_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_565_1512_Closed_Text.style.display='none'; Codehighlighter1_565_1512_Open_Image.style.display='inline'; Codehighlighter1_565_1512_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />            </span><span style="color: #0000ff">if</span><span style="color: #000000"> (</span><span style="color: #0000ff">null</span><span style="color: #000000"> </span><span style="color: #000000">!=</span><span style="color: #000000"> value) </span><span id="Codehighlighter1_565_1512_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_565_1512_Open_Text"><span style="color: #000000">{<br /> </span><span style="color: #008080">22</span><span style="color: #000000"><img id="Codehighlighter1_571_601_Open_Image" onclick="this.style.display='none'; Codehighlighter1_571_601_Open_Text.style.display='none'; Codehighlighter1_571_601_Closed_Image.style.display='inline'; Codehighlighter1_571_601_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_571_601_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_571_601_Closed_Text.style.display='none'; Codehighlighter1_571_601_Open_Image.style.display='inline'; Codehighlighter1_571_601_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />                </span><span id="Codehighlighter1_571_601_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff">/** */</span><span id="Codehighlighter1_571_601_Open_Text"><span style="color: #008000">/**</span><span style="color: #008000"><br /> </span><span style="color: #008080">23</span><span style="color: #008000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                 * q是定义对象的是时候用?br /> </span><span style="color: #008080">24</span><span style="color: #008000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />                 </span><span style="color: #008000">*/</span></span><span style="color: #000000"><br /> </span><span style="color: #008080">25</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                String className </span><span style="color: #000000">=</span><span style="color: #000000"> value.getClass().getName();<br /> </span><span style="color: #008080">26</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                </span><span style="color: #0000ff">if</span><span style="color: #000000"> (className.startsWith(</span><span style="color: #000000">"</span><span style="color: #000000">test.UserManageEvent</span><span style="color: #000000">"</span><span style="color: #000000">)<br /> </span><span style="color: #008080">27</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                        </span><span style="color: #000000">||</span><span style="color: #000000"> className.startsWith(</span><span style="color: #000000">"</span><span style="color: #000000">test.BasicEvent</span><span style="color: #000000">"</span><span style="color: #000000">)<br /> </span><span style="color: #008080">28</span><span style="color: #000000"><img id="Codehighlighter1_808_874_Open_Image" onclick="this.style.display='none'; Codehighlighter1_808_874_Open_Text.style.display='none'; Codehighlighter1_808_874_Closed_Image.style.display='inline'; Codehighlighter1_808_874_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_808_874_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_808_874_Closed_Text.style.display='none'; Codehighlighter1_808_874_Open_Image.style.display='inline'; Codehighlighter1_808_874_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />                        </span><span style="color: #000000">||</span><span style="color: #000000"> className.startsWith(</span><span style="color: #000000">"</span><span style="color: #000000">test.UserManageVo</span><span style="color: #000000">"</span><span style="color: #000000">)) </span><span id="Codehighlighter1_808_874_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_808_874_Open_Text"><span style="color: #000000">{<br /> </span><span style="color: #008080">29</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                    bf.append(object </span><span style="color: #000000">+</span><span style="color: #000000"> </span><span style="color: #000000">"</span><span style="color: #000000"> = </span><span style="color: #000000">"</span><span style="color: #000000"> </span><span style="color: #000000">+</span><span style="color: #000000"> getBeanDesc(value) </span><span style="color: #000000">+</span><span style="color: #000000"> LINE);<br /> </span><span style="color: #008080">30</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />                }</span></span><span style="color: #000000"><br /> </span><span style="color: #008080">31</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" /><br /> </span><span style="color: #008080">32</span><span style="color: #000000"><img id="Codehighlighter1_881_911_Open_Image" onclick="this.style.display='none'; Codehighlighter1_881_911_Open_Text.style.display='none'; Codehighlighter1_881_911_Closed_Image.style.display='inline'; Codehighlighter1_881_911_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_881_911_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_881_911_Closed_Text.style.display='none'; Codehighlighter1_881_911_Open_Image.style.display='inline'; Codehighlighter1_881_911_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />                </span><span id="Codehighlighter1_881_911_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff">/** */</span><span id="Codehighlighter1_881_911_Open_Text"><span style="color: #008000">/**</span><span style="color: #008000"><br /> </span><span style="color: #008080">33</span><span style="color: #008000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                 * q是数组对象的是时候用?br /> </span><span style="color: #008080">34</span><span style="color: #008000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />                 </span><span style="color: #008000">*/</span></span><span style="color: #000000"><br /> </span><span style="color: #008080">35</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                </span><span style="color: #0000ff">if</span><span style="color: #000000"> (className.startsWith(</span><span style="color: #000000">"</span><span style="color: #000000">Ltest.UserManageEvent</span><span style="color: #000000">"</span><span style="color: #000000">)<br /> </span><span style="color: #008080">36</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                        </span><span style="color: #000000">||</span><span style="color: #000000"> className.startsWith(</span><span style="color: #000000">"</span><span style="color: #000000">Ltest.BasicEvent</span><span style="color: #000000">"</span><span style="color: #000000">)<br /> </span><span style="color: #008080">37</span><span style="color: #000000"><img id="Codehighlighter1_1070_1230_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1070_1230_Open_Text.style.display='none'; Codehighlighter1_1070_1230_Closed_Image.style.display='inline'; Codehighlighter1_1070_1230_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_1070_1230_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_1070_1230_Closed_Text.style.display='none'; Codehighlighter1_1070_1230_Open_Image.style.display='inline'; Codehighlighter1_1070_1230_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />                        </span><span style="color: #000000">||</span><span style="color: #000000"> className.startsWith(</span><span style="color: #000000">"</span><span style="color: #000000">Ltest.UserManageVo</span><span style="color: #000000">"</span><span style="color: #000000">)) </span><span id="Codehighlighter1_1070_1230_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_1070_1230_Open_Text"><span style="color: #000000">{<br /> </span><span style="color: #008080">38</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                    Object[] objs </span><span style="color: #000000">=</span><span style="color: #000000"> (Object[]) value;<br /> </span><span style="color: #008080">39</span><span style="color: #000000"><img id="Codehighlighter1_1154_1224_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1154_1224_Open_Text.style.display='none'; Codehighlighter1_1154_1224_Closed_Image.style.display='inline'; Codehighlighter1_1154_1224_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_1154_1224_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_1154_1224_Closed_Text.style.display='none'; Codehighlighter1_1154_1224_Open_Image.style.display='inline'; Codehighlighter1_1154_1224_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />                    </span><span style="color: #0000ff">for</span><span style="color: #000000"> (</span><span style="color: #0000ff">int</span><span style="color: #000000"> i </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">0</span><span style="color: #000000">; i </span><span style="color: #000000"><</span><span style="color: #000000"> objs.length; i</span><span style="color: #000000">++</span><span style="color: #000000">) </span><span id="Codehighlighter1_1154_1224_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_1154_1224_Open_Text"><span style="color: #000000">{<br /> </span><span style="color: #008080">40</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                        bf.append(object </span><span style="color: #000000">+</span><span style="color: #000000"> </span><span style="color: #000000">"</span><span style="color: #000000"> = </span><span style="color: #000000">"</span><span style="color: #000000"> </span><span style="color: #000000">+</span><span style="color: #000000"> getBeanDesc(objs[i]) </span><span style="color: #000000">+</span><span style="color: #000000"> LINE);<br /> </span><span style="color: #008080">41</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />                    }</span></span><span style="color: #000000"><br /> </span><span style="color: #008080">42</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />                }</span></span><span style="color: #000000"><br /> </span><span style="color: #008080">43</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                <br /> </span><span style="color: #008080">44</span><span style="color: #000000"><img id="Codehighlighter1_1241_1282_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1241_1282_Open_Text.style.display='none'; Codehighlighter1_1241_1282_Closed_Image.style.display='inline'; Codehighlighter1_1241_1282_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_1241_1282_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_1241_1282_Closed_Text.style.display='none'; Codehighlighter1_1241_1282_Open_Image.style.display='inline'; Codehighlighter1_1241_1282_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />                </span><span id="Codehighlighter1_1241_1282_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff">/** */</span><span id="Codehighlighter1_1241_1282_Open_Text"><span style="color: #008000">/**</span><span style="color: #008000"><br /> </span><span style="color: #008080">45</span><span style="color: #008000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                 * 对String数组重写toString()Ҏ<br /> </span><span style="color: #008080">46</span><span style="color: #008000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />                 </span><span style="color: #008000">*/</span></span><span style="color: #000000"><br /> </span><span style="color: #008080">47</span><span style="color: #000000"><img id="Codehighlighter1_1336_1507_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1336_1507_Open_Text.style.display='none'; Codehighlighter1_1336_1507_Closed_Image.style.display='inline'; Codehighlighter1_1336_1507_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_1336_1507_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_1336_1507_Closed_Text.style.display='none'; Codehighlighter1_1336_1507_Open_Image.style.display='inline'; Codehighlighter1_1336_1507_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />                </span><span style="color: #0000ff">if</span><span style="color: #000000"> (className.startsWith(</span><span style="color: #000000">"</span><span style="color: #000000">[Ljava.lang.String</span><span style="color: #000000">"</span><span style="color: #000000">)) </span><span id="Codehighlighter1_1336_1507_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_1336_1507_Open_Text"><span style="color: #000000">{<br /> </span><span style="color: #008080">48</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                    Object[] objs </span><span style="color: #000000">=</span><span style="color: #000000"> (Object[]) value;<br /> </span><span style="color: #008080">49</span><span style="color: #000000"><img id="Codehighlighter1_1420_1501_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1420_1501_Open_Text.style.display='none'; Codehighlighter1_1420_1501_Closed_Image.style.display='inline'; Codehighlighter1_1420_1501_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_1420_1501_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_1420_1501_Closed_Text.style.display='none'; Codehighlighter1_1420_1501_Open_Image.style.display='inline'; Codehighlighter1_1420_1501_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />                    </span><span style="color: #0000ff">for</span><span style="color: #000000"> (</span><span style="color: #0000ff">int</span><span style="color: #000000"> i </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">0</span><span style="color: #000000">; i </span><span style="color: #000000"><</span><span style="color: #000000"> objs.length; i</span><span style="color: #000000">++</span><span style="color: #000000">) </span><span id="Codehighlighter1_1420_1501_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_1420_1501_Open_Text"><span style="color: #000000">{<br /> </span><span style="color: #008080">50</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                        bf.append(object </span><span style="color: #000000">+</span><span style="color: #000000"> </span><span style="color: #000000">"</span><span style="color: #000000">[</span><span style="color: #000000">"</span><span style="color: #000000"> </span><span style="color: #000000">+</span><span style="color: #000000"> i </span><span style="color: #000000">+</span><span style="color: #000000"> </span><span style="color: #000000">"</span><span style="color: #000000">]</span><span style="color: #000000">"</span><span style="color: #000000"> </span><span style="color: #000000">+</span><span style="color: #000000"> </span><span style="color: #000000">"</span><span style="color: #000000"> = </span><span style="color: #000000">"</span><span style="color: #000000"> </span><span style="color: #000000">+</span><span style="color: #000000"> objs[i]<br /> </span><span style="color: #008080">51</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                                </span><span style="color: #000000">+</span><span style="color: #000000"> LINE);<br /> </span><span style="color: #008080">52</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />                    }</span></span><span style="color: #000000"><br /> </span><span style="color: #008080">53</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />                }</span></span><span style="color: #000000"><br /> </span><span style="color: #008080">54</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />            }</span></span><span style="color: #000000"><br /> </span><span style="color: #008080">55</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />            bf.append(object </span><span style="color: #000000">+</span><span style="color: #000000"> </span><span style="color: #000000">"</span><span style="color: #000000"> = </span><span style="color: #000000">"</span><span style="color: #000000"> </span><span style="color: #000000">+</span><span style="color: #000000"> value </span><span style="color: #000000">+</span><span style="color: #000000"> LINE);<br /> </span><span style="color: #008080">56</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />        }</span></span><span style="color: #000000"><br /> </span><span style="color: #008080">57</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        bf.append(</span><span style="color: #000000">"</span><span style="color: #000000">}</span><span style="color: #000000">"</span><span style="color: #000000">);<br /> </span><span style="color: #008080">58</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">return</span><span style="color: #000000"> bf.toString();<br /> </span><span style="color: #008080">59</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />    }</span></span><span style="color: #000000"><br /> </span><span style="color: #008080">60</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" alt="" />}</span></span></div> <br /> java代码<br /> <a href="/Files/yjlongfei/beanUtil.rar">/Files/yjlongfei/beanUtil.rar</a> <img src ="http://www.aygfsteel.com/yjlongfei/aggbug/298898.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/yjlongfei/" target="_blank">阳江头夜送客</a> 2009-10-19 21:41 <a href="http://www.aygfsteel.com/yjlongfei/archive/2009/10/19/298898.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>BeanUtils.copyProperties() 用法http://www.aygfsteel.com/yjlongfei/archive/2009/10/19/298894.html阳江头夜送客阳江头夜送客Mon, 19 Oct 2009 13:21:00 GMThttp://www.aygfsteel.com/yjlongfei/archive/2009/10/19/298894.htmlhttp://www.aygfsteel.com/yjlongfei/comments/298894.htmlhttp://www.aygfsteel.com/yjlongfei/archive/2009/10/19/298894.html#Feedback0http://www.aygfsteel.com/yjlongfei/comments/commentRss/298894.htmlhttp://www.aygfsteel.com/yjlongfei/services/trackbacks/298894.html一、简介:

        BeanUtils提供对Java反射和自省API的包装。其主要目的是利用反机制对JavaBean的属性进行处理。我们知道,一个JavaBean通常包含了大量的属性,很多情况下,对JavaBean的处理导致大量get/set代码堆积Q增加了代码长度和阅M码的隑ֺ?/span>

二、用法:

        如果你有两个h很多相同属性的JavaBeanQ我们对一个对象copy 到另外一个对象,可用用下面的Ҏ?br />
1. 导入commons-beanutils.jar
2. 导入commons-logging-1.1.jar
3. 构徏UserManageVo , UserManageEvent 对象 ,q两个对象的属性相?br /> 4. 调用 BeanUtils.copyProperties(UserManageVo, UserManageEvent)
 java 主要代码

 1import java.lang.reflect.InvocationTargetException;
 2import org.apache.commons.beanutils.BeanUtils;
 3import test.BasicEvent;
 4import test.UserManageEvent;
 5import test.UserManageVo;
 6
 7public class TestCase {
 8    
 9    public static void main(String[] args) {
10        UserManageEvent event = new UserManageEvent();
11        event.setName("zhangsan");
12        event.setUserId("1");
13        
14        BasicEvent basicEvt = new BasicEvent();
15        basicEvt.setEventId("2");
16        basicEvt.setVersion("version");
17        
18        event.setEvent(basicEvt);
19        UserManageVo vo = new UserManageVo();
20        try {
21            BeanUtils.copyProperties(vo, event);
22            System.out.println(vo.getUserId());
23            System.out.println(vo.getName());
24            System.out.println(vo.getEvent());
25        }
 catch (IllegalAccessException e) {
26            e.printStackTrace();
27        }
 catch (InvocationTargetException e) {
28            e.printStackTrace();
29        }
 
30    }

31}


java代码Q?br /> /Files/yjlongfei/test.rar



]]>
MyEclipse6.5上基于JAX-WS开发Webservice(中文CZ)http://www.aygfsteel.com/yjlongfei/archive/2009/10/17/298714.html阳江头夜送客阳江头夜送客Sat, 17 Oct 2009 14:50:00 GMThttp://www.aygfsteel.com/yjlongfei/archive/2009/10/17/298714.htmlhttp://www.aygfsteel.com/yjlongfei/comments/298714.htmlhttp://www.aygfsteel.com/yjlongfei/archive/2009/10/17/298714.html#Feedback6http://www.aygfsteel.com/yjlongfei/comments/commentRss/298714.htmlhttp://www.aygfsteel.com/yjlongfei/services/trackbacks/298714.html关键? webservice

1. Introduction
This document will outline the process of developing a JAX-WS web service and deploying it using MyEclipse 6.5 to the internal MyEclipse Tomcat server. The web service used in this tutorial will be a very simple calculator service that provides add, subtract, multiply and divide operations to the caller.

MyEclipse also supports developing web services using the existing XFire framework from previous MyEclipse releases. For folks needing to develop and deploy WebSphere JAX-RPC or WebSphere JAX-WS web services, please take a look at our MyEclipse Blue Edition of the MyEclipse IDE.

Additional resources covering web service creation using JAX-RPC, JAX-WS or XFire are included in the Resources section of this document.


2. System Requirements
This tutorial was created with MyEclipse 6.5. If you are using another version of MyEclipse (possibly newer), most of these screens and instructions should still be very similar.

If you are using a newer version of MyEclipse and notice portions of this tutorial looking different than the screens you are seeing, please let us know and we will make sure to resolve any inconsistencies.

3.新徏一个工E?
开始我们新Z个Web Service Project工程File->New->Web Service Project(Optional Maven Support)

 
Note:A JAX-WS web service can also be generated in any existing Java EE 5 web project.

我们l这个工E取名ؓWebServiceProject.注意JAX-WS支持只在javaEE5或更高版本的工程中是可行的。如果你需要用低版本的工E类?java1.4或?.3)Q那么只能用XFire Web Service代替JAX-WS?

 

q里我们使用上面的JAX—WS?
4.创徏服务c?
服务cd是一个普通的javac,负责提供我们惌发布的执行方法。这里我们写一个简单的计算器类Q实现几个典型的计算器应用方法,如加减乘除?
首先我们先徏一个包QWebServiceProject->src->new->package,取名com.myeclipseide.ws

让后我们在这个包下徏一个类,Calculator.java.


Ҏ上面提到的,q个计算器类实现计算器的加减乘除法Q简单实玎ͼ
Java代码

package com.myeclipseide.ws; 

public class Calculator 
public int add(int a, int b) 
return (a + b); 
}
 

public int subtract(int a, int b) 
return (a - b); 
}
 

public int multiply(int a, int b) 
return (a * b); 
}
 

public int divide(int a, int b) 
return (a / b); 
}
 
}
 


可以看出Q这个类中的Ҏ是非常简单的Q没有用到特D的注释q有接口Q父cMcȝ东西?
5.创徏一个Web Service
在上面的工具条中点击新徏Web Service

NoteQ如果没有的话可以File->New->others->Myeclipse->WebService->webService
点击之后出现的屏q,在Strategy中选择Bottom-up scenarioQ因为我们已l徏立好了Calculatorc而且x据它建立JAX-WS服务?br />

下面是创建的最后一个屏q,你需要选择提供webServiceҎ的javaBeanQ在我们q个例子中就是我们已l徏立好的CalculatorcR?br />

填好之后QMyeclipse会自动帮我们填满其他的项QSelect Generate WSDL in project and hit Finish.


点击完成之后QMyeclipse会自动生成CalculatorDelegate代理c,q有一些必ȝJAX-WS描述W,而且会自动在服务器目录下的web.xml中配|WebService的一些mappingsQ方便将webService部v到服务器中?

到此web service已经建立好了Q我们开始部|它然后q行试?
6.部v和测试webService?
q里我们不用用Myeclipse自带的tomcat服务器,使用自己应经在电脑中部v好的tomcat5.5?
在server面板中右击,选择configure


部v自己的tomcat注意选择jdk要跟目中的相同?

现在要向工程中导入JAX-WS的jar?
在项目名UC叛_->properties->Add Library->Myeclipse Libraries->最后面的两个?

点击完成Q导入成功?
NoteQMyeclipse自带的tomcat中有自带的这两个jar包,可以不用导入?

6.1部v
在部|好的tomcat服务器上叛_选择Add Deployment


点击完成?
6.2试
q行tomcat服务器,在工h中点击launch WebService Explorer

打开后,点击右上角的WSDL视图Q可以看C面的屏幕

在WSDL URL中填写\径:http://localhost:8888/WebServiceProject/CalculatorPort?WSDL
解释下\径组成:
http://localhost:8888/是服务器的\径,我的端口h8888Q可以根据自q更改Q一般都?080?
/WebServiceProject = We know by default the Web Context-root that is used to deploy(部v) web projects matches the name of the projects. (因ؓ我们没有个工E自定义我们的Web Context-rootQ所以他是q个工程的名?
/CalculatorPort = As we saw from the last screenshot in Section #5, when our JAX-WS web service was generated, it was bound using a servlet-mapping in the web.xml file to the /CalculatorPort path.
XML代码
  

<servlet>     
    
<description>JAX-WS endpoint - CalculatorService</description>     
    
<display-name>CalculatorService</display-name>     
    
<servlet-name>CalculatorService</servlet-name>     
    
<servlet-class>     
        com.sun.xml.ws.transport.http.servlet.WSServlet      
    
</servlet-class>     
    
<load-on-startup>1</load-on-startup>     
  
</servlet>     
  
<servlet-mapping>     
    
<servlet-name>CalculatorService</servlet-name>     
    
<url-pattern>/CalculatorPort</url-pattern>     
  
</servlet-mapping>    
<servlet>  
    
<description>JAX-WS endpoint - CalculatorService</description>  
    
<display-name>CalculatorService</display-name>  
    
<servlet-name>CalculatorService</servlet-name>  
    
<servlet-class>  
        com.sun.xml.ws.transport.http.servlet.WSServlet   
    
</servlet-class>  
    
<load-on-startup>1</load-on-startup>  
  
</servlet>  
  
<servlet-mapping>  
    
<servlet-name>CalculatorService</servlet-name>  
    
<url-pattern>/CalculatorPort</url-pattern>  
  
</servlet-mapping>

 WSDL = This is a universal query string argument that can be added to the end of any web service which will tell the web service to return it's full WSDL to the caller. In this case, the WSDL is returned to our Web Services Explorer tool which loads it up, and displays the web services exposed operations to us.
弄清楚之后,我们开始测试,比如我们选择addҎQ?
填写argsQ点击goQ在status中就会显C结果?nbsp; 

l果是正的?
7.创徏Webservice Client
现在我们已经部v好WebserviceQ而且应经试q了Q那我们新徏一个Webservice clientQ来调用Webservice提供的方法?
7.1新徏一个java projectQ给他取个名字。比如我们叫它ClientofWebService


在工h中点击new Web Service Client

然后按照以下步骤操作Q?


The last step of the web service client creation is to specify either a WSDL File or a WSDL URL for the wizard to retrieve the web service WSDL from. In our case we are using the URL and generate the client into the new package com.myeclipseide.ws.client:

http://localhost:8888/WebServiceProject/CalculatorPort?WSDL


点击Next知道完成?
可以看到在新建的java project ClientofWebService中,src文g夹下产生了许多的文gQ根据名U我们大体可以了解其意思,可以打开看一下源代码Q其实不隄解。比如add文gQ就是CalculatorcMaddҎ的两个参数的get和setҎ。其他类伹{?
我们在文件夹下见一个类test.java写一个main函数试
Java代码     

public static void main(String[] args) {    
    
/* Create the service instance */    
    CalculatorService service 
= new CalculatorService();    
    CalculatorDelegate delegate 
= service.getCalculatorPort();    
  
    
/* Using the web service, perform the 4 calculations */    
    System.out.println( 
"1. 3+7=" + delegate.add(37));    
    System.out.println( 
"2. 12-2=" + delegate.subtract(122));    
    System.out.println( 
"3. 9*9=" + delegate.multiply(99));    
    System.out.println( 
"4. 40/2=" + delegate.divide(402));    
}
   

 q行得到如下l果Q?
1. 3+7=10
2. 12-2=10
3. 9*9=81
4. 40/2=20
试完成?

本文来自CSDN博客Q{载请标明出处Qhttp://blog.csdn.net/foart/archive/2009/06/21/4287515.aspx



]]>
վ֩ģ壺 Ͳ| | | | ͤ| ѷ| ͭ| | Ϫ| | ̫| | | Ѿ| | | | | ͷ| | ԣ| º| | ̶| | | ˳| | | | | | | Ƹ| | | | | | Ƥ| |