﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-java神谕-随笔分类-JAVA</title><link>http://www.blogjava.net/javaora/category/3333.html</link><description /><language>zh-cn</language><lastBuildDate>Tue, 27 Feb 2007 08:48:51 GMT</lastBuildDate><pubDate>Tue, 27 Feb 2007 08:48:51 GMT</pubDate><ttl>60</ttl><item><title>MyEC 4.1新增的几个功能</title><link>http://www.blogjava.net/javaora/archive/2006/04/19/42016.html</link><dc:creator>java世界畅谈</dc:creator><author>java世界畅谈</author><pubDate>Wed, 19 Apr 2006 14:35:00 GMT</pubDate><guid>http://www.blogjava.net/javaora/archive/2006/04/19/42016.html</guid><wfw:comment>http://www.blogjava.net/javaora/comments/42016.html</wfw:comment><comments>http://www.blogjava.net/javaora/archive/2006/04/19/42016.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/javaora/comments/commentRss/42016.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/javaora/services/trackbacks/42016.html</trackback:ping><description><![CDATA[1.增加了一个图形编辑器。呵呵～～，以后简单的东西，在Eclipse中就可以编辑了！<br />2.Spring和Hibernate的自动集成<br />3.Jsp Editor，其实这个东西，我们一般是不做使用的。以前的版本出现的经常性打开很慢的情况。<br />4.UML图形<br />5.Javascript<img src ="http://www.blogjava.net/javaora/aggbug/42016.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/javaora/" target="_blank">java世界畅谈</a> 2006-04-19 22:35 <a href="http://www.blogjava.net/javaora/archive/2006/04/19/42016.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MyEclipse JavaScript Debugger (MyEclipse javascript 调试器)</title><link>http://www.blogjava.net/javaora/archive/2006/04/19/42014.html</link><dc:creator>java世界畅谈</dc:creator><author>java世界畅谈</author><pubDate>Wed, 19 Apr 2006 14:24:00 GMT</pubDate><guid>http://www.blogjava.net/javaora/archive/2006/04/19/42014.html</guid><wfw:comment>http://www.blogjava.net/javaora/comments/42014.html</wfw:comment><comments>http://www.blogjava.net/javaora/archive/2006/04/19/42014.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/javaora/comments/commentRss/42014.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/javaora/services/trackbacks/42014.html</trackback:ping><description><![CDATA[
		<p>The MyEclipse JavaScript Debugger is the first fully integrated client-side Eclipse debugger for JavaScript. Feature highlights include: <br />MyEc Javascript 调试器试首个为Javascript。完整集成客户端Eclipse调试器。特征主要包含：</p>
		<ul>
				<li>Debug any web page containing JavaScript source or included JavaScript files, or standalone JavaScript files 
</li>
				<li>调试任何web页面包含Javascript 源代码或包含Javascript 文件，或者单独的Javascript文件
</li>
				<li>Operations: Pause, Resume, Step Into, Step Over, Step to Return, Terminate 
</li>
				<li>操作：暂停、重新开始、进入、跳出、跳入返回、终止
</li>
				<li>Views: 视图
<ul><li>Web Browser View (web 浏览器视图)
</li><li>Call Stack View  （呼叫堆栈视图）
</li><li>Variables View (变量视图)
</li><li>Console View  （控制台视图）</li></ul></li>
				<li>Set JavaScript breakpoints in: 设置javascript断点
<ul><li>JavaScript files (Javascript文件)
</li><li>HTML with embedded JavaScript and linked JavaScript files （包含内置的javascript和关联的javascript文件的HTML）
</li><li>JSP files (jsp 文件)
</li><li>Conditional breakpoints planned for MyEclipse 4.1.1 （为MyEC的有条件的断点计划）</li></ul></li>
				<li>Integrates with Eclipse Launch Manager （集成Eclipse发行管理器）
<ul><li>Quick launch from context-menu using "Debug As" (使用Debug As 迅速调用上下文按钮)
</li><li>Launch from Eclipse Debug toolbar action （从Eclipse 调试工具条行为中调用）
</li><li>Use Launch Profile to modify launch configuration （）
</li><li>Launch JavaScript resource from project location or deployed MyEclipse web-application </li></ul></li>
		</ul>
