锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲第一精品在线视频,亚洲精品高清国产一线久久,亚洲AV无码不卡在线播放http://m.tkk7.com/honzeland/category/16282.html璁板綍鐐規淮銆傘傘?/description>zh-cnFri, 22 Oct 2010 14:51:44 GMTFri, 22 Oct 2010 14:51:44 GMT60Servlet Mappings - rules, pattern....http://m.tkk7.com/honzeland/archive/2010/10/22/335921.htmlhonzelandhonzelandFri, 22 Oct 2010 14:41:00 GMThttp://m.tkk7.com/honzeland/archive/2010/10/22/335921.htmlhttp://m.tkk7.com/honzeland/comments/335921.htmlhttp://m.tkk7.com/honzeland/archive/2010/10/22/335921.html#Feedback0http://m.tkk7.com/honzeland/comments/commentRss/335921.htmlhttp://m.tkk7.com/honzeland/services/trackbacks/335921.htmlhttp://www.rawbw.com/~davidm/tini/TiniHttpServer/docs/ServletMappings.html

honzeland 2010-10-22 22:41 鍙戣〃璇勮
]]>
Java remote invocation frameworks (RPC)http://m.tkk7.com/honzeland/archive/2010/06/09/323153.htmlhonzelandhonzelandWed, 09 Jun 2010 06:25:00 GMThttp://m.tkk7.com/honzeland/archive/2010/06/09/323153.htmlhttp://m.tkk7.com/honzeland/comments/323153.htmlhttp://m.tkk7.com/honzeland/archive/2010/06/09/323153.html#Feedback0http://m.tkk7.com/honzeland/comments/commentRss/323153.htmlhttp://m.tkk7.com/honzeland/services/trackbacks/323153.html1. Remote Method Invocation (RMI)

2. Hessian

3. Burlap

4. HTTP invoker

5. EJB

6. JAX-RPC

7. JMX



honzeland 2010-06-09 14:25 鍙戣〃璇勮
]]>
Tomcat Architecture Diagramhttp://m.tkk7.com/honzeland/archive/2010/05/10/320458.htmlhonzelandhonzelandMon, 10 May 2010 02:39:00 GMThttp://m.tkk7.com/honzeland/archive/2010/05/10/320458.htmlhttp://m.tkk7.com/honzeland/comments/320458.htmlhttp://m.tkk7.com/honzeland/archive/2010/05/10/320458.html#Feedback0http://m.tkk7.com/honzeland/comments/commentRss/320458.htmlhttp://m.tkk7.com/honzeland/services/trackbacks/320458.html

Valve and Filter:
"Valve" is Tomcat specific notion, and they get applied at a higher level than anything in a specific webapp. Also, they work only in Tomcat.

"Filter" is a Servlet Specification notion and should work in any compliant servlet container. They get applied at a lower level than all of Tomcat's
Valves.

However, consider also the division between your application and the application  server. Think whether the feature you're planning is part of your application, or is it rather a generic feature of the application server, which could have uses in other applications as well. This would be the correct criteria to decide between Valve and Filter.

Order for filter: The order in which they are defined matters. The container will execute the filters in the order in which they are defined.


honzeland 2010-05-10 10:39 鍙戣〃璇勮
]]>
Quartz scheduled executionshttp://m.tkk7.com/honzeland/archive/2010/01/21/310422.htmlhonzelandhonzelandThu, 21 Jan 2010 09:38:00 GMThttp://m.tkk7.com/honzeland/archive/2010/01/21/310422.htmlhttp://m.tkk7.com/honzeland/comments/310422.htmlhttp://m.tkk7.com/honzeland/archive/2010/01/21/310422.html#Feedback0http://m.tkk7.com/honzeland/comments/commentRss/310422.htmlhttp://m.tkk7.com/honzeland/services/trackbacks/310422.html 鎴戜滑鐭ラ亾錛孮uartz閲囩敤JobDataMap瀹炵幇鍚慗ob瀹炰緥浼犻侀厤緗睘鎬э紝姝eQuartz瀹樻柟鏂囨。璇寸殑閭f牱錛?br />
How can I provide properties/configuration for a Job instance? The key is the JobDataMap, which is part of the JobDetail object.
The JobDataMap can be used to hold any number of (serializable) objects which you wish to have made available to the job instance when it executes.
JobDataMap map 錛?context.getJobDetail().getJobDataMap();

鎴戜滑閫氳繃map鍚慗ob瀹炰緥浼犻佸涓猳bjects錛屽叾涓湁涓涓槸涓猙ean錛屼竴涓槸鍩烘湰綾誨瀷銆傚浜巗cheduled triggers錛屾垜浠姹俠ean瀵逛簬鎵鏈夌殑搴忓垪閮戒笉鍙橈紝鍖呮嫭鍏跺睘鎬э紝鑰屽熀鏈被鍨嬪彲浠ュ湪Job榪愯榪囩▼涓敼鍙橈紝騫跺獎鍝嶄笅涓涓簭鍒椼傚疄闄呮儏鍐墊槸錛屽浜庝笅涓簭鍒楋紝bean鐨勫睘鎬ц涓婃鐨勪慨鏀逛簡錛岃屽熀鏈被鍨嬪嵈緇存寔絎竴嬈ut鍒癕ap閲岄潰鐨勫箋傛濂藉拰鎴戜滑瑕佹眰鐨勭浉鍙嶃?br />
鍙梑ean鐨勫獎鍝嶏紝浠ヤ負map閲岄潰鍖呭惈鐨勯兘鏄洿鏂扮殑瀵硅薄錛屽嵆姣忎釜搴忓垪閲岄潰鐨凧obDetail鏄悓涓涓璞★紝浣嗘槸鍩烘湰綾誨瀷鐨勭粨鏋滃惁璁や簡榪欎竴鐐廣傚洖澶撮噸鏂扮炕闃呬簡涓婹uartz鐨勬枃妗o細

Now, some additional notes about a job's state data (aka JobDataMap): A Job instance can be defined as "stateful" or "non-stateful". Non-stateful jobs only have their JobDataMap stored at the time they are added to the scheduler. This means that any changes made to the contents of the job data map during execution of the job will be lost, and will not seen by the job the next time it executes.

Job鏈変袱涓瓙鎺ュ彛錛歋tatefulJob and InterruptableJob錛屾垜浠戶鎵跨殑鏄疘nterruptableJob錛屾垨璁窺uartz搴旇鏈変釜InterruptableStatefulJob銆傚彟澶朣tatefulJob涓嶆敮鎸佸茍鍙戞墽琛岋紝鍜屾垜浠殑闇姹備笉鍖歸厤錛屾垜浠湁鑷繁鐨勫悓姝ユ帶鍒訛紝Job蹇呴』鍙互騫跺彂榪愯銆?br />
鐒跺悗鏌ョ湅浜哘uartz鐨勭浉鍏蟲簮鐮侊細

// RAMJobStore.storeJob
public void storeJob(SchedulingContext ctxt, JobDetail newJob,
            
boolean replaceExisting) throws ObjectAlreadyExistsException {
        JobWrapper jw 
= new JobWrapper((JobDetail)newJob.clone()); // clone a new one
        .
        jobsByFQN.put(jw.key, jw);
        
}

涔熷氨鏄錛宻tore閲岄潰鏀劇殑鏄垵濮婮obDetail鐨勫厠闅嗭紝鍦ㄥ簭鍒楄繍琛屽畬鏃訛紝鍙湁StatefulJob鎵嶄細鏇存柊store閲岄潰鐨凧obDetail錛?br />
// RAMJobStore.triggeredJobComplete
public void triggeredJobComplete(SchedulingContext ctxt, Trigger trigger,
            JobDetail jobDetail, 
int triggerInstCode) {
    JobWrapper jw 
= (JobWrapper) jobsByFQN.get(jobKey);
    
    
if (jw != null) {
        JobDetail jd 
= jw.jobDetail;
        
if (jd.isStateful()) {
            JobDataMap newData 
= jobDetail.getJobDataMap();
            
if (newData != null) {
                newData 
= (JobDataMap)newData.clone();
                newData.clearDirtyFlag();
            }
            jd.setJobDataMap(newData); 
// set to new one
            
        
    }

}



鐒跺悗錛屾瘡嬈″簭鍒楄繍琛屾椂鎵鐢ㄧ殑JobDetail錛屾槸瀛樻斁鍦⊿tore閲岄潰鐨勫厠闅嗐?br />
// RAMJobStore.retrieveJob
public JobDetail retrieveJob(SchedulingContext ctxt, String jobName,
        String groupName) {
    JobWrapper jw 
= (JobWrapper) jobsByFQN.get(JobWrapper.getJobNameKey(
        jobName, groupName));
    
return (jw != null? (JobDetail)jw.jobDetail.clone() : null// clone a new
}


闂寰堟竻妤氫簡錛屽瓨鏀懼湪Store閲岄潰鐨凧obDetail鏄垵濮嬪璞$殑鍏嬮殕錛岀劧鍚庢瘡涓簭鍒楁墍鐢ㄧ殑JobDetail錛?鏄疭tore閲岄潰鐨勫厠闅嗭紝鍙湁Stateful job錛孲tore閲岄潰鐨凧obDetail鎵嶆洿鏂般?br /> 鏈鏈塓uartz閲岄潰浣跨敤鐨刢lone():

// Shallow copy the jobDataMap.  Note that this means that if a user
// modifies a value object in this map from the cloned Trigger
// they will also be modifying this Trigger.
if (jobDataMap != null) {
    copy.jobDataMap 
= (JobDataMap)jobDataMap.clone();
}


鎵浠ュ浜庡墠闈㈡墍璁茬殑錛屼慨鏀筨ean鐨勫睘鎬э紝浼氬獎鍝嶆墍鏈塩lone鐨勫璞★紝鍥犳錛屾垜浠彲浠ュ皢鍩烘湰綾誨瀷灝佽鍒頒竴涓猙ean閲岄潰錛宮ap閲岄潰瀛樻斁鐨勬槸bean錛岀劧鍚庨氳繃淇敼bean鐨勫睘鎬э紝鏉ヨ揪鍒板獎鍝嶄笅涓涓簭鍒楃殑鐩殑銆?br />


honzeland 2010-01-21 17:38 鍙戣〃璇勮
]]>
Useful Links: ing...http://m.tkk7.com/honzeland/archive/2008/06/03/205565.htmlhonzelandhonzelandTue, 03 Jun 2008 07:09:00 GMThttp://m.tkk7.com/honzeland/archive/2008/06/03/205565.htmlhttp://m.tkk7.com/honzeland/comments/205565.htmlhttp://m.tkk7.com/honzeland/archive/2008/06/03/205565.html#Feedback0http://m.tkk7.com/honzeland/comments/commentRss/205565.htmlhttp://m.tkk7.com/honzeland/services/trackbacks/205565.html http://www.theserverside.com
http://www.javablogs.com
http://www.java2s.com
Java(TM) Platform Performance: Strategies and Tactics
A Simple Data Access Layer using Hibernate
Discover the secrets of the Java Serialization API
Setting up two-way (mutual) SSL with Tomcat on Java5
Basic Tomcat Tour and Tomcat Security
When Runtime.exec() won't
Asynchronous processing support in Servlet 3.0
About security:
The Types Of Digital Certificates
Cryptography Lecture PPT
MD5 considered harmful today
Cryptography Tutorials - Herong's Tutorial Notes
Defective Sign & Encrypt in S/MIME, PKCS#7, MOSS, PEM, PGP, and XML
Cryptography resources by Bouncycastle
Others:
Colors for the webColors for the web
Test Frameworks
Lightstreamer: a scalable and reliable Server for pushing live data to Rich Internet Applications


honzeland 2008-06-03 15:09 鍙戣〃璇勮
]]>
Managing HttpSession Objectshttp://m.tkk7.com/honzeland/archive/2008/05/21/201933.htmlhonzelandhonzelandWed, 21 May 2008 07:49:00 GMThttp://m.tkk7.com/honzeland/archive/2008/05/21/201933.htmlhttp://m.tkk7.com/honzeland/comments/201933.htmlhttp://m.tkk7.com/honzeland/archive/2008/05/21/201933.html#Feedback0http://m.tkk7.com/honzeland/comments/commentRss/201933.htmlhttp://m.tkk7.com/honzeland/services/trackbacks/201933.htmlzz: java.sys-con.com

Java servlet technology provides developers with functionality, scalability, and portability that can't be found in other server-side languages. One feature of the Java servlet specification that's commonly used, and sometimes misused, is the HttpSession interface. This simple interface allows you to maintain a session or state for Web site visitors.

In my previous article ("Introduction to Session Management," [JDJ, Vol. 7, issue 9]), I introduced you to session management and the HttpSession interface. In that article, we walked through using the HttpSession API to create, use, and destroy session objects for Web site visitors. The next step is to better understand how to manage the sessions and those objects in a session. This article will help you achieve this by helping you understand the following concepts:

  • Code-based session management through listeners
  • Proper design of the session and the objects it contains
  • Controlling what is in the session and why it's there
  • Session persistence
  • Memory management
The Java APIs discussed in this article are from Sun's Java Servlet 2.3 specification.

Listeners
A listener is an object that's called when a specified event occurs. There are four listener interfaces that allow you to monitor changes to sessions and the objects that are in those sessions:

  • HttpSessionListener
  • HttpSessionBindingListener
  • HttpSessionAttributeListener
  • HttpSessionActivationListener
Figure 1 provides a method summary for each of the listener interfaces. The implementing class that you write will override these methods to provide the functionality you need.

HttpSessionListener
The HttpSessionListener interface is used to monitor when sessions are created and destroyed on the application server. Its best practical use would be to track session use statistics for a server.

The use of HttpSessionListener requires a configuration entry in the deployment descriptor, or web.xml file, of the application server. This entry points the server to a class that will be called when a session is created or destroyed. The entry required is simple. All you need is a listener and listener-class element in the following format. The listener-class element must be a fully qualified class name.

<listener>
<listener-class>package.Class</listener-class>
</listener>

As you can see in Figure 1, the class that implements this listener can override two methods: sessionCreated() and sessionDestroyed(). These methods will be notified when the server creates or destroys a session.

These methods take an HttpSessionEvent object as a parameter. HttpSessionEvent is simply a class that represents notifications of changes to the Web application's sessions. HttpSessionEvent has one method, getSession(), that returns the HttpSession object that's been modified.

HttpSessionBindingListener
The HttpSessionBindingListener interface is implemented when an object needs to be notified if it's being bound to a session or unbound from a session.

This interface has two methods, valueBound() and valueUnbound(), that are notified when the status of the object has changed (see Figure 1).

These methods have an HttpSessionBindingEvent parameter that can be used to retrieve the session that the object was bound to and the name it was given in the session. In Figure 2, you can see the methods of this object that are used to get the name that's assigned to the object, the session it's bound to, and the actual object.

HttpSessionAttributeListener
The HttpSessionAttributeListener interface is used to monitor changes to attributes in any session on the server. This can be useful when you know the name assigned to a specific object that gets put into the session and you want to track how often it's being used.

As with HttpSessionListener, HttpSessionAttributeListener also requires an entry in the deployment descriptor for the server. This entry tells the server which class to call when an attribute in a session has changed.

The HttpSessionAttributeListener interface has three methods - attributeAdded(), attributeRemoved(), and attributeReplaced(). These methods, shown in Figure 1, are called by the server when attributes of a session are changed.

HttpSessionActivationListener
The final listener, HttpSessionActivationListener, is implemented when an object needs to know if the session that it's bound to is being activated or passivated (moved). You would come across this scenario if your session is being shared across JVMs or your server is persisting the session in a database or file system.

This interface, displayed in Figure 1, has two methods that are overridden by the implementing class: sessionDidActivate() and sessionWillPassivate(). These methods are called when the status of the session in a JVM is changed.

Session Persistence
Today's J2EE-compliant servers allow for fault-tolerance and failover to provide support in the event that a server suddenly becomes unavailable because of hardware, software, or network failure. This support is usually provided by allowing two or more application servers, often called a cluster, to run together and provide backup support for each other. If one server fails, the others pick up the requests and continue on as if nothing happened. This allows your Web site visitors to keep going without interruption.

A proxy server is usually used in front of the application servers. This server is responsible for directing each HTTP request to the appropriate server. The proxy server can be set up to ensure that the server receiving the first request from a user will continue to receive all subsequent requests from that user. This means that a session created for the user on the application server will continue to be available for that user. If the server suddenly fails, there has to be a system in place to allow the session to continue on without it.

Session persistence allows the session contents to be saved outside the application server so that other servers can access it. Figure 3 shows the relationship between the persisted session data and the application servers that access it. In this figure, you see a client accessing a Web site's HTTP server. The HTTP server is forwarding requests for application resources to one of the application servers through the use of a proxy server. The application servers are persisting the session data in an external form.

There are four types of session persistence:

  1. Memory persistence (one server or a cluster of two or more)
  2. File system persistence
  3. Database persistence
  4. Cookie persistence
Every application server will handle session persistence differently and all servers may not support all types of persistence. Objects that are placed in the session must be serializable for persistence to work.

