锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
1.涓嬭澆
http://activemq.apache.org/download.html
2.瑙e帇
灝嗕笅杞戒笅鏉ョ殑apache-activemq-5.2.0-bin.tar.gz鏀劇疆浜?usr/local
cd /usr/local/
tar xvfz apache-activemq-5.2.0-bin.tar.gz
鍒橝ctiveMQ鐨勫畨瑁呯洰褰曚負錛?usr/local/apache-activemq-5.2.0
3.淇敼activemq榪愯鏂囦歡鐨勬潈闄?br />
cd /usr/local/apache-activemq-5.2.0/bin
chmod 755 activemq
4.榪愯
(1).鏅氬惎鍔?br />
bin/activemq
(2).鎸囧畾鏃ュ織鏂囦歡鐨勫惎鍔ㄦ柟寮?br />
bin/activemq >/tmp/smlog 2>&1 &
(3)鍚庡彴鍚姩鏂瑰紡
nohup bin/activemq >/tmp/smlog 2>&1 &
榪欓噷闇瑕佹敞鎰忥細鍓嶄袱縐嶅惎鍔ㄦ柟寮忓湪linix鍛戒護琛屾垨鑰呴氳繃ssh瀹㈡埛绔惎鍔ㄦ椂鍦ㄥ叧闂搴旂殑紿楀彛鏃禷ctivemq浼氬叧闂紝鐢氳嚦鐩存帴ctrl+c涔熶細瀵艱嚧activemq閫鍑猴紱絎笁縐嶅垯涓嶄細鍑虹幇榪欑鎯呭喌銆?br />
5.楠岃瘉鏈嶅姟绔槸鍚﹀紑鍚紝鏈夊嚑縐嶆柟娉?br />
(1).鏌ョ湅鎺у埗鍙拌緭鍑烘垨鑰呮棩蹇楁枃浠?br />
(2).鐩存帴璁塊棶activemq鐨勭鐞嗛〉闈細http://localhost:8161/admin/
6.鍏抽棴activemq
濡傛灉寮鍚柟寮忔槸浣跨敤(1)鎴?2)錛屽垯鐩存帴ctrl+c鎴栬呭叧闂搴旂殑緇堢鍗沖彲
濡傛灉寮鍚柟寮忔槸(3),鍒欑◢寰夯鐑︿竴鐐癸細
鍏堟煡鎵懼埌activemq瀵瑰簲鐨勮繘紼嬶細
ps -ef | grep activemq
鐒跺悗鎶婂搴旂殑榪涚▼鏉鎺夛紝鍋囪鎵懼埌鐨勮繘紼嬬紪鍙蜂負 168168
kill 168168
]]>
]]>
鍦–XF鏈嶅姟绔厤緗甒EB SERVICE鏃訛紝閫氬父浼氬寘鍚竴浜涙潵姝xf.jar閲岄潰鐨刋ML鏂囦歡錛岀敤浜庤嚜鍔ㄩ厤緗渶瑕佷嬌鐢ㄥ埌鐨凚EAN
渚嬪錛?/p>
浣嗘槸鍦ㄥ鎴風閰嶇疆鐨勬椂鍊欒繖浜涙枃浠舵槸涓嶉渶瑕佺殑錛岀敋鑷抽厤緗細寮曞彂閿欒錛岃緇嗙殑緇忚繃瑙佷笅鏂囥?/p>
緇忚繃錛?/font>
浠婂ぉ鍦ㄩ厤緗鎴風鐨勬椂鍊欙紝姝ラ鍜屽唴瀹歸兘鏄拰寰甯鎬竴鏍風殑錛屼絾鏄?/p>
鍑虹幇涓涓狽ullPointerException 鐨勯敊璇紝鍙煡閬撹繖涓敊璇槸鍦ㄥ垱寤哄鎴風service鐨勬椂鍊欏嚭鐨勯敊錛屼絾鏄師鍥犳壘涓嶅埌銆?/p>
閿欒鍫嗘爤錛?/p>
鐩村埌鍚庢潵鎴戝崟鐙姞杞戒簡鍒涘緩瀹㈡埛绔痵ervice鐨刟pplicationContext鏃訛紝鍒濆鍖栨槸姝e父鐨勶紝鎵浠ュ氨鎬鐤戦厤緗枃浠跺嚭浜嗛棶棰橈紱
褰撲笂闈㈡彁鍒扮殑鍑犱釜琚寘鍚繘鏉ョ殑鏂囦歡鐨勯厤緗鍒犻櫎鍚庯紝涓鍒囧氨姝e父浜嗐?/p>
鐜拌薄錛?/p>
鍦╓eb harvest涓嬌鐢╤ttp璇鋒眰鍘昏幏鍙栨煇涓繙紼嬬殑XML錛屾XML鐨勭壒寰佹槸鏃犳枃浠跺ご(鍗蟲病鏈夌紪鐮佹弿榪扮瓑鍏抽敭淇℃伅)錛岄噰鐢ㄤ簡澶氱鍔炴硶鍘昏幏鍙栵紝鍑虹幇涔辯爜錛屾棤娉曡В鏋愭垚鎴戜滑闇瑕佺殑鏁版嵁銆?/p>
鍔炴硶錛?/p>
(1)鏈鍘熷鍔炴硶錛?/font>浣跨敤Java涓殑URLConnection錛孖nputStream絳夌被璇誨彇瀛楄妭嫻侊紝鏋勯犲瓧絎︿覆錛?/p>
(2)鏈濂界殑鍔炴硶錛?/font>鐩存帴浣跨敤dom4j涓殑SAXReader 闈炲父綆鍗曪紝榪炵紪鐮侀兘涓嶇敤綆★紒 鍏朵腑錛歭ink涓洪渶瑕佽幏鍙朮ML鐨勫湴鍧
]]>
鏈榪戣繖鍑犲ぉ閮藉湪浣跨敤CXF浣滀負webservice鐨勭粍浠訛紝璇曞浘灝嗗叕寮鐨剋ebservice鍔犲叆鍒頒繚鎶ょ殑鑼冨洿鍐呫?/p>
娣誨姞鍒頒繚鎶ょ殑鏂規硶鏈変笁縐嶏細
(1)鎸囧畾鍦板潃璁塊棶錛屽嵆鎸囧畾涓浜汭P鍦板潃錛屽彧鏈夎繖浜涘湴鍧鐨勮姹傛垜浠殑鎺ュ彛鎵嶅鐞嗐?/font>
榪欑鏂規硶鎴戝湪寮鍙戜腑鏈変嬌鐢ㄥ埌錛屽彲浠ラ氳繃WEB瀹瑰櫒涓殑Filter綾繪潵瀹炵幇錛?/p>
鍙渶瑕佹鏌ヨ姹傜殑鍦板潃鏄惁鍦ㄦ垜浠寚瀹氱殑鍦板潃鍒楄〃涓氨鍙互浜嗐?/p>
浼樼偣:澶勪簬璇鋒眰鍝嶅簲閾劇殑鍓嶇錛屽搷搴旈潪甯歌繀閫燂紝鎵浠ユ秷鑰楃殑璧勬簮寰堝皯銆?/p>
緙虹錛?/font>浣跨敤榪欑鏂規硶鍙兘媯鏌ユ寚瀹氬湴鍧鐨勮姹傦紝閫氬父鍙兘搴旂敤鐨勫皬鑼冨洿鍐咃紝濡傚眬鍩熺綉銆?/p>
鍙﹀浣跨敤榪欑楠岃瘉鏂規硶錛屾棤娉曡繘琛屾潈闄愮殑媯鏌ワ紝涓鏃﹂氳繃楠岃瘉灝嗗彲浠ユ墽琛屾墍鏈夊叕寮鐨勬帴鍙c?/p>
(2)鐢ㄦ埛鍚?瀵嗙爜瀵歸獙璇侊紝浣跨敤鎸囧畾鐨勭敤鎴峰悕瀵嗙爜榪涜楠岃瘉
榪欑鏂規硶閫傚悎浜庡叿浣撶敤鎴風殑媯鏌ワ紝榪涜屽彲浠ユ鏌ュ叾鏄惁鏈夋潈闄愭墽琛屽叾璇鋒眰鐨勬搷浣?
浼樼偣錛?/span>鍙互鍙噯紜湴媯鏌ョ敤鎴鳳紝鐢氳嚦楠岃瘉鏉冮檺銆?/p>
緙虹偣錛?/span>榪欑鏂瑰紡涓嶈兘鍜學EB搴旂敤鐨勭櫥褰曚竴鏍鳳紝鍙渶瑕侀獙璇佷竴嬈″氨鍙互浜嗭紱蹇呴』 姣忎釜璇鋒眰閮芥鏌ワ紝濡傛灉闇瑕佷嬌鐢ㄨ繖縐嶆柟娉曞幓鍋氾紝榪橀渶瑕佸鐞嗗ソ綾諱技鐧誨綍/閫鍑烘満鍒躲?/p>
(3)浣跨敤HTTPS榪涜楠岃瘉錛岃繖縐嶆柟娉曞簲璇ヤ篃鍙互鍏蜂綋鐨勯獙璇佽瘉涔︽潵鑷摢涓敤鎴鳳紝榪涜屾鏌ュ叾鏉冮檺銆?/font> 浼樼偣錛?/font>瀹夊叏鏇存湁淇濊瘉 緙虹偣錛?/font>閰嶇疆澶嶆潅錛屽瀹㈡埛绔▼搴忓憳瑕佹眰寰堟瘮杈冮珮銆?/p>
娉ㄦ剰浜嬮」錛?/font> 浣跨敤CXF榪涜WEBService浜や簰鏃訛紝鐗瑰埆鏄繘琛屽鎴風宸ヤ綔鏃訛紝鏈濂藉皢鏈嶅姟绔拰瀹㈡埛绔殑鐜鍓ョ寮鏉ャ?/p>
榪欏嚑澶╃殑宸ヤ綔鏁欎細浜嗘垜榪欎釜浜嬫儏(浠婂ぉ涓婂崍鍦ㄦ祴璇曞鎴風浠g爜鏃跺嚭鐜拌帿鍚嶅叾濡欑殑閿欙紝鏈鍚庡彂鐜版槸JAR鍖呭啿紿侊紝 鍦ㄦ湇鍔″櫒鐨勭幆澧冧腑榪愯瀹㈡埛绔▼搴忔椂錛岀▼搴忓姞杞戒簡榪囨椂鐨凧AR)銆?/p>
鍏跺獎鍝嶄富瑕佽〃鐜板湪涓ゆ柟闈細
(1)瀵規祦紼嬬‘瀹氳繃紼嬬殑褰卞搷
鍦ㄩ氳繃鍒嗘瀽緗戠珯鍦板浘鐨勬柟寮忓幓紜畾嫻佺▼錛屽涓撲笟鍖栫▼搴︿笉鏄偅涔堥珮鐨勭綉绔欒岃█錛屽叾緗戠珯鍒嗙被銆佸垪琛ㄦ柟寮忓熀鏈熀鏈兘閲囩敤閾炬帴鐨勬柟寮忥紝榪欐牱鍦ㄦ祦紼嬪疄鐜版槸寰堝鏄撳氨鍙幏鍙栭渶瑕佺殑閾炬帴錛涜屽涓撲笟鍖栫▼搴﹁緝楂樼殑緗戠珯鑰岃█錛屽湪鍒嗙被涓嬪線寰閫氳繃鎼滅儲銆乯avascript(鍖呮嫭AJAX)緲婚〉鐨勬柟寮忔潵闄堝垪鍚岀被璁板綍錛岃繖鍦ㄦ祦紼嬪疄鐜扮殑鏃跺欙紝灝遍渶瑕佺▼搴忓憳鍘誨垎鏋愪竴浜沯avascript鍑芥暟鎵鍋氱殑鎿嶄綔錛屽幓鐚滃害鐩稿叧鍒楄〃鏂瑰紡鐨刄RL(濡傛悳绱㈢殑琛ㄥ崟濡備綍鎻愪氦銆佺炕欏靛嚱鏁板浣曞鐞嗙炕欏電瓑)銆?/p>
(2)瀵硅幏鍙栬緇嗕俊鎭繃紼嬬殑褰卞搷
鍦ㄨ幏鍙栬緇嗕俊鎭殑鏃跺欙紝鍩烘湰閮芥槸閫氳繃鍒嗗績璇︾粏淇℃伅欏甸潰鐨勭粨鏋勫嚭鍙戠殑銆?/p>
瀵逛笓涓氬寲紼嬪害楂樼殑緗戠珯鑰岃█錛岃緇嗕俊鎭〉闈㈢殑鐨勫埗浣滀篃鏄姇鍏ヤ簡涓浜涚簿鍔涚殑錛岄氬父閮借瀹氬拰欏甸潰鐗瑰畾鐨勪綅緗樉紺虹壒瀹氱殑淇℃伅錛岃繖鏍峰氨渚夸簬鍦ㄥ垎鏋愯繃紼嬩腑鑾峰彇鎸囧畾鐨勬暟鎹?/p>
鑰屽涓撲笟鍖栫▼搴︾◢浣庣殑緗戠珯鑰岃█錛岃緇嗛〉闈㈢殑鍐呭寰堝閮芥槸鐢℉TML緙栬緫鍣ㄧ洿鎺ョ紪杈戝嚭鏉ョ殑鍐呭錛屽湪鍚屼竴棰戦亾鐨勪笉鍚屽垎綾葷殑璇︾粏淇℃伅欏甸潰涓瓨鍦ㄧ潃寰堝ぇ鐨勫樊寮傦紝榪欎嬌寰楄幏鍙栬緇嗕俊鎭儴鍒嗙殑鍒嗘瀽紼嬪簭澶嶆潅搴﹀嶅銆?/p>
涓漢鐨勭編濂芥効鏈涳細瀹佹効鍒嗘瀽鐨勬槸涓撲笟鍖栫▼搴﹂珮涓鐐圭殑绔欑偣錛屽洜涓烘祦紼嬬殑紜畾鍙婂叿浣撳疄鐜版繪槸鍙互鎯沖埌鍔炴硶瑙e喅鐨勶紱璇︾粏淇℃伅鐨勫垎鏋愬瓨鍦ㄥお澶氶〉闈㈢粨鏋勭殑璇濓紝灝嗗湪鑾峰彇璇︾粏淇℃伅浠樺嚭澶ぇ浠d環錛?/p>
榪欓噷闇瑕佹敞鎰忕殑鏈夊嚑涓湴鏂?/strong>:
1:闇瑕佹寚瀹歨ttp-conf鍚嶇О絀洪棿 xmlns:http-conf=http://cxf.apache.org/transports/http/configuration
2:鎸囧畾妯″紡浣嶇疆: http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
3:http-conf:conduit涓殑name灞炴?鎸囧畾璁劇疆鐢熸晥鐨勬湇鍔?濡備緥瀛愪腑,鍙鏈嶅姟鍚嶄負{http://impl.service.product.sww.com/}ProjectService鐨勬湇鍔$敓鏁?
浣跨敤涓嬮潰鐨勮緗垯浼氬鎵鏈夋湇鍔$敓鏁?br />
鏇磋緇嗙殑閰嶇疆璇峰弬鑰僀XF瀹樻柟鏂囨。:
http://cwiki.apache.org/CXF20DOC/client-http-transport-including-ssl-support.html
Whether you program regularly in Java, and know it like the back of your hand, or whether you're new to the language or a casual programmer, you'll make mistakes. It's natural, it's human, and guess what? You'll more than likely make the same mistakes that others do, over and over again. Here's my top ten list of errors that we all seem to make at one time or another, how to spot them, and how to fix them.
Many programmers, particularly when first introduced to Java, have problems with accessing member variables from their main method. The method signature for main is marked static - meaning that we don't need to create an instance of the class to invoke the main method. For example, a Java Virtual Machine (JVM) could call the class MyApplication like this :-
MyApplication.main ( command_line_args );
This means, however, that there isn't an instance of MyApplication - it doesn't have any member variables to access! Take for example the following application, which will generate a compiler error message.
public class StaticDemo { public String my_member_variable = "somedata";
public static void main (String args[]) { // Access a non-static member from static method System.out.println ("This generates a compiler error" + my_member_variable ); } }
If you want to access its member variables from a non-static method (like main), you must create an instance of the object. Here's a simple example of how to correctly write code to access non-static member variables, by first creating an instance of the object.
public class NonStaticDemo { public String my_member_variable = "somedata"; public static void main (String args[]) { NonStaticDemo demo = new NonStaticDemo(); // Access member variable of demo System.out.println ("This WON'T generate an error" + demo.my_member_variable ); } }
Overriding allows programmers to replace a method's implementation with new code. Overriding is a handy feature, and most OO programmers make heavy use of it. If you use the AWT 1.1 event handling model, you'll often override listener implementations to provide custom functionality. One easy trap to fall into with overriding, is to mistype the method name. If you mistype the name, you're no longer overriding a method - you're creating an entirely new method, but with the same parameter and return type.
public class MyWindowListener extends WindowAdapter { // This should be WindowClosed public void WindowClose(WindowEvent e) { // Exit when user closes window System.exit(0); } });
Compilers won't pick up on this one, and the problem can be quite frustrating to detect. In the past, I've looked at a method, believed that it was being called, and taken ages to spot the problem. The symptom of this error will be that your code isn't being called, or you think the method has skipped over its code. The only way to ever be certain is to add a println statement, to record a message in a log file, or to use good trace debugger (like Visual J++ or Borland JBuilder) and step through line by line. If your method still isn't being called, then it's likely you've mistyped the name.
This is an easy error to make. If you're used other languages before, such as Pascal, you'll realize just how poor a choice this was by the language's designers. In Pascal, for example, we use the := operator for assignment, and leave = for comparison. This looks like a throwback to C/C++, from which Java draws its roots.
Fortunately, even if you don't spot this one by looking at code on the screen, your compiler will. Most commonly, it will report an error message like this : "Can't convert xxx to boolean", where xxx is a Java type that you're assigning instead of comparing.
When we use the == operator, we are actually comparing two object references, to see if they point to the same object. We cannot compare, for example, two strings for equality, using the == operator. We must instead use the .equals method, which is a method inherited by all classes from java.lang.Object.
Here's the correct way to compare two strings.
String abc = "abc"; String def = "def"; // Bad way if ( (abc + def) == "abcdef" ) { ...... }
// Good way if ( (abc + def).equals("abcdef") ) { ..... }
This can be a frustrating problem to diagnose, because when you look at the code, you might be sure that its passing by reference, but find that its actually being passed by value. Java uses both, so you need to understand when you're passing by value, and when you're passing by reference.
When you pass a primitive data type, such as a char, int, float, or double, to a function then you are passing by value. That means that a copy of the data type is duplicated, and passed to the function. If the function chooses to modify that value, it will be modifying the copy only. Once the function finishes, and control is returned to the returning function, the "real" variable will be untouched, and no changes will have been saved. If you need to modify a primitive data type, make it a return value for a function, or wrap it inside an object.
When you pass a Java object, such as an array, a vector, or a string, to a function then you are passing by reference. Yes - a String is actually an object, not a primitive data type. So that means that if you pass an object to a function, you are passing a reference to it, not a duplicate. Any changes you make to the object's member variables will be permanent - which can be either good or bad, depending on whether this was what you intended.
On a side note, since String contains no methods to modify its contents, you might as well be passing by value.
I know it's very tempting to write blank exception handlers, and to just ignore errors. But if you run into problems, and haven't written any error messages, it becomes almost impossible to find out the cause of the error. Even the simplest exception handler can be of benefit. For example, put a try { .. } catch Exception around your code, to catch ANY type of exception, and print out the message. You don't need to write a custom handler for every exception (though this is still good programming practice). Don't ever leave it blank, or you won't know what's happening.
For example
public static void main(String args[]) { try { // Your code goes here.. } catch (Exception e) { System.out.println ("Err - " + e ); } }
If you've come from a C/C++ background, you may not find this quite as much a problem as those who have used other languages. In Java, arrays are zero-indexed, meaning that the first element's index is actually 0. Confused? Let's look at a quick example.
// Create an array of three strings String[] strArray = new String[3]; // First element's index is actually 0 strArray[0] = "First string"; // Second element's index is actually 1 strArray[1] = "Second string"; // Final element's index is actually 2 strArray[2] = "Third and final string";
In this example, we have an array of three strings, but to access elements of the array we actually subtract one. Now, if we were to try and access strArray[3], we'd be accessing the fourth element. This will case an ArrayOutOfBoundsException to be thrown - the most obvious sign of forgetting the zero-indexing rule.
Other areas where zero-indexing can get you into trouble is with strings. Suppose you wanted to get a character at a particular offset within a string. Using the String.charAt(int) function you can look this information up - but under Java, the String class is also zero-indexed. That means than the first character is at offset 0, and second at offset 1. You can run into some very frustrating problems unless you are aware of this - particularly if you write applications with heavy string processing. You can be working on the wrong character, and also throw exceptions at run-time. Just like the ArrayOutOfBoundsException, there is a string equivalent. Accessing beyond the bounds of a String will cause a StringIndexOutOfBoundsException to be thrown, as demonstrated by this example.
public class StrDemo { public static void main (String args[]) { String abc = "abc"; System.out.println ("Char at offset 0 : " + abc.charAt(0) ); System.out.println ("Char at offset 1 : " + abc.charAt(1) ); System.out.println ("Char at offset 2 : " + abc.charAt(2) ); // This line should throw a StringIndexOutOfBoundsException System.out.println ("Char at offset 3 : " + abc.charAt(3) ); } }
Note too, that zero-indexing doesn't just apply to arrays, or to Strings. Other parts of Java are also indexed, but not always consistently. The java.util.Date, and java.util.Calendar classes start their months with 0, but days start normally with 1. This problem is demonstrated by the following application.
import java.util.Date; import java.util.Calendar; public class ZeroIndexedDate { public static void main (String args[]) { // Get today's date Date today = new Date(); // Print return value of getMonth System.out.println ("Date.getMonth() returns : " + today.getMonth()); // Get today's date using a Calendar Calendar rightNow = Calendar.getInstance(); // Print return value of get ( Calendar.MONTH ) System.out.println ("Calendar.get (month) returns : " + rightNow.get ( Calendar.MONTH ));
} }
Zero-indexing is only a problem if you don't realize that its occurring. If you think you're running into a problem, always consult your API documentation.
When writing multi-threaded applications, many programmers (myself included) often cut corners, and leave their applications and applets vulnerable to thread conflicts. When two or more threads access the same data concurrently, there exists the possibility (and Murphy's law holding, the probability) that two threads will access or modify the same data at the same time. Don't be fooled into thinking that such problems won't occur on single-threaded processors. While accessing some data (performing a read), your thread may be suspended, and another thread scheduled. It writes its data, which is then overwritten when the first thread makes its changes.
Such problems are not just limited to multi-threaded applications or applets. If you write Java APIs, or JavaBeans, then your code may not be thread-safe. Even if you never write a single application that uses threads, people that use your code WILL. For the sanity of others, if not yourself, you should always take precautions to prevent concurrent access to shared data.
How can this problem be solved? The simplest method is to make your variables private (but you do that already, right?) and to use synchronized accessor methods. Accessor methods allow access to private member variables, but in a controlled manner. Take the following accessor methods, which provide a safe way to change the value of a counter.
public class MyCounter { private int count = 0; // count starts at zero public synchronized void setCount(int amount) { count = amount; } public synchronized int getCount() { return count; } }
This is one of the most frequent errors that we all make. It's so simple to do, and sometimes one can look at an uncapitalized variable or method and still not spot the problem. I myself have often been puzzled by these errors, because I recognize that the method or variable does exist, but don't spot the lack of capitalization.
While there's no silver bullet for detecting this error, you can easily train yourself to make less of them. There's a very simple trick you can learn :-
If you use this pattern for all of your member variables and classes, and then make a conscious effort to get it right, you can gradually reduce the number of mistakes you'll make. It may take a while, but it can save some serious head scratching in the future.
Null pointers are one of the most common errors that Java programmers make. Compilers can't check this one for you - it will only surface at runtime, and if you don't discover it, your users certainly will.
When an attempt to access an object is made, and the reference to that object is null, a NullPointerException will be thrown. The cause of null pointers can be varied, but generally it means that either you haven't initialized an object, or you haven't checked the return value of a function.
Many functions return null to indicate an error condition - but unless you check your return values, you'll never know what's happening. Since the cause is an error condition, normal testing may not pick it up - which means that your users will end up discovering the problem for you. If the API function indicates that null may be returned, be sure to check this before using the object reference!
Another cause is where your initialization has been sloppy, or where it is conditional. For example, examine the following code, and see if you can spot the problem.
public static void main(String args[]) { // Accept up to 3 parameters String[] list = new String[3]; int index = 0; while ( (index < args.length) && ( index < 3 ) ) { list[index++] = args[index]; } // Check all the parameters for (int i = 0; i < list.length; i++) { if (list[i].equals "-help") { // ......... } else if (list[i].equals "-cp") { // ......... } // else ..... } }
This code (while a contrived example), shows a common mistake. Under some circumstances, where the user enters three or more parameters, the code will run fine. If no parameters are entered, you'll get a NullPointerException at runtime. Sometimes your variables (the array of strings) will be initialized, and other times they won't. One easy solution is to check BEFORE you attempt to access a variable in an array that it is not equal to null.
These errors represent but some of the many that we all make. Though it is impossible to completely eliminate errors from the coding process, with care and practice you can avoid repeating the same ones. Rest assured, however, that all Java programmers encounter the same sorts of problems. It's comforting to know, that while you work late into the night tracking down an error, someone, somewhere, sometime, will make the same mistake!
We'd like to thank the readers of the comp.lang.java.programmer newsgroup for their suggestions for the top ten. Regrettably, due to the number of submissions, not every error could be featured - but we think this "Top Ten" list represents the most popular and frequent errors people make. |
Properties Editor
http://propedit.sourceforge.jp/eclipse/updates/
CAS鐢ㄦ潵鏍囧織鐢ㄦ埛鐨則oken鏄瓨鍦ㄥ畠鑷繁鐨勫煙鍚嶄笅鐨?涓嶆槸瀛樺湪web搴旂敤鐨勫煙鍚嶄笅鐨?CAS鍒ゆ柇鐢ㄦ埛鐧誨綍鐢盿gent鍐沖畾,agent楠岃瘉鐢ㄦ埛淇℃伅鏈変袱縐嶅鐞?
1.濡傛灉榪欎釜鐢ㄦ埛鏄互鍓嶆病鐧誨綍榪囩殑,涔熷氨鏄榪欎釜web搴旂敤鐨勫煙鍚嶄笅娌℃湁涓涓猘gent棰佸彂鐨剆essionid(鍦╟ookie閲?鐨勮瘽,閭d箞瀹冧細璺寵漿鍒癈AS server鐨勭櫥褰曠晫闈?榪欓噷鐢盋AS server鍐沖畾鏄惁鏄劇ず鐧誨綍鐣岄潰,榪樻槸鐩存帴灝辮煩杞洖鏉?涔熷氨鏄笉鏄瘡嬈¢兘瑕佹眰杈撳叆瀵嗙爜鐧誨綍鐨?.
2.CAS鐨勭櫥褰曠晫闈細鏈変袱縐嶅鐞?濡傛灉浠ュ墠娌$櫥褰曡繃,涔熷氨鏄湪CAS server鑷繁鐨勫煙鍚嶄笅,娌℃湁鐢ㄦ埛鐨則oken鐨勮瘽,灝辮姹傜櫥褰?濡傛灉鏈塼oken鐨勮瘽,灝辮繑鍥炰竴涓猼icket(涔熷氨鏄笉鏄劇ず鐧誨綍鐣岄潰鐩存帴閲嶅畾鍚戣繑鍥炰簡).
鐒跺悗鎺ョ涓姝ラ噷闈?agent鏀跺埌ticket浠ュ悗灝辨彁浜ょ粰CAS server楠岃瘉,騫跺彇寰楄繑鍥炰俊鎭?鏄釜xml,cas鐨勫崗璁瀹氱殑,涔熷彲浠ョ敤saml涔嬬被鐨?榪欎釜鍦版柟鍙互鍙栧緱闄や簡鐢ㄦ埛濮撳悕浠ュ鐨勪俊鎭?榪欐牱灝卞彲浠ュ仛鍚屾浜?鏉冮檺鐨勯棶棰樺彲浠ヨ繖涔堣В鍐?.鐒跺悗agent灝變繚瀛樻鏃剁殑session,鎶妔essionid鏀懼埌璇eb搴旂敤鍩熷悕涓嬬殑cookie閲?
浠ヤ笂閫昏緫璇存槑浜?鏍囧織鐢ㄦ埛韜喚鐨則oken鍦–AS server鐨勫煙鍚嶄笅,姣忎釜web搴旂敤涓嶄繚瀛樼敤鎴瘋韓浠?鍥犳璺ㄥ煙鏄粷瀵規病闂鐨?鍙槸single sign off灝遍渶瑕丆AS server鐨勯厤鍚堜簡,瑕佹妸閭d釜token鍒犳帀.
涓嶈繃濡傛灉鏍囧織韜喚鐨則oken涓嶅瓨鍦?鑰宻essionid瀛樺湪,閭h繕鏄璁や負鏄櫥褰曠殑,鍙笉榪囨槸鍦ㄧ瓑寰呴偅涓猻ession timeout鑰屽凡.
鍥劇墖涓殑瀛椾綋紼嶅井灝忎簡鐐?鍛靛懙,浣跨敤visio鎴戣繕綆楁槸涓柊鎵?
ps:榪欎釜嫻佺▼鍥炬槸鏍規嵁cas鏈嶅姟绔殑webflow鐨勯厤緗敾鍑烘潵,濡傛湁鏈漢鏈夌悊瑙i敊璇殑!嬈㈣繋鎸囨!
!-----------------------------------------------------------------------------!
! PATTERN FORMATS GLOSSARY !
!-----------------------------------------------------------------------------!
! %n - newline !
! %m - your log message !
! %p - message priority (FATAL, ERROR, WARN, INFO, DEBUG or custom) !
! %r - millisecs since program started running !
! %% - percent sign in output !
! !
!-----------------------SOME MORE CLUTTER IN YOUR LOG-------------------------!
! %c - name of your category (logger), %c{2} will outputs last two components !
! %t - name of current thread !
! %x - Nested Diagnostic Context (NDC) (you supply it!) !
! !
!-------------------------SLOW PERFORMANCE FORMATS----------------------------!
! %d - date and time, also %d{ISO8601}, %d{DATE}, %d{ABSOLUTE}, !
! %d{HH:mm:ss,SSS}, %d{dd MMM yyyy HH:mm:ss,SSS} and so on !
! %l - Shortcut for %F%L%C%M !
! %F - Java source file name !
! %L - Java source line number !
! %C - Java class name, %C{1} will output the last one component !
! %M - Java method name !
! !
!------------------------------FORMAT MODIFIERS-------------------------------!
! %-any_letter_above - Left-justify in min. width (default is right-justify) !
! %20any_letter_above - 20 char. min. width (pad with spaces if reqd.) !
! %.30any_letter_above - 30 char. max. width (truncate beginning if reqd.) !
! %-10.10r - Example. Left-justify time elapsed within 10-wide field. !
! Truncate from beginning if wider than 10 characters. !
!-----------------------------------------------------------------------------!