<img src ="http://www.blogjava.net/javaora/aggbug/42014.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/javaora/" target="_blank">java世界畅谈</a> 2006-04-19 22:24 <a href="http://www.blogjava.net/javaora/archive/2006/04/19/42014.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>PriorityQueue类API 翻译</title><link>http://www.blogjava.net/javaora/archive/2005/10/09/15096.html</link><dc:creator>java世界畅谈</dc:creator><author>java世界畅谈</author><pubDate>Sun, 09 Oct 2005 15:10:00 GMT</pubDate><guid>http://www.blogjava.net/javaora/archive/2005/10/09/15096.html</guid><wfw:comment>http://www.blogjava.net/javaora/comments/15096.html</wfw:comment><comments>http://www.blogjava.net/javaora/archive/2005/10/09/15096.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/javaora/comments/commentRss/15096.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/javaora/services/trackbacks/15096.html</trackback:ping><description><![CDATA[<P>public class PriorityQueue&lt;E&gt;extends AbstractQueue&lt;E&gt;implements Serializable<BR>An unbounded priority queue based on a priority heap. This queue orders elements according to an order specified at construction time, which is specified either according to their natural order (see Comparable), or according to a Comparator, depending on which constructor is used. A priority queue does not permit null elements. A priority queue relying on natural ordering also does not permit insertion of non-comparable objects (doing so may result in ClassCastException). <BR>　　一个极大的优先队列基于一个优先堆栈。这个队列按照一个限定在构造时间顺序排列元素，这是也是按照它们的自然的顺序（查看Comparable）限定的，或者按照一个Comparator,依靠使用的构造子。一个优先队列不允许为空元素。一个优先队列依靠自然顺序也不允许插入一个非comparable对象（这样做会产生ClassCastException的结果）。</P>
<P>The head of this queue is the least element with respect to the specified ordering. If multiple elements are tied for least value, the head is one of those elements -- ties are broken arbitrarily. The queue retrieval operations poll, remove, peek, and element access the element at the head of the queue. <BR>　　这个队列头是最小的元素伴随期望限定的排序。如果多个元素为最小的值约束，头是这些元素中的一个---约束是任意打断的。队列获得操作poll(推),remove(移除)，peek　和在队列头部的元素</P>
<P>A priority queue is unbounded, but has an internal capacity governing the size of an array used to store the elements on the queue. It is always at least as large as the queue size. As elements are added to a priority queue, its capacity grows automatically. The details of the growth policy are not specified. <BR>　　一个优先队列是极大的，但是拥有一个内部的容量调节数组的大小用来存储在队列中的元素。它总是至少和队列大小是是一样大小的。作为元素被加入一个优先队列，它的容量是自动增加的。增加策略的细节是没有指定的。</P>
<P>This class and its iterator implement all of the optional methods of the Collection and Iterator interfaces. The Iterator provided in method iterator() is not guaranteed to traverse the elements of the PriorityQueue in any particular order. If you need ordered traversal, consider using Arrays.sort(pq.toArray()). <BR>　　这个类和它的枚举实现所有可选的集合和枚举接口的方法。这个枚举支持iterator()方法是不保证在任何特定的顺序遍历PriorityQueue的元素。如果你需要顺序的遍历，考虑使用Array.sort(pq.toArray()).</P>
<P>Note that this implementation is not synchronized. Multiple threads should not access a PriorityQueue instance concurrently if any of the threads modifies the list structurally. Instead, use the thread-safe PriorityBlockingQueue class. <BR>　　注意这个实现不是不同步的。多个线程不应当并发访问一个PriorityQueue实例，如果线程在结构上线程任一个被修改。作为替换，使用线程安全的PriorityBlockingQueue类。</P>
<P>Implementation note: this implementation provides O(log(n)) time for the insertion methods (offer, poll, remove() and add) methods; linear time for the remove(Object) and contains(Object) methods; and constant time for the retrieval methods (peek, element, and size). </P>
<P>This class is a member of the Java Collections Framework. </P>
<P>&nbsp;</P>
<P>Since: <BR>1.5 <BR>See Also:<BR>Serialized Form<BR></P><img src ="http://www.blogjava.net/javaora/aggbug/15096.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/javaora/" target="_blank">java世界畅谈</a> 2005-10-09 23:10 <a href="http://www.blogjava.net/javaora/archive/2005/10/09/15096.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Package java.util.concurrent(并发) Description </title><link>http://www.blogjava.net/javaora/archive/2005/10/08/14972.html</link><dc:creator>java世界畅谈</dc:creator><author>java世界畅谈</author><pubDate>Sat, 08 Oct 2005 02:43:00 GMT</pubDate><guid>http://www.blogjava.net/javaora/archive/2005/10/08/14972.html</guid><wfw:comment>http://www.blogjava.net/javaora/comments/14972.html</wfw:comment><comments>http://www.blogjava.net/javaora/archive/2005/10/08/14972.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/javaora/comments/commentRss/14972.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/javaora/services/trackbacks/14972.html</trackback:ping><description><![CDATA[<P>Package java.util.concurrent(并发) Description </P>
<P>Utility classes commonly useful in concurrent programming. This package includes a few small standardized extensible frameworks, as well as some classes that provide useful functionality and are otherwise tedious(沉闷的) or difficult to implement. Here are brief(摘要的) descriptions of the main components. See also the locks(锁) and atomic(原子的) packages. </P>
<P>Executors(执行者)<BR>Interfaces. Executor is a simple standardized interface for defining custom thread-like subsystems(子系统), including thread pools(线程池), asynchronous IO(异步IO), and lightweight task frameworks(轻量级任务框架). Depending on which concrete Executor class is being used, tasks may execute in a newly(以新的方式) created thread, an existing task-execution thread, or the thread calling execute(), and may execute sequentially(继续地) or concurrently(并发地). ExecutorService provides a more complete asynchronous(异步的) task execution framework. An ExecutorService manages queuing(队列) and scheduling(行程安排) of tasks, and allows controlled shutdown. The ScheduledExecutorService subinterface adds support for delayed(延时的) and periodic(定期的) task execution. ExecutorServices provide methods arranging(安排的) asynchronous execution of any function expressed as Callable, the result-bearing analog(类似物) of Runnable. A Future returns the results of a function, allows determination of whether execution has completed, and provides a means to cancel execution. <BR>Implementations. Classes ThreadPoolExecutor and ScheduledThreadPoolExecutor provide tunable(可调的), flexible(灵活的) thread pools. The Executors class provides factory methods for the most common kinds and configurations of Executors, as well as a few utility methods for using them. Other utilities based on Executors include the concrete class FutureTask providing a common extensible implementation of Futures, and ExecutorCompletionService, that assists in coordinating(计算调配中心) the processing of groups of asynchronous(异步的) tasks. <BR>[Executor&nbsp; ExecutorService ScheduledExecutorService ScheduledThreadPoolExecutor ExecutionCompletionService]</P>
<P>Queues(队列)<BR>The java.util.concurrent ConcurrentLinkedQueue class supplies an efficient scalable(可升级的) thread-safe(线程安全) non-blocking(非模块化) FIFO queue. Five implementations in java.util.concurrent support the extended BlockingQueue interface, that defines blocking versions of put and take: LinkedBlockingQueue, ArrayBlockingQueue, SynchronousQueue, PriorityBlockingQueue, and DelayQueue. The different classes cover the most common usage contexts for producer-consumer, messaging, parallel tasking, and related concurrent designs. <BR>[LinkedBlockingQueue ArrayBlockingQueue SynchronousQueue PriorityBlockingQueue DelayQueue]</P>
<P>Timing(定时)<BR>The TimeUnit class provides multiple granularities&lt;间隔尺寸&gt; (including nanoseconds十亿分之一秒) for specifying and controlling time-out(暂停) based operations. Most classes in the package contain operations based on time-outs in addition to(除...以外) indefinite(不确定的) waits. In all cases that time-outs are used, the time-out specifies the minimum time that the method should wait before indicating(指出) that it timed-out. Implementations make a "best effort" to detect（察觉） time-outs as soon as possible after they occur. However, an indefinite(模糊的) amount of time may elapse(流逝) between a time-out being detected and a thread actually executing again after that time-out. </P>
<P>Synchronizers(同步)<BR>Four classes aid(帮助) common special-purpose synchronization idioms(语法). Semaphore(旗语) is a classic concurrency tool. CountDownLatch(Countdown 倒数计秒&nbsp; latch门插销) is a very simple yet very common utility for blocking until a given number of signals, events, or conditions hold. A CyclicBarrier(cyclic 循环的 barrier 屏障) is a resettable(可重置的) multiway(多路的) synchronization point useful in some styles of parallel programming. An Exchanger allows two threads to exchange(交换) objects at a rendezvous point(集合点), and is useful in several pipeline(管道) designs. </P>
<P>Concurrent Collections(并发集合)<BR>Besides Queues, this package supplies a few Collection implementations designed for use in multithreaded contexts: ConcurrentHashMap, CopyOnWriteArrayList, and CopyOnWriteArraySet. <BR>The "Concurrent" prefix used with some classes in this package is a shorthand(速记) indicating several differences from similar "synchronized" classes. For example java.util.Hashtable and Collections.synchronizedMap(new HashMap()) are synchronized. But ConcurrentHashMap is "concurrent". A concurrent collection is thread-safe, but not governed by a single exclusion lock. In the particular case of ConcurrentHashMap, it safely permits any number of concurrent reads as well as a tunable number of concurrent writes. "Synchronized" classes can be useful when you need to prevent all access to a collection via a single lock, at the expense of poorer scalability. In other cases in which multiple threads are expected to access a common collection, "concurrent" versions are normally preferable. And unsynchronized collections are preferable when either collections are unshared, or are accessible only when holding other locks. </P>
<P>Most concurrent Collection implementations (including most Queues) also differ from the usual java.util conventions in that their Iterators provide weakly consistent rather than fast-fail traversal. A weakly consistent iterator is thread-safe, but does not necessarily freeze the collection while iterating, so it may (or may not) reflect any updates since the iterator was created. </P>
<P>&nbsp;</P>
<P>Since: <BR>1.5 <BR></P><img src ="http://www.blogjava.net/javaora/aggbug/14972.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/javaora/" target="_blank">java世界畅谈</a> 2005-10-08 10:43 <a href="http://www.blogjava.net/javaora/archive/2005/10/08/14972.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>String.class 的split方法</title><link>http://www.blogjava.net/javaora/archive/2005/09/29/14429.html</link><dc:creator>java世界畅谈</dc:creator><author>java世界畅谈</author><pubDate>Thu, 29 Sep 2005 08:23:00 GMT</pubDate><guid>http://www.blogjava.net/javaora/archive/2005/09/29/14429.html</guid><wfw:comment>http://www.blogjava.net/javaora/comments/14429.html</wfw:comment><comments>http://www.blogjava.net/javaora/archive/2005/09/29/14429.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/javaora/comments/commentRss/14429.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/javaora/services/trackbacks/14429.html</trackback:ping><description><![CDATA[<H3>　　以前的做分隔符获取一个个字符串很是麻烦，其实JDK中的String 类已经很好的解决了这个问题。正则表达式确实是个好东西！</H3>
<H3>split</H3><PRE>public <A title="class in java.lang" href="file:///F:/jdk-1_5_0-doc/docs/api/java/lang/String.html">String</A>[] <B>split</B>(<A title="class in java.lang" href="file:///F:/jdk-1_5_0-doc/docs/api/java/lang/String.html">String</A>&nbsp;regex)</PRE>
<DL>
<DD>Splits this string around matches of the given regular expression. 
<P>This method works as if by invoking the two-argument <A href="file:///F:/jdk-1_5_0-doc/docs/api/java/lang/String.html#split(java.lang.String, int)"><CODE>split</CODE></A> method with the given expression and a limit argument of zero. Trailing empty strings are therefore not included in the resulting array. 
<P>The string <TT>"boo:and:foo"</TT>, for example, yields the following results with these expressions: 
<BLOCKQUOTE>
<TABLE cellSpacing=0 cellPadding=1 summary="Split examples showing regex and result">
<TBODY>
<TR>
<TH>Regex</TH>
<TH>Result</TH></TR>
<TR>
<TD align=middle>:</TD>
<TD><TT>{ "boo", "and", "foo" }</TT></TD></TR>
<TR>
<TD align=middle>o</TD>
<TD><TT>{ "b", "", ":and:f" }</TT></TD></TR></TBODY></TABLE></BLOCKQUOTE>
<P></P>
<DD>
<DL></DL>
<DD>
<DL>
<DT><B>Parameters:</B> 
<DD><CODE>regex</CODE> - the delimiting regular expression 
<DT><B>Returns:</B> 
<DD>the array of strings computed by splitting this string around matches of the given regular expression 
<DT><B>Throws:</B> 
<DD><CODE><A title="class in java.util.regex" href="file:///F:/jdk-1_5_0-doc/docs/api/java/util/regex/PatternSyntaxException.html">PatternSyntaxException</A></CODE> - if the regular expression's syntax is invalid 
<DT><B>Since:</B> 
<DD>1.4 
<DT><B>See Also:</B> 
<DD><A title="class in java.util.regex" href="file:///F:/jdk-1_5_0-doc/docs/api/java/util/regex/Pattern.html"><CODE>Pattern</CODE></A></DD></DL></DD></DL><img src ="http://www.blogjava.net/javaora/aggbug/14429.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/javaora/" target="_blank">java世界畅谈</a> 2005-09-29 16:23 <a href="http://www.blogjava.net/javaora/archive/2005/09/29/14429.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Interface LoginModule</title><link>http://www.blogjava.net/javaora/archive/2005/09/18/13312.html</link><dc:creator>java世界畅谈</dc:creator><author>java世界畅谈</author><pubDate>Sun, 18 Sep 2005 13:44:00 GMT</pubDate><guid>http://www.blogjava.net/javaora/archive/2005/09/18/13312.html</guid><wfw:comment>http://www.blogjava.net/javaora/comments/13312.html</wfw:comment><comments>http://www.blogjava.net/javaora/archive/2005/09/18/13312.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/javaora/comments/commentRss/13312.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/javaora/services/trackbacks/13312.html</trackback:ping><description><![CDATA[<DL>
<DT><PRE>public interface <B>LoginModule</B></PRE></DT></DL><PRE></PRE>
<P>
<P><CODE>LoginModule</CODE> describes the interface implemented by authentication technology providers. LoginModules are plugged in under applications to provide a particular type of authentication. 
<P>While applications write to the <CODE>LoginContext</CODE> API, authentication technology providers implement the <CODE>LoginModule</CODE> interface. A <CODE>Configuration</CODE> specifies the LoginModule(s) to be used with a particular login application. Therefore different LoginModules can be plugged in under the application without requiring any modifications to the application itself. 
<P>The <CODE>LoginContext</CODE> is responsible&lt;负责&gt; for reading the <CODE>Configuration</CODE> and instantiating the appropriate&lt;适当的&gt; LoginModules. Each <CODE>LoginModule</CODE> is initialized with a <CODE><STRONG>Subject</STRONG></CODE>, a <CODE><STRONG>CallbackHandler</STRONG></CODE>, <STRONG>shared <CODE>LoginModule</CODE> state</STRONG>, and <STRONG>LoginModule-specific options</STRONG>. The <CODE>Subject</CODE> represents the <CODE>Subject</CODE> currently being authenticated and is updated with relevant&lt;相关&gt; Credentials&lt;凭证&gt; if authentication succeeds. LoginModules use the <CODE>CallbackHandler</CODE> to communicate with users. The <CODE>CallbackHandler</CODE> may be used to prompt for usernames and passwords, for example. Note that the <CODE>CallbackHandler</CODE> may be null. LoginModules which absolutely require a <CODE>CallbackHandler</CODE> to authenticate&lt;认证&gt; the <CODE>Subject</CODE> may throw a <CODE>LoginException</CODE>. LoginModules optionally use the shared state to share information or data among themselves. <BR><BR><STRONG>NameCallback:<BR>PasswordCallback:</STRONG> 
<P>The LoginModule-specific options represent the options configured for this <CODE>LoginModule</CODE> by an administrator or user in the login <CODE>Configuration</CODE>. The options are defined by the <CODE>LoginModule</CODE> itself and control the behavior within it. For example, a <CODE>LoginModule</CODE> may define options to support debugging/testing capabilities&lt;能力&gt;. Options are defined using a key-value syntax, such as <I>debug=true</I>. The <CODE>LoginModule</CODE> stores the options as a <CODE>Map</CODE> so that the values may be retrieved using the key. Note that there is no limit to the number of options a <CODE>LoginModule</CODE> chooses to define. 
<P>The calling application sees the authentication process as a single operation. However, the authentication process within the <CODE>LoginModule</CODE> proceeds in two distinct phases. In the first phase, <STRONG>the LoginModule's <CODE>login</CODE> method gets invoked by the LoginContext's <CODE>login</CODE> method</STRONG>. The <CODE>login</CODE> method for the <CODE>LoginModule</CODE> then performs the actual authentication (prompt for and verify a password for example) and saves its authentication status as private state information. Once finished, the LoginModule's <CODE>login</CODE> method either returns <CODE>true</CODE> (if it succeeded) or <CODE>false</CODE> (if it should be ignored), or throws a <CODE>LoginException</CODE> to specify a failure. In the failure case, the <CODE>LoginModule</CODE> must not retry the authentication or introduce delays. The responsibility of such tasks belongs to the application. If the application attempts to retry the authentication, the LoginModule's <CODE>login</CODE> method will be called again. 
<P>In the second phase, if the LoginContext's overall&lt;全面&gt; authentication succeeded (the relevant REQUIRED, REQUISITE&lt;需求&gt;, SUFFICIENT&lt;足够&gt; and OPTIONAL LoginModules succeeded),<STRONG> then the <CODE>commit</CODE> method for the <CODE>LoginModule</CODE> gets invoked.</STRONG> The <CODE>commit</CODE> method for a <CODE>LoginModule</CODE> checks its privately saved state to see if its own authentication succeeded. If the overall <CODE>LoginContext</CODE> authentication succeeded and the LoginModule's own authentication succeeded, then the <CODE>commit</CODE> method associates the relevant&lt;相关&gt; Principals (authenticated identities) and Credentials&lt;凭证&gt; (authentication data such as cryptographic keys) with the <CODE>Subject</CODE> located within the <CODE>LoginModule</CODE>. 
<P>If the LoginContext's overall authentication failed (the relevant REQUIRED, REQUISITE, SUFFICIENT and OPTIONAL LoginModules did not succeed), then the <CODE>abort（异常）</CODE> method for each <CODE>LoginModule</CODE> gets invoked. In this case, the <CODE>LoginModule</CODE> removes/destroys any authentication state originally saved. 
<P>Logging out a <CODE>Subject</CODE> involves only one phase. The <CODE>LoginContext</CODE> invokes the LoginModule's <CODE>logout</CODE> method. The <CODE>logout</CODE> method for the <CODE>LoginModule</CODE> then performs the logout procedures, such as removing Principals or Credentials from the <CODE>Subject</CODE> or logging session information. 
<P>A <CODE>LoginModule</CODE> implementation must have a constructor with no arguments&lt;无参数构造子&gt;. This allows classes which load the <CODE>LoginModule</CODE> to instantiate it. </P><img src ="http://www.blogjava.net/javaora/aggbug/13312.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/javaora/" target="_blank">java世界畅谈</a> 2005-09-18 21:44 <a href="http://www.blogjava.net/javaora/archive/2005/09/18/13312.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>利用HttpSessionListener实现网站在线人数统计功能</title><link>http://www.blogjava.net/javaora/archive/2005/09/12/12760.html</link><dc:creator>java世界畅谈</dc:creator><author>java世界畅谈</author><pubDate>Mon, 12 Sep 2005 08:06:00 GMT</pubDate><guid>http://www.blogjava.net/javaora/archive/2005/09/12/12760.html</guid><wfw:comment>http://www.blogjava.net/javaora/comments/12760.html</wfw:comment><comments>http://www.blogjava.net/javaora/archive/2005/09/12/12760.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/javaora/comments/commentRss/12760.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/javaora/services/trackbacks/12760.html</trackback:ping><description><![CDATA[　在网站中经常需要进行在线人数的统计。过去的一般做法是结合登录和退出功能，即当用户输入用户名密码进行登录的时候计数器加1，然后当用户点击退出按钮退出系统的时候计数器减1。这种处理方式存在一些缺点，例如：用户正常登录后，可能会忘记点击退出按钮，而直接关闭浏览器，导致计数器减1的操作没有及时执行；网站上还经常有一些内容是不需要登录就可以访问的，在这种情况下也无法使用上面的方法进行在线人数统计。<BR>　　我们可以利用Servlet规范中定义的事件监听器（Listener）来解决这个问题，实现更准确的在线人数统计功能。对每一个正在访问的用户，J2EE应用服务器会为其建立一个对应的HttpSession对象。当一个浏览器第一次访问网站的时候，J2EE应用服务器会新建一个HttpSession对象，并触发HttpSession创建事件，如果注册了HttpSessionListener事件监听器，则会调用HttpSessionListener事件监听器的sessionCreated方法。相反，当这个浏览器访问结束超时的时候，J2EE应用服务器会销毁相应的HttpSession对象，触发HttpSession销毁事件，同时调用所注册HttpSessionListener事件监听器的sessionDestroyed方法。<BR>　　可见，对应于一个用户访问的开始和结束，相应的有sessionCreated方法和sessionDestroyed方法执行。这样，我们只需要在HttpSessionListener实现类的sessionCreated方法中让计数器加1，在sessionDestroyed方法中让计数器减1，就轻松实现了网站在线人数的统计功能。<BR>　　下面就是利用HttpSessionListener实现在线人数统计的一个例子，这个例子已经在中创软件的J2EE应用服务器InforWeb中测试通过。<BR>　　首先，编写一个简单的计数器，代码如下：<BR>
<DIV class=codeStyle>
<OL>
<LI><B><FONT color=#0000ff>package</FONT></B>&nbsp;gongfei.cmc.articles.onlinecounter; 
<LI><B><FONT color=#0000ff>public</FONT></B>&nbsp;<B><FONT color=#0000ff>class</FONT></B>&nbsp;OnlineCounter&nbsp;{ 
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<B><FONT color=#0000ff>private</FONT></B>&nbsp;<B><FONT color=#0000ff>static</FONT></B>&nbsp;<B><FONT color=#0000ff>long</FONT></B>&nbsp;online&nbsp;=&nbsp;0;&nbsp;&nbsp;&nbsp;&nbsp; 
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<B><FONT color=#0000ff>public</FONT></B>&nbsp;<B><FONT color=#0000ff>static</FONT></B>&nbsp;<B><FONT color=#0000ff>long</FONT></B>&nbsp;getOnline()&nbsp;{ 
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B><FONT color=#0000ff>return</FONT></B>&nbsp;online; 
<LI>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp; 
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<B><FONT color=#0000ff>public</FONT></B>&nbsp;<B><FONT color=#0000ff>static</FONT></B>&nbsp;<B><FONT color=#0000ff>void</FONT></B>&nbsp;raise(){ 
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;online++; 
<LI>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp; 
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<B><FONT color=#0000ff>public</FONT></B>&nbsp;<B><FONT color=#0000ff>static</FONT></B>&nbsp;<B><FONT color=#0000ff>void</FONT></B>&nbsp;reduce(){ 
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;online--; 
<LI>&nbsp;&nbsp;&nbsp;} 
<LI>} </LI></OL></DIV><BR>　　然后，编写HttpSessionListener实现类，在这个实现类的sessionCreated方法中调用OnlineCounter的raise方法，在sessionDestroyed方法中调用OnlineCounter的reduce方法，代码如下：<BR>
<DIV class=codeStyle>
<OL>
<LI><B><FONT color=#0000ff>package</FONT></B>&nbsp;gongfei.cmc.articles.onlinecounter; 
<LI><B><FONT color=#0000ff>import</FONT></B>&nbsp;javax.servlet.http.<A href="http://www.javaresearch.org/source/j2ee1.3.1/javax/servlet/http/HttpSessionEvent.java.html" target=_blank><FONT class=classLink><U>HttpSessionEvent</U></FONT></A>; 
<LI><B><FONT color=#0000ff>import</FONT></B>&nbsp;javax.servlet.http.<A href="http://www.javaresearch.org/source/j2ee1.3.1/javax/servlet/http/HttpSessionListener.java.html" target=_blank><FONT class=classLink><U>HttpSessionListener</U></FONT></A>; 
<LI><B><FONT color=#0000ff>public</FONT></B>&nbsp;<B><FONT color=#0000ff>class</FONT></B>&nbsp;OnlineCounterListener&nbsp;<B><FONT color=#0000ff>implements</FONT></B>&nbsp;<A href="http://www.javaresearch.org/source/j2ee1.3.1/javax/servlet/http/HttpSessionListener.java.html" target=_blank><FONT class=classLink><U>HttpSessionListener</U></FONT></A>&nbsp;{ 
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<B><FONT color=#0000ff>public</FONT></B>&nbsp;<B><FONT color=#0000ff>void</FONT></B>&nbsp;sessionCreated(<A href="http://www.javaresearch.org/source/j2ee1.3.1/javax/servlet/http/HttpSessionEvent.java.html" target=_blank><FONT class=classLink><U>HttpSessionEvent</U></FONT></A>&nbsp;hse)&nbsp;{ 
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OnlineCounter.raise(); 
<LI>&nbsp;&nbsp;&nbsp;&nbsp;} 
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<B><FONT color=#0000ff>public</FONT></B>&nbsp;<B><FONT color=#0000ff>void</FONT></B>&nbsp;sessionDestroyed(<A href="http://www.javaresearch.org/source/j2ee1.3.1/javax/servlet/http/HttpSessionEvent.java.html" target=_blank><FONT class=classLink><U>HttpSessionEvent</U></FONT></A>&nbsp;hse)&nbsp;{ 
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OnlineCounter.reduce(); 
<LI>&nbsp;&nbsp;&nbsp;&nbsp;} 
<LI>} </LI></OL></DIV><BR>　　再然后，把这个HttpSessionListener实现类注册到网站应用中，也就是在网站应用的web.xml中加入如下内容：<BR>
<DIV class=codeStyle>
<OL>
<LI>&lt;web-app&gt; 
<LI>&nbsp;&nbsp;&nbsp;&nbsp;…… 
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&lt;listener&gt; 
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;listener-<B><FONT color=#0000ff>class</FONT></B>&gt; 
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gongfei.cmc.articles.example.OnlineCounterListener 
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/listener-<B><FONT color=#0000ff>class</FONT></B>&gt; 
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/listener&gt; 
<LI>&nbsp;&nbsp;&nbsp;&nbsp;…… 
<LI>&lt;/web-app&gt; </LI></OL></DIV>
<P><BR>原文地址：<A href="http://www.javaresearch.org/article/showarticle.jsp?column=106&amp;thread=18541">http://www.javaresearch.org/article/showarticle.jsp?column=106&amp;thread=18541</A></P><img src ="http://www.blogjava.net/javaora/aggbug/12760.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/javaora/" target="_blank">java世界畅谈</a> 2005-09-12 16:06 <a href="http://www.blogjava.net/javaora/archive/2005/09/12/12760.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>