锘??xml version="1.0" encoding="utf-8" standalone="yes"?> 1.JMS MS鐖舵帴鍙?/font> PTP Pub/Sub ConnectionFactory QueueConnectionFactory TopicConnectionFactory Connection QueueConnection TopicConnection Destination Queue Topic Session QueueSession TopicSession MessageProducer QueueSender TopicPublisher MessageConsumer QueueReceiver,QueueBrowse r TopicSubscriber
闈㈠悜娑堟伅鐨勪腑闂翠歡錛圡essage Oriented Middleware錛孧OM錛夎緝濂界殑瑙e喅浜嗕互涓婇棶棰樸傚彂閫佽呭皢娑堟伅鍙戦佺粰娑堟伅鏈嶅姟鍣紝娑堟伅鏈嶅姟鍣ㄥ皢娑堟伅瀛樻斁鍦ㄨ嫢騫查槦鍒椾腑錛屽湪鍚堥傜殑鏃跺欏啀灝嗘秷鎭漿鍙戠粰鎺ユ敹鑰呫傝繖縐嶆ā寮忎笅錛屽彂閫佸拰鎺ユ敹鏄紓姝ョ殑錛屽彂閫佽呮棤闇絳夊緟錛涗簩鑰呯殑鐢熷懡鍛ㄦ湡鏈繀鐩稿悓錛氬彂閫佹秷鎭殑鏃跺欐帴鏀惰呬笉涓瀹氳繍琛岋紝鎺ユ敹娑堟伅鐨勬椂鍊欏彂閫佽呬篃涓嶄竴瀹氳繍琛岋紱涓瀵瑰閫氫俊錛氬浜庝竴涓秷鎭彲浠ユ湁澶氫釜鎺ユ敹鑰呫?
宸叉湁鐨凪OM緋葷粺鍖呮嫭IBM鐨凪QSeries銆丮icrosoft鐨凪SMQ鍜孊EA鐨凪essageQ絳夈傜敱浜庢病鏈変竴涓氱敤鐨勬爣鍑嗭紝榪欎簺緋葷粺寰堥毦瀹炵幇浜掓搷浣滃拰鏃犵紳榪炴帴銆侸ava Message Service錛圝MS錛夋槸SUN鎻愬嚭鐨勬棬鍦ㄧ粺涓鍚勭MOM緋葷粺鎺ュ彛鐨勮鑼冿紝瀹冨寘鍚偣瀵圭偣錛圥oint to Point錛孭TP錛夊拰鍙戝竷/璁㈤槄錛圥ublish/Subscribe錛宲ub/sub錛変袱縐嶆秷鎭ā鍨嬶紝鎻愪緵鍙潬娑堟伅浼犺緭銆佷簨鍔″拰娑堟伅榪囨護(hù)絳夋満鍒躲?/font>
JAVA 娑堟伅鏈嶅姟(JMS)瀹氫箟浜咼ava 涓闂秷鎭腑闂翠歡鐨勬帴鍙c侸MS 鍙槸鎺ュ彛錛屽茍娌℃湁緇欎簣瀹炵幇錛屽疄鐜癑MS 鎺ュ彛鐨勬秷鎭腑闂翠歡縐頒負(fù)JMS Provider錛宨Link瀹炵幇浜咼MS鎺ュ彛錛岀敤鎴峰彲浠ラ氳繃浣跨敤JMS鎺ュ彛錛屽湪iLink涓繘琛孞MS緙栫▼銆?iLink鏀寔JMS1.0.2鐗堟湰銆?
2.JMS鎺ュ彛鎻忚堪
JMS 鏀寔涓ょ娑堟伅綾誨瀷PTP 鍜孭ub/Sub錛屽垎鍒О浣滐細(xì)PTP Domain 鍜孭ub/Sub Domain錛岃繖涓ょ鎺ュ彛閮界戶鎵跨粺涓鐨凧MS鐖舵帴鍙o紝JMS 涓昏鎺ュ彛濡備笅鎵紺猴細(xì)
ConnectionFactory 錛氳繛鎺ュ伐鍘傦紝JMS 鐢ㄥ畠鍒涘緩榪炴帴
Connection 錛欽MS 瀹㈡埛绔埌JMS Provider 鐨勮繛鎺?br> Destination 錛氭秷鎭殑鐩殑鍦?br> Session錛?涓涓彂閫佹垨鎺ユ敹娑堟伅鐨勭嚎紼?br> MessageProducer錛?鐢盨ession 瀵硅薄鍒涘緩鐨勭敤鏉ュ彂閫佹秷鎭殑瀵硅薄
MessageConsumer錛?鐢盨ession 瀵硅薄鍒涘緩鐨勭敤鏉ユ帴鏀舵秷鎭殑瀵硅薄
3.JMS娑堟伅妯″瀷
JMS 娑堟伅鐢變互涓嬪嚑閮ㄥ垎緇勬垚錛氭秷鎭ご錛屽睘鎬э紝娑堟伅浣撱?br>
3.1 娑堟伅澶?Header) - 娑堟伅澶村寘鍚秷鎭殑璇嗗埆淇℃伅鍜岃礬鐢變俊鎭紝娑堟伅澶村寘鍚竴浜涙爣鍑嗙殑灞炴у錛欽MSDestination,JMSMessageID 絳夈?
|
3.2 灞炴?Properties) - 闄や簡娑堟伅澶翠腑瀹氫箟濂界殑鏍囧噯灞炴у錛孞MS 鎻愪緵涓縐嶆満鍒跺鍔犳柊灞炴у埌娑堟伅澶?涓紝榪欑鏂板睘鎬у寘鍚互涓嬪嚑縐嶏細(xì)
1. 搴旂敤闇瑕佺敤鍒扮殑灞炴?
2. 娑堟伅澶翠腑鍘熸湁鐨勪竴浜涘彲閫夊睘鎬?
3. JMS Provider 闇瑕佺敤鍒扮殑灞炴с?br> 鏍囧噯鐨凧MS 娑堟伅澶村寘鍚互涓嬪睘鎬э細(xì)
|
3.3 娑堟伅浣?Body) - JMS API 瀹氫箟浜?縐嶆秷鎭綋鏍煎紡錛屼篃鍙秷鎭被鍨嬶紝浣犲彲浠ヤ嬌鐢ㄤ笉鍚屽艦寮忓彂閫佹帴鏀?鏁版嵁騫跺彲浠ュ吋瀹圭幇鏈夌殑娑堟伅鏍煎紡錛屼笅闈㈡弿榪拌繖5縐嶇被鍨嬶細(xì)
|
涓嬩緥婕旂ず鍒涘緩騫跺彂閫佷竴涓猅extMessage鍒頒竴涓槦鍒楋細(xì)
TextMessage message = queueSession.createTextMessage();
message.setText(msg_text); // msg_text is a String
queueSender.send(message);
涓嬩緥婕旂ず鎺ユ敹娑堟伅騫惰漿鎹負(fù)鍚堥傜殑娑堟伅綾誨瀷錛?
Message m = queueReceiver.receive();
if (m instanceof TextMessage) {
TextMessage message = (TextMessage) m;
System.out.println("Reading message: " + message.getText());
} else {
// Handle error
}
4. 娑堟伅鐨勫悓姝ュ紓姝ユ帴鏀?br> 娑堟伅鐨勫悓姝ユ帴鏀舵槸鎸囧鎴風(fēng)涓誨姩鍘繪帴鏀舵秷鎭紝JMS 瀹㈡埛绔彲浠ラ噰鐢∕essageConsumer 鐨剅eceive鏂規(guī)硶鍘繪帴鏀朵笅涓涓秷鎭?br> 娑堟伅鐨勫紓姝ユ帴鏀舵槸鎸囧綋娑堟伅鍒拌揪鏃訛紝涓誨姩閫氱煡瀹㈡埛绔侸MS 瀹㈡埛绔彲浠ラ氳繃娉ㄥ唽涓涓疄 鐜癕essageListener 鎺ュ彛鐨勫璞″埌MessageConsumer錛岃繖鏍鳳紝姣忓綋娑堟伅鍒拌揪鏃訛紝JMS Provider 浼?xì)璋冪敤MessageListener涓殑onMessage 鏂規(guī)硶銆?
5. PTP妯″瀷
PTP(Point-to-Point)妯″瀷鏄熀浜庨槦鍒楃殑錛屽彂閫佹柟鍙戞秷鎭埌闃熷垪錛屾帴鏀舵柟浠庨槦鍒楁帴鏀舵秷鎭紝闃熷垪鐨勫瓨鍦ㄤ嬌寰楁秷鎭殑寮傛浼犺緭鎴愪負(fù)鍙兘銆傚拰閭歡緋葷粺涓殑閭涓鏍鳳紝闃熷垪鍙互鍖呭惈鍚勭娑堟伅錛孞MS Provider 鎻?渚涘伐鍏風(fēng)鐞嗛槦鍒楃殑鍒涘緩銆佸垹闄ゃ侸MS PTP 妯″瀷瀹氫箟浜嗗鎴風(fēng)濡備綍鍚戦槦鍒楀彂閫佹秷鎭紝浠庨槦鍒楁帴鏀舵秷鎭紝嫻忚闃熷垪涓殑娑堟伅銆?br> 涓嬮潰鎻忚堪JMS PTP 妯″瀷涓殑涓昏姒傚康鍜屽璞★細(xì)
|
6. PUB/SUB妯″瀷
JMS Pub/Sub 妯″瀷瀹氫箟浜嗗浣曞悜涓涓唴瀹硅妭鐐瑰彂甯冨拰璁㈤槄娑堟伅錛岃繖浜涜妭鐐硅縐頒綔涓婚(topic)銆?br> 涓婚鍙互琚涓烘槸娑堟伅鐨勪紶杈撲腑浠嬶紝鍙戝竷鑰?publisher)鍙戝竷娑堟伅鍒頒富棰橈紝璁㈤槄鑰?subscribe)浠庝富棰樿闃呮秷鎭備富棰樹嬌寰楁秷鎭闃呰呭拰娑堟伅鍙戝竷鑰呬繚鎸佷簰鐩哥嫭绔嬶紝涓嶉渶瑕佹帴瑙﹀嵆鍙繚璇佹秷鎭殑浼犻併?br> 涓嬮潰鎻忚堪JMS Pub/Sub 妯″瀷涓殑涓昏姒傚康鍜屽璞★細(xì)
|
7. 寮鍙慗MS鐨勬楠?br> 騫夸箟涓婅錛屼竴涓狫MS 搴旂敤鏄嚑涓狫MS 瀹㈡埛绔氦鎹㈡秷鎭紝寮鍙慗MS 瀹㈡埛绔簲鐢ㄧ敱浠ヤ笅鍑犳鏋勬垚錛?
鐢↗NDI 寰楀埌ConnectionFactory 瀵硅薄錛?
鐢↗NDI 寰楀埌鐩爣闃熷垪鎴栦富棰樺璞★紝鍗矰estination 瀵硅薄錛?
鐢–onnectionFactory 鍒涘緩Connection 瀵硅薄錛?
鐢–onnection 瀵硅薄鍒涘緩涓涓垨澶氫釜JMS Session錛?
鐢⊿ession 鍜孌estination 鍒涘緩MessageProducer 鍜孧essageConsumer錛?
閫氱煡Connection 寮濮嬩紶閫掓秷鎭?/font>
<[ServletContext(id=18489944,name=EBLGWeb,context-path=/)]: Deployment descriptor "/WEB-INF/bhr-tags-pagination.tld" is malformed. Check against the DTD: Content is not allowed in prolog. (line 1, column 1).> <[ServletContext(id=18489944,name=EBLGWeb,context-path=/)]: Error while parsing the Tag Library Descriptor at "/WEB-INF/bhr-tags-pagination.tld". org.xml.sax.SAXException: [HTTP:101248][ServletContext(id=18489944,name=EBLGWeb,context-path=/)]: Deployment descriptor "/WEB-INF/bhr-tags-pagination.tld" is malformed. Check against the DTD: Content is not allowed in prolog. (line 1, column 1). at weblogic.apache.xerces.parsers.DOMParser.parse(DOMParser.java:285) at weblogic.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:201) at weblogic.servlet.jsp.dd.JSPEntityResolver.load(JSPEntityResolver.java:81) at weblogic.servlet.jsp.dd.JSPEntityResolver.load(JSPEntityResolver.java:96) at weblogic.servlet.internal.WebAppHelper.registerTagLibListeners(WebAppHelper.java:293) at weblogic.servlet.internal.WebAppServletContext.activateFromDescriptors(WebAppServletContext.java:2530) at weblogic.servlet.internal.WebAppServletContext.activate(WebAppServletContext.java:6163) at weblogic.servlet.internal.WebAppServletContext.setActive(WebAppServletContext.java:6141) at weblogic.servlet.internal.WebAppModule.activate(WebAppModule.java:836) at weblogic.j2ee.J2EEApplicationContainer.activateModule(J2EEApplicationContainer.java:3322) at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:2201) at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:2174) at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:2122) at weblogic.management.deploy.slave.SlaveDeployer$Application.setActivation(SlaveDeployer.java:3099) at weblogic.management.deploy.slave.SlaveDeployer.setActivationStateForAllApplications(SlaveDeployer.java:1768) at weblogic.management.deploy.slave.SlaveDeployer.resume(SlaveDeployer.java:351) at weblogic.management.deploy.DeploymentManagerServerLifeCycleImpl.resume(DeploymentManagerServerLifeCycleImpl.java:229) at weblogic.t3.srvr.SubsystemManager.resume(SubsystemManager.java:136) at weblogic.t3.srvr.T3Srvr.resume(T3Srvr.java:965) at weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:360) at weblogic.Server.main(Server.java:32) >鍘熷洜鍒嗘瀽鍜岃В鍐蟲柟娉?
鏄敱浜庢煇浜涙枃鏈紪杈戝櫒錛圲ltraEdit錛夊瓨鏂囨湰鐨勬椂鍊欎駭鐢熺殑闂銆傚彲浠ヤ嬌鐢╰ext pad, word pad緙栬緫XML鏍煎紡鐨勬枃浠躲?
閫氳繃HTTP鎻愪氦EDI璇鋒眰,褰揈DI澶勭悊鏃墮棿瓚呰繃浜?0鍒嗛挓鍚?灝變細(xì)鐪嬪埌鍦ㄥ彟涓涓獁eblogic server涔熸帴鏀跺埌浜嗚繖涓狤DI璇鋒眰,閲嶆柊澶勭悊榪欎釜鎶ユ枃. 濡傛灉鎶ユ枃澶勭悊鏃墮棿鏇撮暱,姣斿瓚呰繃浜?0鍒嗛挓,灝變細(xì)鍙戠幇榪欎釜鎶ユ枃琚鐞嗕簡3閬嶆垨5閬?鍘熷洜鍒嗘瀽鍜岃В鍐蟲柟娉?
When the Apache HTTP Server Plug-In attempts to connect to WebLogic Server, the plug-in uses several configuration parameters to determine how long to wait for connections to the WebLogic Server host and, after a connection is established, how long the plug-in waits for a response. If the plug-in cannot connect or does not receive a response, the plug-in attempts to connect and send the request to other WebLogic Server instances in the cluster. If the connection fails or there is no response from any WebLogic Server in the cluster, an error message is sent. 鍝嶅簲絳夊緟鏃墮棿鍙傛暟WLIOTimeoutSecs (http://e-docs.bea.com/wls/docs81/plugins/plugin_params.html#1149781. 鎸夌収BEA 鎺ㄨ崘鐨勶紝榪欎釜鍊煎簲璇ヨ寰楀ぇ涓浜? 榪欎釜鍙傛暟鐨勭己鐪佸間負(fù)300s. 瑙佷笅闈細(xì) <Location /EDIHandler> SetHandler weblogic-handler WebLogicCluster apc_app1wls1:7011,apc_app1wls2:7011 KeepAliveEnabled ON WLIOTimeoutSecs 7200 </Location>
MQJMS200713 Oct 2006 16:47:15,484 ERROR MessagingUtilServlet [ExecuteThread: '14' for queue: 'weblogic.kernel.Default'][]: **********EXCEPTION TRACE START************* 13 Oct 2006 16:47:15,484 ERROR MessagingUtilServlet [ExecuteThread: '14' for queue: 'weblogic.kernel.Default'][]: produce error com.bhr.infra.messaging.exception.PMException: JMSException at com.bhr.infra.messaging.PMHandler.send(PMHandler.java:419) at com.bhr.epc.infra.messaging.util.MessagingUtilServlet.produce(MessagingUtilServlet.java:312) at com.bhr.epc.infra.messaging.util.MessagingUtilServlet.service(MessagingUtilServlet.java:74) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1072) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:465) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:348) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6981) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121) at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3892) at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2766) at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224) at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183) Caused by: javax.jms.JMSException: MQJMS2007: failed to send message to MQ queue at com.ibm.mq.jms.services.ConfigEnvironment.newException(ConfigEnvironment.java:553) at com.ibm.mq.jms.MQMessageProducer.sendInternal(MQMessageProducer.java:1589) at com.ibm.mq.jms.MQMessageProducer.send(MQMessageProducer.java:1012) at com.ibm.mq.jms.MQMessageProducer.send(MQMessageProducer.java:1046) at com.bhr.infra.messaging.PMQueueSender.send(PMQueueSender.java:57) at com.bhr.infra.messaging.PMHandler.send(PMHandler.java:410) ... 13 more 13 Oct 2006 16:47:15,486 ERROR MessagingUtilServlet [ExecuteThread: '14' for queue: 'weblogic.kernel.Default'][]: **********EXCEPTION TRACE END**************鍘熷洜鍒嗘瀽鍜岃В鍐蟲柟娉?
It may be caused by use of old version MQ jar. It can receive message, but cannot send message.
榪欎釜闂鐨勬牴鏈師鍥犵敱浜庡搷搴旀湰嬈¤姹傜殑Response瀵硅薄鐨勭姸鎬佹槸宸叉彁浜ょ姸鎬侀犳垚鐨? 瀹冧笉鍏佽鍝嶅簲鎻愪氦澶氭銆? 浠涔堟椂鍊橰esponse瀵硅薄鐨勭姸鎬佸彉鎴愬凡鎻愪氦鐘舵侊細(xì)褰撲綘鐨勫簲鐢ㄥ凡緇忓疄鐜頒簡欏甸潰璺寵漿閫昏緫銆? 閫氬父鍘熷洜錛? 1錛?濡傛灉浣犱嬌鐢ㄤ簡community鐨勮瘽錛?community鐨勫畨鍏ㄨ璇佸拰鎺堟潈濡傛灉娌℃湁閫氳繃錛宑ommunity鍐呴儴浼?xì)杩涜椤甸潰锜╄浆銆備絾浣犵殑搴旂敤(瀵逛簬workshop搴旂敤鐨勮瘽錛屾寚鐨勬槸action)鍙堣瘯鍥捐繘琛岄〉闈㈣煩杞紝灝變細(xì)鍑虹幇榪欐牱鐨勯棶棰樸? /** * @jpf:action * @jpf:forward name="page" path="page.jsp" */ protected Forward actionMethod() { //濡傛灉宸茬粡鎻愪氦浜嗗搷搴旓紝浣犱粛鐒惰瘯鍥懼啀嬈¤繘琛岄〉闈㈣煩杞紝鍗沖啀嬈℃彁浜ゅ搷搴旓紝鍙兘鍑虹幇闂 //閫氬父鍙互鍔犱竴涓垽鏂? if (!getResponse().isCommitted()) { return new Forward("success"); } else { return null; } } protected void beforeAction() { SecurityManager.checkAuthorization(getRequest(), getResponse(), config.getString( CDConstants.CREATE_TERM_ACTION_NAME, "")); //榪欎釜璋冪敤鍙兘瀹炵幇浜嗛〉闈㈣煩杞紝鍗蟲彁浜ゅ搷搴? } 娉ㄦ剰JSP涓疄鐜伴〉闈㈣煩杞悗錛屽姞return 璇彞闃叉緇х畫鎻愪氦鍝嶅簲: <% SecurityManager.checkAuthorization(getRequest(), getResponse(), config.getString( CDConstants.CREATE_TERM_ACTION_NAME, "")); { //鍙兘鏈夊疄鐜伴〉闈㈣煩杞昏緫 ……………forward(); return;//璁板緱鍔爎etrun. } %> 2. .濡傛灉娌℃湁浣跨敤community鐨勮瘽錛屼笅闈㈡儏鏅篃浼?xì)鍑虹幇杩欎釜闂? /** * @jpf:action * @jpf:forward name="page" path="page.jsp" */ protected Forward actionMethod() //鐩存帴鎿嶄綔Response瀵硅薄鍐欏搷搴? getResponse().getPrintWriter().println(); … / // 鍙堟墽琛岀殑欏甸潰璺寵漿錛屼篃鍙兘鍑虹幇闂 return new Forward("index"); }
Error message like below in Web Page is displayed: Page Flow: /com/xxxx/xxx/xxx.jpf Action: update Page Flow Error - No Relevant Page You have tried to return to a recent page in the current page flow through return-to="currentPage", but there is no appropriate page. Exception's stack trace: Exception: No previous page for return-to="currentPage" on action create in page flow /com/gems/mt/web/CreateReleaseCntr/CreateReleaseCntrController.jpf. com.bea.wlw.netui.pageflow.NoPreviousPageException: No relevant page for return-to="currentPage" on action create in page flow /com/gems/mt/web/CreateReleaseCntr/CreateReleaseCntrController.jpf. at com.bea.wlw.netui.pageflow.FlowController.doReturnToPage(FlowController.java:1328) at com.bea.wlw.netui.pageflow.FlowController.forwardTo(FlowController.java:1023) at com.bea.wlw.netui.pageflow.PageFlowController.forwardTo(PageFlowController.java:606) at com.bea.wlw.netui.pageflow.FlowController.internalExecute(FlowController.java:765) ...鍘熷洜鍒嗘瀽鍜岃В鍐蟲柟娉?
When a new page flow is created and its current page is null (it mean you visit at the fist time), so such an exception like NoPreviousPageException occur if you use return-to="currentPage". if a new page flow finish a successful forward, it will treat last page as current page so that we can use current page to display error message conveniently. Solution: ensure page flow finish a successful forward and use current page again. You can also use path="specificPage.jsp" instead of return-to="currentPage" if your original return-to is just one specific page.
Recently found, there is a memory leak bug for list cell renderer in both JDK 1.4.x and JDK 5 (don鈥檛 know whether has the same bug in earlier JDK). The component returned from getListCellRendererComponent() method could not be GC, and all its referenced objects also could not be GC. Unfortunately, this bug is only fixed in JDK 6.
So currently, if a JList use the ListCellRenderer, but only holds a little resource (eg: the JList only has little items, and the component is returned from ListCellRenderer is a simple JLable), you may not care about the memory leak.
But if a JList use the ListCellRenderer, and holds a large resource, you should remember to use the following way to avoid memory leak.
Work Around: Subclass JList and invoke removeAll after painting is done:
聽聽聽聽聽聽 public class xxxList extends JList {
聽聽聽聽聽聽聽聽聽聽聽 private CellRendererPane renderer;
聽聽聽聽聽聽聽聽聽聽聽 private CellRendererPane getRenderer() {
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 if (renderer == null) {
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 for (int i=0; i<getComponents().length; i++) {
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 Component c聽 = getComponents()[i];
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 if (c instanceof CellRendererPane) {
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 renderer = (CellRendererPane)c;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 break;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 }
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 }
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 }
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 return renderer;
聽聽聽聽聽聽聽聽聽聽聽 }
聽聽聽聽聽聽聽聽聽聽聽 protected void paintComponent(Graphics g) {
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 super.paintComponent(g);
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 CellRendererPane renderer = getRenderer();
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 if (renderer != null) {
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 renderer.removeAll();
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 }
聽聽聽聽聽聽聽聽聽聽聽 }
聽聽聽聽聽聽聽 }
Please note that in the state classes, if a method is supported by stateA and not supported by stateB.聽
Then, in stateB, the method body will throw an exception (IllegalArgumentException) to indicate that coder call the wrong method in the wrong state.
Example, in VesselPlanView.java, public boolean addStowage(...).聽 This method is only meaningful to stowageView.
public boolean addStowage(IlvManager manager, List transformList, IlvGraphic stowage, String stadBayN,
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 boolean isSelect) {
聽聽聽聽聽聽聽 throw new IllegalArgumentException(
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 "GrVessel::addStowage-->be sure the vessel at stowage view!");
聽聽聽 }
Hence, in PlanView, the method body will throw exception.
Just to share with you a better way to code.