Memory Persistence
In most cases, a single standalone server will store sessions in memory. This allows for fast retrieval and update of the information. It also means that the session information will be lost when the server is shut down. This is usually the default configuration on most application servers. Memory persistence can be used when two or more servers need to share the session information. The application servers can be configured to share any changes made to the session so that the information is available on multiple servers. This redundancy of the session information helps the cluster preserve the session during a failure.

File System Persistence
File system persistence can be used to serialize any objects that are in the session. The object contents are placed in a file on the server. The location of the files created is configurable; however, the files must be accessible by all the servers in the cluster. The speed at which the file system is accessed can be a factor in the performance of your Web site. A slow disk drive, for example, would result in a delay as data is read from or written to the file.

Database Persistence
Database persistence can be used to provide a central data store for the session contents. Each application server in the cluster must be able to access the database. When sessions are modified, the changes are immediately persisted in the database. A data source is usually set up for JDBC persistence and the connections are pooled. This provides a quicker response. There's also the issue of database failover, which would be addressed at the database level of the system.

Cookie Persistence
The fourth type of session persistence, cookie persistence, is so ineffective and insecure that it doesn't deserve consideration when designing a fail-safe system. Cookie persistence, as the name implies, persists session data by storing the session information in browser cookie(s). There's a limitation on data handling because cookies store only text, not objects, and the amount of data that can be transmitted in a cookie is limited. There's also the fact that cookies transmit data back and forth between the client and the server. This prevents you (at least it should) from saving sensitive information, like a social security number. This type of persistence should be used in only the smallest of Web sites, and only if there's a good reason not to store the session in memory.

The most common type of persistence is database persistence. It provides an efficient way of saving session data and it's usually fairly easy to set up on the application server. Memory persistence in a cluster is also easy to use, if your application server supports it. The only drawback is that sessions can sometimes hold large amounts of data. Storing the session in memory reduces the amount of memory available to the other processes on the server. File system persistence can be slow at times and the file system may not always be accessible to multiple servers.

Watching the Session Size
As you and your fellow employees work on a Web application, you may notice that more and more objects are being thrown into the session, often "for convenience" or "just temporarily." The session becomes a quick catch-all for any information you need to get from your servlets to your JSPs. The HttpSession interface makes sessions easy to use, which can lead to the session being overused. This is a concern because the session takes up space. In most cases that would be memory space. In other cases, it could be database or file system space. In all cases, it means more work for the server and more work for the programmers to manage what is there.

Although the session is convenient because it's accessible from every servlet or JSP, it's not always the best place to put information. Most of the data that's retrieved for display in a Web application will only be used on one page. Instead of putting the information into the session scope, use the request scope and then forward the request from the servlet to the JSP. This causes the objects to be destroyed after the request has ended, which is after the data is displayed by the JSP. If you put the objects into the session, you would either have to remove them in your code or leave them there. Leaving objects in the session is not a good idea because you're using up valuable resources for no reason. This becomes even more of an issue when your Web site has hundreds or thousands of visitors, all of whom have a session that's loaded with objects.

Some objects should be stored in the session. Objects that may be needed over and over again as a user moves through a Web site are those that should be put into the session. Anything that needs to exist longer than one request can be stored in the session, as long as these objects are removed as soon as they're no longer needed.

Considerations for Managing Sessions
When working with sessions, there are a few things to consider before designing or redesigning a Web application:

  • Are sessions needed in the application?
  • How long should the session be inactive before timing out?
  • Are all the objects in the session serializable?
  • Are the objects being bound to the session too large?
  • Do the objects that are in the session really need to be there?
A Need for Sessions
If you have unique users on a Web site and need to know who they are or need to get specific information to them, such as search results, then you should be using sessions. If you follow the guidelines set here, there's no reason not to use the HttpSession interface that Java provides. It's easy to use, flexible, secure, and it helps you to build a better Web site.

There's another architecture that deals with maintaining state for a client. Instead of relying on the HttpSession interface, state for clients can be maintained within Enterprise JavaBeans (EJBs). The EJB architecture takes the business logic for an application and places it in components or beans. A session bean is a type of EJB that exists for a given client/server session and provides database access or other business logic, such as calculations. Session beans can be stateless or they can maintain the state for a client, very much like an HttpSession object.

There is still some debate over where the state for a Web site visitor should be maintained. The best design for the application at this time is to continue using the HttpSession object for maintaining the state of the presentation layer of the Web application and to use stateful EJBs to maintain the state of the business logic and data layer. There are many other factors that should be considered with EJBs, one being the better performance of stateless beans over those that maintain state. These issues, which are outside the scope of this article, should be considered carefully when architecting an application.

Session Timeout
By default, on most servers the session is set to expire after 30 minutes of inactivity. The amount of time can be configured in the deployment descriptor of the Web application. The HttpSession API also provides a setMaxInactiveInterval() method that you can use to specify the timeout period for a session. The getMaxInactiveInterval() method will return this timeout value. The value given is in seconds.

The length of time will vary depending on what your visitors are doing on your site. If they're logging in to check their account balance, a shorter session timeout period can be used because it doesn't take long for a person to read a couple of numbers. If, on the other hand, the user is logging in to read large amounts of data, you need to be sure that you provide enough time for the user to do what he or she wants without being logged out. If the user is constantly navigating through your site, the session will last indefinitely.

Implement Serializable
It's important to make sure that all objects placed in the session can be serialized. This may not be an issue if you know that your Web application will not run in a cluster, but it should still be done anyway. What happens if your Web site grows too big for one server and you suddenly have to move to two? If you implement Serializable in your code now, you won't have to go back and do it later.

Keep It Simple
You should design objects that are going to be placed into a session so that they're not too big and don't contain unnecessary information. A JavaBean that contains a customer's name, address, phone number, e-mail address, credit card numbers, and order history should not be placed into the session if you're only going to use the object to get the customer's name.

Session Contents
When you're working on a Web site, it's important to know which objects are in the session and why they're needed. The size of the session should be kept as small as possible. If you're building a new Web site, work out ahead of time what goes in the session, why it's there, and where it gets removed. If you're redesigning an existing site, this may be a little tougher, especially when you have hundreds of servlets and JSPs to deal with. In this case, try implementing an HttpSessionAttributeListener to get an idea of what is going into the session. With this information, you may be able to better manage your sessions.

Conclusion
Hopefully this article helped you to better understand the design issues involved in using the HttpSession interface. Java provides a more robust session implementation than other languages. It's because of this power and flexibility that you must take the time to properly lay out the use of the session. A well-designed session will help make a Web application better for the programmers and the users.

