你要理解一下Java中对对象的引用,
每个引用都用它的作用域,
如果你没有付给其他的引用,
它就会在“适当”的时候释放,要是你做了Object o2=o1,
则o2和o1一样指向同一个地址空间,
需要就o2赋为null,垃圾收集器才会考虑回收该区域。

解决方案 »

  1.   

    不需要,o1 = null当然这样更好,“只有那些没有任何对象实例引用的内存空间才会被JVM所垃圾收集”是指当一个对象没有任何对象事例引用的时候才回收,反过来说,当一个对象有事例引用的时候就不能回收,这是很正常的啊,至于“如果有一个变量实例, 在创建时分配了一定的内存空间, 如果在对象在使用完毕后却没有并清除, 那么此对象所指向的内存空间就永远不会被JVM所垃圾收集”,这是不对的Java的垃圾收集就是做清除工作的,怎么会不清除呢?只要垃圾收集器发现一个对象没有任何事例引用,它都会清楚,只不过清除的时间不一定,他不同于C++如果C++用完不调用西够函数到是会产生内存泄露。
      

  2.   

    to  study_body(珍惜每一天)
    在垃圾收集器要收集一片内存空间前, 不管这种垃圾收集器是采用那种运作方式, 它都需要判断这片内存是否有对象所引用,如果有一个引用话, 难道垃圾收集器还会回收这片内存空间吗?难道垃圾收集器还会判断到底是这个对象本身还是有另外的对象在引用这边内存吗?
      

  3.   

    to netwebs(netwebs:  
    在我看来, 当我的程序运行结束以后, 在我的内存监视器上表明系统并没有完全释放到运行我的程序时所消耗的内存, 我想这除了内存被泄漏以外并没有其它的解释!
      小生也不敢说自己的理解就是正确的, 所以才会到CSDN来请大家指教是否正确和它的解决方法。  如果你觉得内存泄漏有其它的含义, 可以提出来大家一起研究一下,用不着对小生摆出这么高的姿态吧!
      

  4.   

    摘:在讨论java的垃圾收集机制时,reachable(可达性)常用来描述正在使用的对象。其思想就是,在内存中的活动对象组成一个巨大的相互关联的网,网中的任何对象都可以通过网中的其他的活动的对象到达。如果有一个对象,不能从任何对象到达它,则该对象unreachable,此时它所占有的空间就可以被收集。
      

  5.   

    小生同意JackJia 的理解, 如果有一个对象不可达,那么其所占用的空间当然就可以被收集, 这应该是JVM 的垃圾收集器的运作方式。 但是从理论上进行的理解, 小生还想知道的是, JVM是怎么判断一个对象是处于这种不可达的状态的?  能不能再程序中控制一个对象使之可以被JVM所内存收集, 比如
    Object o1 = new Object(), 在o1 使用完毕后,我可以不可以强制这个对象被JVM所垃圾收集? 如果我令o1 = null, 那么JVM 在开始垃圾收集时是不是就会收集这个o1 对象?
      

  6.   

    内存泄漏的最明显的表现就是程序运行时出现“非法操作”对话框(你访问了不该访问的内存区,即超出了系统分配给你的内存堆范围)。刚开始看这个帖子的名字很好奇,我想:Java也会内存泄漏吗?原来你们所谓的“泄漏”是这样的。
      

  7.   

    java 回收机制 处理不了的情况有 socket连接对象和数据库连接对象
    需要你显示的调用close等方法,否则永远存在该对象的连接
    即便你已完全不用
      

  8.   

    to  allen_zh
    不错, 在程序的运行期间所消耗的内存的确会不断增大, 并且在程序结束时也不能还原到原来的内存值, 所以我才觉得除了内存被泄漏之外没有其他的解释。
    但我翻了一些关于JVM垃圾收集的资料, 大多数只是说明了JVM GC的一些运作机制, 而不能对我的疑惑给一个比较清楚的解散, 所以才会到这里来请教大家?
      

  9.   

    看thinking in java 里面写的很清楚的。
      

  10.   

    To: wugng(我苦苦的追寻我的梦!) 推荐你用Optimizeit(Borland有试用下载,或者jb8里也带)分析一下,这个东东挺好用的。
    祝好运!:-)
      

  11.   

    com中通过应用计数实现对象的自动释放
    java也可以有类似的机制
    因此java可以判断一个对象是不是还在继续被引用
      

  12.   

    我找到一个很不错的编程,网络安全论坛!~~~~
    http://www.yiii.net/app/club/
    太多经典文章了~~~~看都看不过来了
    吐血推荐!~~~
      

  13.   

    你对垃圾回收的理解不够准确。Garbage Collection当然不会完全杜绝内存泄漏的发生,它只是自动能将不再使用的内存回收,重用。 Garbage Collection解决了过早释放内存的问题(另一个指向对象的reference还在使用中),简化了忘记释放内存的问题。简单的说garbage collector是一个由runtime system在背后运行的低优先级的线程,它会自动跟踪已分配的内存空间,并可以判断内存是否被使用。当它发现内存不再被live thread(可以理解为别的代码)引用时,内存将被释放。“如果有一个对象不可达,那么其所占用的空间当然就可以被收集。” 正确的说法是,如果有一个对象不可达unrechable,它符合垃圾回收的条件,仅此而已。你不能确定垃圾回收的时间,甚至不能确定它一定会被回收。判断unreachable的两个方法,一个是将object reference设为null,令一个是将reference指向另外不同的对象。
    Garbage Collection不能强制(force),只能建议(suggest) 。使用System.gc(), 可以建议JVM执行GC, 但你不能确定垃圾回收的确定时间。
    所以在你的例子中, O1 = null 只表示O1符合垃圾回收的条件,对于垃圾回收的时间不可知。 由于垃圾回收的时间不确定,那么JVM 在开始某次垃圾收集时不一定会收集这个o1 对象。
      

  14.   

    建议看看《Thinking in java se》的第四章的垃圾回收器介绍!
      

  15.   

    o2=o1就是o2引用o1引用的内存空间。当你不再有引用指向o1时,o1引用的内存空间就会被回收。^_^再深入,就有所谓的强引用和弱引用了(这个是关于JVM实现时的理论,当然系统提供了访问借口可以自己控制的^_^)。
      

  16.   


    内存泄漏,非常正确,就是内存泄漏! 
    bloodmelon(背后的空间) 说得非常好。不过“如果有一个对象不可达,那么其所占用的空间当然就可以被收集。” 
    所谓“可以”,就是指可以被收集,但并不一定会被收集。
      

  17.   

    垃圾收集
    - 不再需要的分配存储器应取消分配
    - 在其它语言中,取消分配是程序员的责任
    - Java编程语言提供了一种系统级线程以跟踪存储区分配
    - 垃圾收集
    - .可检查和释放不再需要的存储器
    - .可自动完成上述工作
    - .可在JVM实现周期中,产生意想不到的变化
        Java编程语言解除了程序员取消分配存储器的责任,它可提供一种系统级线程以跟踪每一存储器的分配情况。在Java虚拟机的空闲周期,垃圾收集线程检查并释放那些可被释放的存储器。
        垃圾收集在Java技术程序的生命周期中自动进行,它解除了取消分配存储器的要求,并避免了存储器漏洞。然而,垃圾收集可在JVM实现的周期中,产生意想不到的变化。
      

  18.   

    在windows下(因为其他的操作系统不熟悉):
    内存泄漏是指在程序运行期间的内存泄漏
    操作系统会管理资源
    因为操作系统会在程序开始时和运行时会应程序的要求分配资源,包括从堆中建立对象,程序结束后操作系统会全部回收这些资源。所以,一般来讲,程序退出后内存就释放了,不会出现内存泄漏
    但我们操作系统的内存会渐渐减少,系统会变慢,这是什么原因呢,我想其中有一个很大原因就是内存碎片,而不是什么内存泄漏。
    我用C++试过,我动态分配了400M的内存没有释放,结果程序一退出,操作系统就给释放了,内存在程序退出后并没有减少400M,1M也没有减少。
    所以说:内存泄漏是指在程序运行期间的内存泄漏。
    内存泄漏有时不是那么很严重,只有比较严重的内存泄漏和大量的内存泄漏才会导致程序出错。用C++编程时要特别注意,养成自己释放内存的好习惯,
    这样就可以避免大量的和比较严重的内存泄漏,即使有那么一点点地泄漏,也不会影响程序的运行(当然内存泄漏引发的问题比较隐蔽,既然知道那里有泄漏,就应该修改他)。
    而在java中内存泄漏的机会就极少了,因为这些工作JVM替你做了。毫不夸张的说,想故意在JAVA中搞内存泄漏都特别难。你想想,声名一个变量或对象,而这个变量名一退出这个过程生存期就满了,即使你将这个对象引用在集合中,但只要这个集合的生存期满了,这个集合包括这个对象就被释放。
    你的代码:
    Object o1 = new Obejct(); 
    凡是变量和对象都有一个生存期的概念,上面的o1虽然你没有释放,但一旦他的生存期到了,而这个对象又没有其他的变量在引用,则这个对象就不是可达的了,这时这个对象就可以回收了
    别告诉我你不知道生存期的概念
      

  19.   

    1:什么叫内存泄漏
    内存泄漏指得是对内存块的指针的遗失。
    也就是说,你的分配了一块空间并用一个指针指向它,而在程序运行到所有指向该内存块的指针变量失效前,你没有释放该内存块。2:现在你就该明白,并非在程序运行期间存在逻辑上无用而可回收的内存块,就叫有lick. 
    Java的机制保证了对你的程序而言绝对不存在lick.
    但如果你希望提前回收那些 逻辑上无用而可回收的内存块,你必须用你的逻辑去显式清除和所有和其相关联的指针。
      

  20.   

    就我的理解,下面这个类一旦被创建,就永远不会被释放,除了虚拟机被停掉。class Test 
    {
        private Test my = null;
        public Test() {
            my = this;
        }
    }
      

  21.   

    照我的理解,JAVA和DELPHI一样,都是基于对象的引用模型,不同的是DELPI创建的对象(除了你使用接口方式创建的以外)需要自己手工清理,而JAVA的它会自己检测你生成的对象具体有多少个引用,当引用数为零时,它会建议,注意,是建议系统对此资源进行回收,当然了,当系统比较忙或是其它什么情况时,系统可以不理睬这个建议,这部分内存我想,也就相当于没有回收回来了,当然,这种情况比较少出现。但还是会出现。
      

  22.   

    to Commandor(Are you Crazy?) :"....当系统比较忙或是其它什么情况时..."此时系统比较忙,如果是需要更多的内存时,而有一些资源正好可以进行回收而又没有回收时,它就会先将可以回收的内存回收,然后再进行程序,否则俄内存不足,程序无法正常运行。而且,不管是什么时候回收,总之它都会回收,如果程序不忙时,它确实可以不忙着回收,具体什么时候回收,不同的JVM有不同的方式。
      

  23.   

    说一说我碰到的一点问题吧
    过去用java写gui的时候,发现写出来的程序内存占用很厉害,有时用xx=null人为释放了一些对象,在jbuilder里面用调试器观察时发现这些对象还是没有消失,有时这些对象不断积累还会造成文件句柄不够用;这些对象是netscape ldap sdk通过xxxxfactory.getInstance(..)创建的;
    还有swing,也有这种现象,窗口关闭了,也用了xx=null,但是有时就是会出现内存不足。
    不过退出jvm后,操作系统还是可以释放内存的。
      

  24.   

    转贴
    When you switch from a language with manual memory management, such as C or C++, to a
    garbage-collected language, your job as a programmer is made much easier by the fact that
    your objects are automatically reclaimed when you're through with them. It seems almost like
    magic when you first experience it. It can easily lead to the impression that you don't have to
    think about memory management, but this isn't quite true.
    Consider the following simple stack implementation:// Can you spot the "memory leak"?public class Stack {
        private Object[] elements;
        private int size = 0;
        public Stack(int initialCapacity) {
            this.elements = new Object[initialCapacity];
        }    public void push(Object e) {
            ensureCapacity();
            elements[size++] = e;
        }    public Object pop() {
            if (size == 0)
            throw new EmptyStackException();
            return elements[--size];
        }
    /**
    * Ensure space for at least one more element, roughly
    * doubling the capacity each time the array needs to grow.
    */
        private void ensureCapacity() {
            if (elements.length == size) {
            Object[] oldElements = elements;
                elements = new Object[2 * elements.length + 1];
                System.arraycopy(oldElements, 0, elements, 0, size);
            }
        }
    }
      

  25.   

    There's nothing obviously wrong with this program. You could test it exhaustively, and it
    would pass every test with flying colors, but there's a problem lurking. Loosely speaking, the
    program has a “memory leak,” which can silently manifest itself as reduced performance due
    to increased garbage collector activity or increased memory footprint. In extreme cases, such
    memory leaks can cause disk paging and even program failure with an OutOfMemoryError,
    but such failures are relatively rare.
    So where is the memory leak? If a stack grows and then shrinks, the objects that were popped
    off the stack will not be garbage collected, even if the program using the stack has no more
    references to them. This is because the stack maintains obsolete references to these objects.
    An obsolete reference is simply a reference that will never be dereferenced again. In this case,
    any references outside of the “active portion” of the element array are obsolete. The active
    portion consists of the elements whose index is less than size.
    Memory leaks in garbage collected languages (more properly known as unintentional object
    retentions) are insidious. If an object reference is unintentionally retained, not only is that
    object excluded from garbage collection, but so too are any objects referenced by that object,
    and so on. Even if only a few object references are unintentionally retained, many, many
    objects may be prevented from being garbage collected, with potentially large effects on
    performance.
    The fix for this sort of problem is simple: Merely null out references once they become
    obsolete. In the case of our Stack class, the reference to an item becomes obsolete as soon as
    it's popped off the stack. The corrected version of the pop method looks like this:
    public Object pop() {
        if (size==0)
        throw new EmptyStackException();
        Object result = elements[--size];
        elements[size] = null; // Eliminate obsolete reference
        return result;
    }
    An added benefit of nulling out obsolete references is that, if they are subsequently
    dereferenced by mistake, the program will immediately fail with a NullPointerException,
    rather than quietly doing the wrong thing. It is always beneficial to detect programming errors
    as quickly as possible.
      

  26.   

    When programmers are first stung by a problem like this, they tend to overcompensate by
    nulling out every object reference as soon as the program is finished with it. This is neither
    necessary nor desirable as it clutters up the program unnecessarily and could conceivably
    reduce performance. Nulling out object references should be the exception rather than the
    norm. The best way to eliminate an obsolete reference is to reuse the variable in which it was
    contained or to let it fall out of scope. This occurs naturally if you define each variable in the
    narrowest possible scope (Item 29). It should be noted that on present day JVM
    implementations, it is not sufficient merely to exit the block in which a variable is defined;
    one must exit the containing method in order for the reference to vanish.
    So when should you null out a reference? What aspect of the Stack class makes it susceptible
    to memory leaks? Simply put, the Stack class manages its own memory. The storage pool
    consists of the elements of the items array (the object reference cells, not the objects
    themselves). The elements in the active portion of the array (as defined earlier) are allocated,
    and those in the remainder of the array are free. The garbage collector has no way of knowing
    this; to the garbage collector, all of the object references in the items array are equally valid.
    Only the programmer knows that the inactive portion of the array is unimportant. The
    programmer effectively communicates this fact to the garbage collector by manually nulling
    out array elements as soon as they become part of the inactive portion.
    Generally speaking, whenever a class manages its own memory, the programmer should be
    alert for memory leaks. Whenever an element is freed, any object references contained in the
    element should be nulled out.
    Another common source of memory leaks is caches. Once you put an object reference into a
    cache, it's easy to forget that it's there and leave it in the cache long after it becomes
    irrelevant. There are two possible solutions to this problem. If you're lucky enough to be
    implementing a cache wherein an entry is relevant exactly so long as there are references to
    its key outside of the cache, represent the cache as a WeakHashMap; entries will be removed
    automatically after they become obsolete. More commonly, the period during which a cache
    entry is relevant is not well defined, with entries becoming less valuable over time. Under
    these circumstances, the cache should occasionally be cleansed of entries that have fallen into
    disuse. This cleaning can be done by a background thread (perhaps via the java.util.Timer
    API) or as a side effect of adding new entries to the cache. The java.util.LinkedHashMap
    class, added in release 1.4, facilitates the latter approach with its removeEldestEntry
    method.
    Because memory leaks typically do not manifest themselves as obvious failures, they may
    remain present in a system for years. They are typically discovered only as a result of careful
    code inspection or with the aid of a debugging tool known as a heap profiler. Therefore it is
    very desirable to learn to anticipate problems like this before they occur and prevent them
    from happening
      

  27.   

    to JackJia():
    请将我的话全部合在起来理解,gc()执行后,只是建议VM执行资源回收,VM完全有可能并不立即采纳这一建议!因为完全有可能这时系统正忙于繁重的计算,它的调度系统可以要求先将当前任务完全后再说,当然,如果这时系统系统内存不够,当然会进行一些内存的回收,但这时候也不一定就非要收集刚才执行gc()的资源。我同时也认为JAVA中,你永远无法明确界定出你指定的资源何时进行回收,
      

  28.   

    在 java 中不会产生内存泄露。jvm会自动回收资源。
      

  29.   

    多谢大家发言,小生以前对垃圾收集的概念的确有些偏差。 
    事实上, 小生的程序是一个部署在WebLogic上的Web应用, 在使用LoadRunner进行并发的多用户的大数据量测试时, 发现随着访问量的增大, 系统的内存也逐渐减少, 这时程序并没有结束,并且当访问量到达一个临界点时,程序就down掉了,故小生认为这是个内存泄漏。 
    之后通过使用Optimizeit 进行观察, 发现在程序被访问期间,所使用到的对象在某个时间内会被清除到0, 但在访问结束后(没有down掉之前),却并没有被完全释放到0。 确如各位所说Garbage Collection不能强制,只能建议, 并且系统可能由于当前繁忙的任务,并不理会这个建议。 也就是即使这个对象到达了垃圾收集的条件,你也无法控制JVM究竟在什么时候对垃圾进行回收。那末各位有没有遇到过像小生这样的情况呢,小生认为这应该是对象内存管理方面的原因, 各位有没有这方面的经验呀!! 请再指教!
      

  30.   

    <!-- edited with XML Spy v3.0 NT (http://www.xmlspy.com) by abc (appeon) -->
    <ADTConfig>
    <DeveloperID id="1"/>
    <TempDir name="C:\Program Files\Appeon\ADT\"/>
    <Applications default="appeon_code_example">
    <Application name="sales_application_demo" PBLsinProject="1" WebRoot="salesapplicationdemo" DBMS="ODBC" Database="" ServerName="AppeonSample" LogID="dba" LogPass="sql" UserID="" DBPass="" DBParm="ConnectString='DSN=AppeonSample;UID=dba;PWD=sql'">
    <PBLs><PBL name="C:\Program Files\Appeon\ADT\appeondemo\sales_application_demo.pbl"/></PBLs>
    </Application>
    <Application name="visual_controls_demo" PBLsinProject="1" WebRoot="visualcontrolsdemo" DBMS="ODBC" Database="" ServerName="AppeonSample" LogID="dba" LogPass="sql" UserID="" DBPass="" DBParm="ConnectString='DSN=AppeonSample;UID=dba;PWD=sql'">
    <PBLs><PBL name="C:\Program Files\Appeon\ADT\appeondemo\visual_controls_demo.pbl"/></PBLs>
    </Application>
    <Application name="appeon_code_example" PBLsinProject="3" WebRoot="appeon_code_example" DBMS="ODBC" Database="" ServerName="AppeonSample" LogID="dba" LogPass="sql" UserID="" DBPass="" DBParm="ConnectString='DSN=AppeonSample;UID=dba;PWD=sql'">
    <PBLs><PBL name="C:\Program Files\Appeon\ADT\appeondemo\ace_datawindow.pbl"/>
    <PBL name="C:\Program Files\Appeon\ADT\appeondemo\ace_others.pbl"/>
    <PBL name="C:\Program Files\Appeon\ADT\appeondemo\ace_window.pbl"/></PBLs>
    </Application>
    </Applications>
    <DeploymentProfiles default="Local Deployment">
    <DeploymentProfile ProfileName="Local Deployment" WEBServers="1" EAServers="1">
    <WebServers>
    <Server name="Local Web Server"/>
    </WebServers>
    <AppServers>
    <Server name="Local EA Server"/>
    </AppServers>
    </DeploymentProfile>
    </DeploymentProfiles>
    <Servers>
    <WebServers>
    <Server ProfileName="Local Web Server" ServerType="EAServer 4.1.3" DeploymentType="0" HTTPIP="localhost" HTTPPort="9988" CopyDirectory="C:\Program Files\Sybase\EAServer\html" FTPIP="" FTPPort="" FTPUserName="" FTPPassword=""/>
    </WebServers>
    <AppServers>
    <Server ProfileName="Local EA Server" ServerType="EAServer 4.1.3 Developer Edition" EAServerIP="localhost" EAServerPort="9989" UserName="jagadmin" Password=""/>
    </AppServers>
    </Servers>
    <PreviewOptions>
    <QuickPreviews>
    <QuickPreview name="HTML Window Preview" Enable="1"/>
    <QuickPreview name="HTML Menu Preview" Enable="1"/>
    <QuickPreview name="GIF DataWindow Preview" Enable="1"/>
    <QuickPreview name="HTML DataWindow Preview" Enable="1"/>
    <QuickPreview name="PDF DataWindow Preview" Enable="1"/>
    </QuickPreviews>
    <DataWindowSettings>
    <DataWindowsize width="800" height="500"/>
    <Imagesize width="800" height="500"/>
    <Printorientation value="Portrait"/>
    <Papersizes default="A4 210x297mm">
    <Papersize id="0" name="Default"/>
    <Papersize id="1" name="Letter 8.5x11"/>
    <Papersize id="2" name="Letter Small 8.5x11"/>
    <Papersize id="3" name="Tabloid 11x17"/>
    <Papersize id="4" name="Ledger 17x11"/>
    <Papersize id="5" name="Legal 8.5x14"/>
    <Papersize id="6" name="Statement 5.5x8.5"/>
    <Papersize id="7" name="Executive 7.25x10.5"/>
    <Papersize id="8" name="A3 297x420mm"/>
    <Papersize id="9" name="A4 210x297mm"/>
    <Papersize id="10" name="A4 Small 210x297mm"/>
    <Papersize id="11" name="A5 148x210mm"/>
    <Papersize id="12" name="B4 250x354"/>
    <Papersize id="13" name="B5 182x257mm"/>
    <Papersize id="14" name="Folio 8.5x13"/>
    <Papersize id="15" name="Quarto 215x275mm"/>
    <Papersize id="16" name="10x14"/>
    <Papersize id="17" name="11x17"/>
    <Papersize id="18" name="Note 8.5x11"/>
    <Papersize id="19" name="Envelope #9 3.88x8.88"/>
    <Papersize id="20" name="Envelope #10 4.13x9.5, 21"/>
    <Papersize id="21" name="Envelope #11 4.5x10.38"/>
    <Papersize id="22" name="Envelope #12 4\276x11"/>
    <Papersize id="23" name="Envelope #14 5x11.5"/>
    <Papersize id="24" name="C Size Sheet"/>
    <Papersize id="25" name="D Size Sheet"/>
    <Papersize id="26" name="E Size Sheet"/>
    <Papersize id="27" name="Envelope DL 110x220mm"/>
    <Papersize id="28" name="Envelope C5 162x229mm"/>
    <Papersize id="29" name="Envelope C3 324x458mm"/>
    <Papersize id="30" name="Envelope C4 229x324mm"/>
    <Papersize id="31" name="Envelope C6 114x162mm"/>
    <Papersize id="32" name="Envelope C65 114x229mm"/>
    <Papersize id="33" name="Envelope B4 250x353mm"/>
    <Papersize id="34" name="Envelope B5 176x250mm"/>
    <Papersize id="35" name="Envelope B6 176x125mm"/>
    <Papersize id="36" name="Envelope 110x230mm"/>
    <Papersize id="37" name="Envelope Monarch 3.875x7.5"/>
    <Papersize id="38" name="6.75 Envelope 3.63x6.5"/>
    <Papersize id="39" name="US Std Fanfold 14.88x11"/>
    <Papersize id="40" name="German Std Fanfold 8.5x12"/>
    <Papersize id="41" name="German Legal Fanfold 8.5x13' "/>
    </Papersizes>
    </DataWindowSettings>
    <PreviewDir name="previewdir"/>
    </PreviewOptions>
    <AEMSetting AEMURL="localhost:9988/aem/index.jsp" Connectionmethod="HTTP"/>
    <Templates>
    <Template name="MenuTemplate.html" PreviewType="2"/>
    <Template name="HTMLDWTemplate.html" PreviewType="3"/>
    <Template name="PDFDWTemplate.html" PreviewType="4"/>
    <Template name="GIFDWTemplate.html" PreviewType="5"/>
    </Templates>
    <Reports>
    <Report name="UFA_Report.html" Function="ADT_UnsupportedFeatureAnalysis"/>
    <Report name="GWF_Report.html" Function="ADT_GenerateWEBFiles"/>
    <Report name="DWF_Report.html" Function="ADT_DeployWEBFiles"/>
    </Reports>
    <Functions>
    <Function name="ADT_WindowPreview" Number="1"/>
    <Function name="ADT_MenuPreview" Number="2"/>
    <Function name="ADT_DataWindowPreview" Number="3"/>
    <Function name="ADT_UnsupportedFeatureAnalysis" Number="4"/>
    <Function name="ADT_GenerateWEBFiles" Number="5"/>
    <Function name="ADT_DeployWEBFiles" Number="6"/>
    <Function name="ADT_LoadConfig" Number="7"/>
    <Function name="ADT_DiskCleanup" Number="8"/>
    <Function name="ADT_DeployObject" Number="9"/>
    <Function name="ADT_AntiPiracy" Number="10"/>
    </Functions>
    <WebServerTypes>
    <Type name="Apache 1.3"/>
    <Type name="EAServer HTTP Server"/>
    <Type name="iPlanet 4.1"/>
    <Type name="Microsoft IIS 4.0/5.0"/>
    <Type name="Netscape 3.6.x"/>
    </WebServerTypes>
    <ApplicationServerTypes>
    <Type name="EAServer 4.1.3+ Developer Edition"/>
    <Type name="EAServer 4.1.3+ Advanced Edition"/>
    <Type name="EAServer 4.1.3+ Enterprise Edition"/>
    </ApplicationServerTypes>
    <WorkingServers>
    <WorkingEAServer ProfileName="Local EA Server"/>
    <WorkingWEBServer ProfileName="Local Web Server"/>
    </WorkingServers>
    <DefaultTransName name="sqlca"/>
    <charsets default="">
    <charset value="gb2312"/>
    <charset value="big5"/>
    </charsets>
    </ADTConfig>
      

  31.   

    package org.norwaywoods.dialog;/**
     * <p>Title: </p>
     * <p>Description: </p>
     * <p>Copyright: Copyright (c) 2002</p>
     * <p>Company: </p>
     * @author not attributable
     * @version 1.0
     */import java.util.*;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;public class dialog extends JFrame{
            /**
             * The dialog area; <code>null</code> until dialog is layed out.
             */
            JPanel dialogArea;        /**
             * The button bar; <code>null</code> until dialog is layed out.
             */
            JPanel buttonBar;        /**
             * Collection of buttons created by the <code>createButton</code> method.
             */
            private HashMap buttons = new HashMap();        /**
             * Creates a new button with the given id.
             * <p>
             * The <code>Dialog</code> implementation of this framework method
             * creates a standard push button, registers it for selection events
             * including button presses, and registers default buttons with its shell.
             * The button id is stored as the button's client data.  If the button id
             * is <code>IDialogConstants.CANCEL_ID</code>, the new button will be
             * accessible from <code>getCancelButton()</code>.  If the button id is
             * <code>IDialogConstants.OK_ID</code>, the new button will be accesible
             * from <code>getOKButton()</code>.  Note that the parent's layout
             * is assumed to be a <code>GridLayout</code> and the number of columns in this
             * layout is incremented.  Subclasses may override.
             * </p>
             *
             * @param parent the parent composite
             * @param id the id of the button (see
             *  <code>IDialogConstants.*_ID</code> constants
             *  for standard dialog button ids)
             * @param label the label from the button
             * @param defaultButton <code>true</code> if the button is to be the
             *   default button, and <code>false</code> otherwise
             *
             * @return the new button
             *
             * @see getCancelButton
             * @see getOKButton
             */
            protected JButton createButton(Container parent, int id, String label, boolean defaultButton) {
            // increment the number of columns in the button bar
            // ((GridLayout)parent.getLayout()).numColumns++;        JButton button = new JButton();        button.setText(label);
            button.setVerticalTextPosition(AbstractButton.CENTER);
            button.setHorizontalTextPosition(AbstractButton.LEADING);
            // button.setMnemonic(KeyEvent.VK_D);
            button.setActionCommand(new Integer(id).toString());        button.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                            buttonPressed(e);
                    }
            });        button.setFont(parent.getFont());
            buttons.put(new Integer(id), button); //Add to Buttons HashMap        return button;
            }        /**
             * Creates and returns the contents of this dialog's
             * button bar.
             * <p>
             * The <code>Dialog</code> implementation of this framework method
             * lays out a button bar and calls the <code>createButtonsForButtonBar</code>
             * framework method to populate it. Subclasses may override.
             * </p>
             * <p>
             * The returned control's layout data must be an instance of
             * <code>GridData</code>.
             * </p>
             *
             * @param parent the parent composite to contain the button bar
             * @return the button bar control
             */
            protected JPanel createButtonBar(Container parent) {
                    // create a layout with spacing and margins appropriate for the font size.
                    JPanel composite = new JPanel();                composite.setLayout(new FlowLayout());
                    composite.setFont(parent.getFont());                // Add the buttons to the button bar.
                    createButtonsForButtonBar(composite);                return composite;
            }        /**
             * Adds buttons to this dialog's button bar.
             * <p>
             * The <code>Dialog</code> implementation of this framework method adds
             * standard ok and cancel buttons using the <code>createButton</code>
             * framework method. These standard buttons will be accessible from
             * <code>getCancelButton</code>, and <code>getOKButton</code>.
             * Subclasses may override.
             * </p>
             *
             * @param parent the button bar composite
             */
            protected void createButtonsForButtonBar(Container parent) {
                    // create OK and Cancel buttons by default
                    createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
                    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
            }
      

  32.   

    /**
             * Creates and returns the contents of the upper part
             * of this dialog (above the button bar).
             * <p>
             * The <code>Dialog</code> implementation of this framework method
             * creates and returns a new <code>Composite</code> with
             * standard margins and spacing.
             * </p>
             * <p>
             * The returned control's layout data must be an instance of
             * <code>GridData</code>.
             * </p>
             * <p>
             * Subclasses must override this method but may call <code>super</code>
             * as in the following example:
             * </p>
             * <pre>
             *  Composite composite = (Composite)super.createDialogArea(parent);
             *  //add controls to composite as necessary
             *  return composite;
             * </pre>
             *
             * @param parent the parent composite to contain the dialog area
             * @return the dialog area control
             */
            protected JPanel createDialogArea(Container parent) {
                    // create a composite with standard margins and spacing
                    JPanel composite = new JPanel();                composite.setFont(parent.getFont());                return composite;
            }        /**
             * Returns the button created by the method <code>createButton</code>
             * for the specified ID as defined on <code>IDialogConstants</code>. If
             * <code>createButton</code> was never called with this ID, or
             * if <code>createButton</code> is overridden, this method will return
             * <code>null</code>.
             *
             * @return the button for the ID or <code>null</code>
             *
             * @see createButton
             * @since 2.0
             */
            protected JButton getButton(int id) {
                return (JButton)buttons.get(new Integer(id));
            }        /**
             * Returns the button bar control.
             * <p>
             * Clients may call this framework method, but should not override it.
             * </p>
             *
             * @return the button bar, or <code>null</code> if
             * the button bar has not been created yet
             */
            protected JPanel getButtonBar() {
                 return buttonBar;
            }
            
            /**
             * Returns the button created when <code>createButton</code> is called 
             * with an ID of <code>IDialogConstants.CANCEL_ID</code>.  If 
             * <code>createButton</code> was never called with this parameter, or 
             * if <code>createButton</code> is overridden, <code>getCancelButton</code>
             * will return <code>null</code>.
             * 
             * @return the cancel button or <code>null</code>
             * 
             * @see createButton
             * @since 2.0
             * @deprecated Use <code>getButton(IDialogConstants.CANCEL_ID)</code> instead.
             *  This method will be removed soon.
             */
            protected JButton getCancelButton() {
                      return getButton(IDialogConstants.CANCEL_ID);
            }
    /**
     * Returns the dialog area control.
     * <p>
     * Clients may call this framework method, but should not override it.
     * </p>
     *
     * @return the dialog area, or <code>null</code> if
     *   the dialog area has not been created yet
     */
    protected JPanel getDialogArea() {
            return dialogArea;
    }
               /**
           * Notifies that this dialog's button with the given id has been pressed.
           * <p>
           * The <code>Dialog</code> implementation of this framework method calls
           * <code>okPressed</code> if the ok button is the pressed,
           * and <code>cancelPressed</code> if the cancel button is the pressed.
           * All other button presses are ignored. Subclasses may override
           * to handle other buttons, but should call <code>super.buttonPressed</code>
           * if the default handling of the ok and cancel buttons is desired.
           * </p>
           *
           * @param buttonId the id of the button that was pressed (see
           *  <code>IDialogConstants.*_ID</code> constants)
           */
          protected void buttonPressed(ActionEvent e) {
                  String buttonId = e.getActionCommand();
                  switch(new Integer(buttonId).intValue()) {
                    case IDialogConstants.OK_ID:{
                         okPressed();
                         break;
                    }                case IDialogConstants.CANCEL_ID:{
                         cancelPressed();
                         break;
                    }              }
          }      public void okPressed(){      }      public void cancelPressed(){      }
    }