References

  • Hall, M. (2002). More Servlets and JavaServer Pages. Prentice Hall PTR.
  • Java Servlet Technology: http://java.sun.com/products/servlet
  • Enterprise JavaBeans Technology: http://java.sun.com/products/ejb
  • Java BluePrints (J2EE): http://java.sun.com/blueprints/guidelines/ designing_enterprise_applications


  • 鍙﹀錛岃繕鏈変竴浜涙敹闆嗙殑鏉愭枡
    鍏充簬HttpSession鐨勮瑙e疄鍦ㄦ槸澶浜嗭紝鏈潵鏄竴涓緢綆鍗曠殑闂錛屾庝細鎼炵殑濡傛鐨勫鏉傚憿錛熶笅闈㈣璇存垜鐨勭悊瑙e惂錛?br /> 1銆丠TTP鍗忚鏈韓鏄?#8220;榪炴帴-璇鋒眰-搴旂瓟-鍏抽棴榪炴帴”妯″紡鐨勶紝鏄竴縐嶆棤鐘舵佸崗璁紙HTTP鍙槸涓涓紶杈撳崗璁級錛?br /> 2銆丆ookie瑙勮寖鏄負浜嗙粰HTTP澧炲姞鐘舵佽窡韙敤鐨勶紙濡傛灉瑕佺簿紜妸鎻★紝寤鴻浠旂粏闃呰涓涓嬬浉鍏崇殑RFC錛夛紝浣嗕笉鏄敮涓鐨勬墜孌碉紱
    3銆佹墍璋揝ession錛屾寚鐨勬槸瀹㈡埛绔拰鏈嶅姟绔箣闂寸殑涓孌典氦浜掕繃紼嬬殑鐘舵佷俊鎭紙鏁版嵁錛夛紱榪欎釜鐘舵佸浣曠晫瀹氾紝鐢熷懡鏈熸湁澶氶暱錛岃繖鏄簲鐢ㄦ湰韜殑浜嬫儏錛?br /> 4銆佺敱浜嶣/S璁$畻妯″瀷涓綆楁槸鍦ㄦ湇鍔″櫒绔畬鎴愮殑錛屽鎴風鍙湁綆鍗曠殑鏄劇ず閫昏緫錛屾墍浠ワ紝Session鏁版嵁瀵瑰鎴風搴旇鏄忔槑鐨勪笉鍙悊瑙g殑騫朵笖搴旇鍙楁帶浜庢湇鍔$錛汼ession鏁版嵁瑕佷箞淇濆瓨鍒版湇鍔$錛圚ttpSession錛夛紝瑕佷箞鍦ㄥ鎴風鍜屾湇鍔$涔嬮棿浼犻掞紙Cookie鎴杣rl rewritting鎴朒idden input錛夛紱
    5銆佺敱浜嶩TTP鏈韓鐨勬棤鐘舵佹э紝鏈嶅姟绔棤娉曠煡閬撳鎴風鐩哥戶鍙戞潵鐨勮姹傛槸鏉ヨ嚜涓涓鎴風殑錛屾墍浠ワ紝褰撲嬌鐢ㄦ湇鍔$HttpSession瀛樺偍浼氳瘽鏁版嵁鐨勬椂鍊欏鎴風鐨勬瘡涓姹傞兘搴旇鍖呭惈涓涓猻ession鐨勬爣璇?sid, jsessionid 絳夌瓑)鏉ュ憡璇夋湇鍔$錛?br /> 6銆佷細璇濇暟鎹繚瀛樺湪鏈嶅姟绔紙濡侶ttpSession錛夌殑濂藉鏄噺灝戜簡HTTP璇鋒眰鐨勯暱搴︼紝鎻愰珮浜嗙綉緇滀紶杈撴晥鐜囷紱瀹㈡埛绔痵ession淇℃伅瀛樺偍鍒欑浉鍙嶏紱
    7銆佸鎴風Session瀛樺偍鍙湁涓涓姙娉曪細cookie(url rewritting鍜宧idden input鍥犱負鏃犳硶鍋氬埌鎸佷箙鍖栵紝涓嶇畻錛屽彧鑳戒綔涓轟氦鎹ession id鐨勬柟寮忥紝鍗砤 method of session tracking)錛岃屾湇鍔$鍋氭硶澶ц嚧涔熸槸涓涓亾鐞嗭細瀹瑰櫒鏈変釜session綆$悊鍣紙濡倀omcat鐨?org.apache.catalina.session鍖呴噷闈㈢殑綾伙級錛屾彁渚泂ession鐨勭敓鍛藉懆鏈熷拰鎸佷箙鍖栫鐞嗗茍鎻愪緵璁塊棶session鏁版嵁鐨?api錛?br /> 8銆佷嬌鐢ㄦ湇鍔$榪樻槸瀹㈡埛绔痵ession瀛樺偍瑕佺湅搴旂敤鐨勫疄闄呮儏鍐電殑銆備竴鑸潵璇翠笉瑕佹眰鐢ㄦ埛娉ㄥ唽鐧誨綍鐨勫叕鍏辨湇鍔$郴緇燂紙濡俫oogle錛夐噰鐢?cookie鍋氬鎴風session瀛樺偍錛堝google鐨勭敤鎴峰亸濂借緗級錛岃屾湁鐢ㄦ埛綆$悊鐨勭郴緇熷垯浣跨敤鏈嶅姟绔瓨鍌ㄣ傚師鍥犲緢鏄劇劧錛氭棤闇鐢ㄦ埛鐧誨綍鐨勭郴緇熷敮涓鑳藉鏍囪瘑鐢ㄦ埛鐨勫氨鏄敤鎴風殑鐢佃剳錛屾崲涓鍙版満鍣ㄥ氨涓嶇煡閬撹皝鏄皝浜嗭紝鏈嶅姟绔痵ession瀛樺偍鏍規湰涓嶇鐢紱鑰屾湁鐢ㄦ埛綆$悊鐨勭郴緇熷垯鍙互閫氳繃鐢ㄦ埛id鏉ョ鐞嗙敤鎴蜂釜浜烘暟鎹紝浠庤屾彁渚涗換鎰忓鏉傜殑涓у寲鏈嶅姟錛?br /> 9銆佸鎴風鍜屾湇鍔$鐨剆ession瀛樺偍鍦ㄦц兘銆佸畨鍏ㄦс佽法绔欒兘鍔涖佺紪紼嬫柟渚挎х瓑鏂歸潰閮芥湁涓瀹氱殑鍖哄埆錛岃屼笖浼樺姡騫墮潪緇濆錛堣濡俆heServerSide鍙風О涓嶄嬌鐢℉ttpSession錛屾墍浠ユц兘濂斤紝榪欏緢鏄劇劧錛氫竴涓叿鏈変笂浜跨殑璁塊棶鐢ㄦ埛鐨勭郴緇燂紝瑕佸湪鏈嶅姟绔暟鎹簱涓绱㈠嚭鐢ㄦ埛鐨勫亸濂戒俊鎭樉鐒舵槸浣庢晥鐨勶紝Session綆$悊鍣ㄤ笉綆$敤浠涔堟暟鎹粨鏋勫拰綆楁硶閮借鑰楄垂澶ч噺鍐呭瓨鍜孋PU鏃墮棿錛涜岀敤cookie錛屽垯鏍規湰涓嶇敤媯绱㈠拰緇存姢session鏁版嵁錛屾湇鍔″櫒鍙互鍋氭垚鏃犵姸鎬佺殑錛屽綋鐒墮珮鏁堬級錛?br /> reply1:
    涓嶈繃鎴戜滑涔熶笉鑳藉湪session閲岄潰鏀懼叆榪囧鐨勪笢瑗?br /> 涓鑸潵璇翠笉鑳借秴榪?K
    澶浜?br /> 瀵圭郴緇熻祫婧愭槸涓涓緢涓ラ噸鐨勬氮璐?br /> reply2:
    4K宸叉槸寰堝ぇ鐨勪竴涓暟瀛椾簡銆?br /> 鎴戜竴鑸枩嬈㈠啓涓涓被銆傚皝瑁呯敤鎴風櫥闄嗗悗鐨勪竴浜涗俊鎭?br /> 鐒跺悗鎶婅繖涓被鏀懼湪session涓紝鍙栧緱鐩存帴鐢ㄧ被鐨勬柟娉曞彇鐩稿叧淇℃伅錛?br />


    honzeland 2008-05-21 15:49 鍙戣〃璇勮
    ]]>
    Svn revision retrieve and logging to databasehttp://m.tkk7.com/honzeland/archive/2008/04/28/196772.htmlhonzelandhonzelandMon, 28 Apr 2008 07:43:00 GMThttp://m.tkk7.com/honzeland/archive/2008/04/28/196772.htmlhttp://m.tkk7.com/honzeland/comments/196772.htmlhttp://m.tkk7.com/honzeland/archive/2008/04/28/196772.html#Feedback2http://m.tkk7.com/honzeland/comments/commentRss/196772.htmlhttp://m.tkk7.com/honzeland/services/trackbacks/196772.html 1錛?logging to database
    緇忚繃璋冩煡錛屽喅瀹氶噰鐢╨og4j鐨刼rg.apache.log4j.jdbc.JDBCAppender錛屼簬鏄噰鐢細
    # logging to db
    log4j.logger.com.example=DEBUG, DATABASE
    log4j.additivity.com.example=false
    log4j.appender.DATABASE=org.apache.log4j.jdbc.JDBCAppender
    log4j.appender.DATABASE.url=jdbc:postgresql://localhost:5432/test
    log4j.appender.DATABASE.driver=org.postgresql.Driver
    log4j.appender.DATABASE.user=pguser
    log4j.appender.DATABASE.password=post
    log4j.appender.DATABASE.sql=INSERT INTO debug_log(created, logger, priority, message) VALUES (to_timestamp('%d{ISO8601}','YYYY-MM-DD HH:MI:SS.MS'),'%c.%M:%L','%p','%m')
    log4j.appender.DB.layout=org.apache.log4j.PatternLayout
    log4j.appender.DATABASE.layout.ConversionPattern=%d{ISO8601} %p %c.%M:%L %m
    寰堢洿瑙傦紝鐢ㄨ搗鏉ヨ繕寰堟柟渚匡紝浣嗘槸涓嶄箙灝卞嚭鐜頒簡闂錛宼omcat鎶涘嚭浜唀xception銆傚彧濂芥妸涔嬪墠fixed ticket reopen錛屾彁浜ゆ柊鐨刢omments錛歎nfortunately, org.apache.log4j.jdbc.JDBCAppender that ships with the Log4j distribution is not able to process logging messages that have characters like ' (single quote) and , (comma) in it. When logging messages contains characters like single quote or comma, the program will throw an exception.
    閲嶆柊google浜嗭紝鎵懼埌浜嗕竴涓猵lusjdbc錛孡ooking further, I found an alternative JDBCAppender package (org.apache.log4j.jdbcplus.JDBCAppender) from http://www.dankomannhaupt.de/projects/index.html. It can solve this problem. 闀垮徆浜嗕竴涓嬨?br />
    鏈鍚庨噰鐢細
    log4j.appender.DATABASE=org.apache.log4j.jdbcplus.JDBCAppender
    log4j.appender.DATABASE.url=jdbc:postgresql://localhost:5432/test
    log4j.appender.DATABASE.dbclass=org.postgresql.Driver
    log4j.appender.DATABASE.username=pguser
    log4j.appender.DATABASE.password=post
    log4j.appender.DATABASE.sql=INSERT INTO debug_log(created, logger, priority, message) VALUES (to_timestamp('@LAYOUT:1@', 'YYYY-MM-DD HH:MI:SS.MS'),'@LAYOUT:3@','@LAYOUT:2@','@LAYOUT:4@')
    log4j.appender.DATABASE.layout=org.apache.log4j.PatternLayout
    log4j.appender.DATABASE.layout.ConversionPattern=%d{ISO8601}#%p#%c.%M:%L#%m
    log4j.appender.DATABASE.layoutPartsDelimiter=#
    log4j.appender.DATABASE.buffer=1
    log4j.appender.DATABASE.commit=true
    log4j.appender.DATABASE.quoteReplace=true
    闂瑙e喅錛屼絾鏄腑闂存湁鐐瑰皬娉㈡姌錛屽湪鎴戠殑欏圭洰涓紝log4j.jar錛?gt;1.2.9錛夐噸澶嶄簡錛屽湪$CATALINA_HOME/lib涓嬫湁涓浠斤紝鍦╳eb宸ョ▼涓嬬殑WEB-INF/lib涓嬩篃鏈変竴浠斤紝鑰宲lus-jdbc.jar鏀劇疆鍦?CATALINA_HOME/lib涓嬶紝緇撴灉鍚姩Tomcat錛屽嚭鐜?br /> log4j:ERROR A "org.apache.log4j.jdbcplus.JDBCAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
    log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
    log4j:ERROR [WebappClassLoader^M
      delegate: false^M
      repositories:^M
    ----------> Parent Classloader:^M
    org.apache.catalina.loader.StandardClassLoader@1ccb029^M
    ] whereas object of type
    log4j:ERROR "org.apache.log4j.jdbcplus.JDBCAppender" was loaded by [org.apache.catalina.loader.StandardClassLoader@1ccb029].
    log4j:ERROR Could not instantiate appender named "DATABASE".
    鍘熸潵鏄袱涓狫DBCAppender瀹炰緥涓嶅湪鍚屼竴涓猚lasslaoder閲岄潰錛屽皢WEB-INF/lib涓嬬殑log4j.jar鍒犻櫎鎺夛紝閲嶅惎灝辨病闂浜嗭紝鎸夌悊錛屽皢$CATALINA_HOME/lib涓嬬殑plus-jdbc.jar縐誨埌WEB-INF/lib涓嬶紝搴旇涔熸病闂錛屾病鏈夋祴璇曘?br />
    2錛堿dd build revision info in war file and read it on tomcat startup
    榪欎釜緇忓巻姣旇緝鎯ㄧ棝錛屼袱涓棶棰橈紝濡備綍鑾峰彇revision錛?And how to read it when tomcat startup? 絎簩涓棶棰樺掓槸娌′粈涔堬紝閲囩敤javax.servlet.ServletContextListener灝卞彲浠ュ疄鐜幫紝寰堢畝鍗曪紝璧板集璺殑鏄涓涓棶棰橈紝google鍚庡彂鐜版湁涓ょ甯歌鐨勫疄鐜幫細
    As I have learned, there are totally two solutions to get svn revision info.

    First, retrieve the svn revision from local file($BASE_HOME/.svn/entries). Just parsing the xml file, get the revision property and write it to a properties file.錛堝氨鏄姝葷殑xml錛岃繙鍦ㄤ箤鍏嬪叞鐨勫悓浜嬶紝璇ユ枃浠跺嵈涓嶆槸xml鐨勶紝涔熷彧鎬嚜宸辮皟鐮斾笉鍏呭垎錛岃繕寰楁姌鑵句簡鍗婂ぉ錛屽悗鏉ュ彂鐜幫紝鏈鏂扮増鐨剆vn涓轟簡performance鐨勮冭檻錛岄噰鐢╩eta data鏉ュ疄鐜癳ntries錛?br />
    Second, retrieve the svn revision from the remote repository. The solution always use a svn client to perform a demand with remote server to retrieve the revision info. Installing a snv client and using SvnAnt? are most commonly used at present. SvnAnt? is an ant task that provides an interface to Subversion revision control system and encapsulates the svn client. It uses javahl - a native (JNI) java interface for the subversion api if it can find the corresponding library. javahl is platform-dependent.

    Because of needing interaction with the server(鏈嶅姟鍣ㄥ湪鍥藉錛屾洿鏂板緢鎱?, now I employ the first solution. But I found a flaw of this method when i was going off duty. Generally, we may update our project with svn before committing. This may make a mismatch with svn revision between remote server and local file. Svn revision in local file is usually updated when we update our project. But when we take a commit after update, the svn revision in the remote server will change to a new one.

    So, the case is that if we update, commit, and then build, we may get a mismatch with the newest svn revision, and build the error revision into our ROOT.war. If we update , then build ,without commit, we can get right revision info.

    涓嬮潰鏄涓鐗堝疄鐜幫細
        <!--  retrieve the svn revision from the remote repository
        <path id="svnant.lib" >
            <fileset dir="${lib.dir}">
                <include name="svnant.jar"/>
                <include name="svnClientAdapter.jar"/>
                <include name="svnjavahl.jar"/>
            </fileset>
        </path>
       
        <taskdef name="svn" classpathref="svnant.lib" classname="org.tigris.subversion.svnant.SvnTask" />
       
        <target name="get-svn-revision">
            <svn username="*******" password="******" javahl="true">
                    <status urlProperty="https://example.com" path="." revisionProperty="svn.revision" />
            </svn>
            <echo>svn revision: ${svn.revision}</echo>
        </target>   
        -->
       
        <!--  retrieve the svn revision from local file(.svn/entries). The file may contain several  'wc-entries.entry.revision' elements.
        The property will get several values seperated by ',' when using xmlproperty task.  Then the svn revison expected will be the
        max one of these property values.
         -->
        <property name="svn.revision.file" value=".svn/entries" />
        <!-- This property is used to run xmlproperty task successfully with a low version of svn client (under 1.3.1). Don't  sure whether it really makes sense -->
        <property name="build.id" value="foo" />
        <target name="get-svn-revision">
            <xmlproperty file="${svn.revision.file}" collapseAttributes="true"/>
            <echo>svn revision: ${wc-entries.entry.revision}</echo>
        </target>

        <!--
            If the file doesn't contain any 'wc-entries.entry.revision' element, the content of the property file will be: revision = ${wc-entries.entry.revision};
            If contain a 'wc-entries.entry.revision' element, mark this value as $revision_value, then  the content will be: revision = $revision_value;
            If contain several 'wc-entries.entry.revision' elements, mark these values as $value1, $value2, ..., respectively, then the content will be: revision = $value1,$value2,..., seperated by a ',';
        -->
        <property name="svn.revision.propertyfile" value="${build.dir}/revision.properties" />
        <target name="write-svn-revision-to-file" depends="get-svn-revision">
            <delete file="${svn.revision.propertyfile}"/>
            <propertyfile file="${svn.revision.propertyfile}" comment="record svn revision">
                <entry  key="revision" value="${wc-entries.entry.revision}"/>
            </propertyfile>
        </target>

    緇撴灉write-svn-revision-to-file榪欎釜鍦ㄦ垜榪欏掓槸鍙互鑾峰彇鏈湴鐨剆vn revision錛屼絾鏄繙鏂圭殑鍚屼簨鍙ヤ簡錛宐uild鑰佸け璐ワ紝鍙ソ鎶婅繖閮ㄥ垎build娉ㄩ噴浜嗭紝榪樺ソ錛屽埌鍛ㄦ湯浜嗭紝鍙互鍦ㄥ濂藉ソ鐮旂┒涓涓嬶紝寰堝揩鎵句簡涓涓柊鐨勫伐鍏鳳細
    It's my fault. In my version of svn, the entries file is xml formatted. So i parse it using ant task - 'xmlproperty'. Now i have fix this problem by using 'svnkit' tools, a pure java svn toolkit. Now there are two ways to retrieve svn revision. One is from remote repository server. For this one, before building, you should set your own username and password for the remote repository server('remote.repository.username' and 'remote.repository.password' properties in build.xml,respectively). Another one is retrieving revision from local working copy. If using this one, you should set 'local.repository' property in build.xml to your own directory.
    鍒╃敤svnkit錛屼粠鏈嶅姟鍣ㄤ笂鑾峰彇revision澶ф鏄細
                repository = SVNRepositoryFactory.create(SVNURL.parseURIDecoded(urlStr));
                ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(username, password);
                repository.setAuthenticationManager(authManager);
                headRevision = repository.getLatestRevision();
    浠庢湰鍦皐orking copy鑾峰彇revision錛?br />             SVNClientManager clientManager = SVNClientManager.newInstance();
                SVNWCClient wcClient = clientManager.getWCClient();   
                SVNInfo info = wcClient.doInfo(new File(fileUrl), SVNRevision.WORKING);
                headRevision = info.getRevision().getNumber(); 

    鍒╃敤ant task灝嗚幏鍙栫殑revision鍐欏叆鍒頒竴涓厤緗枃浠朵腑錛堝revision.properties錛?鍦╰omcat鍚姩鐨勬椂鍊欏姞杞借繘鏉ワ紝灝卞彲浠ヤ簡銆?nbsp;  


    honzeland 2008-04-28 15:43 鍙戣〃璇勮
    ]]>
    Tomcat ClassLoader and load resourceshttp://m.tkk7.com/honzeland/archive/2008/04/24/195605.htmlhonzelandhonzelandThu, 24 Apr 2008 07:46:00 GMThttp://m.tkk7.com/honzeland/archive/2008/04/24/195605.htmlhttp://m.tkk7.com/honzeland/comments/195605.htmlhttp://m.tkk7.com/honzeland/archive/2008/04/24/195605.html#Feedback0http://m.tkk7.com/honzeland/comments/commentRss/195605.htmlhttp://m.tkk7.com/honzeland/services/trackbacks/195605.html
    1 - Tomcat鐨勭被杞藉叆鍣ㄧ殑緇撴瀯
    Tomcat Server鍦ㄥ惎鍔ㄧ殑鏃跺欏皢鏋勯犱竴涓狢lassLoader鏍戯紝浠ヤ繚璇佹ā鍧楃殑綾誨簱鏄鏈夌殑
    Tomcat Server鐨凜lassLoader緇撴瀯濡備笅錛?br />         +-----------------------------+

            |         Bootstrap           |

            |             |               |

            |          System             |

            |             |               |

            |          Common             |

            |         /      \            |

            |     Catalina  Shared        |

            |               /    \        |

            |          WebApp1  WebApp2   |

            +-----------------------------+

    鍏朵腑錛?br /> - Bootstrap - 杞藉叆JVM鑷甫鐨勭被鍜?JAVA_HOME/jre/lib/ext/*.jar
    - System - 杞藉叆$CLASSPATH/*.class
    - Common - 杞藉叆$CATALINA_HOME/common/...錛屽畠浠TOMCAT鍜屾墍鏈夌殑WEB APP閮藉彲瑙?br /> - Catalina - 杞藉叆$CATALINA_HOME/server/...錛屽畠浠粎瀵筎OMCAT鍙錛屽鎵鏈夌殑WEB APP閮戒笉鍙
    - Shared - 杞藉叆$CATALINA_HOME/shared/...錛屽畠浠粎瀵規墍鏈塛EB APP鍙錛屽TOMCAT涓嶅彲瑙侊紙涔熶笉蹇呰錛?br /> - WebApp - 杞藉叆ContextBase?/WEB-INF/...錛屽畠浠粎瀵硅WEB APP鍙

    2 - ClassLoader鐨勫伐浣滃師鐞?br />
    姣忎釜榪愯涓殑綰跨▼閮芥湁涓涓垚鍛榗ontextClassLoader錛岀敤鏉ュ湪榪愯鏃跺姩鎬佸湴杞藉叆鍏跺畠綾?br /> 緋葷粺榛樿鐨刢ontextClassLoader鏄痵ystemClassLoader錛屾墍浠ヤ竴鑸岃█java紼嬪簭鍦ㄦ墽琛屾椂鍙互浣跨敤JVM鑷甫鐨勭被銆?JAVA_HOME/jre/lib/ext/涓殑綾誨拰$CLASSPATH/涓殑綾?br /> 鍙互浣跨敤Thread.currentThread().setContextClassLoader(...);鏇存敼褰撳墠綰跨▼鐨刢ontextClassLoader錛屾潵鏀瑰彉鍏惰澆鍏ョ被鐨勮涓?br />
    ClassLoader琚粍緇囨垚鏍戝艦錛屼竴鑸殑宸ヤ綔鍘熺悊鏄細
    1) 綰跨▼闇瑕佺敤鍒版煇涓被錛屼簬鏄痗ontextClassLoader琚姹傛潵杞藉叆璇ョ被
    2) contextClassLoader璇鋒眰瀹冪殑鐖禖lassLoader鏉ュ畬鎴愯杞藉叆璇鋒眰
    3) 濡傛灉鐖禖lassLoader鏃犳硶杞藉叆綾伙紝鍒檆ontextClassLoader璇曞浘鑷繁鏉ヨ澆鍏?br />
    娉ㄦ剰錛歐ebApp?ClassLoader鐨勫伐浣滃師鐞嗗拰涓婅堪鏈夊皯璁鎬笉鍚岋細
    瀹冨厛璇曞浘鑷繁杞藉叆綾伙紙鍦–ontextBase?/WEB-INF/...涓澆鍏ョ被錛夛紝濡傛灉鏃犳硶杞藉叆錛屽啀璇鋒眰鐖禖lassLoader瀹屾垚

    鐢辨鍙緱錛?br /> - 瀵逛簬WEB APP綰跨▼錛屽畠鐨刢ontextClassLoader鏄疻ebApp?ClassLoader
    - 瀵逛簬Tomcat Server綰跨▼錛屽畠鐨刢ontextClassLoader鏄疌atalinaClassLoader

    3 綾葷殑鏌ユ壘

    ClassLoader綾諱腑loadClass鏂規硶涓虹己鐪佸疄鐜幫紝鐢ㄤ笅闈㈢殑欏哄簭鏌ユ壘綾伙細
    1銆佽皟鐢╢indLoadedClass鏂規硶鏉ユ鏌ユ槸鍚﹀凡緇忚鍔犺澆銆傚鏋滄病鏈夊垯緇х畫涓嬮潰鐨勬楠ゃ?br /> 2銆佸鏋滃綋鍓嶇被瑁呰澆鍣ㄦ湁涓涓寚瀹氱殑濮旀墭鐖惰杞藉櫒錛屽垯鐢ㄥ鎵樼埗瑁呰澆鍣ㄧ殑loadClass鏂規硶鍔犺澆綾伙紝涔熷氨鏄鎵樼粰鐖惰杞藉櫒鍔犺澆鐩稿簲鐨勭被銆?br /> 3銆佸鏋滆繖涓被瑁呰澆鍣ㄧ殑濮旀墭灞傜駭浣撶郴娌℃湁涓涓被瑁呰澆鍣ㄥ姞杞借綾伙紝鍒欎嬌鐢ㄧ被瑁呰澆鍣ㄥ畾浣嶇被鐨勭壒瀹氬疄鐜版満鍒訛紝璋冪敤findClass鏂規硶鏉ユ煡鎵劇被銆?br />
    4 - 閮ㄥ垎鍘熶唬鐮佸垎鏋?br /> 4.1 - org/apache/catalina/startup/Bootstrap.java
    Bootstrap涓畾涔変簡涓変釜classloader:commonLoader,catalinaLoader,sharedLoader.涓夎呭叧緋誨涓嬶細
    //娉ㄦ剰涓変釜鑷繁瀹氱疆鐨凜lassLoader鐨勫眰嬈″叧緋伙細
                // systemClassLoader (root)
                //   +--- commonLoader
                //          +--- catalinaLoader
                //          +--- sharedLoader

    Tomcat Server綰跨▼鐨勮搗鐐?br /> 鏋勯燙lassLoader鏍戯紝閫氳繃Thread.currentThread().setContextClassLoader(catalinaLoader)璁劇疆褰撳墠鐨刢lassloader涓篶atalinaLoader銆?br /> 杞藉叆鑻ュ共綾伙紝鐒跺悗杞叆org.apache.catalina.startup.Catalina綾諱腑

    4.2 org.apache.catalina.loader.StandardClassLoader.java

    閫氳繃鐪媗oadClass榪欎釜鏂規硶鏉ョ湅tomcat鏄浣曞姞杞界被鐨勶紝欏哄簭濡備笅錛?br />
    (0) Check our previously loaded class cache鏌ユ壘宸茬粡瑁呰澆鐨刢lass
            clazz = findLoadedClass(name);

    (1) If a system class, use system class loader閫氳繃緋葷粺classloader鏉ヨ杞絚lass
            ClassLoader loader = system;
                clazz = loader.loadClass(name);

    (2) Delegate to our parent if requested濡傛灉鏈変唬鐞嗗垯浣跨敤鐖剁被classloader
                ClassLoader loader = parent;
                if (loader == null)
                    loader = system;
                clazz = loader.loadClass(name);

    (3) Search local repositories 鏌ユ壘鏈湴綾繪睜錛屾瘮濡?CATALINA_HOME/server
               clazz = findClass(name);

    (4) Delegate to parent unconditionally 榛樿浣跨敤浠g悊瑁呰澆鍣?br />
    [鏌ョ湅浠g爜]

    4.3 - org/apache/catalina/startup/ClassLoaderFactory.java

    鏍規嵁璁劇疆鍒涘緩騫惰繑鍥濻tandardClassLoader鐨勫疄渚?br />
    [鏌ョ湅浠g爜]

    4.4 - org/apache/catalina/loader/StandardClassLoader.java

    綾昏澆鍏ュ櫒

    4.5 - org/apache/catalina/startup/SecurityClassLoad.java

    璇ョ被浠呭寘鍚竴涓潤鎬佹柟娉曪紝鐢ㄦ潵涓篶atalinaLoader杞藉叆涓浜涚被

    [鏌ョ湅浠g爜]

    Appendix - 鍙傝?br />
    [1] http://jakarta.apache.org/tomcat/涓殑Tomcat 4.1.x鏂囨。Class Loader HOW-TO

    鍦ㄤ竴涓狫VM涓彲鑳藉瓨鍦ㄥ涓狢lassLoader錛屾瘡涓狢lassLoader鎷ユ湁鑷繁鐨凬ameSpace銆備竴涓狢lassLoader鍙兘鎷ユ湁涓涓猚lass瀵硅薄綾誨瀷鐨勫疄渚嬶紝浣嗘槸涓嶅悓鐨凜lassLoader鍙兘鎷ユ湁鐩稿悓鐨刢lass瀵硅薄瀹炰緥錛岃繖鏃跺彲鑳戒駭鐢熻嚧鍛界殑闂銆傚ClassLoaderA錛岃杞戒簡綾籄鐨勭被鍨嬪疄渚婣1錛岃孋lassLoaderB錛屼篃瑁呰澆浜嗙被A鐨勫璞″疄渚婣2銆傞昏緫涓婅A1=A2錛屼絾鏄敱浜嶢1鍜孉2鏉ヨ嚜浜庝笉鍚岀殑ClassLoader錛屽畠浠疄闄呬笂鏄畬鍏ㄤ笉鍚岀殑錛屽鏋淎涓畾涔変簡涓涓潤鎬佸彉閲廲錛屽垯c鍦ㄤ笉鍚岀殑ClassLoader涓殑鍊兼槸涓嶅悓鐨勩?br />
    [2] 娣卞叆Java2騫沖彴瀹夊叏

    zz: http://mail-archives.apache.org/mod_mbox/tomcat-users/200212.mbox/raw/%3c20021204192034.P86616-100000@icarus.apache.org%3e
    try {
        Properties props = new Properties();
        InputStream in = getClass().getResourceAsStream("/conf/db.properties");
        props.load(in);
        ......
        propertie1 = props.getProperty("propertie1");

    The examples already given will find properties files for you just fine whether the file is in a directory structure or inside an archive.  How do you think Java loads classes?  It works out of archives, no? here are some various was to access a properties file ( or any resource, for that matter) in whether the app is deployed as a directory or as a .war file (even inside a .jar file in WEB-INF/lib)....

    1. This will load a file in WEB-INF/classes/conf or any jar file in the classpath with a package of "conf"...
        getClass().getResourceAsStream("/conf/db.properties");
    2. This will load a file relative to the current class.  For instance, if the class is "org.mypackage.MyClass", then the file would be loaded at "org.mypackage.conf.dbproperties".  Note that this is because we didn't prepend "/" to the path.  When that is done, the file is loaded from the root of the current classloader where this loads it relative to the current class...
        getClass().getResourceAsStream("conf/db.properties");
    3. This will find db.properties anywhere in the current classloader as long as it exists in a "conf" package...
        getClass().getClassLoader().getResourceAsStream("conf/db.properties");
    4. This will find the file in a "conf" directory inside the webapp (starting from the root).  This starts looking in the same directory as contains WEB-INF.  When I say "directory", I don't mean "filesystem".  This could be in a .war file as well as in an actual directory on the filesystem...
        getServletContext().getResourceAsStream("/conf/db.properties");
    5. Of course you would probably not want just anyone seeing your db.properties file, so you'd probably want to put in inside WEB-INF of your webapp, so....
        getServletContext().getResourceAsStream("/WEB-INF/conf/db.properties");
    6. If your db.properties exists in another classloader which your app has access to, you can reach it by using:
        Thread.currentThread().getContextClassLoader().getResourceAsStream("conf/db.properties");
    that will act similar to getClass().getClassLoader(), but it can see across all available classloaders where the latter can only see within the classloader that loaded the current class.

    honzeland 2008-04-24 15:46 鍙戣〃璇勮
    ]]>
    Double Checked Locking 妯″紡http://m.tkk7.com/honzeland/archive/2008/02/19/180666.htmlhonzelandhonzelandTue, 19 Feb 2008 06:21:00 GMThttp://m.tkk7.com/honzeland/archive/2008/02/19/180666.htmlhttp://m.tkk7.com/honzeland/comments/180666.htmlhttp://m.tkk7.com/honzeland/archive/2008/02/19/180666.html#Feedback0http://m.tkk7.com/honzeland/comments/commentRss/180666.htmlhttp://m.tkk7.com/honzeland/services/trackbacks/180666.html Double-checked locking: Clever, but broken
    Warning! Threading in a multiprocessor world

    When is a singleton not a singleton?


    honzeland 2008-02-19 14:21 鍙戣〃璇勮
    ]]>
    瀹炵幇java UDP Server 錛嶏紞2008鍐滃巻鏂板勾絎竴璐達紙鍘熷垱錛?/title><link>http://m.tkk7.com/honzeland/archive/2008/02/15/180097.html</link><dc:creator>honzeland</dc:creator><author>honzeland</author><pubDate>Fri, 15 Feb 2008 08:19:00 GMT</pubDate><guid>http://m.tkk7.com/honzeland/archive/2008/02/15/180097.html</guid><wfw:comment>http://m.tkk7.com/honzeland/comments/180097.html</wfw:comment><comments>http://m.tkk7.com/honzeland/archive/2008/02/15/180097.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://m.tkk7.com/honzeland/comments/commentRss/180097.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/honzeland/services/trackbacks/180097.html</trackback:ping><description><![CDATA[涓銆乁DP Server<br /> 欏圭洰鐨勯渶瑕侊紝闇瑕佸埄鐢╦ava瀹炵幇涓涓猽dp server錛屼富瑕佺殑鍔熻兘鏄睛鍚潵鑷鎴風鐨剈dp璇鋒眰錛屽鎴瘋姹傚彲鑳芥槸澶у茍鍙戦噺鐨勶紝瀵逛簬姣忎釜璇鋒眰Server绔殑澶勭悊寰堢畝鍗曪紝澶勭悊姣忎釜璇鋒眰鐨勬椂闂村ぇ綰﹀湪1ms宸﹀彸錛屼絾鏄疭erver绔渶瑕佺淮鎶や竴涓绔嬩簬璇鋒眰鐨勫叏灞鍙橀噺Cache錛岄」鐩湰韜凡緇忛噰鐢∕ina鏋舵瀯錛坔ttp://mina.apache.org/錛夛紝鎴戣寮鍙戠殑Server浣滀負鏁翠釜欏圭洰鐨勪竴涓ā鍧楋紝鐢變簬涔嬪墠娌℃湁寮鍙慤DP Server錛屽彈TCP Server鐨勫獎鍝嶏紝寰堣嚜鐒剁殑鎯沖埄鐢ㄥ綰跨▼鏉ュ疄鐜幫紝瀵逛簬姣忎釜瀹㈡埛璇鋒眰錛屾柊寤轟竴涓嚎紼嬫潵澶勭悊鐩稿簲鐨勯昏緫錛屽湪瀹炵幇鐨勮繃紼嬩腑錛屽埄鐢∕ina鐨凾hread Model錛屽疄鐜頒簡涓涓綰跨▼鐨刄DP Server錛屼絾鏄敱浜庤緇存姢涓涓叏灞Cache錛岄渶瑕佸湪鍚勭嚎紼嬩箣闂村悓姝ワ紝鍔犱箣澶勭悊璇鋒眰鐨勬椂闂村緢鐭紝寰堝揩灝卞彂鐜板湪姝ゅ埄鐢ㄥ綰跨▼錛屽茍涓嶈兘鎻愰珮鎬ц兘錛屼簬鏄喅瀹氶噰鐢ㄥ崟綰跨▼鏉ュ疄鐜幫紝鍦ㄥ姩鎵嬩箣鍓嶏紝榪樻槸鍙戠幇鏈変袱縐嶆柟妗堟潵瀹炵幇鍗曠嚎紼婾DP Server錛?br /> 1錛?閲囩敤JDK鐨凞atagramSocket鍜孌atagramPacket鏉ュ疄鐜?br /> public class UDPServerUseJDK extends Thread{ <br />     /**<br />      * Constructor<br />      * @param port port used to listen incoming connection<br />      * @throws SocketException error to consturct a DatagramSocket with this port<br />      */<br />     public MediatorServerUseJDK(int port) throws SocketException{<br />         this("MediatorServerThread", port);<br />     }<br />     <br />     /**<br />      * Constructor<br />      * @param name the thread name<br />      * @param port port used to listen incoming connection<br />      * @throws SocketException error to consturct a DatagramSocket with this port<br />      */<br />     public MediatorServerUseJDK(String name, int port) throws SocketException{<br />         super(name);<br />         socket = new DatagramSocket(port); <br />         System.out.println("Mediator server started on JDK model...");<br />         System.out.println("Socket buffer size: " + socket.getReceiveBufferSize());<br />     }<br />     <br />     public void run(){<br />         long startTime = 0;<br />         while(true){<br />             try {<br />                 buf = new byte[1024];<br />                 // receive request<br />                 packet = new DatagramPacket(buf, buf.length);<br />                 socket.receive(packet); <br />                 .........<br />             }catch (IOException e) {<br />             .........<br />             }<br />         }<br />     }<br /> 锝?br /> 2錛?閲囩敤Mina鐨凞atagramAcceptor鏉ュ疄鐜幫紝鍦ㄥ垱寤篍xector鐨勬椂鍊欙紝鍙紶閫掑崟涓嚎紼?br /> public class MediatorServerUseMina {<br />     private DatagramAcceptor acceptor;<br /> <br />     public MediatorServerUseMina() {<br /> <br />     }<br /> <br />     public void startListener(InetSocketAddress address, IoHandler handler) {<br />         // create an acceptor with a single thread<br />         this.acceptor = new DatagramAcceptor(Executors.newSingleThreadExecutor());<br />         // configure the thread models<br />         DatagramAcceptorConfig acceptorConfig = acceptor.getDefaultConfig();<br />         acceptorConfig.setThreadModel(ThreadModel.MANUAL);<br />         // set the acceptor to reuse the address<br />         acceptorConfig.getSessionConfig().setReuseAddress(true);<br />         // add io filters<br />         DefaultIoFilterChainBuilder filterChainBuilder = acceptor.getFilterChain();<br />         // add CPU-bound job first,<br />         filterChainBuilder.addLast("codec", new ProtocolCodecFilter(new StringCodecFactory())); <br />         try {<br />             // bind<br />             acceptor.bind(address, handler);<br />             System.out.println("Mediator Server started on mina model...");<br />             System.out.println("Socket buffer size: " + acceptorConfig.getSessionConfig().getReceiveBufferSize());<br />         } catch (IOException e) {<br />             System.err.println("Error starting component listener on port(UDP) " + address.getPort() + ": "<br />                     + e.getMessage());<br />         }<br />     } <br /> }<br /> 浜屻丳erformance Test<br /> 涓轟簡嫻嬭瘯涓や釜Server鐨勬ц兘錛屽啓浜嗕釜綆鍗曠殑嫻嬭瘯瀹㈡埛绔?br /> import java.io.IOException;<br /> import java.net.DatagramPacket;<br /> import java.net.DatagramSocket;<br /> import java.net.InetAddress;<br /> import java.net.SocketException;<br /> import java.net.UnknownHostException;<br /> <br /> /**<br />  * @author Herry Hong<br />  * <br />  */<br /> <br /> public class PerformanceTest {<br />     /** Number of threads to be created */<br />     static final int THREADS = 100;<br />     /** Packets to be sent per thread */<br />     static final int PACKETS = 500;<br />     /** The interval of two packets been sent for each thread */<br />     private static final int INTERVAL = 80;<br />     private static final String DATA = "5a76d93cb435fc54eba0b97156fe38f432a4e1da3a87cce8a222644466ed1317";<br /> <br />     private class Sender implements Runnable {<br />         private InetAddress address = null;<br />         private DatagramSocket socket = null;<br />         private String msg = null;<br />         private String name = null;<br />         private int packet_sent = 0;<br /> <br />         public Sender(String addr, String msg, String name) throws SocketException,<br />                 UnknownHostException {<br />             this.address = InetAddress.getByName(addr);<br />             this.socket = new DatagramSocket();<br />             this.msg = msg;<br />             this.name = name;<br />         }<br /> <br />         @Override<br />         public void run() {<br />             // send request<br />             byte[] buf = msg.getBytes();<br />             DatagramPacket packet = new DatagramPacket(buf, buf.length,<br />                     address, 8000);<br />             try {<br />                 for (int i = 0; i < PerformanceTest.PACKETS; i++) {<br />                     socket.send(packet);<br />                     packet_sent++;<br />                     Thread.sleep(INTERVAL);<br />                 }<br />             } catch (IOException e) {<br />                 e.printStackTrace();<br />             } catch (InterruptedException e) {<br />                 e.printStackTrace();<br />             }<br />             //System.out.println("Thread " + name + " sends " + packet_sent + " packets.");<br />             //System.out.println("Thread " + name + " end!");<br />         }<br />     }<br /> <br />     /**<br />      * @param args<br />      */<br />     public static void main(String[] args) {<br />         if (args.length != 1) {<br />             System.out.println("Usage: java PerformanceTest <hostname>");<br />             return;<br />         }<br />         String msg; <br />         for (int i = 0; i < THREADS; i++) {<br />             if(i % 2 == 0){<br />                 msg = i + "_" + (i+1) + ""r"n" + (i+1) + "_" + i + ""r"n" + DATA;<br />             }else{<br />                 msg = i + "_" + (i-1) + ""r"n" + (i-1) + "_" + i + ""r"n" + DATA;<br />             }<br />             try {<br />                 new Thread(new PerformanceTest().new Sender(args[0], msg, "" + i)).start();<br />             } catch (SocketException e) { <br />                 e.printStackTrace();<br />             } catch (UnknownHostException e) { <br />                 e.printStackTrace();<br />             }<br />         } <br />     }<br /> }<br /> 涓夈佹祴璇曠粨鏋?br /> 嫻嬭瘯鐜錛?br /> Server錛欰MD Athlon(tm) 64 X2 Dual Core Processor 4000+錛?G memory<br /> Client錛欰MD Athlon(tm) 64 X2 Dual Core Processor 4000+錛?G memory<br /> 鍦ㄦ祴璇曠殑榪囩▼涓紝褰揑NTERVAL璁劇疆鐨勫お灝忔椂錛屾湇鍔″櫒绔細鍑虹幇涓㈠寘鐜拌薄錛孖NTERVAL瓚婂皬錛屼涪鍖呰秺涓ラ噸錛屼負浜嗘彁楂楽erver鐨勬ц兘錛岀壒灝哠ocket鐨凴eceiveBufferSize璁劇疆鎴愰粯璁ゅぇ灝忕殑涓ゅ嶏紝<br /> 瀵逛簬JDK瀹炵幇錛?br />     public MediatorServerUseJDK(String name, int port) throws SocketException{<br />         super(name);<br />         socket = new DatagramSocket(port);<br />         // set the receive buffer size to double default size<br />         socket.setReceiveBufferSize(socket.getReceiveBufferSize() * 2); <br />         System.out.println("Mediator server started on JDK model...");<br />         System.out.println("Socket buffer size: " + socket.getReceiveBufferSize());<br />     }<br /> 瀵逛簬Mina瀹炵幇錛?br />         DatagramAcceptorConfig acceptorConfig = acceptor.getDefaultConfig();<br />         acceptorConfig.setThreadModel(ThreadModel.MANUAL);<br />         // set the acceptor to reuse the address<br />         acceptorConfig.getSessionConfig().setReuseAddress(true);<br />         // set the receive buffer size to double default size<br />         int recBufferSize = acceptorConfig.getSessionConfig().getReceiveBufferSize();<br />         acceptorConfig.getSessionConfig().setReceiveBufferSize(recBufferSize * 2);<br /> 姝ゆ椂錛岀浉鍚岀殑INTERVAL錛屼涪鍖呯幇璞℃槑鏄懼噺灝戙?br /> 鎺ヤ笅鏉ワ紝鍐嶆祴璇曚笉鍚屽疄鐜扮殑鎬ц兘宸紓錛?br /> UDP server started on JDK model...<br /> Socket buffer size: 110592<br /> INTERVAL 錛?100ms錛屾病鏈夊嚭鐜頒涪鍖咃紝<br /> Process time: 49988<br /> Process time: 49982<br /> Process time: 49984<br /> Process time: 49986<br /> Process time: 49984<br /> INTERVAL 錛?80ms錛屼粛鐒舵病鏈変涪鍖咃紝涓嶇Server鏄笉鏄垵嬈″惎鍔?br /> Process time: 40006<br /> Process time: 40004<br /> Process time: 40003<br /> Process time: 40005<br /> Process time: 40013<br /> UDP Server started on mina model...<br /> Socket buffer size: 110592<br /> INTERVAL 錛?80ms錛孲erver鍒濇鍚姩鏃訛紝緇忓父浼氬嚭鐜頒涪鍖咃紝褰撶涓嬈★紙鎸囨湇鍔″櫒鍒濇鍚姩鏃訛級娌℃湁涓㈠寘鏃訛紝闅忓悗鍩烘湰涓嶄涪鍖咃紝<br /> Process time: 39973<br /> Process time: 40006<br /> Process time: 40007<br /> Process time: 40008<br /> Process time: 40008<br /> INTERVAL 錛?100ms錛屾病鏈夊嚭鐜頒涪鍖?br /> Process time: 49958<br /> Process time: 49985<br /> Process time: 49983<br /> Process time: 49988<br /> 鍥涖佺粨璁?br /> 鍦ㄨ瑕佹眰涓嬶紝閲囩敤JDK鍜孧ina瀹炵幇鎬ц兘鐩稿綋錛屼絾鏄湪Server鍒濇鍚姩鏃禞DK瀹炵幇鍩烘湰涓嶄細鍑虹幇涓㈠寘錛岃孧ina瀹炵幇鍒欏湪Server鍒濇鍚姩鏃剁粡甯稿嚭鐜頒涪鍖呯幇璞★紝鍦ㄧ粡鍘嗙涓嬈℃祴璇曞悗錛屼袱縐嶅疄鐜板鐞嗘椂闂寸浉榪戯紝璇鋒眰騫跺彂閲忓ぇ姒備負姣弇s涓涓姹傛椂錛屾湇鍔″櫒涓嶄細鍑虹幇涓㈠寘銆?br /> <br /> <img src ="http://m.tkk7.com/honzeland/aggbug/180097.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/honzeland/" target="_blank">honzeland</a> 2008-02-15 16:19 <a href="http://m.tkk7.com/honzeland/archive/2008/02/15/180097.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>灝哋penfire瀵煎叆鍒癊clipse涓?/title><link>http://m.tkk7.com/honzeland/archive/2008/01/25/177812.html</link><dc:creator>honzeland</dc:creator><author>honzeland</author><pubDate>Fri, 25 Jan 2008 09:36:00 GMT</pubDate><guid>http://m.tkk7.com/honzeland/archive/2008/01/25/177812.html</guid><wfw:comment>http://m.tkk7.com/honzeland/comments/177812.html</wfw:comment><comments>http://m.tkk7.com/honzeland/archive/2008/01/25/177812.html#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://m.tkk7.com/honzeland/comments/commentRss/177812.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/honzeland/services/trackbacks/177812.html</trackback:ping><description><![CDATA[1銆?浠嶰penfire SVN Server涓璬ump鍑烘簮鐮侊紱<br /> 2銆?Build: ant  & ant plugins<br /> 3銆?灝哹uild鍚庣殑target/openfire浣滀負openfire_home<br /> 4銆?鍦╰arget/openfire涓嬪緩绔嬩袱涓洰褰曪細src鍜宑lasses錛屽皢dump涓嬫潵鐨勬簮鐮乧opy鍒皊rc璺緞涓嬶紝灝哻lasses璁劇疆涓篹clipse緙栬瘧鍚庣殑杈撳嚭璺緞<br /> 5銆?灝?openfire_home/lib涓嬬殑openfire.jar涓璼rc涓瓨鍦ㄧ殑閮ㄥ垎鍒犻櫎錛屽墿涓嬬殑閮ㄥ垎浣滀負鏂扮殑openfire.jar錛屾敞鎰忥紝鍦╱buntu涓嬩箣闂存墦寮openfire.jar鏃訛紝鐩存帴灝?org/jivesoftware/admin, /org/jivesoftware/openfire, /org/jivesoftware/util涓変釜鐩綍鍒犻櫎錛岃屽浜?org/jivesoftware/database鐩綍錛屽彧灝嗘簮鐮佷腑鏈夌殑閭i儴鍒嗗垹闄わ紝/org/jivesoftware涓嬮潰榪樻湁涓涓殣钘忕洰褰?org/jivesoftware/stringprep錛屼笉鑳藉垹闄わ紝鎺ヤ笅鏉ワ紝灝?openfire_home/lib涓嬬殑jar鍖呬綔涓哄伐紼嬬殑Referenced Libraries.<br /> 6銆?灝嗗彇鍑烘潵鐨勫伐紼嬩笅src/web/WEB-INF/classes/openfire_init.xml瀵煎叆鍒癳clipse鐨勬煡璇㈣礬寰勯噷錛屽灝唖rc/web/WEB-INF/classes鐩綍浣滀負eclipse鐨勬簮鐩綍錛岃繖鏍穙penfire_init.xml鑷姩copy鍒?openfire_home/classses涓嬮潰錛屽皢openfire_init.xml涓殑openfireHome璁劇疆涓?openfire_home<br /> 7銆?淇敼org.jivesoftware.openfire.starter.ServerStarter涓殑濡備笅涓や釜field錛?br />            private static final String DEFAULT_LIB_DIR = "../lib";<br />            private static final String DEFAULT_ADMIN_LIB_DIR = "../plugins/admin/webapp/WEB-INF/lib";<br /> 鏀規垚錛?br />            private static final String DIR_PREFIX = "$openfire_home";     // to be your own openfire_home<br />            private static final String DEFAULT_LIB_DIR = DIR_PREFIX + "lib";<br />            private static final String DEFAULT_ADMIN_LIB_DIR = DIR_PREFIX + "plugins/admin/webapp/WEB-INF/lib";<br /> <img src ="http://m.tkk7.com/honzeland/aggbug/177812.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/honzeland/" target="_blank">honzeland</a> 2008-01-25 17:36 <a href="http://m.tkk7.com/honzeland/archive/2008/01/25/177812.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>DWR 璋冪敤榪斿洖鍊兼柟娉?/title><link>http://m.tkk7.com/honzeland/archive/2008/01/15/175465.html</link><dc:creator>honzeland</dc:creator><author>honzeland</author><pubDate>Tue, 15 Jan 2008 06:45:00 GMT</pubDate><guid>http://m.tkk7.com/honzeland/archive/2008/01/15/175465.html</guid><wfw:comment>http://m.tkk7.com/honzeland/comments/175465.html</wfw:comment><comments>http://m.tkk7.com/honzeland/archive/2008/01/15/175465.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/honzeland/comments/commentRss/175465.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/honzeland/services/trackbacks/175465.html</trackback:ping><description><![CDATA[zz: http://daoger.javaeye.com/blog/47801<br /> <br /> 2.璋冪敤鏈夌畝鍗曡繑鍥炲肩殑java鏂規硶 <br /> 2.1銆?span class="hilite1">dwr</span>.xml鐨勯厤緗? <br /> 閰嶇疆鍚?.1 <br /> <<span id="6661661" class="hilite1">dwr</span>> <br /> <allow> <br /> <create creator="new" javascript="testClass" > <br /> <param name="class" value="com.<span id="6166116" class="hilite1">dwr</span>.TestClass" /> <br /> <include method="testMethod2"/> <br /> </create> <br /> </allow> <br /> </<span id="1611161" class="hilite1">dwr</span>> <br /> 2.2銆乯avascript涓皟鐢? <br /> 棣栧厛錛屽紩鍏avascript鑴氭湰 <br /> 鍏舵錛岀紪鍐欒皟鐢╦ava鏂規硶鐨刯avascript鍑芥暟鍜屾帴鏀惰繑鍥炲肩殑鍥炶皟鍑芥暟 <br /> Function callTestMethod2(){ <br /> testClass.testMethod2(callBackFortestMethod2); <br /> } <br /> Function callBackFortestMethod2(data){ <br /> //鍏朵腑date鎺ユ敹鏂規硶鐨勮繑鍥炲? <br /> //鍙互鍦ㄨ繖閲屽榪斿洖鍊艱繘琛屽鐞嗗拰鏄劇ず絳夌瓑 <br /> alert("the return value is " + data); <br /> } <br /> 鍏朵腑callBackFortestMethod2鏄帴鏀惰繑鍥炲肩殑鍥炶皟鍑芥暟 <br /> <br /> <br /> 3銆佽皟鐢ㄦ湁綆鍗曞弬鏁扮殑java鏂規硶 <br /> 3.1銆?span class="hilite1">dwr</span>.xml鐨勯厤緗? <br /> 閰嶇疆鍚?.1 <br /> <<span id="1661611" class="hilite1">dwr</span>> <br /> <allow> <br /> <create creator="new" javascript="testClass" > <br /> <param name="class" value="com.<span id="6661666" class="hilite1">dwr</span>.TestClass" /> <br /> <include method="testMethod3"/> <br /> </create> <br /> </allow> <br /> </<span id="1161616" class="hilite1">dwr</span>> <br /> 3.2銆乯avascript涓皟鐢? <br /> 棣栧厛錛屽紩鍏avascript鑴氭湰 <br /> 鍏舵錛岀紪鍐欒皟鐢╦ava鏂規硶鐨刯avascript鍑芥暟 <br /> Function callTestMethod3(){ <br /> //瀹氫箟瑕佷紶鍒癹ava鏂規硶涓殑鍙傛暟 <br /> var data; <br /> //鏋勯犲弬鏁? <br /> data = “test String”; <br /> testClass.testMethod3(data); <br /> } <br /> <br /> <br /> 4銆佽皟鐢ㄨ繑鍥濲avaBean鐨刯ava鏂規硶 <br /> 4.1銆?span class="hilite1">dwr</span>.xml鐨勯厤緗? <br /> <<span id="6116166" class="hilite1">dwr</span>> <br /> <allow> <br /> <create creator="new" javascript="testClass" > <br /> <param name="class" value="com.<span id="1116616" class="hilite1">dwr</span>.TestClass" /> <br /> <include method="testMethod4"/> <br /> </create> <br /> <convert converter="bean" match=""com.<span id="1611611" class="hilite1">dwr</span>.TestBean"> <br /> <param name="include" value="username,password" /> <br /> </convert> <br /> </allow> <br /> </<span id="6116661" class="hilite1">dwr</span>> <br /> <creator>鏍囩璐熻矗鍏紑鐢ㄤ簬Web榪滅▼鐨勭被鍜岀被鐨勬柟娉曪紝<convertor>鏍囩鍒欒礋璐h繖浜涙柟娉曠殑鍙傛暟鍜岃繑鍥炵被鍨嬨俢onvert鍏冪礌鐨勪綔鐢ㄦ槸鍛婅瘔<span id="1616166" class="hilite1">DWR</span>鍦ㄦ湇鍔″櫒绔疛ava 瀵硅薄琛ㄧず鍜屽簭鍒楀寲鐨凧avaScript涔嬮棿濡備綍杞崲鏁版嵁綾誨瀷銆?span class="hilite1">DWR</span>鑷姩鍦板湪Java鍜孞avaScript琛ㄧず涔嬮棿璋冩暣綆鍗曟暟鎹被鍨嬨傝繖浜涚被鍨嬪寘鎷琂ava鍘熺敓綾誨瀷鍜屽畠浠悇鑷殑灝佽綾昏〃紺猴紝榪樻湁String銆丏ate銆佹暟緇勫拰闆嗗悎綾誨瀷銆?span class="hilite1">DWR</span>涔熻兘鎶奐avaBean杞崲鎴怞avaScript 琛ㄧず錛屼絾鏄嚭浜庡畨鍏ㄦх殑鍘熷洜錛岃姹傛樉寮忕殑閰嶇疆錛?lt;convertor>鏍囩灝辨槸瀹屾垚姝ゅ姛鑳界殑銆俢onverter="bean"灞炴ф寚瀹氳漿鎹㈢殑鏂瑰紡閲囩敤JavaBean鍛藉悕瑙勮寖錛宮atch=""com.<span id="1616116" class="hilite1">dwr</span>.TestBean"灞炴ф寚瀹氳杞崲鐨刯avabean鍚嶇О錛?lt;param>鏍囩鎸囧畾瑕佽漿鎹㈢殑JavaBean灞炴с? <br /> 4.2銆乯avascript涓皟鐢? <br /> 棣栧厛錛屽紩鍏avascript鑴氭湰 <br /> 鍏舵錛岀紪鍐欒皟鐢╦ava鏂規硶鐨刯avascript鍑芥暟鍜屾帴鏀惰繑鍥炲肩殑鍥炶皟鍑芥暟 <br /> Function callTestMethod4(){ <br /> testClass.testMethod4(callBackFortestMethod4); <br /> } <br /> Function callBackFortestMethod4(data){ <br /> //鍏朵腑date鎺ユ敹鏂規硶鐨勮繑鍥炲? <br /> //瀵逛簬JavaBean榪斿洖鍊鹼紝鏈変袱縐嶆柟寮忓鐞? <br /> //涓嶇煡閬撳睘鎬у悕縐版椂錛屼嬌鐢ㄥ涓嬫柟娉? <br /> for(var property in data){ <br /> alert("property:"+property); <br /> alert(property+":"+data[property]); <br /> } <br /> //鐭ラ亾灞炴у悕縐版椂錛屼嬌鐢ㄥ涓嬫柟娉? <br /> alert(data.username); <br /> alert(data.password); <br /> } <br /> 鍏朵腑callBackFortestMethod4鏄帴鏀惰繑鍥炲肩殑鍥炶皟鍑芥暟 <br /> <br /> 5銆佽皟鐢ㄦ湁JavaBean鍙傛暟鐨刯ava鏂規硶 <br /> 5.1銆?span class="hilite1">dwr</span>.xml鐨勯厤緗? <br /> 閰嶇疆鍚?.1 <br /> <<span id="6616116" class="hilite1">dwr</span>> <br /> <allow> <br /> <create creator="new" javascript="testClass" > <br /> <param name="class" value="com.<span id="1616166" class="hilite1">dwr</span>.TestClass" /> <br /> <include method="testMethod5"/> <br /> </create> <br /> <convert converter="bean" match="com.<span id="1666666" class="hilite1">dwr</span>.TestBean"> <br /> <param name="include" value="username,password" /> <br /> </convert> <br /> </allow> <br /> </<span id="6611661" class="hilite1">dwr</span>> <br /> 5.2銆乯avascript涓皟鐢? <br /> 棣栧厛錛屽紩鍏avascript鑴氭湰 <br /> 鍏舵錛岀紪鍐欒皟鐢╦ava鏂規硶鐨刯avascript鍑芥暟 <br /> Function callTestMethod5(){ <br /> //瀹氫箟瑕佷紶鍒癹ava鏂規硶涓殑鍙傛暟 <br /> var data; <br /> //鏋勯犲弬鏁幫紝date瀹為檯涓婃槸涓涓猳bject <br /> data = { username:"user", password:"password" } <br /> testClass.testMethod5(data); <br /> } <br /> <br /> <br /> 6銆佽皟鐢ㄨ繑鍥濴ist銆丼et鎴栬匨ap鐨刯ava鏂規硶 <br /> 6.1銆?span class="hilite1">dwr</span>.xml鐨勯厤緗? <br /> 閰嶇疆鍚?.1 <br /> <<span id="1111611" class="hilite1">dwr</span>> <br /> <allow> <br /> <create creator="new" javascript="testClass" > <br /> <param name="class" value="com.<span id="6616666" class="hilite1">dwr</span>.TestClass" /> <br /> <include method="testMethod6"/> <br /> </create> <br /> <convert converter="bean" match="com.<span id="1666611" class="hilite1">dwr</span>.TestBean"> <br /> <param name="include" value="username,password" /> <br /> </convert> <br /> </allow> <br /> </<span id="1111661" class="hilite1">dwr</span>> <br /> 娉ㄦ剰錛氬鏋淟ist銆丼et鎴栬匨ap涓殑鍏冪礌鍧囦負綆鍗曠被鍨嬶紙鍖呮嫭鍏跺皝瑁呯被錛夋垨String銆丏ate銆佹暟緇勫拰闆嗗悎綾誨瀷錛屽垯涓嶉渶瑕?lt;convert>鏍囩銆? <br /> 6.2銆乯avascript涓皟鐢?浠ヨ繑鍥濴ist涓轟緥錛孡ist鐨勫厓绱犱負TestBean) <br /> 棣栧厛錛屽紩鍏avascript鑴氭湰 <br /> 鍏舵錛岀紪鍐欒皟鐢╦ava鏂規硶鐨刯avascript鍑芥暟鍜屾帴鏀惰繑鍥炲肩殑鍥炶皟鍑芥暟 <br /> Function callTestMethod6(){ <br /> testClass.testMethod6(callBackFortestMethod6); <br /> } <br /> Function callBackFortestMethod6(data){ <br /> //鍏朵腑date鎺ユ敹鏂規硶鐨勮繑鍥炲? <br /> //瀵逛簬JavaBean榪斿洖鍊鹼紝鏈変袱縐嶆柟寮忓鐞? <br /> //涓嶇煡閬撳睘鎬у悕縐版椂錛屼嬌鐢ㄥ涓嬫柟娉? <br /> for(var i=0;i<data.length;i++){ <br /> for(var property in data){ <br /> alert("property:"+property); <br /> alert(property+":"+data[property]); <br /> } <br /> } <br /> //鐭ラ亾灞炴у悕縐版椂錛屼嬌鐢ㄥ涓嬫柟娉? <br /> for(var i=0;i<data.length;i++){ <br /> alert(data[i].username); <br /> alert(data[i].password); <br /> } <br /> } <br /> <br /> <br /> 7銆佽皟鐢ㄦ湁List銆丼et鎴栬匨ap鍙傛暟鐨刯ava鏂規硶 <br /> 7.1銆?span class="hilite1">dwr</span>.xml鐨勯厤緗? <br /> <<span id="1161661" class="hilite1">dwr</span>> <br /> <allow> <br /> <create creator="new" javascript="testClass" > <br /> <param name="class" value="com.<span id="6116116" class="hilite1">dwr</span>.TestClass" /> <br /> <include method="testMethod7"/> <br /> </create> <br /> <convert converter="bean" match="com.<span id="1666166" class="hilite1">dwr</span>.TestBean"> <br /> <param name="include" value="username,password" /> <br /> </convert> <br /> </allow> <br /> <<span id="1616116" class="hilite2">signatures</span>> <br /> <![CDATA[ <br /> import java.util.List; <br /> import com.<span id="1161111" class="hilite1">dwr</span>.TestClass; <br /> import com.<span id="1661161" class="hilite1">dwr</span>.TestBean; <br /> TestClass.testMethod7(List<TestBean>); <br /> ]]> <br /> </<span id="1111611" class="hilite2">signatures</span>> <br /> </<span id="6661661" class="hilite1">dwr</span>> <br /> <<span id="1166161" class="hilite2">signatures</span>>鏍囩鏄敤鏉ュ0鏄巎ava鏂規硶涓璍ist銆丼et鎴栬匨ap鍙傛暟鎵鍖呭惈鐨勭‘鍒囩被錛屼互渚縥ava浠g爜浣滃嚭鍒ゆ柇銆? <br /> 7.2銆乯avascript涓皟鐢?浠ヨ繑鍥濴ist涓轟緥錛孡ist鐨勫厓绱犱負TestBean) <br /> 棣栧厛錛屽紩鍏avascript鑴氭湰 <br /> 鍏舵錛岀紪鍐欒皟鐢╦ava鏂規硶鐨刯avascript鍑芥暟 <br /> Function callTestMethod7(){ <br /> //瀹氫箟瑕佷紶鍒癹ava鏂規硶涓殑鍙傛暟 <br /> var data; <br /> //鏋勯犲弬鏁幫紝date瀹為檯涓婃槸涓涓猳bject鏁扮粍錛屽嵆鏁扮粍鐨勬瘡涓厓绱犲潎涓簅bject <br /> data = [ <br /> { <br /> username:"user1", <br /> password:"password2" <br /> }, <br /> { <br /> username:"user2", <br /> password:" password2" <br /> } <br /> ]; <br /> testClass.testMethod7(data); <br /> } <br /> <br /> 娉ㄦ剰錛? <br /> 1銆佸浜庣6縐嶆儏鍐碉紝濡傛灉java鏂規硶鐨勮繑鍥炲間負Map錛屽垯鍦ㄦ帴鏀惰榪斿洖鍊肩殑javascript鍥炶皟鍑芥暟涓涓嬪鐞嗭細 <br /> function callBackFortestMethod(data){ <br /> //鍏朵腑date鎺ユ敹鏂規硶鐨勮繑鍥炲? <br /> for(var property in data){ <br /> var bean = data[property]; <br /> alert(bean.username); <br /> alert(bean.password); <br /> } <br /> } <br /> 2銆佸浜庣7縐嶆儏鍐碉紝濡傛灉java鐨勬柟娉曠殑鍙傛暟涓篗ap錛堝亣璁懼叾key涓篠tring錛寁alue涓篢estBean錛夛紝鍒欏湪璋冪敤璇ユ柟娉曠殑javascript鍑芥暟涓敤濡備笅鏂規硶鏋勯犺浼犻掔殑鍙傛暟錛? <br /> function callTestMethod (){ <br /> //瀹氫箟瑕佷紶鍒癹ava鏂規硶涓殑鍙傛暟 <br /> var data; <br /> //鏋勯犲弬鏁幫紝date瀹為檯涓婃槸涓涓猳bject錛屽叾灞炴у悕涓篗ap鐨刱ey錛屽睘鎬у間負Map鐨剉alue <br /> data = { <br /> "key1":{ <br /> username:"user1", <br /> password:"password2" <br /> }, <br /> "key2":{ <br /> username:"user2", <br /> password:" password2" <br /> } <br /> }; <br /> testClass.testMethod(data); <br /> } <br /> 騫朵笖鍦?span class="hilite1">dwr</span>.xml涓鍔犲涓嬬殑閰嶇疆孌? <br /> <<span id="6661161" class="hilite2">signatures</span>> <br /> <![CDATA[ <br /> import java.util.List; <br /> import com.<span id="6111661" class="hilite1">dwr</span>.TestClass; <br /> import com.<span id="1116166" class="hilite1">dwr</span>.TestBean; <br /> TestClass.testMethod7(Map<String,TestBean>); <br /> ]]> <br /> </<span id="1161116" class="hilite2">signatures</span>> <br /> 3銆佺敱浠ヤ笂鍙互鍙戠幇錛屽浜巎ava鏂規硶鐨勮繑鍥炲間負List(Set)鐨勬儏鍐碉紝<span id="1166166" class="hilite1">DWR</span>灝嗗叾杞寲涓篛bject鏁扮粍錛屼紶閫掍釜javascript錛涘浜巎ava鏂規硶鐨勮繑鍥炲間負Map鐨勬儏鍐碉紝<span id="1116666" class="hilite1">DWR</span>灝嗗叾杞寲涓轟竴涓狾bject錛屽叾涓璒bject鐨勫睘鎬т負鍘烳ap鐨刱ey鍊鹼紝灞炴у間負鍘烳ap鐩稿簲鐨剉alue鍊箋? <br /> 4銆佸鏋渏ava鏂規硶鐨勫弬鏁頒負List(Set)鍜孧ap鐨勬儏鍐碉紝javascript涓篃瑕佹牴鎹?縐嶆墍璇達紝鏋勯犵浉搴旂殑javascript鏁版嵁鏉ヤ紶閫掑埌java涓?br /> <img src ="http://m.tkk7.com/honzeland/aggbug/175465.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/honzeland/" target="_blank">honzeland</a> 2008-01-15 14:45 <a href="http://m.tkk7.com/honzeland/archive/2008/01/15/175465.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>glassfish java.net.UnknownHostException: xxx: xxxhttp://m.tkk7.com/honzeland/archive/2008/01/09/174021.htmlhonzelandhonzelandWed, 09 Jan 2008 07:19:00 GMThttp://m.tkk7.com/honzeland/archive/2008/01/09/174021.htmlhttp://m.tkk7.com/honzeland/comments/174021.htmlhttp://m.tkk7.com/honzeland/archive/2008/01/09/174021.html#Feedback0http://m.tkk7.com/honzeland/comments/commentRss/174021.htmlhttp://m.tkk7.com/honzeland/services/trackbacks/174021.html xxx@xxx:/opt$ asadmin start-domain domain1
    Jan 9, 2008 2:49:18 PM com.sun.enterprise.util.ASenvPropertyReader setSystemProperties
    SEVERE: property_reader.unknownHost
    java.net.UnknownHostException: xxx: xxx
            at java.net.InetAddress.getLocalHost(InetAddress.java:1353)
            at com.sun.enterprise.util.net.NetUtils.getCanonicalHostName(NetUtils.java:102)
            at com.sun.enterprise.util.ASenvPropertyReader.setSystemProperties(ASenvPropertyReader.java:201)
            at com.sun.enterprise.cli.commands.S1ASCommand.<init>(S1ASCommand.java:164)
            at com.sun.enterprise.cli.commands.BaseLifeCycleCommand.<init>(BaseLifeCycleCommand.java:101)
            at com.sun.enterprise.cli.commands.StartDomainCommand.<init>(StartDomainCommand.java:78)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
            at java.lang.Class.newInstance0(Class.java:355)
            at java.lang.Class.newInstance(Class.java:308)
            at com.sun.enterprise.cli.framework.CommandFactory.createCommand(CommandFactory.java:91)
            at com.sun.enterprise.cli.framework.CLIMain.invokeCommand(CLIMain.java:160)
            at com.sun.enterprise.cli.framework.CLIMain.main(CLIMain.java:79)
    Starting Domain domain1, please wait.
    Log redirected to /opt/glassfish/domains/domain1/logs/server.log.
    Redirecting output to /opt/glassfish/domains/domain1/logs/server.log
    Domain domain1 is ready to receive client requests. Additional services are being started in background.
    java.net.UnknownHostException: hongzeguo: hongzeguo
    CLI156 Could not start the domain domain1.

    Solution錛?br /> xxx@xxx:/opt$ nslookup xxx
    Server:         202.106.46.151
    Address:        202.106.46.151#53

    ** server can't find xxx: NXDOMAIN

    Check your /etc/hosts file. Does it have an entry with actual name and ip address of your box?
    For example: append follows  to /etc/hosts
    127.0.0.1 xxx




    honzeland 2008-01-09 15:19 鍙戣〃璇勮
    ]]>
    JMock Exampleshttp://m.tkk7.com/honzeland/archive/2007/12/13/167464.htmlhonzelandhonzelandThu, 13 Dec 2007 04:45:00 GMThttp://m.tkk7.com/honzeland/archive/2007/12/13/167464.htmlhttp://m.tkk7.com/honzeland/comments/167464.htmlhttp://m.tkk7.com/honzeland/archive/2007/12/13/167464.html#Feedback0http://m.tkk7.com/honzeland/comments/commentRss/167464.htmlhttp://m.tkk7.com/honzeland/services/trackbacks/167464.html
    The servlet:
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.ServletException;
    import java.io.IOException;
    import java.util.Map;

    public class MyServlet extends HttpServlet {
        private MyService myService;
        public void setMyService(MyService myService) {
            this.myService = myService;
        }

        public void process(HttpServletRequest request, HttpServletResponse response) {
            String action = request.getParameter("action");
            if ("update".equals(action)) {
                Map parameters = request.getParameterMap();
                try {
                    myService.updateModel(parameters);
                } catch (MyException e) {
                    request.setAttribute("error", e.getMessage());
                }
            }
            request.setAttribute("model", myService.getModel());
            getServletContext().getRequestDispatcher("myView.jsp").forward(request, response);
        }

        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            process(request, response);
        }
    }

    The unit test:
        * if the action is update, does it call myService.updateModel (example is below)
        * if myService.updateModel throws an exception does the response contain the exceptions message (not implemented below)
    import org.jmock.Mock;
    import org.jmock.MockObjectTestCase;
    public class MyServletTest extends MockObjectTestCase {
        private Mock mockMyService;
        private Mock mockRequest;
        private Mock mockResponse;
        private MyService myService;
        private HttpServletRequest request;
        private HttpServletResponse response;
        private MyServlet myServlet;
        
        protected void setUp() throws java.lang.Exception {
            mockMyService = mock(MyService.class);
            mockRequest = mock(HttpServletRequest.class);
            mockResponse = mock(HttpServletResponse.class);
            myService = (MyService) mockMyService.proxy();
            request = (HttpServletRequest) mockRequest.proxy();
            response = (HttpServletResponse) mockResponse.proxy();
            myServlet = new MyServlet();
        }

        public void testUpdate() {
            // SETUP ANY OBJECTS USED ONLY IN THIS TESTCASE
            Map parameters = new Hashtable();
            // SETUP THE EXPECTED CALLS TO THE MOCK OBJECTS
            // setup the mock request object to have the getParameter
            // method called once with argument being equal to the
            // string action and have it return the string update
            mockRequest.expects(once()).method("getParameter").
                with(eq("action")).will(returnValue("update"));
            // setup the mock request object to have the getParameterMap
            // method called once with no arguments and have it
            // return an empty map
            mockRequest.expects(once()).method("getParameterMap")
                .will(returnValue(parameters));
            // setup the mock myService object to have the updateModel
            // method called once with the parameters map as the
            // argument
            mockMyService.expects(once()).method("updateModel").with(same(parameters));
            // setup the mock myService object to have the getModel
            // method called once with no arguments and have it
            // return an empty map
            mockMyService.expects(once()).method("getModel")
                .will(returnValue(parameters));
            // setup the mock myService object to have the updateModel
            // method called once with the parameters map as the
            // argument
            mockRequest.expects(once()).method("setAttribute").with(eq("model"), same(parameters));
            // RUN THE TEST
            // add the myService mock object to the servlet so
            // that it can handle calls later
            myServlet.setMyService(myService);
            myServlet.process(request, response);
        }
    }





    honzeland 2007-12-13 12:45 鍙戣〃璇勮
    ]]>
    Eclipse 鍚姩璁劇疆錛岄伩鍏峅ut of Memoryhttp://m.tkk7.com/honzeland/archive/2007/12/13/167463.htmlhonzelandhonzelandThu, 13 Dec 2007 04:40:00 GMThttp://m.tkk7.com/honzeland/archive/2007/12/13/167463.htmlhttp://m.tkk7.com/honzeland/comments/167463.htmlhttp://m.tkk7.com/honzeland/archive/2007/12/13/167463.html#Feedback0http://m.tkk7.com/honzeland/comments/commentRss/167463.htmlhttp://m.tkk7.com/honzeland/services/trackbacks/167463.html -Xmx512M
    -XX:PermSize=64M
    -XX:MaxPermSize=128M



    honzeland 2007-12-13 12:40 鍙戣〃璇勮
    ]]>
    鍥藉钁楀悕java鎶鏈祫鏂欑綉绔?/title><link>http://m.tkk7.com/honzeland/archive/2007/05/18/118366.html</link><dc:creator>honzeland</dc:creator><author>honzeland</author><pubDate>Fri, 18 May 2007 06:59:00 GMT</pubDate><guid>http://m.tkk7.com/honzeland/archive/2007/05/18/118366.html</guid><wfw:comment>http://m.tkk7.com/honzeland/comments/118366.html</wfw:comment><comments>http://m.tkk7.com/honzeland/archive/2007/05/18/118366.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/honzeland/comments/commentRss/118366.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/honzeland/services/trackbacks/118366.html</trackback:ping><description><![CDATA[<p style="color: red;"><a target="_blank">http://www.onjava.com</a></p> <p>    <span style="color: red;">O'Reilly鐨凧ava緗戠珯. 姣忓懆閮芥湁鏂版枃绔?/span></p> <p><a target="_blank">http://java.sun.com</a></p> <p>    瀹樻柟鐨凧ava寮鍙戣呯綉绔?- 姣忓懆閮芥湁鏂版枃绔犲彂琛?/p> <p><a target="_blank">http://www.developer.com/java</a></p> <p>    <span style="color: red;">鐢盙amelan.com 緇存姢鐨凧ava鎶鏈枃绔犵綉绔?/span></p> <p><a target="_blank">http://www.java.net</a></p> <p>    Sun鍏徃緇存姢鐨勪竴涓狫ava紺懼尯緗戠珯</p> <p><a target="_blank">http://www.ibm.com/developerworks/java</a> </p> <p>    IBM鐨凞eveloperworks鎶鏈綉绔? 榪欐槸鍏朵腑鐨凧ava鎶鏈富欏?/p> <p><a target="_blank">http://www.javaworld.com</a></p> <p>    <span style="color: red;">鏈鏃╃殑涓涓狫ava绔欑偣. 姣忓懆鏇存柊Java鎶鏈枃绔?/span></p> <a target="_blank">http://www.javadesktop.org</a> <p>    浣嶄簬Java.net鐨勪竴涓狫ava妗岄潰鎶鏈ぞ鍖虹綉绔? </p> <p><a target="_blank">http://www.theserverside.com</a> </p> <p>    榪欐槸涓涓璁烘墍鏈塉ava鏈嶅姟鍣ㄧ鎶鏈殑緗戠珯. </p> <p><a target="_blank">http://www.jars.com</a> </p> <p>    鎻愪緵Java璇勮鏈嶅姟. 鍖呮嫭鍚勭framework鍜屽簲鐢ㄧ▼搴?/p> <p><a target="_blank">http://www.ibiblio.org/javafaq/javafaq.html</a> </p> <p>    comp.lang.java鐨凢AQ绔欑偣 - 鏀墮泦浜嗘潵鑷猚omp.lang.java鏂伴椈緇勭殑闂鍜岀瓟妗堢殑鍒嗙被鐩綍. </p> <p><a target="_blank">http://java.sun.com/docs/books/tutorial/</a> </p> <p>    鏉ヨ嚜SUN鍏徃鐨勫畼鏂笿ava鎸囧崡 - 瀵逛簬浜嗚В鍑犱箮鎵鏈夌殑java鎶鏈壒鎬ч潪甯告湁甯姪. </p> <p><a target="_blank">http://www.javablogs.com</a> </p>     浜掕仈緗戜笂鏈媧昏穬鐨勪竴涓狫ava Blog緗戠珯. <p style="color: red;"><a target="_blank">http://www.java2s.com</a></p>   <span style="color: red;">  Java Codes</span><br> <img src ="http://m.tkk7.com/honzeland/aggbug/118366.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/honzeland/" target="_blank">honzeland</a> 2007-05-18 14:59 <a href="http://m.tkk7.com/honzeland/archive/2007/05/18/118366.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鍏充簬ServerSocket.accept()http://m.tkk7.com/honzeland/archive/2006/11/30/84607.htmlhonzelandhonzelandThu, 30 Nov 2006 08:46:00 GMThttp://m.tkk7.com/honzeland/archive/2006/11/30/84607.htmlhttp://m.tkk7.com/honzeland/comments/84607.htmlhttp://m.tkk7.com/honzeland/archive/2006/11/30/84607.html#Feedback0http://m.tkk7.com/honzeland/comments/commentRss/84607.htmlhttp://m.tkk7.com/honzeland/services/trackbacks/84607.html 瀵逛簬TCP濂楁帴瀛楋紝鍦ㄦ湇鍔″櫒绔氬父閲囩敤涓嬮潰鐨勮鍙ユ潵瀹炵幇錛?/font>
    聽聽聽聽ServerSocket welcomeSocket = new ServerSocket(6789);聽聽(1)
    聽聽聽聽Socket connectionSocket聽= welcomeSocket.accept();聽聽聽聽聽(2)
    絎紙1錛夊彞鍒涘緩浜嗕竴涓兘鐩戝惉鏌愪簺瀹㈡埛鏈?span lang="EN-US">鈥?/span>鏁查棬鈥?/span>澹扮殑闂紝welcomeSocket鍦?span lang="EN-US">6789绔彛涓婄洃鍚紱褰撴煇浜涘鎴鋒満涓?span lang="EN-US">welcomeSocket
    榪炴帴鏃訛紝絎紙2錛夊彞鍒涘緩浜嗕竴涓柊鐨勫鎺ュ瓧錛岀О涓?span lang="EN-US">connectionSocket錛岃繖涓鎺ュ瓧涔熶嬌鐢?span lang="EN-US">6789绔彛錛岃繖鏃訛紝涓や釜濂楁帴瀛椾嬌鐢ㄤ簡鐩稿悓鐨勭鍙e彿錛屽洜涓?span lang="EN-US">TCP榪炴帴濂楁帴瀛?/span>鐢變竴涓洓鍏冪粍錛堟簮IP鍦板潃錛屾簮绔彛鍙鳳紝鐩殑IP鍦板潃錛岀洰鐨勭鍙e彿錛夋潵鏍囪瘑錛?span lang="EN-US">UDP濂楁帴瀛楋紙闈㈠悜鏃犺繛鎺ョ殑錛夌敱涓涓寘鍚洰鐨?span lang="EN-US">IP鍦板潃鍜岀洰鐨勭鍙e彿緇勬垚鐨勪簩鍏冪粍鏉ユ爣璇嗐備箣鍚庯紝TCP鍦ㄥ鎴風鐨?span lang="EN-US">clientSocket鍜屾湇鍔″櫒绔殑connectionSocket涔嬮棿寤虹珛浜嗕竴鏉$洿鎺ョ殑铏氱ぜ綆¢亾錛岃瀹㈡埛鏈轟笌鏈嶅姟鍣ㄥ彲浠ラ氳繃璇ョ閬撳郊姝ゅ彂閫佸瓧鑺傦紝騫朵笖鍙戦佺殑鎵鏈夊瓧鑺傚皢鎸夐『搴忓埌杈懼鏂廣傞殢鐫connectionSocket鐨勫緩绔嬶紝璇ユ湇鍔″櫒鑳界戶緇嬌鐢?span lang="EN-US">welcomeSocket鐩戝惉鍏跺畠瀹㈡埛鏈虹殑榪炴帴璇鋒眰銆?span lang="EN-US">



    honzeland 2006-11-30 16:46 鍙戣〃璇勮
    ]]>
    Override and Overloadhttp://m.tkk7.com/honzeland/archive/2006/11/10/80325.htmlhonzelandhonzelandFri, 10 Nov 2006 02:37:00 GMThttp://m.tkk7.com/honzeland/archive/2006/11/10/80325.htmlhttp://m.tkk7.com/honzeland/comments/80325.htmlhttp://m.tkk7.com/honzeland/archive/2006/11/10/80325.html#Feedback0http://m.tkk7.com/honzeland/comments/commentRss/80325.htmlhttp://m.tkk7.com/honzeland/services/trackbacks/80325.html Override: 錛堣鐩栵級
    1 銆?/span> Override 鍙戠敓鍦ㄧ戶鎵夸腑錛屼嬌寰椾竴涓瓙綾?/span> Override 鍏剁埗綾葷殑涓涓?/span> method 銆?/span>
    2
    銆?/span> Override Rules 錛?/span> Keeping the contract 銆傚瓙綾?/span> override 鐖剁被鐨?/span> method 鏃訛紝蹇呴』瑕佷繚璇?/span> overriding method 鍜岀埗綾諱腑鐨?/span> overridden method 鍏鋒湁鐩稿悓鐨勫澶栧崗璁?/span> contract 錛屽嵆鐩稿悓鐨勫弬鏁板垪琛ㄥ拰鍏煎鐨勮繑鍥炵被鍨?/span>銆?/span>
    3
    銆?/span> Arguments must be the same, and return types must be compatible.
    4
    銆?/span> The method can't be less accessible. 鑰冭檻濡備笅鎯呭喌錛氬鏋滆闂潈闄愬彉灝忎簡錛屽鐢辯埗綾?/span> Parent 涓殑 public void test() 鍙樻垚瀛愮被 Son 涓殑 private void test() 錛屽鏋滅紪璇戝櫒鍏佽鏉冮檺鍙樺皬錛屽湪鏌愪竴綾諱腑鏈夊涓嬭鍙ワ細 Parent聽p = new Son() 錛?/span> p.test() 錛涘垯榪欎簺璇彞鑳藉閫氳繃緙栬瘧錛屽綋璇ョ被鍔犺澆榪愯鏃訛紝灝嗕細鍑虹幇閿欒錛屽洜涓虹埗綾?/span> reference p 鎸囧悜鐨勬槸涓瀛愮被 Son 鐨勫璞★紝鑰?/span> Son 涓殑 test() 鏄?/span> private 錛屼笉鑳藉湪鍏朵粬綾諱腑 invoke 銆?/span>
    聽聽聽聽聽聽
    鍙﹀錛屼笂闈㈢殑璇彞鍦ㄧ紪璇戝櫒鍏佽鏉冮檺鍙樺皬鎯呭喌涓嬩箣鎵浠ヨ兘澶熼氳繃緙栬瘧錛屾槸鍥犱負鍦?/span> 鈥淧arent聽p = new Son() 錛?/span> 鈥?/span> 涓紝澹版槑浜嗕竴涓埗綾?/span> Parent 鐨?/span> reference p 錛岀敱浜?/span> p 鏄埗綾葷殑 reference 錛岀敱浜庣埗綾諱腑鐨?/span> test() 鏄?/span> public 錛屾晠 鈥減.test() 錛?/span> 鈥?/span> 鑳藉閫氳繃緙栬瘧錛涜屽湪榪愯鏃訛紝 p 鎸囧悜鐨勬槸涓涓瓙綾葷殑瀵硅薄錛?/span> p.test() 鍦ㄨ繍琛屾椂璋冪敤鐨勬槸瀛愮被瀵硅薄涓殑 test() 銆?/span>

    Overload
    錛氾紙閲嶈澆錛?/span>
    1 銆侀噸杞斤細涓や釜鎴栧涓?/span> methods 鍏鋒湁鐩稿悓鐨?/span> name 錛?/span> 鍜?/span> 涓嶅悓鐨?/span> argument lists 銆?/span>
    2
    銆?/span> The return types can be different.
    3
    銆?/span> You can't change ONLY the return type 錛氫笉鑳戒粎浠呮敼鍙樿繑鍥炵被鍨嬶紝 To overload a method, you MUST change the argument list, although you can change the return type to anything.
    4
    銆?/span> You can vary the access levels in any direction.



    honzeland 2006-11-10 10:37 鍙戣〃璇勮
    ]]>
    鍏ㄩ潰瑙f瀽Java涓殑String鏁版嵁綾誨瀷http://m.tkk7.com/honzeland/archive/2006/11/05/79190.htmlhonzelandhonzelandSun, 05 Nov 2006 06:32:00 GMThttp://m.tkk7.com/honzeland/archive/2006/11/05/79190.htmlhttp://m.tkk7.com/honzeland/comments/79190.htmlhttp://m.tkk7.com/honzeland/archive/2006/11/05/79190.html#Feedback0http://m.tkk7.com/honzeland/comments/commentRss/79190.htmlhttp://m.tkk7.com/honzeland/services/trackbacks/79190.html 1. 棣栧厛 String 涓嶅睘浜?/span> 8 縐嶅熀鏈暟鎹被鍨嬶紝 String 鏄竴涓璞°?/span>
    銆銆鍥犱負瀵硅薄鐨勯粯璁ゅ兼槸 null 錛屾墍浠?/span> String 鐨勯粯璁ゅ間篃鏄?/span> null 錛涗絾瀹冨張鏄竴縐嶇壒孌婄殑瀵硅薄錛屾湁鍏跺畠瀵硅薄娌℃湁鐨勪竴浜涚壒鎬с?/span>
    2. new String()
    鍜?/span> new String(鈥溾? 閮芥槸鐢蟲槑涓涓柊鐨勭┖瀛楃涓詫紝鏄┖涓蹭笉鏄?/span> null 錛?/span>
    3. String str=鈥漦vill鈥?/span>
    錛?/span> String str=new String (鈥渒vill鈥?; 鐨勫尯鍒細鍦ㄨ繖閲岋紝鎴戜滑涓嶈皥鍫嗭紝涔熶笉璋堟爤錛屽彧鍏堢畝鍗曞紩鍏ュ父閲忔睜榪欎釜綆鍗曠殑姒傚康銆?/span>
    銆銆甯擱噺姹?/span> (constant pool) 鎸囩殑鏄湪緙栬瘧鏈熻紜畾錛屽茍琚繚瀛樺湪宸茬紪璇戠殑 .class 鏂囦歡涓殑涓浜涙暟鎹傚畠鍖呮嫭浜嗗叧浜庣被銆佹柟娉曘佹帴鍙g瓑涓殑甯擱噺錛屼篃鍖呮嫭瀛楃涓插父閲忋?/span>
    銆銆鐪嬩緥 1 錛?/span>
    String s0=鈥漦vill鈥?
    String s1=鈥漦vill鈥?
    String s2=鈥漦v鈥?+ 鈥渋ll鈥?
    System.out.println( s0==s1 );
    System.out.println( s0==s2 );

    銆銆緇撴灉涓猴細
    true
    true
    銆銆棣栧厛錛屾垜浠鐭ョ粨鏋滀負閬?/span> Java 浼氱‘淇濅竴涓瓧絎︿覆甯擱噺鍙湁涓涓嫹璐?/span> 銆?/span>
    銆銆鍥犱負渚嬪瓙涓殑 s0 鍜?/span> s1 涓殑 鈥漦vill鈥?/span> 閮芥槸瀛楃涓插父閲忥紝瀹冧滑鍦ㄧ紪璇戞湡灝辮紜畾浜?/span>錛屾墍浠?/span> s0==s1 涓?/span> true 錛涜?/span> 鈥漦v鈥?/span> 鍜?/span> 鈥漣ll鈥?/span> 涔熼兘鏄瓧絎︿覆甯擱噺錛屽綋涓涓瓧絎︿覆鐢卞涓瓧絎︿覆甯擱噺榪炴帴鑰屾垚鏃訛紝瀹冭嚜宸辮偗瀹氫篃鏄瓧絎︿覆甯擱噺錛屾墍浠?/span> s2 涔熷悓鏍峰湪緙栬瘧鏈熷氨琚В鏋愪負涓涓瓧絎︿覆甯擱噺錛屾墍浠?/span> s2 涔熸槸甯擱噺姹犱腑 鈥漦vill鈥?/span> 鐨勪竴涓紩鐢ㄣ?/span>
    銆銆鎵浠ユ垜浠緱鍑?/span> s0==s1==s2; 鐢?/span> new String() 鍒涘緩鐨勫瓧絎︿覆涓嶆槸甯擱噺錛屼笉鑳藉湪緙栬瘧鏈熷氨紜畾錛屾墍浠?/span> new String() 鍒涘緩鐨勫瓧絎︿覆涓嶆斁鍏ュ父閲忔睜涓紝瀹冧滑鏈夎嚜宸辯殑鍦板潃絀洪棿銆?/span>
    銆銆鐪嬩緥 2 錛?/span>
    String s0=鈥漦vill鈥?
    String s1=new String(鈥漦vill鈥?;
    String s2=鈥漦v鈥?+ new String(鈥渋ll鈥?;
    System.out.println( s0==s1 );
    System.out.println( s0==s2 );
    System.out.println( s1==s2 );
    銆銆緇撴灉涓猴細
    false
    false
    false

    銆銆渚?/span> 2 涓?/span> s0 榪樻槸甯擱噺姹犱腑 鈥漦vill鈥?/span> 鐨勫簲鐢紝 s1 鍥犱負鏃犳硶鍦ㄧ紪璇戞湡紜畾錛屾墍浠ユ槸榪愯鏃跺垱寤虹殑鏂板璞?/span> 鈥漦vill鈥?/span> 鐨勫紩鐢紝 s2 鍥犱負鏈夊悗鍗婇儴鍒?/span> new String(鈥渋ll鈥? 鎵浠ヤ篃鏃犳硶鍦ㄧ紪璇戞湡紜畾錛屾墍浠ヤ篃鏄竴涓柊鍒涘緩瀵硅薄 鈥漦vill鈥?/span> 鐨勫簲鐢?/span> ; 鏄庣櫧浜嗚繖浜涗篃灝辯煡閬撲負浣曞緱鍑烘緇撴灉浜嗐?/span>
    4. String.intern()
    錛?/span>
    銆銆鍐嶈ˉ鍏呬粙緇嶄竴鐐癸細瀛樺湪浜?/span> .class 鏂囦歡涓殑甯擱噺姹狅紝鍦ㄨ繍琛屾湡琚?/span> JVM 瑁呰澆錛屽茍涓斿彲浠ユ墿鍏呫?/span> String 鐨?/span> intern() 鏂規硶灝辨槸鎵╁厖甯擱噺姹犵殑涓涓柟娉曪紱褰撲竴涓?/span> String 瀹炰緥 str 璋冪敤 intern() 鏂規硶鏃訛紝 Java 鏌ユ壘甯擱噺姹犱腑鏄惁鏈夌浉鍚?/span> Unicode 鐨勫瓧絎︿覆甯擱噺錛屽鏋滄湁錛屽垯榪斿洖鍏剁殑寮曠敤錛屽鏋滄病鏈夛紝鍒欏湪甯擱噺姹犱腑澧炲姞涓涓?/span> Unicode 絳変簬 str 鐨勫瓧絎︿覆騫惰繑鍥炲畠鐨勫紩鐢紱鐪嬩緥 3 灝辨竻妤氫簡
    銆銆渚?/span> 3 錛?/span>
    String s0= 鈥渒vill鈥?
    String s1=new String(鈥漦vill鈥?;
    String s2=new String(鈥渒vill鈥?;
    System.out.println( s0==s1 );
    System.out.println( 鈥?*********鈥?);
    s1.intern();
    s2=s2.intern(); //
    鎶婂父閲忔睜涓?/span> 鈥渒vill鈥?/span> 鐨勫紩鐢ㄨ祴緇?/span> s2
    System.out.println( s0==s1);
    System.out.println( s0==s1.intern() );
    System.out.println( s0==s2 );
    銆銆緇撴灉涓猴細
    false
    **********
    false //
    铏界劧鎵ц浜?/span> s1.intern(), 浣嗗畠鐨勮繑鍥炲兼病鏈夎祴緇?/span> s1
    true //
    璇存槑 s1.intern() 榪斿洖鐨勬槸甯擱噺姹犱腑 鈥漦vill鈥?/span> 鐨勫紩鐢?/span>
    true
    銆銆鏈鍚庢垜鍐嶇牬闄や竴涓敊璇殑鐞嗚В錛氭湁浜鴻錛?/span> 鈥?/span> 浣跨敤 String.intern() 鏂規硶鍒欏彲浠ュ皢涓涓?/span> String 綾葷殑淇濆瓨鍒頒竴涓叏灞 String 琛ㄤ腑錛屽鏋滃叿鏈夌浉鍚屽肩殑 Unicode 瀛楃涓插凡緇忓湪榪欎釜琛ㄤ腑錛岄偅涔堣鏂規硶榪斿洖琛ㄤ腑宸叉湁瀛楃涓茬殑鍦板潃錛屽鏋滃湪琛ㄤ腑娌℃湁鐩稿悓鍊肩殑瀛楃涓詫紝鍒欏皢鑷繁鐨勫湴鍧娉ㄥ唽鍒拌〃涓?/span> 鈥?/span> 濡傛灉鎴戞妸浠栬鐨勮繖涓叏灞鐨?/span> String 琛ㄧ悊瑙d負甯擱噺姹犵殑璇濓紝浠栫殑鏈鍚庝竴鍙ヨ瘽錛?/span> 鈥?/span> 濡傛灉鍦ㄨ〃涓病鏈夌浉鍚屽肩殑瀛楃涓詫紝鍒欏皢鑷繁鐨勫湴鍧娉ㄥ唽鍒拌〃涓?/span> 鈥?/span> 鏄敊鐨勶細
    銆銆鐪嬩緥 4 錛?/span>
    String s1=new String("kvill");
    String s2=s1.intern();
    System.out.println( s1==s1.intern() );
    System.out.println( s1+" "+s2 );
    System.out.println( s2==s1.intern() );
    銆銆緇撴灉錛?/span>

    false
    kvill kvill
    true
    銆銆鍦ㄨ繖涓被涓垜浠病鏈夊0鍚嶄竴涓?/span> 鈥漦vill鈥?/span> 甯擱噺錛屾墍浠ュ父閲忔睜涓竴寮濮嬫槸娌℃湁 鈥漦vill鈥?/span> 鐨勶紝褰撴垜浠皟鐢?/span> s1.intern() 鍚庡氨鍦ㄥ父閲忔睜涓柊娣誨姞浜嗕竴涓?/span> 鈥漦vill鈥?/span> 甯擱噺錛屽師鏉ョ殑涓嶅湪甯擱噺姹犱腑鐨?/span> 鈥漦vill鈥?/span> 浠嶇劧瀛樺湪錛屼篃灝變笉鏄?/span> 鈥?/span> 灝嗚嚜宸辯殑鍦板潃娉ㄥ唽鍒板父閲忔睜涓?/span> 鈥?/span> 浜嗐?/span>
    銆銆 s1==s1.intern() 涓?/span> false 璇存槑鍘熸潵鐨?/span> 鈥渒vill鈥?/span> 浠嶇劧瀛樺湪錛?/span> s2 鐜板湪涓哄父閲忔睜涓?/span> 鈥渒vill鈥?/span> 鐨勫湴鍧錛屾墍浠ユ湁 s2==s1.intern() 涓?/span> true 銆?/span>
    5.
    鍏充簬 equals() 鍜?/span> ==
    銆銆榪欎釜瀵逛簬 String 綆鍗曟潵璇村氨鏄瘮杈冧袱瀛楃涓茬殑 Unicode 搴忓垪鏄惁鐩稿綋錛屽鏋滅浉絳夎繑鍥?/span> true; 鑰?/span> == 鏄瘮杈冧袱瀛楃涓茬殑鍦板潃鏄惁鐩稿悓錛屼篃灝辨槸鏄惁鏄悓涓涓瓧絎︿覆鐨勫紩鐢ㄣ?/span>
    6.
    鍏充簬 String 鏄笉鍙彉鐨?/span>
    銆銆榪欎竴璇村張瑕佽寰堝錛屽ぇ瀹跺彧瑕佺煡閬?/span> String 鐨勫疄渚嬩竴鏃︾敓鎴愬氨涓嶄細鍐嶆敼鍙樹簡錛屾瘮濡傝錛?/span> String str=鈥漦v鈥?鈥漣ll鈥?鈥?鈥?鈥漚ns鈥?
    銆銆灝辨槸鏈?/span> 4 涓瓧絎︿覆甯擱噺錛岄鍏?/span> 鈥漦v鈥?/span> 鍜?/span> 鈥漣ll鈥?/span> 鐢熸垚浜?/span> 鈥漦vill鈥?/span> 瀛樺湪鍐呭瓨涓紝鐒跺悗 鈥漦vill鈥?/span> 鍙堝拰 鈥?鈥? 鐢熸垚 鈥漦vill 鈥?/span> 瀛樺湪鍐呭瓨涓紝鏈鍚庡張鍜岀敓鎴愪簡 鈥漦vill ans鈥? 騫舵妸榪欎釜瀛楃涓茬殑鍦板潃璧嬬粰浜?/span> str, 灝辨槸鍥犱負 String 鐨?/span> 鈥?/span> 涓嶅彲鍙?/span> 鈥?/span> 浜х敓浜嗗緢澶氫復鏃跺彉閲忥紝榪欎篃灝辨槸涓轟粈涔堝緩璁敤 StringBuffer 鐨勫師鍥犱簡錛屽洜涓?/span> StringBuffer 鏄彲鏀瑰彉鐨勩?/span>



    honzeland 2006-11-05 14:32 鍙戣〃璇勮
    ]]>
    Abstract class and interfacehttp://m.tkk7.com/honzeland/archive/2006/10/26/77439.htmlhonzelandhonzelandThu, 26 Oct 2006 09:27:00 GMThttp://m.tkk7.com/honzeland/archive/2006/10/26/77439.htmlhttp://m.tkk7.com/honzeland/comments/77439.htmlhttp://m.tkk7.com/honzeland/archive/2006/10/26/77439.html#Feedback0http://m.tkk7.com/honzeland/comments/commentRss/77439.htmlhttp://m.tkk7.com/honzeland/services/trackbacks/77439.html 1 銆佹娊璞$被鍜屾帴鍙i兘涓嶈兘琚疄渚嬪寲錛?/span>

    2 銆佹娊璞$被錛氭娊璞$被涓彲浠ヤ笉鍖呭惈鎶借薄鏂規硶錛屽嵆綾諱腑鐨勬柟娉曢兘鏄潪鎶借薄鐨勶紝浣嗘槸鍦ㄧ被鐨勫0鏄庝腑鍔犱笂 abstract 錛屼互浣垮緱璇ョ被鏄娊璞$殑錛岀洰鐨勬槸闃叉瀹㈡埛绔▼搴忓憳鍒涘緩璇ョ被鐨勫璞★紱

    3 銆佹帴鍙d腑鐨勬柟娉曟繪槸 abstract and public 錛屼笉綆℃槸鍚﹁鏄劇ず鐨勫0鏄庯紱

    4 銆佹帴鍙d腑鐨?/span> field 鍙兘鏄?/span> public static final 錛?/span>

    5 銆佹帴鍙f湰韜彲浠ユ槸 public or protected 錛?/span>

    6 銆?/span> extended class 蹇呴』瀹炵幇鎶借薄綾諱腑鐨勬墍鏈夋娊璞℃柟娉曪紝 implemented class 蹇呴』瀹炵幇鎺ュ彛涓殑鎵鏈夋柟娉曪紝鍥犱負鎺ュ彛涓殑鎵鏈夋柟娉曢兘鏄?/span> abstract 銆?/span>



    honzeland 2006-10-26 17:27 鍙戣〃璇勮
    ]]>
    J2EE瀛︿範絎旇錛?/title><link>http://m.tkk7.com/honzeland/archive/2006/10/13/75013.html</link><dc:creator>honzeland</dc:creator><author>honzeland</author><pubDate>Fri, 13 Oct 2006 07:53:00 GMT</pubDate><guid>http://m.tkk7.com/honzeland/archive/2006/10/13/75013.html</guid><wfw:comment>http://m.tkk7.com/honzeland/comments/75013.html</wfw:comment><comments>http://m.tkk7.com/honzeland/archive/2006/10/13/75013.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/honzeland/comments/commentRss/75013.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/honzeland/services/trackbacks/75013.html</trackback:ping><description><![CDATA[ <p> <font color="#ff0000" size="5"> <strong>Part One: The Web Tier</strong> </font> </p> <p> <font size="5"> <strong> <font size="4">Section One: Configuring Web Applications</font> </strong> </font> </p> <p> <font size="4"> <strong> <font size="3">Mapping URLs to Web Components</font> </strong> </font> </p> <p class="pBody">When a request is received by the web container it must determine which web component should handle the request. It does so by mapping the URL path contained in the request to a web application and a web component. A URL path contains the context root and an alias: </p> <p class="pPreformattedRelative">http://<code class="cVariable">host</code>:<code class="cVariable">port</code>/<code class="cVariable">context_root</code>/<code class="cVariable">alias</code><a name="wp219218"></a></p> <p>A context root identifies a web application in a Java EE server. You specify the context root when you deploy a web module. A context root must start with a forward slash (/) and end with a string.<br />聽<br />The alias identifies the web component that should handle a request. The alias path must start with a forward slash (/) and end with a string or a wildcard expression with an extension (for example, *.jsp). Since web containers automatically map an alias that ends with *.jsp, you do not have to specify an alias for a JSP page unless you wish to refer to the page by a name other than its file name. </p> <p class="pHeading2"> <font size="4"> <strong> <font size="3">Declaring Welcome Files</font> </strong> </font> </p> <a name="wp85893"> </a> <p class="pBody">For example, suppose you define a welcome file welcome.html. When a client requests a URL such as host:port/webapp/directory, where directory is not mapped to a servlet or JSP page, the file host:port/webapp/directory/welcome.html is returned to the client.<br /></p> <p class="pBody">If no welcome file is specified, the Application Server will use a file named <code class="cCode">index.</code><code class="cVariable">XXX</code>, where <code class="cVariable">XXX</code> can be <code class="cCode">html</code> or <code class="cCode">jsp</code>, as the default welcome file. If there is no welcome file and no file named <code class="cCode">index.</code><code class="cVariable">XXX</code>, the Application Server returns a directory listing. </p> <a name="wp222536"> </a> <p class="pBody">To specify a welcome file in the web application deployment descriptor, you need to nest a <code class="cCode">welcome-file</code> element inside a <code class="cCode">welcome-file-list</code> element. The <code class="cCode">welcome-file</code> element defines the JSP page to be used as the welcome page. Make sure this JSP page is actually included in your WAR file. <br /><br /></p> <p class="pHeading2"> <font size="4"> <strong> <font size="3">Setting Initialization Parameters</font> </strong> </font> </p> <a name="wp222559"> </a> <p class="pBody">The web components in a web module share an object that represents their application context. You can pass initialization parameters to the context or to a web component. </p> <a name="wp226898"> </a> <p class="pBody">To add a context parameter you need the following in the example's web.xml file: </p> <div id="6161666" class="pSmartList1"> <ul class="pSmartList1"> <a name="wp226899"> </a> <div id="6116111" class="pSmartList1"> <li>A <code class="cCode">param-name</code> element that specifies the context object </li> </div> <a name="wp229279"> </a> <div id="6616616" class="pSmartList1"> <li>A <code class="cCode">param-value</code> element that specifies the parameter to pass to the context object. </li> </div> <a name="wp229280"> </a> <div id="6111166" class="pSmartList1"> <li>A <code class="cCode">context-param</code> element that encloses the previous two elements. </li> </div> </ul> </div> <a name="wp229284"> </a> <p class="pBody">To add a web component initialization parameter you need the following in the example's web.xml file: </p> <div id="6166166" class="pSmartList1"> <ul class="pSmartList1"> <a name="wp229291"> </a> <div id="6666661" class="pSmartList1"> <li>A <code class="cCode">param-name</code> element that specifies the name of the initialization parameter </li> </div> <a name="wp229292"> </a> <div id="6161111" class="pSmartList1"> <li>A <code class="cCode">param-value</code> element that specifies the value of the initialization parameter </li> </div> <a name="wp229293"> </a> <div id="1111161" class="pSmartList1"> <li>An <code class="cCode">init-param</code> element that encloses the previous two elements </li> </div> </ul> </div> <a name="wp83548"> </a> <p class="pHeading2"> <strong>Mapping Errors to Error Screens </strong> </p> <p class="pHeading2"> <strong>Declaring Resource References </strong> </p> <p class="pBody"> <br /> </p> <img src ="http://m.tkk7.com/honzeland/aggbug/75013.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/honzeland/" target="_blank">honzeland</a> 2006-10-13 15:53 <a href="http://m.tkk7.com/honzeland/archive/2006/10/13/75013.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>感谢您访问我们的网站,您可能还对以下资源感兴趣:</p> <a href="http://m.tkk7.com/" title="亚洲av成人片在线观看">亚洲av成人片在线观看</a> <div class="friend-links"> </div> </div> </footer> 主站蜘蛛池模板: <a href="http://gg596gg.com" target="_blank">九九精品成人免费国产片</a>| <a href="http://yx6768.com" target="_blank">xxx毛茸茸的亚洲</a>| <a href="http://246210.com" target="_blank">国产aⅴ无码专区亚洲av麻豆</a>| <a href="http://ivr69.com" target="_blank">国产jizzjizz免费看jizz</a>| <a href="http://666za.com" target="_blank">国产男女猛烈无遮挡免费视频 </a>| <a href="http://tmg-beelen.com" target="_blank">直接进入免费看黄的网站</a>| <a href="http://gzjing365.com" target="_blank">亚洲午夜理论片在线观看</a>| <a href="http://ebhqd.com" target="_blank">亚洲自偷自偷在线成人网站传媒</a>| <a href="http://linmh.com" target="_blank">亚洲伦理中文字幕</a>| <a href="http://www988555.com" target="_blank">亚洲一线产品二线产品</a>| <a href="http://9527paotui.com" target="_blank">亚洲色欲啪啪久久WWW综合网</a>| <a href="http://dghxm168.com" target="_blank">亚洲人AV在线无码影院观看</a>| <a href="http://jjv5.com" target="_blank">亚洲av无一区二区三区</a>| <a href="http://myzhoubian.com" target="_blank">色偷偷亚洲第一综合网</a>| <a href="http://jinlaifubuxiugang.com" target="_blank">美女黄色免费网站</a>| <a href="http://ldcatv.com" target="_blank">aa级女人大片喷水视频免费</a>| <a href="http://lfhuanxin.com" target="_blank">十八禁在线观看视频播放免费</a>| <a href="http://usagaa.com" target="_blank">毛片在线全部免费观看</a>| <a href="http://1314con.com" target="_blank">日本一卡精品视频免费</a>| <a href="http://786087.com" target="_blank">999国内精品永久免费观看</a>| <a href="http://caita88.com" target="_blank">免费可以在线看A∨网站</a>| <a href="http://www50884.com" target="_blank">午夜免费福利影院</a>| <a href="http://66eeb.com" target="_blank">亚洲高清无码综合性爱视频</a>| <a href="http://26uuyy.com" target="_blank">亚洲色精品aⅴ一区区三区</a>| <a href="http://ydxcsh.com" target="_blank">国产成A人亚洲精V品无码</a>| <a href="http://kencery.com" target="_blank">亚洲黄网在线观看</a>| <a href="http://by6216.com" target="_blank">亚洲乱码在线卡一卡二卡新区</a>| <a href="http://tjtangpu.com" target="_blank">亚洲欧洲国产综合AV无码久久</a>| <a href="http://v1s3u5.com" target="_blank">免费国产黄网站在线观看动图 </a>| <a href="http://zaidongmaixi.com" target="_blank">亚洲国产成a人v在线</a>| <a href="http://zbvip888.com" target="_blank">亚洲影院天堂中文av色</a>| <a href="http://www24ckck.com" target="_blank">无码一区二区三区亚洲人妻</a>| <a href="http://benjiebf.com" target="_blank">一级做α爱过程免费视频</a>| <a href="http://s4lm0x.com" target="_blank">日本亚洲欧洲免费天堂午夜看片女人员</a>| <a href="http://yy7699.com" target="_blank">91制片厂制作传媒免费版樱花</a>| <a href="http://adcacs.com" target="_blank">在线观看人成网站深夜免费</a>| <a href="http://trgod.com" target="_blank">亚洲乱亚洲乱少妇无码</a>| <a href="http://zgj688.com" target="_blank">内射少妇36P亚洲区</a>| <a href="http://miya863.com" target="_blank">亚洲人成未满十八禁网站</a>| <a href="http://cqtchtwq.com" target="_blank">大妹子影视剧在线观看全集免费</a>| <a href="http://jcmy5188.com" target="_blank">99re在线这里只有精品免费</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>