[jboss-svn-commits] JBL Code SVN: r5353 - in labs/jbossesb/branches/refactor: . product product/core product/core/common/src/org/jboss/soa/esb/common product/core/common/src/org/jboss/soa/esb/helpers product/core/common/src/org/jboss/soa/esb/helpers/persist product/core/common/src/org/jboss/soa/esb/notification product/core/common/src/org/jboss/soa/esb/services product/core/common/src/org/jboss/soa/esb/util product/core/common/tests product/core/common/tests/src/org/jboss/soa/esb product/core/common/tests/src/org/jboss/soa/esb/common/tests/parameters product/core/common/tests/src/org/jboss/soa/esb/helpers product/core/common/tests/src/org/jboss/soa/esb/util product/core/listeners/src/org/jboss/soa/esb/listeners product/core/listeners/tests product/core/processors/src/org/jboss/soa/esb/processors product/core/processors/tests product/core/processors/tests/src/org/jboss/soa/esb/processors/tests product/core/services/src/org/jboss/soa/esb/internal/core/objectstore product/core/services/s! rc/org/jboss/soa/esb/services product/core/services/src/org/jboss/soa/esb/services/EJB product/core/services/tests product/core/services/tests/src/org/jboss/soa/esb/services/tests/notification product/docs/Install/conf product/docs/samples product/docs/samples/trailblazer product/docs/samples/trailblazer/bankloanbrokerdemo product/docs/samples/trailblazer/bankloanbrokerdemo/banks product/docs/samples/trailblazer/bankloanbrokerdemo/banks/lib product/docs/samples/trailblazer/bankloanbrokerdemo/banks/lib/ext product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples product/docs/samples/trailblazer/! bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org product/docs/samples/trai
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sat Jul 29 18:11:04 EDT 2006
Author: arvinder
Date: 2006-07-29 18:08:33 -0400 (Sat, 29 Jul 2006)
New Revision: 5353
Added:
labs/jbossesb/branches/refactor/ant.bat
labs/jbossesb/branches/refactor/product/ant.bat
labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/common/EsbSysProps.java
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/StreamUtils.java
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/StringUtils.java
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/W3CDomUtils.java
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/AppServerContextUnitTest.java
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/DomElementUnitTest.java
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/EsbEmailUnitTest.java
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/KeyValuePairUnitTest.java
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/expected_01.xml
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/expected_02.xml
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/expected_03.xml
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/testfile1.xml
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/testfile2.xml
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/testfile3.xml
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/testfile4.xml
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/util/
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/util/BobjStdDTOUnitTest.java
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/util/BobjStdDTOUnitTest_testfile1.xml
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/util/EsbUtilUnitTest.java
labs/jbossesb/branches/refactor/product/core/processors/src/org/jboss/soa/esb/processors/Zap.java
labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/Zap.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/bank.properties
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/build.xml
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/lib/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/lib/ext/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/lib/ext/junit-4.1.jar
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/lib/ext/org.sadun.util.jar
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/lib/ext/pollmgt.jar
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/lib/ext/xstream-1.1.3.jar
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/log4j.xml
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/Bank.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteReply.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequest.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/FileUtil.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/ManagerFlatFile.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/ManagerJMS.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteReplyTest.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequestTest.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/BankTest.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/FlatFileProcessorTest.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/JmsProcessorTest.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/conf/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/conf/LoanBrokerConfig.xml
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/conf/ObjStore.xml
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessCreditRequest.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessCreditResponse.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/adapters/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/adapters/CustomerAdapter.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditAgency.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditAgencyJMSConsumer.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditCheckRequest.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditCheckResponse.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/domain/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/domain/CreditRating.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/domain/Customer.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/domain/LoanBrokerConstants.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/web/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/web/LaunchDummy.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/web/LoanBrokerWS.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/web/WebCustomer.java
labs/jbossesb/branches/refactor/product/lib/ext/emma.jar
labs/jbossesb/branches/refactor/product/lib/ext/emma_ant.jar
Removed:
labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/common/EsbSysProps.java
labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/common/connection/
labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/helpers/NormalizedDate.java
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/AppServerContextUnitTest.java
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/DomElementUnitTest.java
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/EsbEmailUnitTest.java
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/KeyValuePairUnitTest.java
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/expected_01.xml
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/expected_02.xml
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/expected_03.xml
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/testfile1.xml
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/testfile2.xml
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/testfile3.xml
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/testfile4.xml
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/util/BobjStdDTOUnitTest.java
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/util/BobjStdDTOUnitTest_testfile1.xml
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/util/EsbUtilUnitTest.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/bank.properties
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/build.xml
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/lib/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/lib/ext/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/lib/ext/junit-4.1.jar
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/lib/ext/org.sadun.util.jar
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/lib/ext/pollmgt.jar
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/lib/ext/xstream-1.1.3.jar
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/log4j.xml
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/Bank.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteReply.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequest.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/FileUtil.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/ManagerFlatFile.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/ManagerJMS.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteReplyTest.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequestTest.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/BankTest.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/FlatFileProcessorTest.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/JmsProcessorTest.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/conf/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/conf/LoanBrokerConfig.xml
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/conf/ObjStore.xml
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessCreditRequest.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessCreditResponse.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/adapters/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/adapters/CustomerAdapter.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditAgency.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditAgencyJMSConsumer.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditCheckRequest.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditCheckResponse.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/domain/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/domain/CreditRating.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/domain/Customer.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/domain/LoanBrokerConstants.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/web/
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/web/LaunchDummy.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/web/LoanBrokerWS.java
labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/web/WebCustomer.java
Modified:
labs/jbossesb/branches/refactor/
labs/jbossesb/branches/refactor/product/
labs/jbossesb/branches/refactor/product/core/build.xml
labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/helpers/AppServerContext.java
labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/helpers/DomElement.java
labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/helpers/EsbEmail.java
labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/helpers/KeyValuePair.java
labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/helpers/persist/JdbcCleanConn.java
labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/MacroExpander.java
labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/NotificationList.java
labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/NotificationTarget.java
labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/NotifyEmail.java
labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/NotifyFiles.java
labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/NotifyJMS.java
labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/NotifySqlTable.java
labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/NotifyUtil.java
labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/services/InotificationHandler.java
labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/util/BaseBusinessObject.java
labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/util/BobjStdDTO.java
labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/util/EsbUtil.java
labs/jbossesb/branches/refactor/product/core/common/tests/build.xml
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/common/tests/parameters/ParamsRepositoryUnitTest.java
labs/jbossesb/branches/refactor/product/core/listeners/src/org/jboss/soa/esb/listeners/JmsQueueListener.java
labs/jbossesb/branches/refactor/product/core/listeners/src/org/jboss/soa/esb/listeners/SqlTablePoller.java
labs/jbossesb/branches/refactor/product/core/listeners/tests/build.xml
labs/jbossesb/branches/refactor/product/core/processors/src/org/jboss/soa/esb/processors/EsbAbstractProcessor.java
labs/jbossesb/branches/refactor/product/core/processors/src/org/jboss/soa/esb/processors/EsbMsgProcessor.java
labs/jbossesb/branches/refactor/product/core/processors/tests/build.xml
labs/jbossesb/branches/refactor/product/core/processors/tests/src/org/jboss/soa/esb/processors/tests/DummyUnitTest.java
labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/internal/core/objectstore/BobjStore.java
labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/EJB/JbossEsbNotificationHandler.java
labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/EJB/JbossEsbNotificationHandlerBean.java
labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/EJB/JbossEsbNotificationHandlerHome.java
labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/EJB/JbossEsbNotificationHandlerLocal.java
labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/EJB/JbossEsbNotificationHandlerLocalHome.java
labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/EJB/JbossEsbPersistHandler.java
labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/EJB/JbossEsbPersistHandlerLocalHome.java
labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/NotifHandlerBsDelegateLocal.java
labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/NotifHandlerBsDelegateRemote.java
labs/jbossesb/branches/refactor/product/core/services/tests/build.xml
labs/jbossesb/branches/refactor/product/core/services/tests/src/org/jboss/soa/esb/services/tests/notification/NotificationFuncTest.java
labs/jbossesb/branches/refactor/product/docs/Install/conf/jbossEsb.properties
Log:
Synch with trunk to prepare for merge
Property changes on: labs/jbossesb/branches/refactor
___________________________________________________________________
Name: svn:ignore
+
.settings
.classpath
.project
Copied: labs/jbossesb/branches/refactor/ant.bat (from rev 5352, labs/jbossesb/trunk/ant.bat)
Property changes on: labs/jbossesb/branches/refactor/product
___________________________________________________________________
Name: svn:ignore
+
build
Copied: labs/jbossesb/branches/refactor/product/ant.bat (from rev 5352, labs/jbossesb/trunk/product/ant.bat)
Modified: labs/jbossesb/branches/refactor/product/core/build.xml
===================================================================
--- labs/jbossesb/branches/refactor/product/core/build.xml 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/build.xml 2006-07-29 22:08:33 UTC (rev 5353)
@@ -79,38 +79,24 @@
<!-- Clean all -->
<!-- =================================================================== -->
<target name="clean" description="Clean dist directory and cleans subprojects">
- <delete dir="${org.jboss.esb.internal.dest}"/>
- <!--
- for now I am going to delete the build directory as each module builds
- to a common place, so calling clean on each module does not make sense,
- that is unless we later configure the clean task to delete <module>
- specific classes
- -->
- <!--
+ <delete dir="${org.jboss.esb.internal.dest}/classes"/>
+
<ant dir="common" target="clean"/>
<ant dir="listeners" target="clean"/>
<ant dir="processors" target="clean"/>
<ant dir="services" target="clean"/>
- -->
- <!-- tests are now per module, this will be cleaned up later
- <ant dir="tests" target="clean"/>
- -->
+
</target>
<target name="purge" depends="clean">
- <!--
+
<delete dir="${org.jboss.esb.internal.dest}/dist"/>
- -->
- <!-- see comment above w.r.t clean and where module are build to -->
- <!--
+
<ant dir="common" target="purge"/>
<ant dir="listeners" target="purge"/>
<ant dir="processors" target="purge"/>
<ant dir="services" target="purge"/>
- -->
- <!-- tests are now per module, this will be cleaned up later
- <ant dir="tests" target="purge"/>
- -->
+
</target>
<!-- =================================================================== -->
Deleted: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/common/EsbSysProps.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/common/EsbSysProps.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/common/EsbSysProps.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,103 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.soa.esb.common;
-
-import org.jboss.soa.esb.helpers.KeyValuePair;
-
-public class EsbSysProps
-{
- public static final String SMTP_HOST = "jbossEsb.mail.smtp.host";
- public static final String SMTP_USERNAME = "jbossEsb.mail.smtp.user";
- public static final String SMTP_PASSWORD = "jbossEsb.mail.smtp.password";
- public static final String SMTP_PORT = "jbossEsb.mail.smtp.port";
-
- public static final String JNDI_SERVER_TYPE = "jbossEsb.jndi.server.type";
- public static final String JNDI_SERVER_URL = "jbossEsb.jndi.server.url";
-
- public static final String PARAMS_REPOS_FACTORY_CLASS
- = "jbossEsb.paramsRepository.factory.class";
- public static final String OBJECT_STORE_CONFIG_FILE
- = "jbossEsb.objStore.configfile";
- public static final String ENCRYPT_FACTORY_CLASS
- = "jbossEsb.encryption.factory.class";
-
- private static KeyValuePair[] s_oaKV = new KeyValuePair[]
- {new KeyValuePair(SMTP_HOST ,getSmtpHost())
- ,new KeyValuePair(SMTP_USERNAME ,getSmtpUsername())
- ,new KeyValuePair(SMTP_PASSWORD ,getSmtpPassword())
- ,new KeyValuePair(SMTP_PORT ,getSmtpPort())
- ,new KeyValuePair(JNDI_SERVER_TYPE, getJndiServerType())
- ,new KeyValuePair(JNDI_SERVER_URL,getJndiServerURL())
- ,new KeyValuePair(PARAMS_REPOS_FACTORY_CLASS, getParamsReposFactoryClass())
- ,new KeyValuePair(OBJECT_STORE_CONFIG_FILE, getObjStoreConfigFile())
- ,new KeyValuePair(ENCRYPT_FACTORY_CLASS, getEncryptionFactoryClass())
-
- };
-
- public static String dump()
- { StringBuilder sb = new StringBuilder("Dump of EsbSysProps:\n");
- for (KeyValuePair oCurr : s_oaKV)
- sb.append(oCurr.getKey()).append("=").append(oCurr.getValue()).append("\n")
- ;
- return sb.append("______________________________________").toString();
- } //________________________________
-
- public static String getSmtpHost()
- { return System.getProperty(SMTP_HOST,"localhost");
- }
-
- public static String getSmtpUsername()
- { return System.getProperty(SMTP_USERNAME,"");
- }
-
- public static String getSmtpPassword()
- { return System.getProperty(SMTP_PASSWORD,"");
- }
-
- public static String getSmtpPort()
- { return System.getProperty(SMTP_PORT,"25");
- }
-
- public static String getJndiServerType()
- { return System.getProperty(JNDI_SERVER_TYPE,"jboss"); }
-
- public static String getJndiServerURL()
- { return System.getProperty(JNDI_SERVER_URL,"localhost"); }
-
-
- public static String getParamsReposFactoryClass()
- { return System.getProperty(PARAMS_REPOS_FACTORY_CLASS
- ,"org.jboss.soa.esb.parameters.DefaultReposFactory");
- }
-
- public static String getObjStoreConfigFile()
- { return System.getProperty(OBJECT_STORE_CONFIG_FILE);
- }
-
- public static String getEncryptionFactoryClass()
- { return System.getProperty(ENCRYPT_FACTORY_CLASS
- ,"org.jboss.soa.esb.services.DefaultEncryptionFactory");
- }
-
-
-} //_____________________________________________________________________
Copied: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/common/EsbSysProps.java (from rev 5352, labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/common/EsbSysProps.java)
Modified: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/helpers/AppServerContext.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/helpers/AppServerContext.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/helpers/AppServerContext.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,110 +1,104 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.soa.esb.helpers;
import java.util.*;
import javax.naming.*;
import org.apache.log4j.Logger;
+
+
/**
- * Obtains JNDI naming context for a predefined list of 'well known' server types
- *
+ * Obtains JNDI naming context for a predefined list of 'well known' server
+ * types
+ *
*/
+public abstract class AppServerContext {
+ /**
+ * Logger for this class
+ */
+ private static final Logger m_oLogger = Logger
+ .getLogger(AppServerContext.class);
-public class AppServerContext
-{
- /**
- * Logger for this class
- */
- private static final Logger m_oLogger = Logger
- .getLogger(AppServerContext.class);
+ /**
+ * Indicates that a jboss context is requested
+ */
+ public static final String CTX_JBOSS = "jboss";
- /**
- * Indicates that a jboss context is requested
- */
- public static final String CTX_JBOSS = "jboss";
+ public static final int MAX_RETRIES = 10;
- public static final int MAX_RETRIES = 10;
- public static final int WAIT_FOR_RETRY = 30;
+ public static final int WAIT_FOR_RETRY = 30;
- public enum SERVER_TYPE
- {
- jboss
- ,weblogic
- ,websphere
- ,oracle
- };
+ public enum SERVER_TYPE {
+ jboss, weblogic, websphere, oracle
+ };
- // No public default constructor
- private AppServerContext() {}
+ public static Context getServerContext(String pType, String p_sJndiServer) {
+ return getServerContext(SERVER_TYPE.valueOf(pType), p_sJndiServer);
+ }
+
+ // REVIEW: What is all this about... this class doesn't support anything other than a JBoss Server!!
- /**
- * Equivalent to calling getServerContext(CTX_JBOSS);
- */
- public static Context getServerContext(String p_sJndiServer)
- { return getServerContext(SERVER_TYPE.jboss,p_sJndiServer); }
+ /**
+ * Searches a predefined table of 'well known' app server types, and returns
+ * the corresponding naming context
+ *
+ * @param p_sServer:
+ * name or IP of server, and optionally port #
+ */
+ private static Context getServerContext(SERVER_TYPE pType,
+ String p_sJndiServer) {
+ switch (pType) {
+ case jboss:
+ return jbossContext(p_sJndiServer);
+ }
- public static Context getServerContext(String pType , String p_sJndiServer)
- { return getServerContext(SERVER_TYPE.valueOf(pType),p_sJndiServer); }
+ return null;
+ } // __________________________________
- /**
- * Searches a predefined table of 'well known' app server types, and returns
- * the corresponding naming context
- * @param p_sServer: name or IP of server, and optionally port #
- */
- public static Context getServerContext(SERVER_TYPE pType , String p_sJndiServer)
- {
- switch (pType)
- { case jboss : return jbossContext(p_sJndiServer);
- }
+ private static Context jbossContext(String p_sJndiServer) {
+ Properties oPr = new Properties();
+ oPr.setProperty(Context.PROVIDER_URL, p_sJndiServer);
+ oPr.setProperty(Context.INITIAL_CONTEXT_FACTORY,
+ "org.jnp.interfaces.NamingContextFactory");
+ oPr.setProperty(Context.URL_PKG_PREFIXES,
+ "jboss.naming:org.jnp.interfaces");
- return null;
- } //__________________________________
+ boolean bCtxOK = false;
+ Context oCtx = null;
+ for (int i1 = 0; (!bCtxOK) && i1 < MAX_RETRIES; i1++) {
+ // check if context is valid
+ try {
+ oCtx = new InitialContext(oPr);
+ oCtx.list("__dummy2@#$%");
+ bCtxOK = true;
+ } catch (NamingException nex) {
+ bCtxOK = true;
+ }
+ }
+ if (bCtxOK)
+ return oCtx;
+ m_oLogger.error("Can't connect to jndiServer <" + p_sJndiServer + ">");
+ return null;
- private static Context jbossContext(String p_sJndiServer)
- {
- Properties oPr = new Properties();
- oPr.setProperty(Context.PROVIDER_URL, p_sJndiServer);
- oPr.setProperty(Context.INITIAL_CONTEXT_FACTORY
- ,"org.jnp.interfaces.NamingContextFactory");
- oPr.setProperty(Context.URL_PKG_PREFIXES
- ,"jboss.naming:org.jnp.interfaces");
+ } // ________________________
- boolean bCtxOK = false;
- Context oCtx = null;
- for (int i1=0; (! bCtxOK) && i1<MAX_RETRIES; i1++)
- {
- // check if context is valid
- try
- { oCtx = new InitialContext(oPr);
- oCtx.list("__dummy2@#$%");
- bCtxOK = true;
- }
- catch (NamingException nex) {bCtxOK = true; }
- }
- if (bCtxOK)
- return oCtx;
- m_oLogger.error("Can't connect to jndiServer <" + p_sJndiServer + ">") ;
- return null;
-
- } //________________________
-
-} //____________________________________________________________________________
+} // ____________________________________________________________________________
Modified: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/helpers/DomElement.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/helpers/DomElement.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/helpers/DomElement.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,326 +1,319 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.soa.esb.helpers;
import java.io.*;
import java.util.*;
import org.w3c.dom.*;
+import org.xml.sax.SAXException;
+
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;
-public class DomElement
-{
- private static final String s_sLS = System.getProperty("line.separator");
- private static final transient String s_sCharset = "ISO-8859-1";
- private static final transient String s_sEncoding
- = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
+public class DomElement {
+ protected static final String LINE_BREAK = System.getProperty("line.separator");
- private transient static DocumentBuilder s_oDB;
- private transient static Transformer s_tf;
- private transient Element m_oElem;
- private DomElement m_oDad;
- public DomElement getDad() { return m_oDad; }
+ private static final transient String s_sCharset = "ISO-8859-1";
- static
- { try
- {
- s_oDB = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- s_tf = TransformerFactory.newInstance().newTransformer();
- s_tf.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,"yes");
- s_tf.setOutputProperty(OutputKeys.INDENT,"no");
- s_tf.setOutputProperty(OutputKeys.ENCODING, s_sCharset);
- }
- catch (Exception e) {}
- };
+// private static final transient String s_sEncoding = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
- private DomElement() {}
+ private transient static DocumentBuilder s_oDocumentBuilder;
- public DomElement(Element p_oE)
- { this();
- Document oDoc = null;
- synchronized (s_oDB) { oDoc = s_oDB.newDocument(); }
- Node oNew = oDoc.importNode(p_oE.cloneNode(true),true);
- m_oElem = (Element)oDoc.appendChild(oNew);
- } //__________________________________
+ private transient static Transformer s_Transformer;
- public DomElement(String p_sName) { this (p_sName,null); }
+ private transient Element m_oRootW3CElement;
- /**
- * Construct a new DomElement object by cloning arg 1
- * <p>Cloning makes it safe to work on the new object without altering the
- * contents of the argument
- * </p>
- * @param p_oP DomElement
- * @throws Exception
- */
- protected DomElement(DomElement p_oP) throws Exception
- {m_oElem = p_oP.cloneObj().m_oElem; }
+ private DomElement m_oParentDomElement;
- private DomElement(String p_sName,DomElement p_oDad)
- { this();
- Document oDoc = null;
- if (null == p_oDad)
- { synchronized(s_oDB) { oDoc = s_oDB.newDocument(); }
- m_oElem = (Element)oDoc.appendChild(oDoc.createElement(p_sName));
- }
- else
- { m_oDad = p_oDad;
- oDoc = p_oDad.m_oElem.getOwnerDocument();
- m_oElem = (Element)p_oDad.m_oElem.appendChild(oDoc.createElement(p_sName));
- }
- } //__________________________________
+ public DomElement getDad() {
+ return m_oParentDomElement;
+ }
- public static DomElement fromInputStream(InputStream p_oIS) throws Exception
- { Document oDoc = null;
- synchronized(s_oDB) { oDoc = s_oDB.parse(p_oIS); }
- DomElement oRet = new DomElement();
- oRet.m_oElem = oDoc.getDocumentElement();
- return oRet;
- } //__________________________________
+ static {
+ try {
+ s_oDocumentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ s_Transformer = TransformerFactory.newInstance().newTransformer();
+ s_Transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ s_Transformer.setOutputProperty(OutputKeys.INDENT, "no");
+ s_Transformer.setOutputProperty(OutputKeys.ENCODING, s_sCharset);
+ } catch (Exception e) {
+ }
+ };
- public static DomElement fromURL(String p_sFname) throws Exception
- { Document oDoc = null;
- synchronized(s_oDB) { oDoc = s_oDB.parse(p_sFname); }
- DomElement oRet = new DomElement();
- oRet.m_oElem = oDoc.getDocumentElement();
- return oRet;
- } //__________________________________
+ private DomElement() {
+ }
- public static DomElement fromXml(String p_s) throws Exception
- { Document oDoc = null;
- StringBuffer sb = new StringBuffer(s_sEncoding).append(p_s);
- InputStream oIS = new ByteArrayInputStream (sb.toString().getBytes(s_sCharset));
- synchronized(s_oDB) { oDoc = s_oDB.parse(oIS); }
- DomElement oRet = new DomElement();
- oRet.m_oElem = oDoc.getDocumentElement();
- return oRet;
- } //__________________________________
+ protected DomElement(Element p_oE) {
+ this();
+ Document oDoc = null;
+ synchronized (s_oDocumentBuilder) {
+ oDoc = s_oDocumentBuilder.newDocument();
+ }
+ Node oNew = oDoc.importNode(p_oE.cloneNode(true), true);
+ m_oRootW3CElement = (Element) oDoc.appendChild(oNew);
+ } // __________________________________
- public String toString()
- { return toXml().toString()
- .replaceAll(s_sLS," ")
- .replaceAll("\t","")
- +s_sLS;
- } //________________________________
+ public DomElement(String p_sName) {
+ this(p_sName, null);
+ }
- public ByteArrayOutputStream toXml()
- { Document oDoc = null;
- synchronized(s_oDB) { oDoc = s_oDB.newDocument(); }
- oDoc.appendChild(oDoc.importNode(m_oElem,true));
- oDoc.normalize();
- DOMSource src = new DOMSource(oDoc);
+ /**
+ * Construct a new DomElement object by cloning arg 1
+ * <p>
+ * Cloning makes it safe to work on the new object without altering the
+ * contents of the argument
+ * </p>
+ *
+ * @param p_oP
+ * DomElement
+ * @throws Exception
+ */
+ protected DomElement(DomElement p_oP) throws Exception {
+ m_oRootW3CElement = p_oP.cloneObj().m_oRootW3CElement;
+ }
- ByteArrayOutputStream oStrm = new ByteArrayOutputStream(5000);
- StreamResult res = new StreamResult(oStrm);
+ private DomElement(String p_sName, DomElement p_oParentDomElement) {
+ this();
+ Document oW3CDoc = null;
+ if (null == p_oParentDomElement) {
+ synchronized (s_oDocumentBuilder) {
+ oW3CDoc = s_oDocumentBuilder.newDocument();
+ }
+ m_oRootW3CElement = (Element) oW3CDoc.appendChild(oW3CDoc.createElement(p_sName));
+ } else {
+ m_oParentDomElement = p_oParentDomElement;
+ oW3CDoc = p_oParentDomElement.m_oRootW3CElement.getOwnerDocument();
+ m_oRootW3CElement = (Element) p_oParentDomElement.m_oRootW3CElement.appendChild(oW3CDoc
+ .createElement(p_sName));
+ }
+ } // __________________________________
- try
- { synchronized (s_tf) { s_tf.transform(src,res); }
- }
- catch (Exception e)
- { try { oStrm.write("ERROR Dom3Element.toXml()".getBytes()); }
- catch (Exception e1) {}
- }
- return oStrm;
- } //__________________________________
+ public static DomElement fromInputStream(InputStream p_oIS) throws SAXException, IOException {
+ Document oDoc = null;
+ synchronized (s_oDocumentBuilder) {
+ oDoc = s_oDocumentBuilder.parse(p_oIS);
+ }
+ DomElement oRet = new DomElement();
+ oRet.m_oRootW3CElement = oDoc.getDocumentElement();
+ return oRet;
+ } // __________________________________
-//_________ GETTERS ____________________________________________________________
+ public static DomElement fromURL(String p_sFname) throws Exception
+ { return fromInputStream(new FileInputStream(p_sFname));
+ } //__________________________________
- public Element getDomElement() { return m_oElem; }
+ public static DomElement fromXml(String p_xmlString) throws SAXException, IOException {
+ // TF: Modified this constructor to use the fromInputStream method.
- public String getName() { return m_oElem.getNodeName(); }
+ if(p_xmlString == null || p_xmlString.trim().equals("")) {
+ throw new IllegalArgumentException("Null or empty 'p_xmlString' arg in call.");
+ }
+
+ InputStream oIS = new ByteArrayInputStream(p_xmlString.getBytes(s_sCharset));
- public String[] getAttrKeys()
- { NamedNodeMap NM = m_oElem.getAttributes();
- String[] saRet = new String[NM.getLength()];
- for (int i1=0; i1<saRet.length;i1++)
- saRet[i1] = NM.item(i1).getNodeName();
- return saRet;
- } //__________________________________
+ return fromInputStream(oIS);
+ } // __________________________________
- public String getAttr(String p_sKey)
- { if (! m_oElem.hasAttribute(p_sKey)) return null;
- return m_oElem.getAttribute(p_sKey);
- } //__________________________________
+ public String toString() {
+ return toXml().toString().replaceAll(LINE_BREAK, " ").replaceAll("\t",
+ "")
+ + LINE_BREAK;
+ } // ________________________________
- public String getFirstTextChild (String p_sKey)
- { NodeList NL = m_oElem.getElementsByTagName(p_sKey);
- StringBuffer sb = new StringBuffer(100);
- if (NL.getLength()>0)
- { Node nCurr = NL.item(0).getFirstChild();
- sb.setLength(0);
- while (null != nCurr)
- { if (nCurr instanceof Text) sb.append(nCurr.getNodeValue());
- nCurr = nCurr.getNextSibling();
- }
- return sb.toString();
- }
- return null;
- } //__________________________________
+ public ByteArrayOutputStream toXml() {
+ Document oDoc = null;
+ synchronized (s_oDocumentBuilder) {
+ oDoc = s_oDocumentBuilder.newDocument();
+ }
+ oDoc.appendChild(oDoc.importNode(m_oRootW3CElement, true));
+ oDoc.normalize();
+ DOMSource src = new DOMSource(oDoc);
- public static String getTextValue (Node p_n)
- { StringBuffer sb = new StringBuffer();
- Node nCurr = p_n.getFirstChild();
- while (null != nCurr)
- { if (nCurr instanceof Text) sb.append(nCurr.getNodeValue());
- nCurr = nCurr.getNextSibling();
- }
- return sb.toString();
- } //__________________________________
+ ByteArrayOutputStream oStrm = new ByteArrayOutputStream(5000);
+ StreamResult res = new StreamResult(oStrm);
- public String [] getTextChildren (String p_sKey)
- { NodeList NL = m_oElem.getElementsByTagName(p_sKey);
- List<String> oL = new ArrayList<String>();
- for (int i1=0; i1<NL.getLength();i1++)
- oL.add(getTextValue(NL.item(i1)));
- String[] saRet = new String[oL.size()];
- oL.toArray(saRet);
- return saRet;
- } //__________________________________
+ try {
+ synchronized (s_Transformer) {
+ s_Transformer.transform(src, res);
+ }
+ } catch (Exception e) {
+ try {
+ oStrm.write("ERROR Dom3Element.toXml()".getBytes());
+ } catch (Exception e1) {
+ }
+ }
+ return oStrm;
+ } // __________________________________
- public DomElement [] getElementChildren (String p_sKey)
- { DomElement oDE = null;
- NodeList NL = m_oElem.getElementsByTagName(p_sKey);
- List<DomElement> oL = new ArrayList<DomElement>();
- for (int i1=0; i1<NL.getLength();i1++)
- { Node nCurr = NL.item(i1);
- if (nCurr instanceof Element)
- { oL.add(oDE = new DomElement( (Element) nCurr));
- oDE.m_oDad = this;
- }
- }
- DomElement[] oaRet = new DomElement[oL.size()];
- oL.toArray(oaRet);
- return oaRet;
- } //__________________________________
+ // _________ GETTERS
+ // ____________________________________________________________
- public DomElement getFirstElementChild (String p_sKey)
- { DomElement oDE = null;
- NodeList NL = m_oElem.getElementsByTagName(p_sKey);
- for (int i1=0; i1<NL.getLength();i1++)
- { Node nCurr = NL.item(i1);
- if (nCurr instanceof Element)
- { oDE = new DomElement( (Element) nCurr);
- oDE.m_oDad = this;
- return oDE;
- }
- }
- return null;
- } //__________________________________
+ public Element getDomElement() {
+ return m_oRootW3CElement;
+ }
- public DomElement [] getAllElemChildren ()
- { DomElement oDE = null;
- List<DomElement> oL = new ArrayList<DomElement>();
- Node nCurr = m_oElem.getFirstChild();
- while (null != nCurr)
- { if (nCurr instanceof Element)
- { oL.add(oDE = new DomElement( (Element) nCurr));
- oDE.m_oDad = this;
- }
- nCurr = nCurr.getNextSibling();
- }
- DomElement[] oaRet = new DomElement[oL.size()];
- oL.toArray(oaRet);
- return oaRet;
- } //__________________________________
+ public String getName() {
+ return m_oRootW3CElement.getNodeName();
+ }
-//_________ SETTERS ____________________________________________________________
+ public String[] getAttrKeys() {
+ NamedNodeMap NM = m_oRootW3CElement.getAttributes();
+ String[] saRet = new String[NM.getLength()];
+ for (int i1 = 0; i1 < saRet.length; i1++)
+ saRet[i1] = NM.item(i1).getNodeName();
+ return saRet;
+ } // __________________________________
- public void setAttr(String p_sKey,String p_sVal)
- { if (null==p_sKey) return;
- m_oElem.removeAttribute(p_sKey);
- if (null!=p_sVal) m_oElem.setAttribute(p_sKey,p_sVal);
- } //__________________________________
+ public String getAttr(String p_sAttribName) {
+ if (!m_oRootW3CElement.hasAttribute(p_sAttribName))
+ return null;
+ return m_oRootW3CElement.getAttribute(p_sAttribName);
+ } // __________________________________
- public void setAttributes(Map p_oM)
- { if (null==p_oM) return;
- for (Iterator II=p_oM.keySet().iterator(); II.hasNext(); )
- { String sKey = II.next().toString();
- setAttr(sKey, p_oM.get(sKey).toString());
- }
- } //__________________________________
+ public static String getTextValue(Node p_Node) {
+ StringBuffer sb = new StringBuffer();
+ Node nCurr = p_Node.getFirstChild();
+ while (null != nCurr) {
+ if (nCurr instanceof Text)
+ sb.append(nCurr.getNodeValue());
+ nCurr = nCurr.getNextSibling();
+ }
+ return sb.toString();
+ } // __________________________________
- public void addTextChild (String p_sKey, String p_sVal)
- { if (null==p_sKey || null==p_sVal) return;
- DomElement oNew = new DomElement(p_sKey,this);
- oNew.m_oElem.appendChild(m_oElem.getOwnerDocument().createTextNode(p_sVal));
- } //__________________________________
+ public String[] getTextChildren(String p_sElementName) {
+ NodeList NL = getElementNodeList(p_sElementName);
+ List<String> oL = new ArrayList<String>();
+ for (int i1 = 0; i1 < NL.getLength(); i1++)
+ oL.add(getTextValue(NL.item(i1)));
+ String[] saRet = new String[oL.size()];
+ oL.toArray(saRet);
+ return saRet;
+ } // __________________________________
- public void addTextChildren (String p_sKey, String[] p_saVal)
- { if (null==p_sKey || null==p_saVal) return;
- for (int i1=0; i1<p_saVal.length;i1++)
- addTextChild(p_sKey,p_saVal[i1]);
- } //__________________________________
+ public DomElement[] getElementChildren(String p_sElementName) {
+ DomElement oDE = null;
+
+ NodeList NL = getElementNodeList(p_sElementName);
+ List<DomElement> oL = new ArrayList<DomElement>();
- public void addElemChild (DomElement p_oE)
- { p_oE.m_oDad = this;
- Document oDoc = m_oElem.getOwnerDocument();
- m_oElem.appendChild(oDoc.importNode(p_oE.m_oElem,true));
- } //__________________________________
+ for (int i1 = 0; i1 < NL.getLength(); i1++) {
+ Node nCurr = NL.item(i1);
+ if (nCurr instanceof Element) {
+ oL.add(oDE = new DomElement((Element) nCurr));
+ oDE.m_oParentDomElement = this;
+ }
+ }
+ DomElement[] oaRet = new DomElement[oL.size()];
+ oL.toArray(oaRet);
+ return oaRet;
+ } // __________________________________
- public DomElement newElemChild (String p_sKey)
- {
- DomElement oNew = new DomElement(p_sKey,this);
- oNew.m_oDad = this;
- return oNew;
- } //__________________________________
+ public DomElement getFirstElementChild(String p_sElementName) {
+ DomElement[] children = getElementChildren(p_sElementName);
- public void rmvChildsByName (String p_sKey)
- { NodeList NL = m_oElem.getElementsByTagName(p_sKey);
- for (int i1=0; i1<NL.getLength();i1++)
- m_oElem.removeChild(NL.item(i1));
- } //__________________________________
+ if(children != null && children.length > 0) {
+ return children[0];
+ } else {
+ return null;
+ }
+ } // __________________________________
-//_________ UTILITIES / HELPERS_________________________________________________
+ /**
+ * Get a nodelist for the specified element name from the associated Document.
+ * @param p_sElementName Element tag name.
+ * @return Nodelist.
+ */
+ private NodeList getElementNodeList(String p_sElementName) {
+ // TF: Modified the following line to allow the document root element be included in the lookup..
+ return m_oRootW3CElement.getOwnerDocument().getElementsByTagName(p_sElementName);
+ }
+ public DomElement[] getAllElemChildren() {
+ DomElement oDE = null;
+ List<DomElement> oL = new ArrayList<DomElement>();
+ Node nCurr = m_oRootW3CElement.getFirstChild();
+
+ while (null != nCurr) {
+ if (nCurr instanceof Element) {
+ oL.add(oDE = new DomElement((Element) nCurr));
+ oDE.m_oParentDomElement = this;
+ }
+ nCurr = nCurr.getNextSibling();
+ }
+ DomElement[] oaRet = new DomElement[oL.size()];
+ oL.toArray(oaRet);
+ return oaRet;
+ } // __________________________________
- public DomElement cloneObj() throws Exception
- { return DomElement.fromXml(this.toString());
- } //__________________________________
+ // _________ SETTERS
+ // ____________________________________________________________
- public void dump (OutputStream p_OS)
- { StringBuffer sb = new StringBuffer(toXml().toString());
- int iFrom = 0;
- while (iFrom < sb.length())
- { iFrom = sb.indexOf(">",iFrom);
- if (iFrom < 0) break;
- for (int i1=1+iFrom; i1<sb.length();i1++)
- { char cCurr = sb.charAt(i1);
- if (Character.isWhitespace(cCurr)) continue;
- if (Character.getType(cCurr) == Character.DIRECTIONALITY_WHITESPACE)
- continue;
- if ('<' == cCurr) { sb.replace(1+iFrom,i1,"\n"); iFrom++; }
- break;
- }
- iFrom++;
- }
+ public void setAttr(String p_sAttribName, String p_sAttribValue) {
+ if (null == p_sAttribName) {
+ // REVIEW: Shouldn't this throw an IllegalArgumentException???
+ return;
+ }
+ m_oRootW3CElement.removeAttribute(p_sAttribName);
+ if (null != p_sAttribValue) {
+ m_oRootW3CElement.setAttribute(p_sAttribName, p_sAttribValue);
+ }
+ } // __________________________________
- try
- { p_OS.write(sb.toString().getBytes(s_sCharset));
- p_OS.write(s_sLS.getBytes());
- }
- catch (Exception e) {}
- } //__________________________________
+ public void addTextChild (String p_sKey, String p_sVal)
+ { if (null==p_sKey || null==p_sVal) return;
+ DomElement oNew = new DomElement(p_sKey,this);
+ oNew.m_oRootW3CElement.appendChild(m_oRootW3CElement.getOwnerDocument().createTextNode(p_sVal));
+ } //__________________________________
-} //____________________________________________________________________________
+ public void addTextChildren (String p_sKey, String[] p_saVal)
+ { if (null==p_sKey || null==p_saVal) return;
+ for (int i1=0; i1<p_saVal.length;i1++)
+ addTextChild(p_sKey,p_saVal[i1]);
+ } //__________________________________
+
+ public void addElemChild(DomElement p_oE) {
+ p_oE.m_oParentDomElement = this;
+ Document oDoc = m_oRootW3CElement.getOwnerDocument();
+ m_oRootW3CElement.appendChild(oDoc.importNode(p_oE.m_oRootW3CElement, true));
+ } // __________________________________
+
+ public void rmvChildsByName(String p_sTagName) {
+ NodeList NL = m_oRootW3CElement.getElementsByTagName(p_sTagName);
+ for (int i1 = 0; i1 < NL.getLength(); i1++)
+ m_oRootW3CElement.removeChild(NL.item(i1));
+ } // __________________________________
+
+ // _________ UTILITIES /
+ // HELPERS_________________________________________________
+
+ public DomElement cloneObj() throws SAXException, IOException {
+ // REVIEW: This must be a performance killer - surely the
+ // associated DOM can be cloned Vs serialising to a string and parsing
+ // from scratch again!!!
+ return DomElement.fromXml(this.toString());
+ } // __________________________________
+
+} // ____________________________________________________________________________
Modified: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/helpers/EsbEmail.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/helpers/EsbEmail.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/helpers/EsbEmail.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,155 +1,283 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.soa.esb.helpers;
-import java.util.*;
-import javax.mail.*;
-import javax.mail.internet.*;
-import javax.activation.*;
+import java.util.Properties;
-import org.jboss.soa.esb.util.*;
+import javax.activation.DataHandler;
+import javax.activation.FileDataSource;
+import javax.mail.Address;
+import javax.mail.Authenticator;
+import javax.mail.BodyPart;
+import javax.mail.MessagingException;
+import javax.mail.Multipart;
+import javax.mail.PasswordAuthentication;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.AddressException;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
-import org.jboss.soa.esb.common.*;
+import org.jboss.soa.esb.common.EsbSysProps;
/**
- * Simplifies sending of e-mails with attachments from java
- * <p>Author: Heuristica - Buenos Aires - Argentina </p>
+ * Simplifies sending of e-mails with attachments from java.
+ * <p/>
+ * The message is sent via a subsequent call to the {@link #sendMessage()}
+ * method.
+ *
+ * <h3 id="p_oMessageParms">Message Parmeters</h3>
+ * The class constructor is supplied the following parameters via a
+ * {@link org.jboss.soa.esb.helpers.DomElement} instance:
+ * <ol>
+ * <li><b>FROM</b>: valid e-mail address</li>
+ * <li><b>SENDTO</b>: valid comma separated list of e-mail addresses</li>
+ * <li><b>SUBJECT</b>: free text that will appear as subject of the e-mail</li>
+ * <li><b>MESSAGE</b>: free text that will appear as contents of the e-mail</li>
+ * <li><b>ATTACH</b>: list (as Text children) of valid accessible filenames to
+ * attach to the e-mail</li>
+ * </ol>
+ * All parameters except 'ATTACH' are attributes of the DomElement argument. ATTACH
+ * parameters (attachments) are added as child DomElements of the supplied
+ * DomElement.
+ *
+ * @author: Heuristica - Buenos Aires - Argentina
*/
-public class EsbEmail
-{
- /**
- * DomElement attribute : will be the contents of the From: field in the outgoing message
- */
- public static final String FROM = "from";
- /**
- * DomElement attribute : comma separated list of recipients
- */
- public static final String SENDTO = "sendTo";
- /**
- * DomElement attribute : comma separated list of Copy recipients
- */
- public static final String COPYTO = "ccTo";
- /**
- * DomElement attribute : will be the contents of the Subject: field in the outgoing message
- */
- public static final String SUBJECT = "subject";
- /**
- * DomElement attribute : Value of this attribute will be the content of
- * the e-mail's text
- */
- public static final String ATTACH = "attachment";
- /**
- * DomElement child Text elements : Each child represents the name of a
- * file to be attached in the outgoing message
- */
- public static final String MESSAGE = "message";
+public class EsbEmail {
+ /**
+ * DomElement attribute : will be the contents of the From: field in the
+ * outgoing message
+ */
+ public static final String FROM = "from";
- /**
- * Constructor attempts to send e-mail using the information provided
- * in the argument
- * <p>
- * <li> FROM valid e-mail address</li>
- * <li> SENDTO valid comma separated list of e-mail addresses</li>
- * <li> SUBJECT free text that will appear as subject of the e-mail</li>
- * <li> MESSAGE free text that will appear as contents of the e-mail</li>
- * <li> ATTACH list (as Text children) of valid accessible filenames to attach to the e-mail</li>
- * <li> All elements except 'ATTACH' are attributes of the DomElement argument</li>
- * </p>
- * @param p_oParms A DomElement object containing the elements mentioned above
- * @see DomElement
- *
- */
- public EsbEmail(DomElement p_oParms) throws Exception
- {
- Authenticator oAuth = null;
- String sSmtpUser = EsbSysProps.getSmtpUsername();
- if (null != sSmtpUser)
- oAuth = new MyAuth(sSmtpUser,EsbSysProps.getSmtpPassword());
+ /**
+ * DomElement attribute : comma separated list of recipients
+ */
+ public static final String SENDTO = "sendTo";
- Properties oMailP = new Properties();
- oMailP.setProperty("mail.smtp.host",EsbSysProps.getSmtpHost());
- try
- { String sPort = EsbSysProps.getSmtpPort();
- Integer.parseInt(sPort);
- oMailP.setProperty("mail.smtp.port",sPort);
- }
- catch (Exception e) { /* OK just leave standard port */ }
-
- javax.mail.Session oMailSess = javax.mail.Session.getDefaultInstance
- (oMailP, oAuth);
- MimeMessage oMess = new MimeMessage(oMailSess);
+ /**
+ * DomElement attribute : comma separated list of Copy recipients
+ */
+ public static final String COPYTO = "ccTo";
- String sFrom = p_oParms.getAttr(FROM);
- InternetAddress oFrom = new InternetAddress(sFrom);
+ /**
+ * DomElement attribute : will be the contents of the Subject: field in the
+ * outgoing message
+ */
+ public static final String SUBJECT = "subject";
- String sAtt = (String)p_oParms.getAttr(SUBJECT);
- if (null != sAtt) oMess.setSubject(sAtt);
+ /**
+ * DomElement attribute : Value of this attribute will be the content of the
+ * e-mail's text
+ */
+ public static final String ATTACH = "attachment";
- oMess.setFrom(oFrom);
- oMess.setReplyTo(new Address[] {oFrom});
- InternetAddress[] oaTo = InternetAddress.parse(p_oParms.getAttr(SENDTO));
- for (int i1=0; i1<oaTo.length;i1++)
- oMess.addRecipient(MimeMessage.RecipientType.TO,oaTo[i1]);
+ /**
+ * DomElement child Text elements : Each child represents the name of a file
+ * to be attached in the outgoing message
+ */
+ public static final String MESSAGE = "message";
- sAtt = (String)p_oParms.getAttr(COPYTO);
- if (null != sAtt)
- { oaTo = InternetAddress.parse(sAtt);
- for (int i1=0; i1<oaTo.length;i1++)
- oMess.addRecipient(MimeMessage.RecipientType.CC,oaTo[i1]);
- }
+ /**
+ * The message to b sent via a subsequent call to {@link #sendMessage()}.
+ */
+ private MimeMessage mailMessage;
- BodyPart oBodyP;
- Multipart oMultiP;
- oMess.setContent(oMultiP = new MimeMultipart());
+ /**
+ * Public constructor.
+ * <p/>
+ * Initialises the mail server session and creates the mail message using
+ * the information provided in the p_oMessageParms
+ * <a href="p_oMessageParms">listed above</a>.
+ * <p/>
+ * The message is sent via a subsequent call to the {@link #sendMessage()}
+ * method.
+ *
+ * @param p_oMessageParms
+ * A DomElement object containing the elements mentioned above
+ * @throws MessagingException
+ * @throws AddressException
+ * @see DomElement
+ *
+ */
+ public EsbEmail(DomElement p_oMessageParms) throws AddressException, MessagingException {
+ // REVIEW: How about typing the parameters a little better??? Looks as though that might have a huge ripple-on effect accross the codebase!!
+ // REVIEW: Does the session need to ne initialised every time???
+ Session oMailSess = initMailServerSession();
+
+ // Initialise the oMailMess property...
+ mailMessage = createMailMessage(p_oMessageParms, oMailSess);
+
+ // Message can be "sent" via a subsequent call to the sendMessage method!
+ } // __________________________________
- oMultiP.addBodyPart(oBodyP = new MimeBodyPart());
- String sText = p_oParms.getAttr(MESSAGE);
- if (null == sText) sText = "";
- oBodyP.setText(sText+"\n");
+ /**
+ * Send the mail message associated with this instance.
+ * @throws MessagingException Unable to transport the message associated with this
+ * EsbEmail instance.
+ */
+ public void sendMessage() throws MessagingException {
+ Transport.send(mailMessage);
+ }
+
+ /**
+ * Get the {@link MimeMessage mail message} associated with this EsbMail
+ * instance.
+ * @return The mailMessage property value.
+ */
+ public MimeMessage getMailMessage() {
+ return mailMessage;
+ }
- String [] saFn = p_oParms.getTextChildren(ATTACH);
- for (int i1=0; i1<saFn.length; i1++)
- { oMultiP.addBodyPart(oBodyP = new MimeBodyPart());
- String sFile = saFn[i1];
- oBodyP.setDataHandler(new DataHandler(new FileDataSource(sFile)));
- oBodyP.setFileName(sFile.substring(1 + sFile.lastIndexOf("\\")));
- }
+ /**
+ * Create the mail message instance to be {@link #sendMessage() sent}.
+ * @param p_oMessageParms <a href="p_oMessageParms">Message parameters.</a>.
+ * @param oMailSess Mail session on which the message is to be transported.
+ * @return The message.
+ * @throws AddressException
+ * @throws MessagingException
+ */
+ private MimeMessage createMailMessage(DomElement p_oMessageParms, Session oMailSess) throws AddressException, MessagingException {
+ MimeMessage oMessage = new MimeMessage(oMailSess);
+
+ // Populate the message with the data supplied in the p_oMessageParms DomElement.
+ addMessageAddressing(p_oMessageParms, oMessage);
+ addMessageSubject(p_oMessageParms, oMessage);
+ addMessageContent(p_oMessageParms, oMessage);
+
+ return oMessage;
+ }
- try { Transport.send(oMess); }
- catch (Exception e)
- { EsbUtil.getDefaultLogger(this.getClass()).error("Send Mail Failed",e);
- throw e;
- }
- } //__________________________________
+ /**
+ * Add the message addressing information to the message.
+ * @param p_oMessageParms <a href="p_oMessageParms">Message parameters.</a>.
+ * @param oMessage The message.
+ * @throws AddressException
+ * @throws MessagingException
+ */
+ private void addMessageAddressing(DomElement p_oMessageParms, MimeMessage oMessage) throws AddressException, MessagingException {
+ String sFrom = p_oMessageParms.getAttr(FROM);
+ InternetAddress oFrom = new InternetAddress(sFrom);
+
+ oMessage.setFrom(oFrom);
+ oMessage.setReplyTo(new Address[] { oFrom });
+ InternetAddress[] oaTo =
+ InternetAddress.parse(p_oMessageParms.getAttr(SENDTO));
+
+ for (int i1 = 0; i1 < oaTo.length; i1++) {
+ oMessage.addRecipient(MimeMessage.RecipientType.TO, oaTo[i1]);
+ }
+
+ String sCopyToAddress = (String) p_oMessageParms.getAttr(COPYTO);
+ if (null != sCopyToAddress) {
+ oaTo = InternetAddress.parse(sCopyToAddress);
+ for (int i1 = 0; i1 < oaTo.length; i1++) {
+ oMessage.addRecipient(MimeMessage.RecipientType.CC, oaTo[i1]);
+ }
+ }
+ }
- private class MyAuth extends Authenticator
- { private String m_sUser, m_sPwd;
- private MyAuth(String p_sU, String p_sP)
- { m_sUser = p_sU; m_sPwd = p_sP; }
- protected PasswordAuthentication getPasswordAuthentication()
- { return new PasswordAuthentication(m_sUser,m_sPwd);
- } //________________________________
- } //______________________________________________________
+ /**
+ * Add the message Subject to the message.
+ * @param p_oMessageParms <a href="p_oMessageParms">Message parameters.</a>.
+ * @param oMessage The message.
+ * @throws MessagingException
+ */
+ private void addMessageSubject(DomElement p_oMessageParms, MimeMessage oMessage) throws MessagingException {
+ String sSubject = (String) p_oMessageParms.getAttr(SUBJECT);
-} //____________________________________________________________________________
+ if (null != sSubject) {
+ oMessage.setSubject(sSubject);
+ }
+ }
+ /**
+ * Add the message content (body, attachments etc) to from the
+ * message parameters to the message.
+ * @param p_oMessageParms <a href="p_oMessageParms">Message parameters.</a>.
+ * @param oMessage The message.
+ * @throws MessagingException
+ */
+ private void addMessageContent(DomElement p_oMessageParms, MimeMessage oMessage) throws MessagingException {
+ BodyPart oBodyP = new MimeBodyPart();
+ Multipart oMultiP = new MimeMultipart();
+
+ oMultiP.addBodyPart(oBodyP);
+ oMessage.setContent(oMultiP);
+ String sBodyPartText = p_oMessageParms.getAttr(MESSAGE);
+ if (null == sBodyPartText) {
+ sBodyPartText = "";
+ }
+ oBodyP.setText(sBodyPartText + "\n");
+
+ String[] saFn = p_oMessageParms.getTextChildren(ATTACH);
+ for (int i1 = 0; i1 < saFn.length; i1++) {
+ oMultiP.addBodyPart(oBodyP = new MimeBodyPart());
+ String sFile = saFn[i1];
+ oBodyP.setDataHandler(new DataHandler(new FileDataSource(sFile)));
+ oBodyP.setFileName(sFile.substring(1 + sFile.lastIndexOf("\\")));
+ }
+ }
+
+ /**
+ * Initialise an authenticated {@link javax.mail.Session} with the mail server.
+ * @return The {@link javax.mail.Session}.
+ */
+ private Session initMailServerSession() {
+ Authenticator oAuth = null;
+ String sSmtpUser = EsbSysProps.getSmtpUsername();
+
+ if (null != sSmtpUser) {
+ oAuth = new MyAuth(sSmtpUser, EsbSysProps.getSmtpPassword());
+ }
+
+ Properties oMailP = new Properties();
+ oMailP.setProperty("mail.smtp.host", EsbSysProps.getSmtpHost());
+ try {
+ String sPort = EsbSysProps.getSmtpPort();
+ Integer.parseInt(sPort);
+ oMailP.setProperty("mail.smtp.port", sPort);
+ } catch (Exception e) { /* OK just leave standard port */
+ }
+ javax.mail.Session oMailSess =
+ javax.mail.Session.getDefaultInstance(oMailP, oAuth);
+ return oMailSess;
+ }
+
+ private class MyAuth extends Authenticator {
+ private String m_sUser, m_sPwd;
+
+ private MyAuth(String p_sU, String p_sP) {
+ m_sUser = p_sU;
+ m_sPwd = p_sP;
+ }
+
+ protected PasswordAuthentication getPasswordAuthentication() {
+ return new PasswordAuthentication(m_sUser, m_sPwd);
+ } // ________________________________
+ } // ______________________________________________________
+
+} // ____________________________________________________________________________
+
Modified: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/helpers/KeyValuePair.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/helpers/KeyValuePair.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/helpers/KeyValuePair.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,45 +1,56 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.soa.esb.helpers;
import java.io.Serializable;
-public class KeyValuePair implements Serializable
-{
+public class KeyValuePair implements Serializable {
private static final long serialVersionUID = 1L;
private String mKey, mVal;
- public KeyValuePair(String pKey, String pVal)
- { mKey = pKey; mVal = pVal; }
- public String getKey() { return mKey; }
- public String getValue() { return mVal; }
- public String setKey(String arg0)
- {String sRet = mKey; mKey = arg0.toString(); return sRet; }
- public String setValue(String arg0)
- {String sRet = mVal; mVal = arg0.toString(); return sRet; }
- public String toString()
- { return mVal; }
- public String dump()
- { return "KVpair["+mKey+"="+mVal+"]"; }
-} //____________________________________________________________________________
+ public KeyValuePair(String pKey, String pVal) {
+ if(pKey == null || pKey.trim().equals("")) {
+ throw new IllegalArgumentException("null or empty 'pKey' arg in call.");
+ }
+
+ mKey = pKey;
+ mVal = pVal;
+ }
+
+ public String getKey() {
+ return mKey;
+ }
+
+ public String getValue() {
+ return mVal;
+ }
+
+ public String toString() {
+ return mVal;
+ }
+
+ public String dump() {
+ return "KVpair[" + mKey + "=" + mVal + "]";
+ }
+} // ____________________________________________________________________________
Deleted: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/helpers/NormalizedDate.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/helpers/NormalizedDate.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/helpers/NormalizedDate.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,99 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.soa.esb.helpers;
-
-import java.util.*;
-import java.text.*;
-
- at SuppressWarnings("serial")
-public class NormalizedDate extends Date
-{
- public static final long NULL = -5361913154553L; // "1800 01 01"
-
- private static SimpleDateFormat s_odf = new SimpleDateFormat("yyyyMMdd");
-
- public NormalizedDate() { super(System.currentTimeMillis()); }
- public NormalizedDate(Date p_oD) { super(p_oD.getTime()); }
- public NormalizedDate(String p_s) throws Exception
- { super (s_odf.parse(p_s).getTime());
- } //__________________________________
- public NormalizedDate(String p_s,String p_sFormat) throws Exception
- { super (new SimpleDateFormat(p_sFormat).parse(p_s).getTime());
- } //__________________________________
-
- public String toString()
- { return (this.isNull()) ? "" : s_odf.format(this);
- } //__________________________________
- public boolean isNull()
- { return this.getTime()<=NULL;
- } //__________________________________
-
- public static String toString(Date p_oD) { return s_odf.format(p_oD); }
- public static String toString(long p_oL) { return s_odf.format(new Date(p_oL)); }
- public static NormalizedDate getNull() { return new NormalizedDate(new Date(NULL)); }
-
- static final Exception s_oInv = new Exception("Invalid Date");
-
- public String dateToString()
- {
- return NormalizedDate.dateToString(this,"dd/MM/yyyy");
- }
-
- public static String dateToString(NormalizedDate p_o,String p_sFmt)
- { return (null == p_o)?"":new SimpleDateFormat(p_sFmt).format(p_o); }
-
- public static NormalizedDate parseDate (String p_s) throws Exception
- { Calendar oCal = Calendar.getInstance();
- StringTokenizer ST = new StringTokenizer(p_s,"/");
- if (ST.countTokens() < 2)
- { StringBuffer sb = new StringBuffer(p_s);
- if (sb.length()<6)sb.append(" ");
- sb.insert(2,"/").insert(5,"/");
- ST = new StringTokenizer(sb.toString(),"/");
- }
- try
- { int iDay = Integer.parseInt(ST.nextToken());
- int iMonth = Integer.parseInt(ST.nextToken());
- int iYr = Integer.parseInt(ST.nextToken());
- iYr = (iYr < 20) ? 2000 + iYr
- : (iYr < 100)? 1900 + iYr
- : iYr;
-// if (iYr < 1920 || iYr > 2010) throw s_oInv;
- if (iMonth < 1 || iMonth > 12) throw s_oInv;
- if (iDay < 1) throw s_oInv;
- oCal.set(iYr,iMonth-1,1);
- if (iDay > oCal.getActualMaximum(Calendar.DAY_OF_MONTH)) throw s_oInv;
- oCal.set(iYr,iMonth-1,iDay);
- return new NormalizedDate(oCal.getTime());
- }
- catch (Exception pe) { throw s_oInv; }
- } //_______________________________________________
-
- public static long todayMillis()
- { Calendar oCal = Calendar.getInstance();
- oCal.set(Calendar.HOUR_OF_DAY,0);
- oCal.set(Calendar.MINUTE,0);
- oCal.set(Calendar.SECOND,0);
- oCal.set(Calendar.MILLISECOND,0);
- return oCal.getTimeInMillis();
- } //__________________________________
-} //____________________________________________________________________________
Modified: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/helpers/persist/JdbcCleanConn.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/helpers/persist/JdbcCleanConn.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/helpers/persist/JdbcCleanConn.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,24 +1,24 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.soa.esb.helpers.persist;
@@ -28,107 +28,131 @@
import org.apache.log4j.*;
-public class JdbcCleanConn
-{
- private DataSource m_oDS=null;
- private Connection m_conn=null;
- protected List<PreparedStatement> m_olPrepSt
- = new ArrayList<PreparedStatement>();
- protected Logger m_oLogger;
+public class JdbcCleanConn {
+ private DataSource m_oDS = null;
- public JdbcCleanConn(DataSource p_oDS) throws Exception
- { m_oDS = p_oDS;
- m_oLogger = Logger.getLogger(this.getClass());
- }
+ private Connection m_conn = null;
- public void commit () throws Exception { if (null != m_conn)m_conn.commit(); }
- public void rollback () throws Exception { if (null != m_conn)m_conn.rollback(); }
+ protected List<PreparedStatement> m_olPrepSt = new ArrayList<PreparedStatement>();
- public void release()
- { if (null != m_conn)
- { try { m_conn.rollback(); }
- catch (Exception eRoll) {}
+ protected Logger m_oLogger;
- for (PreparedStatement PS : m_olPrepSt)
- try { PS.close(); } catch (Exception e) {}
- try { m_conn.close(); }
- catch (Exception e1) {}
- }
- m_olPrepSt.clear();
- m_conn = null;
- } //__________________________________
+ public JdbcCleanConn(DataSource p_oDS) throws Exception {
+ m_oDS = p_oDS;
+ m_oLogger = Logger.getLogger(this.getClass());
+ }
- public PreparedStatement prepareStatement (String p_sSt, int p_i1, int p_i2)
- throws Exception
- {
- if (null == m_conn) connect();
- PreparedStatement PS = m_conn.prepareStatement(p_sSt, p_i1, p_i2);
- m_olPrepSt.add(PS);
- return PS;
- } //__________________________________
+ public void commit() throws Exception {
+ if (null != m_conn)
+ m_conn.commit();
+ }
- public PreparedStatement prepareStatement (String p_sSt) throws Exception
- {
- if (null == m_conn) connect();
- PreparedStatement PS = m_conn.prepareStatement(p_sSt);
- m_olPrepSt.add(PS);
- return PS;
- } //__________________________________
+ public void rollback() throws Exception {
+ if (null != m_conn)
+ m_conn.rollback();
+ }
- public ResultSet execQueryWait(PreparedStatement p_PS, int p_iQtry)
- throws Exception
- {
- Exception eRet=null;
- int iQtry = (p_iQtry<1) ? 1 : (p_iQtry < 50) ? p_iQtry : 50;
- for (int i1=0; i1<iQtry; i1++)
- { try { return p_PS.executeQuery(); }
- catch (Exception e)
- { if (null==eRet) eRet = new Exception(e.getMessage());
-// System.out.println("Retrying "+i1);
- Thread.sleep(100+(new Double(100*Math.random())).longValue());
- }
- }
- m_oLogger.error("execQueryWait() FAILED",eRet);
- throw eRet;
- } //__________________________________
+ public void release() {
+ if (null != m_conn) {
+ try {
+ m_conn.rollback();
+ } catch (Exception eRoll) {
+ }
- public void execUpdWait(PreparedStatement p_PS, int p_iQtry)
- throws Exception
- {
- Exception eRet=null;
- int iQtry = (p_iQtry<1) ? 1 : (p_iQtry < 50) ? p_iQtry : 50;
- for (int i1=0; i1<iQtry; i1++)
- { try { p_PS.executeUpdate(); return; }
- catch (Exception e)
- { if (null==eRet) eRet = new Exception(e.getMessage());
-// System.out.println("Retrying "+i1);
- Thread.sleep(100+(new Double(100*Math.random())).longValue());
- }
- }
- m_oLogger.error("execUpdWait() FAILED",eRet);
- throw eRet;
- } //__________________________________
+ for (PreparedStatement PS : m_olPrepSt)
+ try {
+ PS.close();
+ } catch (Exception e) {
+ }
+ try {
+ m_conn.close();
+ } catch (Exception e1) {
+ }
+ }
+ m_olPrepSt.clear();
+ m_conn = null;
+ } // __________________________________
- private void connect() throws Exception
- {
- Exception eRet = null;
- for (int i1=0; i1<5; i1++)
- { try { m_conn = m_oDS.getConnection(); eRet = null; break; }
- catch (Exception e)
- { if (null==eRet) eRet = new Exception(e.getMessage());
- System.out.println("Connecting "+i1);
- Thread.sleep(2000+(new Double(100*Math.random())).longValue());
- }
- }
- if (null != eRet)
- { m_oLogger.error("connect() FAILED",eRet);
- throw eRet;
- }
- m_conn.setAutoCommit(false);
- m_conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
+ public PreparedStatement prepareStatement(String p_sSt, int p_i1, int p_i2)
+ throws Exception {
+ if (null == m_conn)
+ connect();
+ PreparedStatement PS = m_conn.prepareStatement(p_sSt, p_i1, p_i2);
+ m_olPrepSt.add(PS);
+ return PS;
+ } // __________________________________
- m_olPrepSt.clear();
+ public PreparedStatement prepareStatement(String p_sSt) throws Exception {
+ if (null == m_conn)
+ connect();
+ PreparedStatement PS = m_conn.prepareStatement(p_sSt);
+ m_olPrepSt.add(PS);
+ return PS;
+ } // __________________________________
- } //__________________________________
+ public ResultSet execQueryWait(PreparedStatement p_PS, int p_iQtry)
+ throws Exception {
+ Exception eRet = null;
+ int iQtry = (p_iQtry < 1) ? 1 : (p_iQtry < 50) ? p_iQtry : 50;
+ for (int i1 = 0; i1 < iQtry; i1++) {
+ try {
+ return p_PS.executeQuery();
+ } catch (Exception e) {
+ if (null == eRet)
+ eRet = new Exception(e.getMessage());
+ // System.out.println("Retrying "+i1);
+ Thread.sleep(100 + (new Double(100 * Math.random()))
+ .longValue());
+ }
+ }
+ m_oLogger.error("execQueryWait() FAILED", eRet);
+ throw eRet;
+ } // __________________________________
-} //____________________________________________________________________________
+ public void execUpdWait(PreparedStatement p_PS, int p_iQtry)
+ throws Exception {
+ Exception eRet = null;
+ int iQtry = (p_iQtry < 1) ? 1 : (p_iQtry < 50) ? p_iQtry : 50;
+ for (int i1 = 0; i1 < iQtry; i1++) {
+ try {
+ p_PS.executeUpdate();
+ return;
+ } catch (Exception e) {
+ if (null == eRet)
+ eRet = new Exception(e.getMessage());
+ // System.out.println("Retrying "+i1);
+ Thread.sleep(100 + (new Double(100 * Math.random()))
+ .longValue());
+ }
+ }
+ m_oLogger.error("execUpdWait() FAILED", eRet);
+ throw eRet;
+ } // __________________________________
+
+ private void connect() throws Exception {
+ Exception eRet = null;
+ for (int i1 = 0; i1 < 5; i1++) {
+ try {
+ m_conn = m_oDS.getConnection();
+ eRet = null;
+ break;
+ } catch (Exception e) {
+ if (null == eRet)
+ eRet = new Exception(e.getMessage());
+ System.out.println("Connecting " + i1);
+ Thread.sleep(2000 + (new Double(100 * Math.random()))
+ .longValue());
+ }
+ }
+ if (null != eRet) {
+ m_oLogger.error("connect() FAILED", eRet);
+ throw eRet;
+ }
+ m_conn.setAutoCommit(false);
+ m_conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
+
+ m_olPrepSt.clear();
+
+ } // __________________________________
+
+} // ____________________________________________________________________________
Modified: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/MacroExpander.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/MacroExpander.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/MacroExpander.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,73 +1,75 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
-
package org.jboss.soa.esb.notification;
import java.util.*;
import org.jboss.soa.esb.helpers.*;
-public class MacroExpander
-{
- private static final String CTX_PREFIX = "@@ctx@@";
- public static final String CTX_BATCH_UID = CTX_PREFIX+"batchUid";
- public static final String CTX_BATCH_NUM = CTX_PREFIX+"batchNum";
- public static final String CTX_INPUT_FILE = CTX_PREFIX+"inputFile";
- public static final String CTX_POST_FILE = CTX_PREFIX+"postFile";
+public class MacroExpander {
+ private static final String CTX_PREFIX = "@@ctx@@";
- private static final String[] s_saMacros =
- {CTX_BATCH_UID, CTX_BATCH_NUM ,CTX_INPUT_FILE, CTX_POST_FILE };
+ public static final String CTX_BATCH_UID = CTX_PREFIX + "batchUid";
+ public static final String CTX_BATCH_NUM = CTX_PREFIX + "batchNum";
- public void replaceMacros(DomElement p_oParm, Map p_oMap)
- {
- String[] saAtt = p_oParm.getAttrKeys();
- for (int i1 = 0; i1 < saAtt.length; i1++)
- {
- String sKey = saAtt[i1];
- String sVal = p_oParm.getAttr(sKey);
+ public static final String CTX_INPUT_FILE = CTX_PREFIX + "inputFile";
- boolean bSubst = false;
- int iWh = 0;
- int iPos = 0;
- while (0 <= (iPos = sVal.indexOf(CTX_PREFIX, iWh)))
- {
- String sRest = sVal.substring(iPos);
- for (int i2 = 0; i2 < s_saMacros.length; i2++)
- {
- String sMac = s_saMacros[i2];
- if (!sRest.startsWith(sMac))continue;
- Object oRpl = (null != p_oMap) ? p_oMap.get(sMac) : null;
- if (null == oRpl)continue;
- bSubst = true;
- sVal = sVal.substring(0, iPos)
- + oRpl.toString() + sVal.substring(iPos + sMac.length());
- }
- }
- if (bSubst) p_oParm.setAttr(sKey, sVal);
- }
- DomElement[] oaChilds = p_oParm.getAllElemChildren();
- for (int i1 = 0; i1 < oaChilds.length; i1++)
- replaceMacros(oaChilds[i1], p_oMap);
- } //_________________________
+ public static final String CTX_POST_FILE = CTX_PREFIX + "postFile";
+
+ private static final String[] s_saMacros = { CTX_BATCH_UID, CTX_BATCH_NUM,
+ CTX_INPUT_FILE, CTX_POST_FILE };
+
+ public static void replaceMacros(DomElement p_oParm, Map p_oMap) {
+ String[] saAtt = p_oParm.getAttrKeys();
+
+ for (int i1 = 0; i1 < saAtt.length; i1++) {
+ String sKey = saAtt[i1];
+ String sVal = p_oParm.getAttr(sKey);
+ boolean bSubst = false;
+ int iWh = 0;
+ int iPos = 0;
+
+ while (0 <= (iPos = sVal.indexOf(CTX_PREFIX, iWh))) {
+ String sRest = sVal.substring(iPos);
+ for (int i2 = 0; i2 < s_saMacros.length; i2++) {
+ String sMac = s_saMacros[i2];
+ if (!sRest.startsWith(sMac))
+ continue;
+ Object oRpl = (null != p_oMap) ? p_oMap.get(sMac) : null;
+ if (null == oRpl)
+ continue;
+ bSubst = true;
+ sVal = sVal.substring(0, iPos) + oRpl.toString()
+ + sVal.substring(iPos + sMac.length());
+ }
+ }
+ if (bSubst)
+ p_oParm.setAttr(sKey, sVal);
+ }
+ DomElement[] oaChilds = p_oParm.getAllElemChildren();
+ for (int i1 = 0; i1 < oaChilds.length; i1++) {
+ replaceMacros(oaChilds[i1], p_oMap);
+ }
+ } // _________________________
}
Modified: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/NotificationList.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/NotificationList.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/NotificationList.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,105 +1,131 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
-
package org.jboss.soa.esb.notification;
import org.jboss.soa.esb.helpers.*;
+import java.io.Serializable;
/**
- * Holds lists of NotificationTarget objects so that the JbossEsbNotificationHandler
- * EJB behaviour can be controlled at runtime by client applications
- * <p>Description: Objects of this class will hold a list of objects that
- * extend the NotificationTarget base class. It's main purpose is to allow
- * Rosetta users to configure lists of recipients of specific events, and request
- * the JbossEsbNotificationHandler EJB to take care of triggering the events to
- * each object specified as a child "target" element
+ * Holds lists of NotificationTarget objects so that the
+ * JbossEsbNotificationHandler EJB behaviour can be controlled at runtime by
+ * client applications
+ * <p>
+ * Description: Objects of this class will hold a list of objects that extend
+ * the NotificationTarget base class. It's main purpose is to allow Rosetta
+ * users to configure lists of recipients of specific events, and request the
+ * JbossEsbNotificationHandler EJB to take care of triggering the events to each
+ * object specified as a child "target" element
* </p>
- * <p>Author: Heuristica - Buenos Aires - Argentina</p>
+ * <p>
+ * Author: Heuristica - Buenos Aires - Argentina
+ * </p>
+ *
* @version 1.0
*/
-public class NotificationList extends DomElement
-{
- /**
- * Mnemonic name for the XML element name for the serialized form of objects
- * of this class
- */
- public static final String ELEMENT = "NotificationList";
- public static final String TYPE = "type";
- public static final String CHILD_TGT = "target";
+public class NotificationList extends DomElement {
+ /**
+ * Mnemonic name for the XML element name for the serialized form of objects
+ * of this class
+ */
+ public static final String ELEMENT = "NotificationList";
- private String m_sType;
- /**
- * Instantiate an object according to the contents of <arg 1>
- * @param p_oP DomElement - Parameter object containing the information
- * needed to instantiate this object, including child elements named "target"
- * that represent each individual NotificationTarget object
- * @throws Exception - the getMessage() of the Exception explains the problem
- */
- public NotificationList(DomElement p_oP) throws Exception
- { super(p_oP);
- m_sType = p_oP.getAttr(TYPE);
- if (null!=m_sType) m_sType = m_sType.toLowerCase();
- } //__________________________________
+ public static final String TYPE = "type";
- private NotificationTarget[] getTargets() throws Exception
- { DomElement[] oaTgts = super.getElementChildren(CHILD_TGT);
- NotificationTarget[] oaRet = new NotificationTarget[oaTgts.length];
- for (int i1=0; i1<oaRet.length;i1++)
- oaRet[i1] = NotificationTarget.fromParams(oaTgts[i1]);
+ public static final String CHILD_TGT = "target";
- return oaRet;
- } //__________________________________
- /**
- * Invoke the sendNotification() method for all targets in the list. The method
- * iterates along it's NotificationTarget child nodes and invokes the sendNotification()
- * method with the same object to all of them
- * @param p_o Object - The event to notify to all targets
- * @throws Exception - use Exception.getMessage() at runtime
- */
- public void sendNotification(Object p_o) throws Exception
- { NotificationTarget[] oaTgt = getTargets();
- for (int i1=0; i1<oaTgt.length; i1++)
- oaTgt[i1].sendNotification(p_o);
- } //__________________________________
- /**
- * Is this an OK (success) NotificationList ?
- * @return boolean - Yes, Attribute "type" of constructor parameters starts with "ok",
- * OR there was no "type" attribute in the constructor
- * <li>A NotificationList can be both OK and Error if no "type" attribute
- * was specified at constructor time in the DomElement argument</li>
- * @see DomElement#getAttr(String)
- */
- public boolean isOK()
- { return (null==m_sType) ? true : m_sType.startsWith("ok"); }
- /**
- * Is this an Error (failure) NotificationList ?
- * @return boolean - Yes, Attribute "type" of constructor parameters starts with "err",
- * OR there was no "type" attribute in the constructor
- * <li>A NotificationList can be both OK and Error if no "type" attribute
- * was specified at constructor time in the DomElement argument</li>
- * @see DomElement#getAttr(String)
- */
- public boolean isErr()
- { return (null==m_sType) ? true : m_sType.startsWith("err"); }
+ private String m_sType;
-} //____________________________________________________________________________
+ /**
+ * Instantiate an object according to the contents of <arg 1>
+ *
+ * @param p_oP
+ * DomElement - Parameter object containing the information
+ * needed to instantiate this object, including child elements
+ * named "target" that represent each individual
+ * NotificationTarget object
+ * @throws Exception -
+ * the getMessage() of the Exception explains the problem
+ */
+ public NotificationList(DomElement p_oP) throws Exception {
+ super(p_oP);
+ m_sType = p_oP.getAttr(TYPE);
+ if (null != m_sType)
+ m_sType = m_sType.toLowerCase();
+ } // __________________________________
+
+ private NotificationTarget[] getTargets() throws Exception {
+ DomElement[] oaTgts = super.getElementChildren(CHILD_TGT);
+ NotificationTarget[] oaRet = new NotificationTarget[oaTgts.length];
+ for (int i1 = 0; i1 < oaRet.length; i1++)
+ oaRet[i1] = NotificationTarget.fromParams(oaTgts[i1]);
+
+ return oaRet;
+ } // __________________________________
+
+ /**
+ * Invoke the sendNotification() method for all targets in the list. The
+ * method iterates along it's NotificationTarget child nodes and invokes the
+ * sendNotification() method with the same object to all of them
+ *
+ * @param p_o
+ * Object - The event to notify to all targets
+ * @throws Exception -
+ * use Exception.getMessage() at runtime
+ */
+ public void sendNotification(Serializable p_o) throws Exception {
+ NotificationTarget[] oaTgt = getTargets();
+
+ for (int i1 = 0; i1 < oaTgt.length; i1++) {
+ oaTgt[i1].sendNotification(p_o);
+ }
+ } // __________________________________
+
+ /**
+ * Is this an OK (success) NotificationList ?
+ *
+ * @return boolean - Yes, Attribute "type" of constructor parameters starts
+ * with "ok", OR there was no "type" attribute in the constructor
+ * <li>A NotificationList can be both OK and Error if no "type"
+ * attribute was specified at constructor time in the DomElement
+ * argument</li>
+ * @see DomElement#getAttr(String)
+ */
+ public boolean isOK() {
+ return (null == m_sType) ? true : m_sType.startsWith("ok");
+ }
+
+ /**
+ * Is this an Error (failure) NotificationList ?
+ *
+ * @return boolean - Yes, Attribute "type" of constructor parameters starts
+ * with "err", OR there was no "type" attribute in the constructor
+ * <li>A NotificationList can be both OK and Error if no "type"
+ * attribute was specified at constructor time in the DomElement
+ * argument</li>
+ * @see DomElement#getAttr(String)
+ */
+ public boolean isErr() {
+ return (null == m_sType) ? true : m_sType.startsWith("err");
+ }
+
+} // ____________________________________________________________________________
Modified: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/NotificationTarget.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/NotificationTarget.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/NotificationTarget.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -43,7 +43,7 @@
* @throws Exception - invoke Exception.getMessage() at runtime for this object
* @see DomElement
*/
- public abstract void sendNotification(Object p_o) throws Exception;
+ public abstract void sendNotification(java.io.Serializable p_o) throws Exception;
private static final String NOTIF_PFX = "org.jboss.soa.esb.notification";
Modified: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/NotifyEmail.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/NotifyEmail.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/NotifyEmail.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,36 +1,43 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
-
package org.jboss.soa.esb.notification;
+import java.io.Serializable;
+
import javax.mail.internet.*;
import org.jboss.soa.esb.helpers.*;
+import org.jboss.soa.esb.util.EsbUtil;
/**
* This class will send an e-mail using the EsbEmail class
- * <p>Description: </p>
- * <p>Author: Heuristica - Buenos Aires - Argentina</p>
+ * <p>
+ * Description:
+ * </p>
+ * <p>
+ * Author: Heuristica - Buenos Aires - Argentina
+ * </p>
+ *
* @version 1.0
*/
public class NotifyEmail extends NotificationTarget
@@ -39,18 +46,19 @@
* Instantiate a NotifyEmail object using the information contained in <arg 1>
* @param p_oP DomElement - See attributes and structure needed for the
* EsbEmail(DomElement) constructor - The MESSAGE attribute will be filled
- * in at sendNotification(Object) time
+ * in at sendNotification(Serializable) time
* @throws Exception
* @see EsbEmail#EsbEmail(DomElement)
- * @see NotifyEmail#sendNotification(Object)
+ * @see NotifyEmail#sendNotification(Serializable)
*/
public NotifyEmail(DomElement p_oP) throws Exception
{ super (p_oP);
- String sAtt = (String)m_oParms.getAttr(EsbEmail.FROM);
- if (null != sAtt) InternetAddress.parse(sAtt);
+ String sAtt = (String) m_oParms.getAttr(EsbEmail.FROM);
+ if (null != sAtt)
+ InternetAddress.parse(sAtt);
- InternetAddress.parse(m_oParms.getAttr(EsbEmail.SENDTO));
+ InternetAddress.parse(m_oParms.getAttr(EsbEmail.SENDTO));
sAtt = (String)m_oParms.getAttr(EsbEmail.COPYTO);
if (null != sAtt) InternetAddress.parse(sAtt);
@@ -61,7 +69,7 @@
* @param p_o Object - This object's toString() method will supply contents
* of mail message
*/
- public void sendNotification(Object p_o)
+ public void sendNotification(Serializable p_o)
{ try
{ DomElement oP = m_oParms.cloneObj();
String sMsg = oP.getAttr(EsbEmail.MESSAGE);
@@ -69,10 +77,15 @@
// HB added line for debugging
//System.out.println("Sending Email Notification ->" +sMsg );
- oP.setAttr(EsbEmail.MESSAGE,sMsg);
- new EsbEmail(oP);
- }
- catch (Exception e) { e.printStackTrace();}
- } //__________________________________
+ oP.setAttr(EsbEmail.MESSAGE, sMsg);
+ EsbEmail esbMail = new EsbEmail(oP);
+ esbMail.sendMessage();
+ }
+ catch (Exception e)
+ {
+ EsbUtil.getDefaultLogger(this.getClass()).error("Send Mail Failed", e);
+ e.printStackTrace();
+ }
+ } // __________________________________
-} //____________________________________________________________________________
+} // ____________________________________________________________________________
Modified: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/NotifyFiles.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/NotifyFiles.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/NotifyFiles.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -95,27 +95,50 @@
}
} //__________________________________
/**
- * Writes the result of p_o.toString() into each one of the File objects
+ * Writes the result of p_o into each one of the File objects
* contained in the m_oaOutF array
* @param p_o Object - This object's toString() results will be written to
* (appended to) each one of the files in m_oaOutF
* @see NotifyFiles#setFiles(DomElement[])
* @see NotifyFiles#m_oaOutF
*/
- public void sendNotification(Object p_o)
- { FileOutputStream OS = null;
- int iCurr = 0;
+ public void sendNotification(Serializable p_o)
+ {
+ FileOutputStream OS = null;
+ int iCurr = 0;
for (File oCurr : m_oaOutF)
{ try
{
OS = new FileOutputStream(oCurr,m_baAppend[iCurr++]);
- OS.write(p_o.toString().getBytes());
- OS.write("\n".getBytes());
- OS.close();
+ if (p_o instanceof String)
+ stringNotification(OS,(String)p_o);
+ else
+ objectNotification(OS,p_o);
}
- catch (Exception e) { continue; }
- finally { try { OS.close();} catch (Exception eCl) {} }
+ catch (Exception e) { /* We do nothing here for the time being */ }
+ finally
+ { try { OS.close(); }
+ catch (Exception eCl) {/* Unable to Close - What could we do */ }
+ }
}
} //__________________________________
+ private void stringNotification(FileOutputStream p_oF,String p_s)
+ { try
+ {
+ p_oF.write(p_s.getBytes());
+ if (!p_s.endsWith("\n"))
+ p_oF.write("\n".getBytes());
+ }
+ catch (Exception e) { /* We do nothing here for the time being */ }
+ } //__________________________________
+
+ private void objectNotification(FileOutputStream p_oF,Object p_o)
+ { try
+ { ObjectOutputStream OS = new ObjectOutputStream(p_oF);
+ OS.writeObject(p_o);
+ }
+ catch (Exception e) { /* We do nothing here for the time being */ }
+ } //__________________________________
+
} //____________________________________________________________________________
Modified: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/NotifyJMS.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/NotifyJMS.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/NotifyJMS.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -23,6 +23,7 @@
package org.jboss.soa.esb.notification;
+import java.io.Serializable;
import java.util.*;
import javax.jms.*;
import javax.naming.*;
@@ -124,15 +125,19 @@
try { m_oConn.close(); } catch (Exception e2) {}
} //__________________________________
/**
- * Send a JMS message using p_o.toString() to fill in the message text
+ * Send a JMS message using p_o to fill in the message content
* and the list of message properties that will be added to the JMS
* message header fields
- * @param p_o Object - This object's toString() method will supply contents
- * of JMS message
+ * @param p_o Object - This object or thie object's toString() method
+ * will supply contents of JMS message
* @see NotifyJMS#CHILD_MSG_PROP
*/
- public void sendNotification(Object p_o) throws Exception
- { Message oMsg = m_oSess.createTextMessage(p_o.toString());
+ public void sendNotification(Serializable p_o) throws Exception
+ { Message oMsg = null;
+ if (p_o instanceof String)
+ oMsg = m_oSess.createTextMessage(p_o.toString());
+ else
+ oMsg = m_oSess.createObjectMessage((Serializable)p_o);
for (Iterator II=m_oProps.keySet().iterator(); II.hasNext(); )
{ String sKey = (String)II.next();
String sVal = m_oProps.getProperty(sKey);
Modified: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/NotifySqlTable.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/NotifySqlTable.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/NotifySqlTable.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -89,7 +89,7 @@
return sbCol.append(")").append(sbPrm).append(")").toString();
} //__________________________________
- public void sendNotification(Object p_o)
+ public void sendNotification(java.io.Serializable p_o)
{ m_oCols.setProperty(m_sDataCol,p_o.toString());
JdbcCleanConn oConn = null;
try
Modified: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/NotifyUtil.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/NotifyUtil.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/notification/NotifyUtil.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,26 +1,25 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
-
package org.jboss.soa.esb.notification;
import java.io.*;
@@ -29,52 +28,52 @@
import org.jboss.soa.esb.helpers.*;
import org.jboss.soa.esb.services.*;
-public class NotifyUtil
-{
+public class NotifyUtil {
- public static void notifyOK(InotificationHandler p_oNH, DomElement p_oParent
- , Object p_o, Map p_oCtx)
- { try
- { String sMsg = p_o.toString();
- DomElement[] oaP = p_oParent.getElementChildren(NotificationList.ELEMENT);
- for (int i1=0; i1<oaP.length;i1++)
- { NotificationList oCurr = new NotificationList(oaP[i1]);
- if (! oCurr.isOK()) continue;
- DomElement oCpy = oaP[i1].cloneObj();
- new MacroExpander().replaceMacros(oCpy, p_oCtx);
- p_oNH.sendNotifications(oCpy,sMsg);
- }
- }
- catch (Exception e)
- {
- e.printStackTrace(System.out);
- }
- } //__________________________________
+ public static void notifyOK(InotificationHandler p_oNH,
+ DomElement p_oParent, Serializable p_o, Map p_oCtx) {
+ try {
+ DomElement[] oaP = p_oParent
+ .getElementChildren(NotificationList.ELEMENT);
+ for (int i1 = 0; i1 < oaP.length; i1++) {
+ NotificationList oCurr = new NotificationList(oaP[i1]);
+ if (!oCurr.isOK())
+ continue;
+ DomElement oCpy = oaP[i1].cloneObj();
+ MacroExpander.replaceMacros(oCpy, p_oCtx);
+ p_oNH.sendNotifications(oCpy, p_o);
+ }
+ } catch (Exception e) {
+ e.printStackTrace(System.out);
+ }
+ } // __________________________________
- public static void notifyError(InotificationHandler p_oNH, DomElement p_oParent
- , Object p_o, Map p_oCtx, Exception p_e)
- { ByteArrayOutputStream oBO = new ByteArrayOutputStream();
- PrintStream oPS = new PrintStream(oBO);
- try
- { oPS.println(p_o.toString());
- if (null != p_e) p_e.printStackTrace(oPS);
- oPS.close();
+ public static void notifyError(InotificationHandler p_oNH,
+ DomElement p_oParent, Object p_o, Map p_oCtx, Exception p_e) {
+ ByteArrayOutputStream oBO = new ByteArrayOutputStream();
+ PrintStream oPS = new PrintStream(oBO);
+ try {
+ oPS.println(p_o.toString());
+ if (null != p_e)
+ p_e.printStackTrace(oPS);
+ oPS.close();
- String sMsg = oBO.toString();
- DomElement[] oaP = p_oParent.getElementChildren(NotificationList.ELEMENT);
- // if (oaP.length<1) // Uncomment this line to send only to the list
- p_oNH.sendNotifications(sMsg);
- for (int i1=0; i1<oaP.length;i1++)
- { NotificationList oCurr = new NotificationList(oaP[i1]);
- if (! oCurr.isErr()) continue;
- new MacroExpander().replaceMacros(oaP[i1], p_oCtx);
- p_oNH.sendNotifications(oaP[i1],sMsg);
- }
- }
- catch (Exception e)
- {
- e.printStackTrace(System.out);
- }
- } //__________________________________
+ String sMsg = oBO.toString();
+ DomElement[] oaP = p_oParent
+ .getElementChildren(NotificationList.ELEMENT);
+ // if (oaP.length<1) // Uncomment this line to send only to the list
+ p_oNH.sendNotifications(sMsg);
+ for (int i1 = 0; i1 < oaP.length; i1++) {
+ NotificationList oCurr = new NotificationList(oaP[i1]);
+ if (!oCurr.isErr()) {
+ continue;
+ }
+ MacroExpander.replaceMacros(oaP[i1], p_oCtx);
+ p_oNH.sendNotifications(oaP[i1], sMsg);
+ }
+ } catch (Exception e) {
+ e.printStackTrace(System.out);
+ }
+ } // __________________________________
-} //____________________________________________________________________________
+} // ____________________________________________________________________________
Modified: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/services/InotificationHandler.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/services/InotificationHandler.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/services/InotificationHandler.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -25,9 +25,10 @@
package org.jboss.soa.esb.services;
import org.jboss.soa.esb.helpers.*;
+import java.io.Serializable;
public interface InotificationHandler
{
- public void sendNotifications (DomElement p_oP, Object p_o) throws Exception;
- public void sendNotifications (Object p_o) throws Exception;
+ public void sendNotifications (DomElement p_oP, Serializable p_o) throws Exception;
+ public void sendNotifications (Serializable p_o) throws Exception;
} //____________________________________________________________________________
Modified: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/util/BaseBusinessObject.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/util/BaseBusinessObject.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/util/BaseBusinessObject.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,257 +1,362 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.soa.esb.util;
import java.util.*;
import java.lang.reflect.*;
-public class BaseBusinessObject
-{
- public BobjStdDTO toDTO() throws Exception { return getBaseDTO(); }
- public String classNm() { return this.getClass().getSimpleName(); }
- public boolean isNull () { return false; }
- public String toString ()
- { try { return this.toDTO().toXml(); }
- catch (Exception e) {return null; }
- } //__________________________________
+public class BaseBusinessObject {
+ public BobjStdDTO toDTO() throws Exception {
+ return getBaseDTO();
+ }
- public String [] locator() { return new String [] {}; }
- public String [] locator(int p_i)
- { return (0==p_i) ? locator() : new String [] {};
- }
- /**
- * Get all locators for a given BaseBusinessObject
- * <p /> Override this method in your class if you have more than 1 locator array
- * @return An array of String arrays containing all locators
- */
- public String[][] allLocators() { return new String[][] {locator()}; }
+ public String classNm() {
+ return this.getClass().getSimpleName();
+ }
- public final ObjLocator getObjLocator() { return getObjLocator(0); }
- public final ObjLocator getObjLocator(int p_i)
- { return new ObjLocator(m_lUid,locator(p_i)); }
+ public boolean isNull() {
+ return false;
+ }
- private enum ATTRIB
- {elem
- ,rol
- };
- enum HIDDEN
- {uid
- ,stamp
- ,type
- ,snap
- ,dtSnap
- ,batch
- };
- private EnumMap<ATTRIB,String>m_oData;
- public String setField(ATTRIB pKey, String pVal)
- { if (null==pKey) return null;
- String sRet = (null==m_oData)? null : m_oData.remove(pKey);
- if (! EsbUtil.isNullString(pVal))
- { if (null==m_oData)
- m_oData = new EnumMap<ATTRIB,String>(ATTRIB.class);
- m_oData.put(pKey,pVal);
+ public String toString() {
+ try {
+ return this.toDTO().toXml();
+ } catch (Exception e) {
+ return null;
+ }
+ } // __________________________________
+
+ public String[] locator() {
+ return new String[] {};
}
- return sRet;
- } //__________________________________
- public String getField(ATTRIB pKey)
- { if (null==pKey) return null;
- if (null==m_oData) return null;
- return m_oData.get(pKey);
- } //__________________________________
+ public String[] locator(int p_i) {
+ return (0 == p_i) ? locator() : new String[] {};
+ }
- private long m_lStamp = -1;
- private long m_lUid = -1;
- private long m_lLastSnap =0;
- private long m_lBatch =0;
- private String m_sDtSnap = null;
- private String m_sPkg = null;
+ /**
+ * Get all locators for a given BaseBusinessObject
+ * <p />
+ * Override this method in your class if you have more than 1 locator array
+ *
+ * @return An array of String arrays containing all locators
+ */
+ public String[][] allLocators() {
+ return new String[][] { locator() };
+ }
- public boolean hasUid () { return m_lUid > 0; }
+ public final ObjLocator getObjLocator() {
+ return getObjLocator(0);
+ }
- public void setElemNm(String p_s){ setField(ATTRIB.elem,p_s); }
- public void setRole(String p_s) { setField(ATTRIB.rol,p_s); }
- public void setStamp (long p_l) { m_lStamp = p_l; }
- public void setUid (long p_l) { m_lUid = p_l; }
- public void setSnap (long p_l) { m_lLastSnap = p_l; }
- public void setBatchNum(long p_l) { m_lBatch = p_l; }
- public void setSnapDate(String p_s) { m_sDtSnap = p_s; }
- public void setPackage()
- { m_sPkg = this.getClass().getPackage().getName(); }
+ public final ObjLocator getObjLocator(int p_i) {
+ return new ObjLocator(m_lUid, locator(p_i));
+ }
- public String getElemNm() { return getField(ATTRIB.elem); }
- public String getRole() { return getField(ATTRIB.rol); }
- public long getStamp() { return m_lStamp; }
- public long getUid () { return m_lUid; }
- public long getSnap () { return m_lLastSnap; }
- public long getBatchNum() { return m_lBatch; }
- public String getSnapDate() { return m_sDtSnap; }
+ private enum ATTRIB {
+ elem, rol
+ };
- public BaseBusinessObject() {this((String)null); }
- protected BaseBusinessObject(String p_sElem) { this(p_sElem,-1); }
- protected BaseBusinessObject(String p_sElem, long p_lUid)
- { setField(ATTRIB.elem,p_sElem);
- m_lUid = p_lUid;
- if (null != getElemNm()) return;
- String sClass = getClass().getSimpleName();
- if (null == p_sElem)
- setField(ATTRIB.elem,sClass);
- } //________________________________
+ enum HIDDEN {
+ uid, stamp, type, snap, dtSnap, batch
+ };
- protected BaseBusinessObject(BobjStdDTO p_oDto) throws Exception
- { this (p_oDto.elementNm());
- if (p_oDto.isList()) return;
- commonFieldsFromDTO(this,p_oDto);
- } //________________________________
+ private EnumMap<ATTRIB, String> m_oData;
- private static final void commonFieldsFromDTO(BaseBusinessObject p_obj,BobjStdDTO p_oDto)
- throws Exception
- { for(ATTRIB oCurr : ATTRIB.values())
- p_obj.setField(oCurr,p_oDto.getAttr(oCurr.toString()));
+ public String setField(ATTRIB pKey, String pVal) {
+ if (null == pKey)
+ return null;
+ String sRet = (null == m_oData) ? null : m_oData.remove(pKey);
+ if (!EsbUtil.isNullString(pVal)) {
+ if (null == m_oData)
+ m_oData = new EnumMap<ATTRIB, String>(ATTRIB.class);
+ m_oData.put(pKey, pVal);
+ }
+ return sRet;
+ } // __________________________________
- String sAux = p_oDto.getAttr(HIDDEN.uid.toString());
- if (null != sAux) p_obj.m_lUid = Long.parseLong(sAux);
+ public String getField(ATTRIB pKey) {
+ if (null == pKey)
+ return null;
+ if (null == m_oData)
+ return null;
+ return m_oData.get(pKey);
+ } // __________________________________
- sAux = p_oDto.getAttr(HIDDEN.stamp.toString());
- if (null != sAux) p_obj.m_lStamp = Long.parseLong(sAux);
+ private long m_lStamp = -1;
- sAux = p_oDto.getAttr(HIDDEN.snap.toString());
- if (null != sAux) p_obj.m_lLastSnap = Long.parseLong(sAux);
+ private long m_lUid = -1;
- sAux = p_oDto.getAttr(HIDDEN.batch.toString());
- p_obj.setBatchNum((null != sAux)? Long.parseLong(sAux) : 0);
+ private long m_lLastSnap = 0;
- // Special treatment for package - only needed for root BaseBusinessObj
- // this is so only to make XML more compact
- p_obj.m_sPkg = p_oDto.getAttr(BobjStdDTO.BOBJ_PACKAGE);
- } //________________________________
+ private long m_lBatch = 0;
- public static final BaseBusinessObject getFromDTO(BobjStdDTO p_oDto)
- throws Exception
- { return new BaseBusinessObject().fromDTO(p_oDto);
- } //________________________________
+ private String m_sDtSnap = null;
- private BaseBusinessObject fromDTO(BobjStdDTO p_oDto)
- throws Exception
- { if (null == p_oDto) return null;
+ private String m_sPkg = null;
- Class oClass = Class.forName(p_oDto.fullClassName());
- Constructor CC=oClass.getConstructor (new Class[]{BobjStdDTO.class});
- BaseBusinessObject oRet = (BaseBusinessObject)CC.newInstance(new Object []{p_oDto});
+ public boolean hasUid() {
+ return m_lUid > 0;
+ }
- commonFieldsFromDTO(oRet,p_oDto);
- return oRet;
- } //________________________________
+ public void setElemNm(String p_s) {
+ setField(ATTRIB.elem, p_s);
+ }
- protected BobjStdDTO getBaseDTO()
- { String sClass = getClass().getSimpleName();
- BobjStdDTO oRet = new BobjStdDTO(sClass,getElemNm(),null);
- if (hasUid())
- try { oRet.addAttr(HIDDEN.uid.toString(),Long.toString(m_lUid)); }
- catch (Exception e) {}
- putStdAtts(oRet);
- return oRet;
- } //________________________________
+ public void setRole(String p_s) {
+ setField(ATTRIB.rol, p_s);
+ }
- protected void putStdAtts(BobjStdDTO p_oRet)
- { try
- { p_oRet.addAttr(ATTRIB.rol.toString(),getRole());
-// if (this instanceof XtfStorable)
-// p_oRet.addAttr(HIDDEN.type.toString(),((XtfStorable)this).getSnapType());
- if (m_lStamp > 0) p_oRet.addAttr(HIDDEN.stamp.toString()
- ,Long.toString(m_lStamp));
- if (m_lLastSnap > 0) p_oRet.addAttr(HIDDEN.snap.toString()
- ,Long.toString(m_lLastSnap));
- if (! EsbUtil.isNullString(m_sDtSnap))
- p_oRet.addAttr(HIDDEN.dtSnap.toString(),m_sDtSnap);
- if (getBatchNum() > 0)
- p_oRet.addAttr(HIDDEN.batch.toString() ,Long.toString(getBatchNum()));
- if (! EsbUtil.isNullString(m_sPkg))
- p_oRet.addAttr(BobjStdDTO.BOBJ_PACKAGE,m_sPkg);
- }
- catch (Exception e1) { }
- } //________________________________
+ public void setStamp(long p_l) {
+ m_lStamp = p_l;
+ }
- public static final BobjStdDTO getDtoList (Class p_Class
- , List<? extends BaseBusinessObject> p_oList)
- throws Exception
- { if (null == p_oList) return null;
- List<BobjStdDTO> LL = new ArrayList<BobjStdDTO>();
- for (BaseBusinessObject oCurr : p_oList)
- LL.add( oCurr.toDTO());
- String sElem = p_Class.getSimpleName();
- return (LL.size()<1) ? null : new BobjStdDTO(sElem,null,LL);
- } //__________________________________
+ public void setUid(long p_l) {
+ m_lUid = p_l;
+ }
- public static BaseBusinessObject getRoleFromList(String p_sRole
- , List<? extends BaseBusinessObject> p_oL)
- { if (null == p_sRole) return null;
- if (null == p_oL) return null;
- for (BaseBusinessObject oCurr : p_oL)
- if (p_sRole.equals(oCurr.getRole()))
- return oCurr;
- return null;
- } //__________________________________
+ public void setSnap(long p_l) {
+ m_lLastSnap = p_l;
+ }
- public static BaseBusinessObject getElemFromList
- (String p_sElemNm, List<? extends BaseBusinessObject> p_oL)
- { if (null == p_sElemNm) return null;
- if (null == p_oL) return null;
- for (BaseBusinessObject oCurr : p_oL)
- if (p_sElemNm.equals(oCurr.getElemNm()))
- return oCurr;
- return null;
- } //__________________________________
+ public void setBatchNum(long p_l) {
+ m_lBatch = p_l;
+ }
- public static BaseBusinessObject rmvElemFromList(String p_sElemNm, List<BaseBusinessObject> p_oL)
- { if (null == p_sElemNm) return null;
- if (null == p_oL) return null;
- for (ListIterator<BaseBusinessObject> II=p_oL.listIterator(); II.hasNext();)
- { BaseBusinessObject oCurr = II.next();
- if (p_sElemNm.equals(oCurr.getElemNm()))
- { II.remove();
- return oCurr;
- }
- }
- return null;
- } //__________________________________
+ public void setSnapDate(String p_s) {
+ m_sDtSnap = p_s;
+ }
- public static boolean anyFieldNull(String [] p_sa)
- { if (null == p_sa) return false;
- for (int i1=0; i1<p_sa.length;i1++)
- if (null == p_sa[i1]) return true;
- return false;
- } //__________________________________
+ public void setPackage() {
+ m_sPkg = this.getClass().getPackage().getName();
+ }
- public static boolean allFieldsNull(String [] p_sa)
- { if (null == p_sa) return false;
- if (p_sa.length<1) return false;
- for (int i1=0; i1<p_sa.length;i1++)
- { String sCurr = p_sa[i1];
- if (null == sCurr) continue;
- if (sCurr.trim().length()>0) return false;
- }
- return true;
- } //__________________________________
+ public String getElemNm() {
+ return getField(ATTRIB.elem);
+ }
-} //____________________________________________________________________________
+ public String getRole() {
+ return getField(ATTRIB.rol);
+ }
+
+ public long getStamp() {
+ return m_lStamp;
+ }
+
+ public long getUid() {
+ return m_lUid;
+ }
+
+ public long getSnap() {
+ return m_lLastSnap;
+ }
+
+ public long getBatchNum() {
+ return m_lBatch;
+ }
+
+ public String getSnapDate() {
+ return m_sDtSnap;
+ }
+
+ public BaseBusinessObject() {
+ this((String) null);
+ }
+
+ protected BaseBusinessObject(String p_sElem) {
+ this(p_sElem, -1);
+ }
+
+ protected BaseBusinessObject(String p_sElem, long p_lUid) {
+ setField(ATTRIB.elem, p_sElem);
+ m_lUid = p_lUid;
+ if (null != getElemNm())
+ return;
+ String sClass = getClass().getSimpleName();
+ if (null == p_sElem)
+ setField(ATTRIB.elem, sClass);
+ } // ________________________________
+
+ protected BaseBusinessObject(BobjStdDTO p_oDto) throws Exception {
+ this(p_oDto.elementNm());
+ if (p_oDto.isList())
+ return;
+ commonFieldsFromDTO(this, p_oDto);
+ } // ________________________________
+
+ private static final void commonFieldsFromDTO(BaseBusinessObject p_obj,
+ BobjStdDTO p_oDto) throws Exception {
+ for (ATTRIB oCurr : ATTRIB.values())
+ p_obj.setField(oCurr, p_oDto.getAttr(oCurr.toString()));
+
+ String sAux = p_oDto.getAttr(HIDDEN.uid.toString());
+ if (null != sAux)
+ p_obj.m_lUid = Long.parseLong(sAux);
+
+ sAux = p_oDto.getAttr(HIDDEN.stamp.toString());
+ if (null != sAux)
+ p_obj.m_lStamp = Long.parseLong(sAux);
+
+ sAux = p_oDto.getAttr(HIDDEN.snap.toString());
+ if (null != sAux)
+ p_obj.m_lLastSnap = Long.parseLong(sAux);
+
+ sAux = p_oDto.getAttr(HIDDEN.batch.toString());
+ p_obj.setBatchNum((null != sAux) ? Long.parseLong(sAux) : 0);
+
+ // Special treatment for package - only needed for root BaseBusinessObj
+ // this is so only to make XML more compact
+ p_obj.m_sPkg = p_oDto.getAttr(BobjStdDTO.BOBJ_PACKAGE);
+ } // ________________________________
+
+ public static final BaseBusinessObject getFromDTO(BobjStdDTO p_oDto)
+ throws Exception {
+ return new BaseBusinessObject().fromDTO(p_oDto);
+ } // ________________________________
+
+ private BaseBusinessObject fromDTO(BobjStdDTO p_oDto) throws Exception {
+ if (null == p_oDto)
+ return null;
+
+ Class oClass = Class.forName(p_oDto.fullClassName());
+ Constructor CC = oClass
+ .getConstructor(new Class[] { BobjStdDTO.class });
+ BaseBusinessObject oRet = (BaseBusinessObject) CC
+ .newInstance(new Object[] { p_oDto });
+
+ commonFieldsFromDTO(oRet, p_oDto);
+ return oRet;
+ } // ________________________________
+
+ protected BobjStdDTO getBaseDTO() {
+ String sClass = getClass().getSimpleName();
+ BobjStdDTO oRet = new BobjStdDTO(sClass, getElemNm(), null);
+ if (hasUid())
+ try {
+ oRet.addAttr(HIDDEN.uid.toString(), Long.toString(m_lUid));
+ } catch (Exception e) {
+ }
+ putStdAtts(oRet);
+ return oRet;
+ } // ________________________________
+
+ protected void putStdAtts(BobjStdDTO p_oRet) {
+ try {
+ p_oRet.addAttr(ATTRIB.rol.toString(), getRole());
+ // if (this instanceof XtfStorable)
+ // p_oRet.addAttr(HIDDEN.type.toString(),((XtfStorable)this).getSnapType());
+ if (m_lStamp > 0)
+ p_oRet
+ .addAttr(HIDDEN.stamp.toString(), Long
+ .toString(m_lStamp));
+ if (m_lLastSnap > 0)
+ p_oRet.addAttr(HIDDEN.snap.toString(), Long
+ .toString(m_lLastSnap));
+ if (!EsbUtil.isNullString(m_sDtSnap))
+ p_oRet.addAttr(HIDDEN.dtSnap.toString(), m_sDtSnap);
+ if (getBatchNum() > 0)
+ p_oRet.addAttr(HIDDEN.batch.toString(), Long
+ .toString(getBatchNum()));
+ if (!EsbUtil.isNullString(m_sPkg))
+ p_oRet.addAttr(BobjStdDTO.BOBJ_PACKAGE, m_sPkg);
+ } catch (Exception e1) {
+ }
+ } // ________________________________
+
+ public static final BobjStdDTO getDtoList(Class p_Class,
+ List<? extends BaseBusinessObject> p_oList) throws Exception {
+ if (null == p_oList)
+ return null;
+ List<BobjStdDTO> LL = new ArrayList<BobjStdDTO>();
+ for (BaseBusinessObject oCurr : p_oList)
+ LL.add(oCurr.toDTO());
+ String sElem = p_Class.getSimpleName();
+ return (LL.size() < 1) ? null : new BobjStdDTO(sElem, null, LL);
+ } // __________________________________
+
+ public static BaseBusinessObject getRoleFromList(String p_sRole,
+ List<? extends BaseBusinessObject> p_oL) {
+ if (null == p_sRole)
+ return null;
+ if (null == p_oL)
+ return null;
+ for (BaseBusinessObject oCurr : p_oL)
+ if (p_sRole.equals(oCurr.getRole()))
+ return oCurr;
+ return null;
+ } // __________________________________
+
+ public static BaseBusinessObject getElemFromList(String p_sElemNm,
+ List<? extends BaseBusinessObject> p_oL) {
+ if (null == p_sElemNm)
+ return null;
+ if (null == p_oL)
+ return null;
+ for (BaseBusinessObject oCurr : p_oL)
+ if (p_sElemNm.equals(oCurr.getElemNm()))
+ return oCurr;
+ return null;
+ } // __________________________________
+
+ public static BaseBusinessObject rmvElemFromList(String p_sElemNm,
+ List<BaseBusinessObject> p_oL) {
+ if (null == p_sElemNm)
+ return null;
+ if (null == p_oL)
+ return null;
+ for (ListIterator<BaseBusinessObject> II = p_oL.listIterator(); II
+ .hasNext();) {
+ BaseBusinessObject oCurr = II.next();
+ if (p_sElemNm.equals(oCurr.getElemNm())) {
+ II.remove();
+ return oCurr;
+ }
+ }
+ return null;
+ } // __________________________________
+
+ public static boolean anyFieldNull(String[] p_sa) {
+ if (null == p_sa)
+ return false;
+ for (int i1 = 0; i1 < p_sa.length; i1++)
+ if (null == p_sa[i1])
+ return true;
+ return false;
+ } // __________________________________
+
+ public static boolean allFieldsNull(String[] p_sa) {
+ if (null == p_sa)
+ return false;
+ if (p_sa.length < 1)
+ return false;
+ for (int i1 = 0; i1 < p_sa.length; i1++) {
+ String sCurr = p_sa[i1];
+ if (null == sCurr)
+ continue;
+ if (sCurr.trim().length() > 0)
+ return false;
+ }
+ return true;
+ } // __________________________________
+
+} // ____________________________________________________________________________
Modified: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/util/BobjStdDTO.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/util/BobjStdDTO.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/util/BobjStdDTO.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,24 +1,24 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.soa.esb.util;
@@ -32,378 +32,461 @@
import org.w3c.dom.*;
+/**
+ * {@link org.jboss.soa.esb.util.BaseBusinessObject} Data Transfer Object.
+ * <p/>
+ * {@link org.jboss.soa.esb.util.BaseBusinessObject} implementations use this
+ * class to create a serialized XML representation of their data. They do this
+ * in their {@link org.jboss.soa.esb.util.BaseBusinessObject#toDTO()} method
+ * implementation.
+ * <p/>
+ * This serialized XML form is used for object persistense. The DTO is also
+ * decorated with the following properties to aid lookup and processing
+ * of their persisted form:
+ * <ul>
+ * <li><b>{@link #getUid() UID}</b> //TODO: Define!!</li>
+ * <li><b>{@link #getStamp()() Stamp}</b> //TODO: Define!!</li>
+ * <li><b>{@link #getSnap()() Snap}</b> //TODO: Define!!</li>
+ * <li><b>{@link #getSnapType()()() SnapType}</b> //TODO: Define!!</li>
+ * <li><b>{@link #getSnapDate()()()() SnapDate}</b> //TODO: Define!!</li>
+ * <li><b>{@link #getBatch()()() Batch}</b> //TODO: Define!!</li>
+ * </ul>
+ *
+ * @see #getFromXml(String)
+ * @author <a href="mailto:schifest at gmail.com">Esteban Shifman</a>
+ */
+
@SuppressWarnings("serial")
-public class BobjStdDTO implements Serializable
-{
- private static final transient String s_sCharset = "ISO-8859-1";
- public static String getCharset() { return s_sCharset; }
+public class BobjStdDTO implements Serializable {
+ private static final transient String s_sCharset = "ISO-8859-1";
- private static final transient String s_sEncoding
- = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
+ public static String getCharset() {
+ return s_sCharset;
+ }
- // Some attribute names for the toXML() and fromXML()
- public final static String BOBJ_PACKAGE = "__BobjPkg";
- public final static String BOBJ_CLASS = "__Class";
+ private static final transient String s_sEncoding = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
- protected String m_sClassNm;
- protected String m_sElemNm;
- protected Map<String,Object> m_oAtts;
- protected List<BobjStdDTO> m_oChild;
- protected String[][] m_saaLocators;
- public void setLocators(String[][] p_saa) { m_saaLocators = p_saa; }
- public String[][] getLocators() { return m_saaLocators; }
+ // Some attribute names for the toXML() and fromXML()
+ public final static String BOBJ_PACKAGE = "__BobjPkg";
- //Getters
- public String classNm() { return m_sClassNm; }
- public String elementNm() { return m_sElemNm; }
- public boolean isList() { return null!=m_oChild; }
- public boolean isEmpty()
- {return (isList()) ? (m_oChild).isEmpty() : m_oAtts.isEmpty(); }
+ public final static String BOBJ_CLASS = "__Class";
-// protected BObjStdDTO() {}
- public BobjStdDTO(String p_sClassNm) {this(p_sClassNm,null,null); }
- public BobjStdDTO(String p_sClassNm, String p_sElemNm)
- {this(p_sClassNm,p_sElemNm,null); }
- public BobjStdDTO(String p_sClassNm, List<BobjStdDTO> p_oList)
- {this(p_sClassNm,null,p_oList); }
- protected BobjStdDTO(String p_sClassNm, String p_sElemNm, List<BobjStdDTO> p_oList)
- {initialize(p_sClassNm,p_sElemNm,p_oList); }
+ protected String m_sClassNm;
- protected BobjStdDTO(BobjStdDTO p_o)
- { if (null!=p_o)
- { m_sClassNm = p_o.m_sClassNm;
- m_sElemNm = p_o.m_sElemNm;
- if (null!=p_o.m_oChild)m_oChild = new ArrayList<BobjStdDTO>(p_o.m_oChild);
- if (null!=p_o.m_oAtts) m_oAtts = new HashMap<String,Object>(p_o.m_oAtts);
- }
- } //__________________________________
+ protected String m_sElemNm;
- private void initialize(String p_sClassNm, String p_sElemNm, List<BobjStdDTO> p_oList)
- { m_sClassNm = p_sClassNm;
- m_sElemNm = (null != p_sElemNm) ? p_sElemNm
- : m_sClassNm.substring(1+m_sClassNm.lastIndexOf("."));
- m_oChild= p_oList;
- if (null==m_oChild)
- m_oAtts = new HashMap<String,Object>();
- } //__________________________________
+ protected Map<String, Object> m_oAtts;
- private BobjStdDTO (Element p_n) throws Exception
- { String sElem = p_n.getNodeName();
+ protected List<BobjStdDTO> m_oChild;
- String sClass = null;
- try { sClass = p_n.getAttribute(BOBJ_CLASS); }
- catch (Exception eC) {}
- sClass = (null == sClass) ? sElem
- : ("".equals(sClass)) ? sElem : sClass;
- p_n.removeAttribute(BOBJ_CLASS);
+ protected String[][] m_saaLocators;
- String sList = null;
- try { sList = p_n.getAttribute("List"); }
- catch (Exception eL) { }
- boolean m_bList = (null == sList) ? false
- : ("".equals(sList)) ? false : true;
- p_n.removeAttribute("List");
+ public void setLocators(String[][] p_saa) {
+ m_saaLocators = p_saa;
+ }
- NodeList NL = p_n.getChildNodes();
- int iQch = NL.getLength();
- if (m_bList)
- { List<BobjStdDTO> olCh = new ArrayList<BobjStdDTO>();
- for (int i1=0; i1<iQch; i1++)
- { Node oCurr = NL.item(i1);
- if (Node.ELEMENT_NODE != oCurr.getNodeType()) continue;
- BobjStdDTO oThisCh = new BobjStdDTO((Element)NL.item(i1));
- oThisCh.m_sElemNm = oThisCh.m_sClassNm = sClass;
- olCh.add(oThisCh);
- }
- initialize(sClass,sElem,olCh);
- return;
- }
+ public String[][] getLocators() {
+ return m_saaLocators;
+ }
- initialize(sClass,sElem,null);
- this.addMap(mapFromAtts(p_n.getAttributes()));
+ // Getters
+ public String classNm() {
+ return m_sClassNm;
+ }
- for (int i1=0; i1<iQch; i1++)
- { Node oCurr = NL.item(i1);
- if (Node.ELEMENT_NODE != oCurr.getNodeType()) continue;
- this.addDto(((Element)oCurr).getNodeName()
- ,new BobjStdDTO(((Element)oCurr)));
- }
- } //__________________________________
-
- private void setLongAttr(String p_s,long pL)
- { try { addAttr(p_s,Long.toString(pL)); }
- catch (Exception e) { e.printStackTrace(); }
- } //__________________________________
- private void setStringAttr(String p_s,String pVal)
- { try { addAttr(p_s,pVal); }
- catch (Exception e) { e.printStackTrace(); }
- } //__________________________________
-
- private long attrAsLong(String p_s)
- { try
- { String sVal = getAttr(p_s);
- if (! EsbUtil.isNullString(sVal))
- return Long.parseLong(sVal);
+ public String elementNm() {
+ return m_sElemNm;
}
- catch (Exception e) {/* OK just fall through and return default*/ }
- return 0;
- } //__________________________________
- private String attrAsString(String p_s)
- { try { return getAttr(p_s); }
- catch (Exception e) {/* OK just fall through and return default*/ }
- return null;
- } //__________________________________
+ public boolean isList() {
+ return null != m_oChild;
+ }
- public long getStamp(){ return attrAsLong(BaseBusinessObject.HIDDEN.stamp.toString()); }
- public long getUid() { return attrAsLong(BaseBusinessObject.HIDDEN.uid.toString()); }
- public long getSnap() { return attrAsLong(BaseBusinessObject.HIDDEN.snap.toString()); }
- public long getBatch(){ return attrAsLong(BaseBusinessObject.HIDDEN.batch.toString()); }
- public String getSnapType(){ return attrAsString(BaseBusinessObject.HIDDEN.type.toString()); }
- public String getSnapDate(){ return attrAsString(BaseBusinessObject.HIDDEN.dtSnap.toString()); }
+ public boolean isEmpty() {
+ return (isList()) ? (m_oChild).isEmpty() : m_oAtts.isEmpty();
+ }
- public void setStamp (long pL) { setLongAttr(BaseBusinessObject.HIDDEN.stamp.toString(),pL); }
- public void setUid (long pL) { setLongAttr(BaseBusinessObject.HIDDEN.uid.toString(),pL); }
- public void setSnap (long pL) { setLongAttr(BaseBusinessObject.HIDDEN.snap.toString(),pL); }
- public void setBatch (long pL) { setLongAttr(BaseBusinessObject.HIDDEN.batch.toString(),pL); }
- public void setSnapType(String pS){ setStringAttr(BaseBusinessObject.HIDDEN.type.toString(),pS); }
- public void setSnapDate(String pS){ setStringAttr(BaseBusinessObject.HIDDEN.dtSnap.toString(),pS); }
-
- public String fullClassName()
- { String sPkg = "";
- try { sPkg = getAttr(BobjStdDTO.BOBJ_PACKAGE); }
- catch (Exception e) {/* just leave it empty */ }
- String sConstrPkg = (sPkg.endsWith(".")) ? sPkg : sPkg+".";
- return sConstrPkg+classNm();
- } //__________________________________
+ protected BobjStdDTO(String p_sClassNm, String p_sElemNm,
+ List<BobjStdDTO> p_oList) {
+ initialize(p_sClassNm, p_sElemNm, p_oList);
+ }
- public List<? extends BaseBusinessObject> getChildObjList(String p_sElem, Class pCls) throws Exception
- { BobjStdDTO oChDto = this.getDTO(p_sElem);
- if (null == oChDto) return null;
- if (! oChDto.isList()) throw new Exception ("Child DTO is not List");
- return oChDto.listDtoToList(pCls);
- } //__________________________________
+ private void initialize(String p_sClassNm, String p_sElemNm,
+ List<BobjStdDTO> p_oList) {
+ m_sClassNm = p_sClassNm;
+ m_sElemNm = (null != p_sElemNm) ? p_sElemNm : m_sClassNm
+ .substring(1 + m_sClassNm.lastIndexOf("."));
+ m_oChild = p_oList;
+ if (null == m_oChild)
+ m_oAtts = new HashMap<String, Object>();
+ } // __________________________________
- private List<BaseBusinessObject> listDtoToList(Class pCls) throws Exception
- { if (! isList()) throw new Exception("BObjStdDTO is not a List");
- Class [] oaCls = {BobjStdDTO.class};
- Constructor CC=pCls.getConstructor (oaCls);
- List<BaseBusinessObject> LL = new ArrayList<BaseBusinessObject>();
- Object [] oaParms = new BobjStdDTO[1];
- for (BobjStdDTO oCurr : m_oChild)
- { oaParms[0] = oCurr;
- LL.add((BaseBusinessObject)CC.newInstance(oaParms));
- }
- return (LL.size()>0) ? LL : null;
- } //__________________________________
+ private BobjStdDTO(Element p_n) throws Exception {
+ String sElem = p_n.getNodeName();
- public Map<String,Object> getAttrMap() throws Exception
- { return m_oAtts;
- } //__________________________________
+ String sClass = null;
+ try {
+ sClass = p_n.getAttribute(BOBJ_CLASS);
+ } catch (Exception eC) {
+ }
+ sClass = (null == sClass) ? sElem : ("".equals(sClass)) ? sElem
+ : sClass;
+ p_n.removeAttribute(BOBJ_CLASS);
- public BobjStdDTO getDTO(String p_sKey) throws Exception
- { if (isList()) throw new Exception("BObjStdDTO is a List");
- Object oRet = m_oAtts.get(p_sKey);
- if (null == oRet) return null;
- if (oRet instanceof BobjStdDTO) return (BobjStdDTO)oRet;
- throw new Exception ("Value is not BObjStdDTO");
- } //__________________________________
+ String sList = null;
+ try {
+ sList = p_n.getAttribute("List");
+ } catch (Exception eL) {
+ }
+ boolean m_bList = (null == sList) ? false : ("".equals(sList)) ? false
+ : true;
+ p_n.removeAttribute("List");
- public String getAttr(String p_sKey) throws Exception
- { if (isList()) throw new Exception("BObjStdDTO is a List");
- Object oRet = m_oAtts.get(p_sKey);
- if (null == oRet) return null;
- if (oRet instanceof String) return (String)oRet;
- throw new Exception ("Value is not an attribute");
- } //__________________________________
+ NodeList NL = p_n.getChildNodes();
+ int iQch = NL.getLength();
+ if (m_bList) {
+ List<BobjStdDTO> olCh = new ArrayList<BobjStdDTO>();
+ for (int i1 = 0; i1 < iQch; i1++) {
+ Node oCurr = NL.item(i1);
+ if (Node.ELEMENT_NODE != oCurr.getNodeType())
+ continue;
+ BobjStdDTO oThisCh = new BobjStdDTO((Element) NL.item(i1));
+ oThisCh.m_sElemNm = oThisCh.m_sClassNm = sClass;
+ olCh.add(oThisCh);
+ }
+ initialize(sClass, sElem, olCh);
+ return;
+ }
- @SuppressWarnings("unchecked")
- public void addAttr(String p_sKey, String p_sAtt) throws Exception
- { if (isList()) throw new Exception("BObjStdDTO is a List");
- if (null == p_sKey) return;
- m_oAtts.remove(p_sKey);
- if (null != p_sAtt)
- if (p_sAtt.trim().length() > 0)
- m_oAtts.put(p_sKey,p_sAtt.trim());
- } //__________________________________
+ initialize(sClass, sElem, null);
+ this.addMap(mapFromAtts(p_n.getAttributes()));
- @SuppressWarnings("unchecked")
- public void addDto(String p_sKey, BobjStdDTO p_oDto) throws Exception
- { if (isList()) throw new Exception("BObjStdDTO is a List");
- if (null == p_sKey) return;
- m_oAtts.remove(p_sKey);
- if (null == p_oDto) return;
- if (p_oDto.isEmpty()) return;
- p_oDto.m_sElemNm=p_sKey;
- m_oAtts.put(p_sKey,p_oDto);
- } //__________________________________
+ for (int i1 = 0; i1 < iQch; i1++) {
+ Node oCurr = NL.item(i1);
+ if (Node.ELEMENT_NODE != oCurr.getNodeType())
+ continue;
+ this.addDto(((Element) oCurr).getNodeName(), new BobjStdDTO(
+ ((Element) oCurr)));
+ }
+ } // __________________________________
- @SuppressWarnings("unchecked")
- public void addBobj(String p_sKey, BaseBusinessObject p_oBob) throws Exception
- { if (isList()) throw new Exception("BObjStdDTO is a List");
- if (null == p_sKey) return;
- m_oAtts.remove(p_sKey);
- if (null == p_oBob) return;
- BobjStdDTO oDto = p_oBob.toDTO();
- if (oDto.isEmpty()) return;
- oDto.m_sElemNm=p_sKey;
- m_oAtts.put(p_sKey,oDto);
- } //__________________________________
+ private void setLongAttr(String p_s, long pL) {
+ try {
+ addAttr(p_s, Long.toString(pL));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } // __________________________________
- @SuppressWarnings("unchecked")
- private void addMap(Map<String,Object> p_oM) throws Exception
- { if (isList()) throw new Exception("BObjStdDTO is a List");
- if (null == p_oM) return;
- for (Map.Entry<String,Object> oCurr : p_oM.entrySet())
- m_oAtts.put(oCurr.getKey(), oCurr.getValue());
- } //__________________________________
+ private void setStringAttr(String p_s, String pVal) {
+ try {
+ addAttr(p_s, pVal);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } // __________________________________
- public String toXml() throws Exception { return toXml(false); }
+ private long attrAsLong(String p_s) {
+ try {
+ String sVal = getAttr(p_s);
+ if (!EsbUtil.isNullString(sVal))
+ return Long.parseLong(sVal);
+ } catch (Exception e) {/* OK just fall through and return default */
+ }
+ return 0;
+ } // __________________________________
- public String toXml(boolean p_bDecl) throws Exception
- { Document oDoc = toDoc();
- oDoc.normalize();
- DOMSource src = new DOMSource(oDoc);
+ private String attrAsString(String p_s) {
+ try {
+ return getAttr(p_s);
+ } catch (Exception e) {/* OK just fall through and return default */
+ }
+ return null;
+ } // __________________________________
- OutputStream oStrm = new ByteArrayOutputStream(1000);
- StreamResult res = new StreamResult(oStrm);
+ public long getStamp() {
+ return attrAsLong(BaseBusinessObject.HIDDEN.stamp.toString());
+ }
- Transformer oTf = TransformerFactory.newInstance().newTransformer();
- oTf.setOutputProperty(OutputKeys.INDENT, "no");
- oTf.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION
- ,(p_bDecl)? "no":"yes");
+ public long getUid() {
+ return attrAsLong(BaseBusinessObject.HIDDEN.uid.toString());
+ }
- oTf.setOutputProperty(OutputKeys.ENCODING, s_sCharset);
- oTf.transform(src,res);
- return oStrm.toString();
- } //__________________________________
+ public long getSnap() {
+ return attrAsLong(BaseBusinessObject.HIDDEN.snap.toString());
+ }
- public BaseBusinessObject getBobj(String p_sObj)
- { if (null == p_sObj) return null;
- try
- { BobjStdDTO oDto = this.getDTO(p_sObj);
- return BaseBusinessObject.getFromDTO(oDto);
- }
- catch (Exception e) {return null; }
- } //__________________________________
+ public long getBatch() {
+ return attrAsLong(BaseBusinessObject.HIDDEN.batch.toString());
+ }
- public Document toDoc()
- {
- DocumentBuilder oDB = null;
- try { oDB = DocumentBuilderFactory.newInstance().newDocumentBuilder(); }
- catch (Exception e) {}
- Document oDoc = oDB.newDocument();
- oDoc.appendChild(toElement(oDoc));
- return oDoc;
- } //__________________________________
+ public String getSnapType() {
+ return attrAsString(BaseBusinessObject.HIDDEN.type.toString());
+ }
- public Node toElement(Document p_oDoc)
- { return (isList()) ? listToElement(p_oDoc)
- : mapToElement (p_oDoc);
- } //__________________________________
+ public String getSnapDate() {
+ return attrAsString(BaseBusinessObject.HIDDEN.dtSnap.toString());
+ }
- private Node mapToElement(Document p_oDoc)
- { if (null == m_oAtts) return null;
- Element onRet = p_oDoc.createElement(m_sElemNm);
- for (Map.Entry<String,Object> oCurr: m_oAtts.entrySet())
- { if (oCurr.getValue() instanceof BobjStdDTO)
- { onRet.appendChild(((BobjStdDTO)oCurr.getValue()).toElement(p_oDoc));
- continue;
- }
- else
-// System.out.println("Elem<"+sKey+"> Val<"+oVal.toString()+">");
- onRet.setAttribute(oCurr.getKey(),oCurr.getValue().toString());
- }
+ public void setStamp(long pL) {
+ setLongAttr(BaseBusinessObject.HIDDEN.stamp.toString(), pL);
+ }
- boolean bPutClass = (null != m_sClassNm) && (! m_sElemNm.equals(m_sClassNm));
- if (bPutClass)onRet.setAttribute(BOBJ_CLASS,m_sClassNm);
- else onRet.removeAttribute(BOBJ_CLASS);
+ public void setUid(long pL) {
+ setLongAttr(BaseBusinessObject.HIDDEN.uid.toString(), pL);
+ }
- return onRet;
- } //__________________________________
+ public void setSnap(long pL) {
+ setLongAttr(BaseBusinessObject.HIDDEN.snap.toString(), pL);
+ }
- private Node listToElement(Document p_oDoc)
- { if (null == m_oChild) return null;
- if (m_oChild.isEmpty()) return null;
+ public void setBatch(long pL) {
+ setLongAttr(BaseBusinessObject.HIDDEN.batch.toString(), pL);
+ }
- Element onRet = p_oDoc.createElement(m_sElemNm);
- onRet.setAttribute("List","yes");
- if ( ! m_sElemNm.equals(m_sClassNm))
- onRet.setAttribute(BOBJ_CLASS,m_sClassNm);
+ public void setSnapType(String pS) {
+ setStringAttr(BaseBusinessObject.HIDDEN.type.toString(), pS);
+ }
- for (BobjStdDTO oCurr : m_oChild)
- { oCurr.m_sClassNm=null;
- oCurr.m_sElemNm="it";
- onRet.appendChild(oCurr.toElement(p_oDoc));
- }
- return onRet;
- } //__________________________________
+ public void setSnapDate(String pS) {
+ setStringAttr(BaseBusinessObject.HIDDEN.dtSnap.toString(), pS);
+ }
- public static synchronized BobjStdDTO getFromXml(String p_s) throws Exception
- {StringBuffer sb = new StringBuffer(s_sEncoding)
- .append("\n").append(p_s);
- DocumentBuilder oDB = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document oDoc = oDB.parse(new ByteArrayInputStream (sb.toString()
- .getBytes(s_sCharset)));
- return new BobjStdDTO(oDoc.getDocumentElement());
- } //__________________________________
+ public String fullClassName() {
+ String sPkg = "";
+ try {
+ sPkg = getAttr(BobjStdDTO.BOBJ_PACKAGE);
+ } catch (Exception e) {/* just leave it empty */
+ }
+ String sConstrPkg = (sPkg.endsWith(".")) ? sPkg : sPkg + ".";
+ return sConstrPkg + classNm();
+ } // __________________________________
- @SuppressWarnings("unused")
- private static synchronized List<BobjStdDTO> getChildList
- (String p_sClass, NodeList p_nl, String p_sPkgPfx)
- throws Exception
- { int iQel = p_nl.getLength();
- if (iQel < 1) return null;
- Class oClass = Class.forName(p_sPkgPfx+p_sClass);
- Class [] oaCls = new Class[] {String.class};
- Object [] oaStr = new Object[] {p_sClass};
- Constructor CC = oClass.getConstructor(oaCls);
- List<BobjStdDTO> olRet = new ArrayList<BobjStdDTO>(2*iQel);
- for (int i1=0; i1<iQel; i1++)
- { Node onCurr = p_nl.item(i1);
- if (Node.ELEMENT_NODE != onCurr.getNodeType()) continue;
- BobjStdDTO oDto = ((BaseBusinessObject)CC.newInstance(oaStr)).toDTO();
- oDto.addMap(BobjStdDTO.mapFromAtts(onCurr.getAttributes()));
- olRet.add(oDto);
- }
- return olRet;
- } //__________________________________
+ public List<? extends BaseBusinessObject> getChildObjList(String p_sElem,
+ Class pCls) throws Exception {
+ BobjStdDTO oChDto = this.getDTO(p_sElem);
+ if (null == oChDto)
+ return null;
+ if (!oChDto.isList())
+ throw new Exception("Child DTO is not List");
+ return oChDto.listDtoToList(pCls);
+ } // __________________________________
- private static synchronized Map<String,Object> mapFromAtts(NamedNodeMap p_oNnm)
- { if (null == p_oNnm) return null;
- int iQatt = p_oNnm.getLength();
- if (iQatt < 1) return null;
- Map<String,Object> omAtts = new HashMap<String,Object>();
- for (int i2=0; i2<iQatt;i2++)
- { Node nAtt = p_oNnm.item(i2);
- omAtts.put(nAtt.getNodeName(),nAtt.getNodeValue());
- }
- return omAtts;
- } //__________________________________
+ private List<BaseBusinessObject> listDtoToList(Class pCls) throws Exception {
+ if (!isList())
+ throw new Exception("BObjStdDTO is not a List");
+ Class[] oaCls = { BobjStdDTO.class };
+ Constructor CC = pCls.getConstructor(oaCls);
+ List<BaseBusinessObject> LL = new ArrayList<BaseBusinessObject>();
+ Object[] oaParms = new BobjStdDTO[1];
+ for (BobjStdDTO oCurr : m_oChild) {
+ oaParms[0] = oCurr;
+ LL.add((BaseBusinessObject) CC.newInstance(oaParms));
+ }
+ return (LL.size() > 0) ? LL : null;
+ } // __________________________________
- public void Dump(String p_s) throws Exception { System.out.println(p_s);Dump(0); }
+ public Map<String, Object> getAttrMap() throws Exception {
+ return m_oAtts;
+ } // __________________________________
- public void Dump(int p_iLev) throws Exception
- { byte[] ba = new byte[3*p_iLev]; Arrays.fill(ba,(byte)' ');
- String sTab = new String(ba);
- System.out.print(sTab+"Elem "+m_sElemNm+" Class "+m_sClassNm);
- if (isList())
- { System.out.println(" LIST");
- for (BobjStdDTO oCurr : m_oChild)
- oCurr.Dump(1+p_iLev);
- return;
- }
- System.out.print("\n"+sTab);
+ public BobjStdDTO getDTO(String p_sKey) throws Exception {
+ if (isList())
+ throw new Exception("BObjStdDTO is a List");
+ Object oRet = m_oAtts.get(p_sKey);
+ if (null == oRet)
+ return null;
+ if (oRet instanceof BobjStdDTO)
+ return (BobjStdDTO) oRet;
+ throw new Exception("Value is not BObjStdDTO");
+ } // __________________________________
- for (EnumMap.Entry<String,Object> oCurr : m_oAtts.entrySet())
- { if (oCurr.getValue() instanceof String)
- System.out.print(" " + oCurr.getKey()+"<"+oCurr.getValue()+">");
- }
- System.out.println();
- for (EnumMap.Entry<String,Object> oCurr : m_oAtts.entrySet())
- { if (oCurr.getValue() instanceof BobjStdDTO)
- ((BobjStdDTO)oCurr.getValue()).Dump(1+p_iLev);
- }
- } //__________________________________
-
-} //____________________________________________________________________________
+ public String getAttr(String p_sAttrName) throws Exception {
+ if (isList()) {
+ throw new UnsupportedOperationException("BObjStdDTO is a List. Cannot call getAttr method. Use isList to check!");
+ }
+ Object oRet = m_oAtts.get(p_sAttrName);
+ if (null == oRet) {
+ return null;
+ }
+ if (oRet instanceof String) {
+ return (String) oRet;
+ }
+ throw new IllegalArgumentException("p_sAttrName is not an attribute");
+ } // __________________________________
+
+ @SuppressWarnings("unchecked")
+ public void addAttr(String p_sKey, String p_sAtt) throws Exception {
+ if (isList())
+ throw new Exception("BObjStdDTO is a List");
+ if (null == p_sKey)
+ return;
+ m_oAtts.remove(p_sKey);
+ if (null != p_sAtt)
+ if (p_sAtt.trim().length() > 0)
+ m_oAtts.put(p_sKey, p_sAtt.trim());
+ } // __________________________________
+
+ @SuppressWarnings("unchecked")
+ public void addDto(String p_sKey, BobjStdDTO p_oDto) throws Exception {
+ if (isList())
+ throw new Exception("BObjStdDTO is a List");
+ if (null == p_sKey)
+ return;
+ m_oAtts.remove(p_sKey);
+ if (null == p_oDto)
+ return;
+ if (p_oDto.isEmpty())
+ return;
+ p_oDto.m_sElemNm = p_sKey;
+ m_oAtts.put(p_sKey, p_oDto);
+ } // __________________________________
+
+ @SuppressWarnings("unchecked")
+ private void addMap(Map<String, Object> p_oM) throws Exception {
+ if (isList())
+ throw new Exception("BObjStdDTO is a List");
+ if (null == p_oM)
+ return;
+ for (Map.Entry<String, Object> oCurr : p_oM.entrySet())
+ m_oAtts.put(oCurr.getKey(), oCurr.getValue());
+ } // __________________________________
+
+ public String toXml() throws Exception {
+ return toXml(false);
+ }
+
+ public String toXml(boolean p_bDecl) throws Exception {
+ Document oDoc = toDoc();
+ oDoc.normalize();
+ DOMSource src = new DOMSource(oDoc);
+
+ OutputStream oStrm = new ByteArrayOutputStream(1000);
+ StreamResult res = new StreamResult(oStrm);
+
+ Transformer oTf = TransformerFactory.newInstance().newTransformer();
+ oTf.setOutputProperty(OutputKeys.INDENT, "no");
+ oTf.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, (p_bDecl) ? "no"
+ : "yes");
+
+ oTf.setOutputProperty(OutputKeys.ENCODING, s_sCharset);
+ oTf.transform(src, res);
+ return oStrm.toString();
+ } // __________________________________
+
+ public Document toDoc() {
+ DocumentBuilder oDB = null;
+ try {
+ oDB = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ } catch (Exception e) {
+ }
+ Document oDoc = oDB.newDocument();
+ oDoc.appendChild(toElement(oDoc));
+ return oDoc;
+ } // __________________________________
+
+ public Node toElement(Document p_oDoc) {
+ return (isList()) ? listToElement(p_oDoc) : mapToElement(p_oDoc);
+ } // __________________________________
+
+ private Node mapToElement(Document p_oDoc) {
+ if (null == m_oAtts)
+ return null;
+ Element onRet = p_oDoc.createElement(m_sElemNm);
+ for (Map.Entry<String, Object> oCurr : m_oAtts.entrySet()) {
+ if (oCurr.getValue() instanceof BobjStdDTO) {
+ onRet.appendChild(((BobjStdDTO) oCurr.getValue())
+ .toElement(p_oDoc));
+ continue;
+ } else
+ // System.out.println("Elem<"+sKey+">
+ // Val<"+oVal.toString()+">");
+ onRet.setAttribute(oCurr.getKey(), oCurr.getValue().toString());
+ }
+
+ boolean bPutClass = (null != m_sClassNm)
+ && (!m_sElemNm.equals(m_sClassNm));
+ if (bPutClass)
+ onRet.setAttribute(BOBJ_CLASS, m_sClassNm);
+ else
+ onRet.removeAttribute(BOBJ_CLASS);
+
+ return onRet;
+ } // __________________________________
+
+ private Node listToElement(Document p_oDoc) {
+ if (null == m_oChild)
+ return null;
+ if (m_oChild.isEmpty())
+ return null;
+
+ Element onRet = p_oDoc.createElement(m_sElemNm);
+ onRet.setAttribute("List", "yes");
+ if (!m_sElemNm.equals(m_sClassNm))
+ onRet.setAttribute(BOBJ_CLASS, m_sClassNm);
+
+ for (BobjStdDTO oCurr : m_oChild) {
+ oCurr.m_sClassNm = null;
+ oCurr.m_sElemNm = "it";
+ onRet.appendChild(oCurr.toElement(p_oDoc));
+ }
+ return onRet;
+ } // __________________________________
+
+ public static synchronized BobjStdDTO getFromXml(String xmlBob)
+ throws Exception {
+
+ if(EsbUtil.isNullString(xmlBob)) {
+ throw new IllegalArgumentException("null or empty 'xmlBob' arg in call.");
+ }
+
+ StringBuffer sb = new StringBuffer(s_sEncoding).append("\n")
+ .append(xmlBob);
+ DocumentBuilder oDB = DocumentBuilderFactory.newInstance()
+ .newDocumentBuilder();
+ Document oDoc = oDB.parse(new ByteArrayInputStream(sb.toString()
+ .getBytes(s_sCharset)));
+ return new BobjStdDTO(oDoc.getDocumentElement());
+ } // __________________________________
+
+ private static synchronized Map<String, Object> mapFromAtts(
+ NamedNodeMap p_oNnm) {
+ if (null == p_oNnm)
+ return null;
+ int iQatt = p_oNnm.getLength();
+ if (iQatt < 1)
+ return null;
+ Map<String, Object> omAtts = new HashMap<String, Object>();
+ for (int i2 = 0; i2 < iQatt; i2++) {
+ Node nAtt = p_oNnm.item(i2);
+ omAtts.put(nAtt.getNodeName(), nAtt.getNodeValue());
+ }
+ return omAtts;
+ } // __________________________________
+
+ public void Dump(int p_iLev) throws Exception {
+ byte[] ba = new byte[3 * p_iLev];
+ Arrays.fill(ba, (byte) ' ');
+ String sTab = new String(ba);
+ System.out.print(sTab + "Elem " + m_sElemNm + " Class " + m_sClassNm);
+ if (isList()) {
+ System.out.println(" LIST");
+ for (BobjStdDTO oCurr : m_oChild)
+ oCurr.Dump(1 + p_iLev);
+ return;
+ }
+ System.out.print("\n" + sTab);
+
+ for (EnumMap.Entry<String, Object> oCurr : m_oAtts.entrySet()) {
+ if (oCurr.getValue() instanceof String)
+ System.out.print(" " + oCurr.getKey() + "<"
+ + oCurr.getValue() + ">");
+ }
+ System.out.println();
+ for (EnumMap.Entry<String, Object> oCurr : m_oAtts.entrySet()) {
+ if (oCurr.getValue() instanceof BobjStdDTO)
+ ((BobjStdDTO) oCurr.getValue()).Dump(1 + p_iLev);
+ }
+ } // __________________________________
+
+} // ____________________________________________________________________________
Modified: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/util/EsbUtil.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/util/EsbUtil.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/util/EsbUtil.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,24 +1,24 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.soa.esb.util;
@@ -27,93 +27,77 @@
import javax.naming.*;
import org.apache.log4j.*;
-public class EsbUtil
-{
- private EsbUtil() {}
+public class EsbUtil {
+ private EsbUtil() {
+ }
- public static void dumpSysProps(PrintStream p_OS)
- { String[] sa = new String[System.getProperties().size()];
- System.getProperties().keySet().toArray(sa);
- Arrays.sort(sa);
- for (String sCurr : sa)
- p_OS.println(sCurr+"<"+System.getProperty(sCurr)+">");
- } //__________________________________
+ public static void dumpSysProps(PrintStream p_OS) {
+ String[] sa = new String[System.getProperties().size()];
+ System.getProperties().keySet().toArray(sa);
+ Arrays.sort(sa);
+ for (String sCurr : sa)
+ p_OS.println(sCurr + "=" + System.getProperty(sCurr));
+ } // __________________________________
- public static boolean isNullString(String p_s)
- { return (null==p_s) ? true : p_s.trim().length()<1;
- } //__________________________________
+ public static boolean isNullString(String p_s) {
+ return (null == p_s) ? true : p_s.trim().length() < 1;
+ } // __________________________________
- public static boolean isLong(String p_s)
- { if (isNullString(p_s)) return false;
- try
- { Long.parseLong(p_s);
- return true;
- }
- catch (Exception e) { return false; }
- } //__________________________________
+ public static boolean isLong(String p_s) {
+ if (isNullString(p_s))
+ return false;
+ try {
+ Long.parseLong(p_s);
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+ } // __________________________________
- public static boolean isPositiveLong(String p_s)
- { if (isNullString(p_s)) return false;
- try
- { long lBk = Long.parseLong(p_s);
- return lBk > 0;
- }
- catch (Exception e) { return false; }
- } //__________________________________
+ public static boolean isPositiveLong(String p_s) {
+ if (isNullString(p_s))
+ return false;
+ try {
+ long lBk = Long.parseLong(p_s);
+ return lBk > 0;
+ } catch (Exception e) {
+ return false;
+ }
+ } // __________________________________
- public static int parseInt(String s)
- {
- if ( s == null) return 0;
- String sVal = s.trim();
- if (sVal.length() < 1)
- return 0;
- else
- try { return Integer.parseInt(s); }
- catch (NumberFormatException ex) { return 0; }
- } //__________________________________
+ public static int parseInt(String s) {
+ if (s == null)
+ return 0;
+ String sVal = s.trim();
+ if (sVal.length() < 1)
+ return 0;
+ else
+ try {
+ return Integer.parseInt(s);
+ } catch (NumberFormatException ex) {
+ return 0;
+ }
+ } // __________________________________
- public static long parseLong(String s)
- {
- if ( s == null) return 0;
- String sVal = s.trim();
- if (sVal.length() < 1)
- return 0;
- else
- try { return Long.parseLong(s); }
- catch (NumberFormatException ex) { return 0; }
- } //__________________________________
+ public static long parseLong(String s) {
+ if (s == null)
+ return 0;
+ String sVal = s.trim();
+ if (sVal.length() < 1)
+ return 0;
+ else
+ try {
+ return Long.parseLong(s);
+ } catch (NumberFormatException ex) {
+ return 0;
+ }
+ } // __________________________________
+ public static Logger getDefaultLogger(Class p_oCls) {
+ Logger oRet = Logger.getLogger(p_oCls.getName());
+ Appender oApp = new ConsoleAppender(new TTCCLayout("ISO8601"));
+ oRet.addAppender(oApp);
+ return oRet;
+ } // __________________________________
- public static Context getJndiContext()
- { return jndiContextFromSysProp(null);
- } //__________________________________
-
- public static Context jndiContextFromSysProp(String p_sSysProp)
- { String sProp = (null==p_sSysProp) ? "appServer" : p_sSysProp;
- return getJbossJndiContext(System.getProperty(sProp));
- } //__________________________________
-
- public static Context getJbossJndiContext(String p_sServer)
- { if (null==p_sServer) return null;
- Properties oPr = new Properties();
- oPr.setProperty(Context.PROVIDER_URL,p_sServer);
- oPr.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
- oPr.setProperty(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
- try { return new InitialContext(oPr); }
- catch (Exception e) { e.printStackTrace(); return null; }
- } //__________________________________
-
- public static String classSuffix(Class pCls)
- { return pCls.getSimpleName();
- } //__________________________________
-
- public static Logger getDefaultLogger(Class p_oCls)
- { Logger oRet = Logger.getLogger(p_oCls.getName());
- Appender oApp = new ConsoleAppender(new TTCCLayout("ISO8601"));
- oRet.addAppender(oApp);
- return oRet;
-} //__________________________________
-
-
-
-} //____________________________________________________________________________
+} // ____________________________________________________________________________
Modified: labs/jbossesb/branches/refactor/product/core/common/tests/build.xml
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/tests/build.xml 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/tests/build.xml 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,10 +1,11 @@
<?xml version="1.0"?>
<project name="build.common.tests" default="org.jboss.esb.common.tests.compile" basedir=".">
+ <property name="org.jboss.esb.module.src.dir" value="../src"/>
+ <property name="org.jboss.esb.module.classes.dir" value="${org.jboss.esb.internal.dest}/classes/common"/>
+ <property name="org.jboss.esb.module.tests.src.dir" value="${basedir}/src"/>
<property name="org.jboss.esb.tests.classes.dir" value="${org.jboss.esb.internal.dest}/tests"/>
<property name="org.jboss.esb.tests.report.dir" value="${org.jboss.esb.internal.dest}/tests/junit"/>
- <property name="org.jboss.esb.core.classes.dir" value="${org.jboss.esb.internal.dest}/classes/common"/>
- <property name="org.jboss.esb.tests.src.dir" value="${basedir}/src"/>
<property name="org.jboss.esb.root.dir" value="../.."/>
<property environment="env"/>
@@ -15,8 +16,8 @@
<path id="org.jboss.esb.tests.base.classpath">
<fileset dir="../${org.jboss.esb.ext.lib.dir}"
- includes="activation.jar jbossall-client.jar log4j.jar mail.jar junit.jar"/>
- <pathelement location="${org.jboss.esb.core.classes.dir}"/>
+ includes="activation.jar jbossall-client.jar log4j.jar mail.jar junit.jar emma.jar emma_ant.jar"/>
+ <pathelement location="${org.jboss.esb.module.classes.dir}"/>
</path>
<target name="org.jboss.esb.tests.init">
@@ -42,68 +43,68 @@
debug="${org.jboss.esb.debug}"
optimize="${org.jboss.esb.optimize}"
>
- <src path="${org.jboss.esb.tests.src.dir}"/>
+ <src path="${org.jboss.esb.module.tests.src.dir}"/>
</javac>
</target>
+ <taskdef resource="emma_ant.properties" classpathref="org.jboss.esb.tests.base.classpath" />
- <!-- ====================================================================== -->
+ <!-- ====================================================================== -->
<!-- T E S T -->
<!-- ====================================================================== -->
<target name="org.jboss.esb.common.internal.test">
- <antcall target="org.jboss.esb.common.internal.test.unit"/>
- <antcall target="org.jboss.esb.common.internal.test.functional"/>
- </target>
+ <property name="org.jboss.esb.module.tests.coverage.dir" value="${org.jboss.esb.internal.dest}/tests/coverage/common"/>
+ <property name="org.jboss.esb.module.classes.instr.dir" value="${org.jboss.esb.module.tests.coverage.dir}/instr" />
+ <!-- Instrument the code for code coverage - using emma... -->
+ <delete dir="${org.jboss.esb.module.tests.coverage.dir}" />
+ <mkdir dir="${org.jboss.esb.module.tests.coverage.dir}" />
+ <emma>
+ <instr instrpath="${org.jboss.esb.module.classes.dir}"
+ destdir="${org.jboss.esb.module.classes.instr.dir}"
+ metadatafile="${org.jboss.esb.module.tests.coverage.dir}/coverage.emma" />
+ </emma>
- <!-- ====================================================================== -->
- <!-- U N I T T E S T S -->
- <!-- ====================================================================== -->
- <target name="org.jboss.esb.common.internal.test.unit">
- <echo message="Running tests for module"/>
- <junit printsummary="yes" haltonerror="yes" haltonfailure="yes" showoutput="no" fork="true">
- <formatter type="plain" usefile="false"/>
- <formatter type="xml"/>
- <batchtest todir="${org.jboss.esb.tests.report.dir}">
- <fileset dir="${org.jboss.esb.tests.classes.dir}">
- <include name="**/**/common/**/**UnitTest.class"/>
- </fileset>
- </batchtest>
- <classpath>
- <path refid="org.jboss.esb.tests.base.classpath"/>
- <pathelement location="${org.jboss.esb.core.classes.dir}"/>
- <pathelement location="${org.jboss.esb.tests.classes.dir}"/>
- </classpath>
- </junit>
- <junitreport>
- <fileset dir="${org.jboss.esb.tests.report.dir}">
- <include name="*.xml"/>
- </fileset>
- <report format="frames" todir="${org.jboss.esb.tests.report.dir}"/>
- <report format="noframes" todir="${org.jboss.esb.tests.report.dir}"/>
- </junitreport>
+ <!-- Run the tests -->
+ <antcall target="org.jboss.esb.services.internal.test.exec"/>
+
+ <!-- Generate the coverage report -->
+ <emma>
+ <report sourcepath="${org.jboss.esb.module.src.dir}" sort="+block,+name,+method,+class" metrics="method:70,block:80,line:80,class:100">
+ <fileset dir="${org.jboss.esb.module.tests.coverage.dir}" >
+ <include name="*.emma" />
+ </fileset>
+ <html outfile="${org.jboss.esb.module.tests.coverage.dir}/index.html" depth="method" columns="name,line,class,method,block"/>
+ </report>
+ </emma>
</target>
-
<!-- ====================================================================== -->
- <!-- F U NC T I O N A L T E S T S -->
+ <!-- U N I T A N D F U N C T I O N A L T E S T S -->
<!-- ====================================================================== -->
- <target name="org.jboss.esb.common.internal.test.functional">
+ <target name="org.jboss.esb.services.internal.test.exec">
<echo message="Running tests for module"/>
<junit printsummary="yes" haltonerror="yes" haltonfailure="yes" showoutput="no" fork="true">
<formatter type="plain" usefile="false"/>
<formatter type="xml"/>
<batchtest todir="${org.jboss.esb.tests.report.dir}">
- <fileset dir="${org.jboss.esb.tests.classes.dir}">
- <include name="**/**/common/**/**FuncTest.class"/>
+ <fileset dir="${org.jboss.esb.module.tests.src.dir}">
+ <include name="**/**UnitTest.java"/>
+ <include name="**/**FuncTest.java"/>
</fileset>
</batchtest>
<classpath>
+ <!-- using instrumented code for code coverage -->
+ <pathelement location="${org.jboss.esb.module.classes.instr.dir}"/>
+ <pathelement location="${org.jboss.esb.tests.classes.dir}"/>
+ <!-- Need the tests src folder because there may be non-compiled test resources -->
+ <pathelement location="${org.jboss.esb.module.tests.src.dir}"/>
<path refid="org.jboss.esb.tests.base.classpath"/>
- <pathelement location="${org.jboss.esb.core.classes.dir}"/>
- <pathelement location="${org.jboss.esb.tests.classes.dir}"/>
</classpath>
+ <!-- emma jvm args -->
+ <jvmarg value="-Demma.coverage.out.file=${org.jboss.esb.module.tests.coverage.dir}/coverage.emma" />
+ <jvmarg value="-Demma.coverage.out.merge=true" />
</junit>
<junitreport>
<fileset dir="${org.jboss.esb.tests.report.dir}">
@@ -113,5 +114,4 @@
<report format="noframes" todir="${org.jboss.esb.tests.report.dir}"/>
</junitreport>
</target>
-
</project>
Copied: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/StreamUtils.java (from rev 5352, labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/StreamUtils.java)
Copied: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/StringUtils.java (from rev 5352, labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/StringUtils.java)
Copied: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/W3CDomUtils.java (from rev 5352, labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/W3CDomUtils.java)
Modified: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/common/tests/parameters/ParamsRepositoryUnitTest.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/common/tests/parameters/ParamsRepositoryUnitTest.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/common/tests/parameters/ParamsRepositoryUnitTest.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -21,9 +21,9 @@
*/
package org.jboss.soa.esb.common.tests.parameters;
-import javax.naming.*;
+//import javax.naming.*;
-import org.jboss.soa.esb.helpers.*;
+//import org.jboss.soa.esb.helpers.*;
import org.jboss.soa.esb.parameters.*;
import org.jboss.soa.esb.common.tests.BaseTest;
Copied: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers (from rev 5352, labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/helpers)
Deleted: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/AppServerContextUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/helpers/AppServerContextUnitTest.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/AppServerContextUnitTest.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,46 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.soa.esb.helpers;
-
-import java.util.Hashtable;
-
-import javax.naming.Context;
-import javax.naming.NamingException;
-
-import junit.framework.TestCase;
-
-/**
- * AppServerContex unit tests.
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- */
-public class AppServerContextUnitTest extends TestCase {
-
- public void test_AppServerContext() throws NamingException {
- Context ctx = AppServerContext.getServerContext("jboss", "http://localhost:1234");
-
- Hashtable props = ctx.getEnvironment();
- System.out.println(props);
- assertEquals("org.jnp.interfaces.NamingContextFactory", props.get(Context.INITIAL_CONTEXT_FACTORY));
- assertEquals("http://localhost:1234", props.get(Context.PROVIDER_URL));
- assertEquals("jboss.naming:org.jnp.interfaces", props.get("java.naming.factory.url.pkgs"));
- }
-}
Copied: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/AppServerContextUnitTest.java (from rev 5352, labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/helpers/AppServerContextUnitTest.java)
Deleted: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/DomElementUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/helpers/DomElementUnitTest.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/DomElementUnitTest.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,260 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.soa.esb.helpers;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.util.Arrays;
-
-import org.jboss.soa.esb.StreamUtils;
-import org.jboss.soa.esb.StringUtils;
-import org.jboss.soa.esb.common.tests.BaseTest;
-import org.xml.sax.SAXException;
-
-/**
- * Unit tests for the DomElement class.
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- */
-public class DomElementUnitTest extends BaseTest {
-
- public void test_fromInputStream_args() throws SAXException, IOException {
- try {
- DomElement.fromInputStream(null);
- fail("Expected IllegalArgumentException on null stream.");
- } catch(IllegalArgumentException e) {
- // Expected
- }
- }
-
- public void test_fromInputStream_and_toXML() throws SAXException, IOException {
- DomElement domElement = DomElement.fromInputStream(getClass().getResourceAsStream("testfile1.xml"));
- ByteArrayOutputStream output;
- byte[] expected = StreamUtils.readStream(getClass().getResourceAsStream("expected_01.xml"));
-
- // Create the DomElement from a Stream. Then...
- // Dump the XML to a buffer and compare it with the expected - checking that the
- // Created DomElement DOM is the same as what was supplied in the stream. Also
- // tests the toXML method. If this fails, either fromInputStream is not working correctly
- // or the toXML method is not serialising correctly.
- output = domElement.toXml();
- assertTrue("DomElement creation from a stream failed, or, DomElement toXML failed - failed to produce the same XML.",
- StringUtils.equalsIgnoreLinebreaks(new String(expected), output.toString(), false));
- }
-
- public void test_fromXML_args() throws SAXException, IOException {
- try {
- DomElement.fromXml(null);
- fail("Expected IllegalArgumentException on null String.");
- } catch(IllegalArgumentException e) {
- // Expected
- }
- try {
- DomElement.fromXml(" ");
- fail("Expected IllegalArgumentException on null String.");
- } catch(IllegalArgumentException e) {
- // Expected
- }
- }
-
- public void test_fromXML_and_toXML() throws SAXException, IOException {
- byte[] source = StreamUtils.readStream(getClass().getResourceAsStream("expected_01.xml"));
- DomElement domElement = DomElement.fromXml(new String(source));
- ByteArrayOutputStream output;
- byte[] expected = source;
-
- // Create the DomElement from a String. Then...
- // Dump the XML to a buffer and compare it with the expected - checking that the
- // Created DomElement DOM is the same as what was supplied in the stream. Also
- // tests the toXML method. If this fails, either fromInputStream is not working correctly
- // or the toXML method is not serialising correctly.
- output = domElement.toXml();
- assertTrue("DomElement creation from a String failed, or, DomElement toXML failed - failed to produce the same XML.",
- StringUtils.equalsIgnoreLinebreaks(new String(expected), output.toString(), false));
- }
-
- public void test_Constructor_W3CElement() throws SAXException, IOException {
- DomElement domElement = DomElement.fromInputStream(getClass().getResourceAsStream("testfile1.xml"));
-// ByteArrayOutputStream output;
- byte[] expected = StreamUtils.readStream(getClass().getResourceAsStream("expected_01.xml"));
-
- // Create a new DomElement from an existing one and compare it with the expected.
- domElement = new DomElement(domElement.getDomElement());
- assertTrue("DomElement creation from a stream failed, or, DomElement(Element) Constructor failed - failed to produce the same XML.",
- StringUtils.equalsIgnoreLinebreaks(new String(expected), new String(domElement.toXml().toByteArray()), false));
- }
-
- public void test_Constructor_String_withoutparent() throws SAXException, IOException {
- // Create a new DomElement from without a parent DomElement.
- DomElement domElement = new DomElement("newDomElement");
-
- assertEquals("New DomElement invalid.", "<newDomElement/>" + DomElement.LINE_BREAK, domElement.toString());
- }
-
- public void test_getName() {
- DomElement domElement = new DomElement("newDomElement");
- assertEquals("getName returned invalid data.", "newDomElement", domElement.getName());
- }
-
- public void test_getAttrKeys_hasnokeys() throws SAXException, IOException {
- DomElement domElement = new DomElement("newDomElement");
- String[] expected = new String[] {};
- String[] actual = domElement.getAttrKeys();
-
- assertTrue("invalid attribute name list", Arrays.equals(expected, actual));
- }
-
- public void test_getAttrKeys_haskeys() throws SAXException, IOException {
- DomElement domElement = DomElement.fromInputStream(getClass().getResourceAsStream("testfile2.xml"));
- String[] expected = new String[] {"attrib1", "attrib2", "attrib3"};
- String[] actual = domElement.getAttrKeys();
-
- assertTrue("invalid attribute name list", Arrays.equals(expected, actual));
- }
-
- public void test_getAttr() throws SAXException, IOException {
- DomElement domElement = DomElement.fromInputStream(getClass().getResourceAsStream("testfile2.xml"));
-
- assertEquals("invalid attribute value", "value2", domElement.getAttr("attrib2"));
- assertEquals("invalid attribute value", null, domElement.getAttr("attribXX"));
- }
-
- public void test_getTextChildren() throws SAXException, IOException {
- // This test also tests the static method getTextValue.
- DomElement domElement = DomElement.fromInputStream(getClass().getResourceAsStream("testfile3.xml"));
-
- // REVIEW: These tests capture the current behavior of the getTextChildren method. I'm not convinced this behavior is correct!!
- // I think perhaps this method should not be depending on getTextValue because getTextValue
- // concatentates the child text nodes.
- assertTrue("invalid Text Children list",
- Arrays.equals(new String[] {"Some root text... and some more root text..."}, domElement.getTextChildren("root")));
- assertTrue("invalid Text Children list",
- Arrays.equals(new String[] {"", "Some nested text..."}, domElement.getTextChildren("el")));
- }
-
- public void test_getElementChildren() throws SAXException, IOException {
- DomElement domElement = DomElement.fromInputStream(getClass().getResourceAsStream("testfile3.xml"));
- DomElement[] domElements;
-
- // Test the root element - of which there's only 1...
- domElements = domElement.getElementChildren("root");
- assertEquals("Wrong number of DomElement ElementChildren.", 1, domElements.length);
- String expected = new String(StreamUtils.readStream(getClass().getResourceAsStream("expected_03.xml"))).trim();
- assertEquals("Wrong DomElement ElementChild value.", expected, domElements[0].toString().trim());
-
- // Test the nested <el> elements - of which there are 2...
- domElements = domElement.getElementChildren("el");
- assertEquals("Wrong number of DomElement ElementChildren.", 2, domElements.length);
- assertEquals("Wrong DomElement ElementChild value.", "<el index=\"1\"/>", domElements[0].toString().trim());
- assertEquals("Wrong DomElement ElementChild value.", "<el index=\"2\">Some nested text...</el>", domElements[1].toString().trim());
-
- // Test for a non-existant element...
- domElements = domElement.getElementChildren("xxxx");
- assertEquals("Wrong number of DomElement ElementChildren.", 0, domElements.length);
- }
-
- public void test_getFirstElementChild() throws SAXException, IOException {
- DomElement domElement = DomElement.fromInputStream(getClass().getResourceAsStream("testfile3.xml"));
-
- // Test the root element - of which there's only 1...
- domElement = domElement.getFirstElementChild("root");
- String expected = new String(StreamUtils.readStream(getClass().getResourceAsStream("expected_03.xml"))).trim();
- assertEquals("Wrong DomElement ElementChild value.", expected, domElement.toString().trim());
-
- // Test the nested <el> elements - of which there are 2...
- domElement = domElement.getFirstElementChild("el");
- assertEquals("Wrong DomElement ElementChild value.", "<el index=\"1\"/>", domElement.toString().trim());
-
- // Test for a non-existant element...
- domElement = domElement.getFirstElementChild("xxxx");
- assertEquals("Expected null DomElement ElementChildren for non-existant element.", null, domElement);
- }
-
- public void test_getAllElemChildren() throws SAXException, IOException {
- DomElement domElement = DomElement.fromInputStream(getClass().getResourceAsStream("testfile3.xml"));
- DomElement[] domElements;
-
- domElements = domElement.getAllElemChildren();
- assertEquals("Wrong number of DomElement ElementChildren.", 2, domElements.length);
- assertEquals("Wrong DomElement ElementChild value.", "<el index=\"1\"/>", domElements[0].toString().trim());
- assertEquals("Wrong DomElement ElementChild value.", "<el index=\"2\">Some nested text...</el>", domElements[1].toString().trim());
-
- // REVIEW: Note, this method only returns DomElement instances for the child elements
- // of the document root node. Comparing this to the behaviour of getFirstElementChild
- // would seem to demonstrate an inconsitency??? To be consistent, I would expect this method
- // to return a list of 3 DomElement instances - the <root> and 2 <el> elements.
- }
-
- public void test_setAttr() throws SAXException, IOException {
- DomElement domElement = new DomElement("newDomElement");
-
- domElement.setAttr("attrib1", "value1");
- assertEquals("value1", domElement.getAttr("attrib1"));
-
- // A null value removes the attribute.
- domElement.setAttr("attrib1", null);
- assertEquals(null, domElement.getAttr("attrib1"));
-
- // null attrib name currently just causes the method to return???
- domElement.setAttr(null, null);
- }
-
- public void test_addElemChild() throws SAXException, IOException {
- DomElement domElement1 = new DomElement("newDomElement");
- DomElement domElementX = new DomElement("X");
- DomElement domElementY1 = new DomElement("Y1");
- DomElement domElementY2 = new DomElement("Y2");
-
- domElement1.addElemChild(domElementX);
- domElement1.addElemChild(domElementY1);
- domElementX.addElemChild(domElementY2);
- assertEquals("<newDomElement><X/><Y1/></newDomElement>", domElement1.toString().trim());
- // REVIEW: Note how Y2 wasn't added to X???
- }
-
- public void test_rmvChildsByName() throws SAXException, IOException {
- DomElement domElement1 = new DomElement("newDomElement");
- DomElement domElementX = new DomElement("X");
- DomElement domElementY1 = new DomElement("Y1");
- DomElement domElementY2 = new DomElement("Y2");
-
- domElement1.addElemChild(domElementX);
- domElement1.addElemChild(domElementY1);
- domElementX.addElemChild(domElementY2);
- assertEquals("<newDomElement><X/><Y1/></newDomElement>", domElement1.toString().trim());
- domElement1.rmvChildsByName("Y1");
- assertEquals("<newDomElement><X/></newDomElement>", domElement1.toString().trim());
- }
-
- public void test_cloneObj() throws SAXException, IOException {
- DomElement domElement1 = new DomElement("newDomElement");
- DomElement domElementX = new DomElement("X");
- DomElement domElementY = new DomElement("Y");
-
- domElement1.addElemChild(domElementX);
- domElement1.addElemChild(domElementY);
-
- DomElement clone = domElement1.cloneObj();
-
- assertTrue("Clone should produce a completely different object", (domElement1 != clone));
- assertEquals("Clone should produce the same XML", domElement1.toString(), clone.toString());
- }
-}
Copied: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/DomElementUnitTest.java (from rev 5352, labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/helpers/DomElementUnitTest.java)
Deleted: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/EsbEmailUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/helpers/EsbEmailUnitTest.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/EsbEmailUnitTest.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,87 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.soa.esb.helpers;
-
-import java.io.IOException;
-
-import javax.mail.Address;
-import javax.mail.MessagingException;
-import javax.mail.internet.AddressException;
-import javax.mail.internet.MimeBodyPart;
-import javax.mail.internet.MimeMessage;
-import javax.mail.internet.MimeMultipart;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for the EsbEmail class.
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- */
-public class EsbEmailUnitTest extends TestCase {
-
- private DomElement mailParams;
-
- @Override
- protected void setUp() throws Exception {
- mailParams = DomElement.fromInputStream(getClass().getResourceAsStream("testfile4.xml"));
- }
-
- public void test_EsbEmail() throws AddressException, MessagingException, IOException {
- // Look at the source message in testfile4.xml before reading this test.
-
- EsbEmail esbMail = new EsbEmail(mailParams);
- MimeMessage message = esbMail.getMailMessage();
- Address[] addresses;
-
- // Check the "from" address details...
- addresses = message.getFrom();
- assertEquals(1, addresses.length);
- assertEquals("x.x at x.com", addresses[0].toString());
-
- // Check the "to" address details...
- addresses = message.getRecipients(MimeMessage.RecipientType.TO);
- assertEquals(2, addresses.length);
- assertEquals("b.b at b.com", addresses[0].toString());
- assertEquals("c.c at c.com", addresses[1].toString());
-
- // Check the "cc" address details...
- addresses = message.getRecipients(MimeMessage.RecipientType.CC);
- assertEquals(2, addresses.length);
- assertEquals("d.d at c.com", addresses[0].toString());
- assertEquals("e.e at e.com", addresses[1].toString());
-
- // Check the "subject"...
- assertEquals("Unit Test - Subject", message.getSubject());
-
- // Check the message body, including attachments...
- MimeMultipart content = (MimeMultipart) message.getContent(); // expect a cast exception if it's not the expected type!
- assertEquals(3, content.getCount()); // the message and the 2 attachments - see testfile4.xml
- MimeBodyPart part = (MimeBodyPart) content.getBodyPart(0); // the message
- assertEquals("Unit Test - Message", ((String)part.getContent()).trim());
- part = (MimeBodyPart) content.getBodyPart(1); // attachement 1
- assertEquals("attachment1.txt", ((String)part.getFileName()).trim());
- part = (MimeBodyPart) content.getBodyPart(2); // attachement 2
- assertEquals("attachment2.txt", ((String)part.getFileName()).trim());
- }
-
- // TODO: Add some negative tests!!!
-}
Copied: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/EsbEmailUnitTest.java (from rev 5352, labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/helpers/EsbEmailUnitTest.java)
Deleted: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/KeyValuePairUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/helpers/KeyValuePairUnitTest.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/KeyValuePairUnitTest.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,58 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.soa.esb.helpers;
-
-import junit.framework.TestCase;
-
-/**
- * Unit tests for the KeyValuePair class.
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- */
-public class KeyValuePairUnitTest extends TestCase {
-
- public void test_Constructor_args() {
- try {
- new KeyValuePair(null, "aaa");
- fail("Expected IllegalArgumentException");
- } catch(IllegalArgumentException e) {
- // expected
- }
- try {
- new KeyValuePair(" ", "aaa");
- fail("Expected IllegalArgumentException");
- } catch(IllegalArgumentException e) {
- // expected
- }
- new KeyValuePair("a", "aaa");
- new KeyValuePair("a", null);
- new KeyValuePair("a", "");
- }
-
- public void test_methods() {
- KeyValuePair kvp = new KeyValuePair("key", "value");
-
- assertEquals("key", kvp.getKey());
- assertEquals("value", kvp.getValue());
- assertEquals("value", kvp.toString());
- assertEquals("KVpair[key=value]", kvp.dump());
- }
-}
Copied: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/KeyValuePairUnitTest.java (from rev 5352, labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/helpers/KeyValuePairUnitTest.java)
Deleted: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/expected_01.xml
===================================================================
--- labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/helpers/expected_01.xml 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/expected_01.xml 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,7 +0,0 @@
-<test>
- <el index="1"/>
- <el index="2">
- <el index="2.1"/>
- And some text...
- </el>
-</test>
Copied: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/expected_01.xml (from rev 5352, labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/helpers/expected_01.xml)
Deleted: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/expected_02.xml
===================================================================
--- labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/helpers/expected_02.xml 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/expected_02.xml 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1 +0,0 @@
-<test> <el index="1"/> <el index="2"> <el index="2.1"/> And some text... </el> </test>
\ No newline at end of file
Copied: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/expected_02.xml (from rev 5352, labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/helpers/expected_02.xml)
Deleted: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/expected_03.xml
===================================================================
--- labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/helpers/expected_03.xml 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/expected_03.xml 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1 +0,0 @@
-<root><el index="1"/>Some root text...<el index="2">Some nested text...</el> and some more root text...</root>
\ No newline at end of file
Copied: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/expected_03.xml (from rev 5352, labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/helpers/expected_03.xml)
Deleted: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/testfile1.xml
===================================================================
--- labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/helpers/testfile1.xml 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/testfile1.xml 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,7 +0,0 @@
-<test>
- <el index="1"/>
- <el index="2">
- <el index="2.1"/>
- And some text...
- </el>
-</test>
\ No newline at end of file
Copied: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/testfile1.xml (from rev 5352, labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/helpers/testfile1.xml)
Deleted: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/testfile2.xml
===================================================================
--- labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/helpers/testfile2.xml 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/testfile2.xml 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1 +0,0 @@
-<test attrib1="value1" attrib2="value2" attrib3="valu3" />
\ No newline at end of file
Copied: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/testfile2.xml (from rev 5352, labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/helpers/testfile2.xml)
Deleted: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/testfile3.xml
===================================================================
--- labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/helpers/testfile3.xml 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/testfile3.xml 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1 +0,0 @@
-<root><el index="1"/>Some root text...<el index="2">Some nested text...</el> and some more root text...</root>
\ No newline at end of file
Copied: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/testfile3.xml (from rev 5352, labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/helpers/testfile3.xml)
Deleted: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/testfile4.xml
===================================================================
--- labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/helpers/testfile4.xml 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/testfile4.xml 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,9 +0,0 @@
-<mailParams from="x.x at x.com"
- sendTo="b.b at b.com,c.c at c.com"
- ccTo="d.d at c.com,e.e at e.com"
- subject="Unit Test - Subject" message="Unit Test - Message">
-
- <attachment>attachment1.txt</attachment>
- <attachment>attachment2.txt</attachment>
-
-</mailParams>
\ No newline at end of file
Copied: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/helpers/testfile4.xml (from rev 5352, labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/helpers/testfile4.xml)
Copied: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/util (from rev 5352, labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/util)
Deleted: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/util/BobjStdDTOUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/util/BobjStdDTOUnitTest.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/util/BobjStdDTOUnitTest.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,123 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.soa.esb.util;
-
-import org.jboss.soa.esb.StreamUtils;
-import org.jboss.soa.esb.StringUtils;
-import org.jboss.soa.esb.W3CDomUtils;
-import org.w3c.dom.Document;
-
-import junit.framework.TestCase;
-
-/**
- * BobjStdDTO unit tests.
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- */
-public class BobjStdDTOUnitTest extends TestCase {
-
- public void test_getFromXml_String() throws Exception {
- try {
- BobjStdDTO.getFromXml(null);
- fail("expected IllegalArgumentException");
- } catch(IllegalArgumentException e) {
- // expected
- }
- try {
- BobjStdDTO.getFromXml(" ");
- fail("expected IllegalArgumentException");
- } catch(IllegalArgumentException e) {
- // expected
- }
-
- String source = new String(StreamUtils.readStream(
- getClass().getResourceAsStream("BobjStdDTOUnitTest_testfile1.xml")));
- BobjStdDTO rootBob = BobjStdDTO.getFromXml(source);
-
- // Check the attributes on the root element of the serialised object representation...
- assertEquals("Brum", rootBob.getAttr("fmlyN"));
- assertEquals("Daniel", rootBob.getAttr("givN"));
- assertEquals("Mr.", rootBob.getAttr("pfx"));
- assertEquals("the 1st.", rootBob.getAttr("sfx"));
- assertTrue(!rootBob.isEmpty());
- assertTrue(!rootBob.isList());
-
- // Check the nested Address - this is a "List"....
- BobjStdDTO childBob = rootBob.getDTO("Laddr");
- assertNotNull(childBob);
- assertTrue(!childBob.isEmpty());
- assertTrue(childBob.isList());
- // Address is a list type. Calling getAttr should result in an exception...
- try {
- childBob.getAttr("xx");
- fail("expected UnsupportedOperationException");
- } catch (UnsupportedOperationException e) {
- // expected
- }
- assertEquals("Address", childBob.m_sClassNm);
- assertEquals(null, childBob.m_oAtts);
-
- // Run a few more checks...
- childBob = rootBob.getDTO("Lpho");
- assertNotNull(childBob);
- childBob = rootBob.getDTO("Lemail");
- assertNotNull(childBob);
-
- // TODO: Add tests for the locator and batch "stuff"!
- }
-
- public void test_toDoc() throws Exception {
- String source = new String(StreamUtils.readStream(
- getClass().getResourceAsStream("BobjStdDTOUnitTest_testfile1.xml")));
- BobjStdDTO bob = BobjStdDTO.getFromXml(source);
-
- // Call toDoc on the Bob, serialise it and compare the serialised
- // form to the original input. They should match...
- Document doc = bob.toDoc();
- String serialisedVer = W3CDomUtils.serialize(doc);
- assertTrue(StringUtils.equalsIgnoreLinebreaks(source, serialisedVer, false));
- }
-
- public void test_MiscTests() throws Exception {
- String source = new String(StreamUtils.readStream(
- getClass().getResourceAsStream("BobjStdDTOUnitTest_testfile1.xml")));
- BobjStdDTO bob = BobjStdDTO.getFromXml(source);
-
- // Calling dump simply to improve the coverage figures - this is a dev utility method
- // so testing this isn't so important...
- bob.Dump(0);
-
- // Check the setter and getter methods. This is a bit anal but makes a
- // big diff on the coverage figures for this class...
- bob.setUid(1234);
- assertEquals(1234, bob.getUid());
- bob.setBatch(1234);
- assertEquals(1234, bob.getBatch());
- bob.setSnap(1234);
- assertEquals(1234, bob.getSnap());
- bob.setStamp(1234);
- assertEquals(1234, bob.getStamp());
- bob.setSnapDate("30/12/1990");
- assertEquals("30/12/1990", bob.getSnapDate());
- bob.setSnapType("blah");
- assertEquals("blah", bob.getSnapType());
- }
-}
Copied: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/util/BobjStdDTOUnitTest.java (from rev 5352, labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/util/BobjStdDTOUnitTest.java)
Deleted: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/util/BobjStdDTOUnitTest_testfile1.xml
===================================================================
--- labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/util/BobjStdDTOUnitTest_testfile1.xml 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/util/BobjStdDTOUnitTest_testfile1.xml 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,18 +0,0 @@
-<Person fmlyN="Brum" givN="Daniel" pfx="Mr." sfx="the 1st.">
-<Laddr List="yes" __Class="Address">
-<it cntry="Argentina" postalZip="1642" provSt="Buenos Aires" strLine1="Balcarce" strNum="50" twnCty1="San Isidro">
-<Lpho List="yes" __Class="Telephone">
-<it city="416" num="555-1212" rol="torIP"/>
-<it city="11" cntry="54" ext="7" num="4555-1111" rol="home"/>
-</Lpho>
-</it>
-</Laddr>
-<Lpho List="yes" __Class="Telephone">
-<it city="416" cntry="1" num="555-1212" rol="basement"/>
-<it city="416" num="666-4444" rol="cell"/>
-</Lpho>
-<Lemail List="yes" __Class="OneValue">
-<it rol="home" v="myaddr at gmail.com"/>
-<it rol="work" v="john.smith at jboss.com"/>
-</Lemail>
-</Person>
\ No newline at end of file
Copied: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/util/BobjStdDTOUnitTest_testfile1.xml (from rev 5352, labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/util/BobjStdDTOUnitTest_testfile1.xml)
Deleted: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/util/EsbUtilUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/util/EsbUtilUnitTest.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/util/EsbUtilUnitTest.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,109 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.soa.esb.util;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-/**
- * EsbUtil unit tests.
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- */
-public class EsbUtilUnitTest extends TestCase {
-
- public void testDumpSysProps() throws IOException {
- ByteArrayOutputStream buf = new ByteArrayOutputStream();
-
- EsbUtil.dumpSysProps(new PrintStream(buf));
-
- Properties props = new Properties();
- props.load(new ByteArrayInputStream(buf.toByteArray()));
-
- // Just make sure that something was dumped to the printstream
- // by checking for a property we know will be in the System...
- assertTrue(props.containsKey("file.separator"));
- }
-
- public void testIsNullString() {
- assertTrue(EsbUtil.isNullString(null));
- assertTrue(EsbUtil.isNullString(""));
- assertTrue(EsbUtil.isNullString(" "));
- assertTrue(!EsbUtil.isNullString("a"));
- }
-
- public void testIsLong() {
- assertTrue(!EsbUtil.isLong(null));
- assertTrue(!EsbUtil.isLong(""));
- assertTrue(!EsbUtil.isLong(" "));
- assertTrue(!EsbUtil.isLong("a"));
- assertTrue(!EsbUtil.isLong(" 1"));
- assertTrue(!EsbUtil.isLong("1 "));
- assertTrue(!EsbUtil.isLong("1.1"));
- assertTrue(EsbUtil.isLong("1"));
- assertTrue(EsbUtil.isLong("-1"));
- }
-
- public void testIsPositiveLong() {
- assertTrue(!EsbUtil.isPositiveLong(null));
- assertTrue(!EsbUtil.isPositiveLong(""));
- assertTrue(!EsbUtil.isPositiveLong(" "));
- assertTrue(!EsbUtil.isPositiveLong("a"));
- assertTrue(!EsbUtil.isPositiveLong(" 1"));
- assertTrue(!EsbUtil.isPositiveLong("1 "));
- assertTrue(!EsbUtil.isPositiveLong("1.1"));
- assertTrue(EsbUtil.isPositiveLong("1"));
- assertTrue(!EsbUtil.isPositiveLong("0"));
- assertTrue(!EsbUtil.isPositiveLong("-1"));
- }
-
- public void testParseInt() {
- assertEquals(0, EsbUtil.parseInt("a"));
- assertEquals(0, EsbUtil.parseInt(""));
- assertEquals(0, EsbUtil.parseInt(" "));
- assertEquals(0, EsbUtil.parseInt(" 1"));
- assertEquals(0, EsbUtil.parseInt("1 "));
- assertEquals(0, EsbUtil.parseInt("0"));
- assertEquals(1, EsbUtil.parseInt("1"));
- assertEquals(-1, EsbUtil.parseInt("-1"));
- }
-
- public void testParseLong() {
- assertEquals(0L, EsbUtil.parseLong("a"));
- assertEquals(0L, EsbUtil.parseLong(""));
- assertEquals(0L, EsbUtil.parseLong(" "));
- assertEquals(0L, EsbUtil.parseLong(" 1"));
- assertEquals(0L, EsbUtil.parseLong("1 "));
- assertEquals(0L, EsbUtil.parseLong("0"));
- assertEquals(1L, EsbUtil.parseLong("1"));
- assertEquals(-1L, EsbUtil.parseLong("-1"));
- }
-
- public void testGetDefaultLogger() {
- // Cheating here - just getting the coverage results up a little more :-)
- EsbUtil.getDefaultLogger(EsbUtil.class);
- }
-}
Copied: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/util/EsbUtilUnitTest.java (from rev 5352, labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/util/EsbUtilUnitTest.java)
Modified: labs/jbossesb/branches/refactor/product/core/listeners/src/org/jboss/soa/esb/listeners/JmsQueueListener.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/listeners/src/org/jboss/soa/esb/listeners/JmsQueueListener.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/listeners/src/org/jboss/soa/esb/listeners/JmsQueueListener.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -12,7 +12,6 @@
import javax.naming.*;
import javax.jms.*;
-//import org.jboss.soa.esb.samples.loanbroker.domain.LoanBrokerConstants;
import org.jboss.soa.esb.services.*;
import org.jboss.soa.esb.util.*;
import org.jboss.soa.esb.common.*;
@@ -62,7 +61,7 @@
- protected JmsQueueListener(String p_sParamsUid) throws Exception
+ public JmsQueueListener(String p_sParamsUid) throws Exception
{
m_oLogger = EsbUtil.getDefaultLogger(this.getClass());
@@ -77,7 +76,7 @@
{ try
{ String sMsg = (null == m_oParms)
? "Initial Parameter loading" : "Reloading Params";
- m_oLogger.info(formatLogMsg(sMsg));
+ m_oLogger.debug(formatLogMsg(sMsg));
m_oParms = m_oParmRepos.getElement(m_oParmsName);
}
catch (Exception e)
@@ -113,7 +112,7 @@
{
oneScan(oCurr, bFirst);
}
- if (waitForQuiesce(1000))
+ if (waitForQuiesce(5000))
{ m_bEndRequested = true;
return;
}
@@ -258,9 +257,8 @@
protected QueueConnection m_oQconn;
protected QueueSession m_oQsess;
protected Queue m_oQueue;
+ protected String m_sSelector;
- protected String m_sSelectorService;
-
protected GroupOfChilds(ThreadGroup p_oThrGrp) throws Exception
{
m_oThrGrp = p_oThrGrp;
@@ -273,15 +271,11 @@
{
if (p_oUsrObj instanceof Integer)
{
- updQthreads( ( (Integer) p_oUsrObj).intValue());
+ int iAdd = ((Integer) p_oUsrObj).intValue();
+ m_iQthr += iAdd;
}
} //________________________________
- private synchronized void updQthreads(int p_i)
- {
- m_iQthr += p_i;
- } //________________________________
-
private void execute(DomElement p_oP) throws Exception
{
m_sb.setLength(m_iSbIni);
@@ -338,19 +332,20 @@
m_sb.setLength(m_iSbIni);
m_oChParms = p_oP.cloneObj();
m_oChParms.rmvChildsByName(EsbAbstractProcessor.PARMS_THIS_INSTANCE);
- setMaxThreads(p_oP,1);
+ setMaxThreads(p_oP,10);
obtainAtt(p_oP,LISTEN_QUEUE,null);
- m_sSelectorService = obtainAtt(p_oP,LISTEN_MSG_SELECTOR,null);
+ m_sSelector = obtainAtt(p_oP,LISTEN_MSG_SELECTOR,null);
-
-
-
String sClass = obtainAtt(p_oP,PARM_ACTION_CLASS,null);
if (EsbUtil.isNullString(sClass))
throw new Exception(formatLogMsg("Missing value for "+PARM_ACTION_CLASS));
m_oExecClass = Class.forName(sClass);
+ Constructor m_oConstructor = m_oExecClass.getConstructor
+ (new Class[] {DomElement.class});
+ if (null==m_oConstructor)
+ throw new Exception ("No constructor "+sClass+"(DomElement) found");
} //________________________________
protected final void obtainQueue(DomElement p_oP) throws JMSException, NamingException
@@ -387,49 +382,46 @@
protected void doYourJob(DomElement p_oP) throws Exception
{
+ obtainQueue(p_oP);
while(System.currentTimeMillis() < m_lNextReload)
{
- if (m_iQthr > m_iMaxThr)
- { m_oLogger.info(m_sb.append("Waiting for available threads").toString());
- m_sb.setLength(m_iSbIni);
- Thread.sleep(5000);
- continue;
- }
- obtainQueue(p_oP);
- //String sSelector = m_oParms.getAttr(LISTEN_MSG_SELECTOR);
- MessageConsumer oReader = m_oQsess.createReceiver(m_oQueue, m_sSelectorService);
- Message oMsg = (null==oReader) ? null
- : oReader.receiveNoWait();
- if (null==oMsg)
- { Thread.sleep(1000);
- continue;
- }
+ if (m_iQthr >= m_iMaxThr)
+ return;
- MsgChildProcess oNew = getMsgChildProcess(this,oMsg);
+ MsgChildProcess oNew = getMsgChildProcess(this,p_oP);
new Thread(m_oThrGrp,oNew).start();
// Wait a little bit, so thread count will be updated
// at some point in the past, this sleep was indispensable
// new thread control classes in Java 5 might have solved the problem
Thread.sleep(500);
}
+ if (null!=m_oQsess)
+ try { m_oQsess.close(); }
+ catch (Exception e1) {}
+ if (null!=m_oQconn)
+ try { m_oQconn.close(); }
+ catch (Exception e2) {}
+
} //________________________________
protected MsgChildProcess getMsgChildProcess
- (GroupOfChilds pDad, Message pMsg) throws Exception
- { return new MsgChildProcess (pDad,pMsg); }
+ (GroupOfChilds pDad, DomElement p_oP) throws Exception
+ { return new MsgChildProcess (pDad,p_oP); }
} //______________________________________________________
protected class MsgChildProcess extends Observable implements Runnable
{
protected GroupOfChilds m_oParent; // you can always go there for common stuff
- protected Message m_oMsg;
+ protected DomElement m_oParms;
+ protected EsbMsgProcessor m_oExec;
- public MsgChildProcess(GroupOfChilds p_oGrp, Message p_oMsg)
+ public MsgChildProcess(GroupOfChilds p_oGrp, DomElement p_oParms)
throws Exception
{
+ m_oLogger.debug("Child "+p_oParms.getName());
m_oParent = p_oGrp;
- m_oMsg = p_oMsg;
+ m_oParms = p_oParms;
this.addObserver(m_oParent);
setChanged();
// add 1 to child thread count
@@ -438,26 +430,40 @@
public void run()
{
- Exception oAbend = null;
+ Class[] oaArgs = {DomElement.class};
+ MessageConsumer oReader = null;
try
{
- Constructor oCnst = m_oParent.m_oExecClass
- .getConstructor (new Class[] {DomElement.class});
- DomElement oParms = m_oParent.m_oChParms.cloneObj();
- Object oInst = oCnst.newInstance (new Object[] {oParms});
- EsbMsgProcessor oMP = (EsbMsgProcessor)oInst;
- oMP.processMessage(m_oMsg);
-
+ oReader = m_oParent.m_oQsess.createReceiver
+ (m_oParent.m_oQueue, m_oParent.m_sSelector);
+
+ long lSlack;
+ while ((lSlack=m_lNextReload-System.currentTimeMillis()) > 0)
+ {
+ Message oMsg = (null==oReader) ? null
+ : oReader.receive(lSlack);
+ if (null==oMsg)
+ continue;
+
+ try
+ {
+ DomElement oParms = m_oParms.cloneObj();
+ Constructor oCns = m_oParent.m_oExecClass.getConstructor(oaArgs);
+ Object oInst = oCns.newInstance (new Object[] {oParms});
+ m_oExec = (EsbMsgProcessor)oInst;
+ m_oExec.processMessage(oMsg);
+ notifyOK();
+ }
+ catch (Exception e)
+ { e.printStackTrace();
+ notifyError(e);
+ }
+ }
}
- catch (Exception e)
- { m_oLogger.error("run() FAILED",e);
- oAbend = e;
+ catch (JMSException oJ)
+ {
+ m_oLogger.error(oJ);
}
-
- if (null==oAbend)
- notifyOK();
- else
- notifyError(oAbend);
setChanged();
// decrease child thread count in parent group
@@ -467,11 +473,11 @@
public void notifyOK()
{ try
{
- String sNotif = getOkNotifContent();
+ Serializable oNotif = m_oExec.getOkNotification();
for (DomElement oCurr : m_oParms.getElementChildren(NotificationList.ELEMENT))
{ NotificationList oNL = new NotificationList(oCurr);
if (! oNL.isOK()) continue;
- getNotifHandler().sendNotifications(oCurr,sNotif);
+ getNotifHandler().sendNotifications(oCurr,oNotif);
}
}
catch (Exception e) {}
@@ -479,11 +485,13 @@
public void notifyError(Exception p_e)
{
- String sNotif = getErrorNotifContent();
+ Serializable oNotif = (null==m_oExec)
+ ? "No action class instantiated"
+ : m_oExec.getErrorNotification();
ByteArrayOutputStream oBO = new ByteArrayOutputStream();
PrintStream oPS = new PrintStream(oBO);
try
- { oPS.println(sNotif);
+ { oPS.println(oNotif.toString());
if (null != p_e) p_e.printStackTrace(oPS);
oPS.close();
@@ -511,21 +519,6 @@
}
} //______________________________
- // These methods to be overriden by you own derived class
- protected String getOkNotifContent()
- {
- return "Success";
- }
- protected String getErrorNotifContent()
- {
- return "FAILURE";
- }
-
} //______________________________________________________
- public static void main(String[] args) throws Exception
- {
- new JmsQueueListener(args[0]);
- }
-
} //____________________________________________________________________________
Modified: labs/jbossesb/branches/refactor/product/core/listeners/src/org/jboss/soa/esb/listeners/SqlTablePoller.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/listeners/src/org/jboss/soa/esb/listeners/SqlTablePoller.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/listeners/src/org/jboss/soa/esb/listeners/SqlTablePoller.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -24,6 +24,7 @@
package org.jboss.soa.esb.listeners;
import java.util.*;
+import java.io.Serializable;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.lang.reflect.*;
@@ -542,11 +543,11 @@
public void notifyOK()
{ try
{
- String sNotif = getOkNotifContent();
+ java.io.Serializable oNotif = getOkNotifContent();
for (DomElement oCurr : m_oParms.getElementChildren(NotificationList.ELEMENT))
{ NotificationList oNL = new NotificationList(oCurr);
if (! oNL.isOK()) continue;
- getNotifHandler().sendNotifications(oCurr,sNotif);
+ getNotifHandler().sendNotifications(oCurr,oNotif);
}
}
catch (Exception e) {}
@@ -554,11 +555,11 @@
public void notifyError(Exception p_e)
{
- String sNotif = getErrorNotifContent();
+ Serializable oNotif = getErrorNotifContent();
ByteArrayOutputStream oBO = new ByteArrayOutputStream();
PrintStream oPS = new PrintStream(oBO);
try
- { oPS.println(sNotif);
+ { oPS.println(oNotif);
if (null != p_e) p_e.printStackTrace(oPS);
oPS.close();
@@ -587,11 +588,11 @@
} //______________________________
// These methods to be overriden by you own derived class
- protected String getOkNotifContent()
+ protected Serializable getOkNotifContent()
{
return "Success";
}
- protected String getErrorNotifContent()
+ protected Serializable getErrorNotifContent()
{
return "FAILURE";
}
Modified: labs/jbossesb/branches/refactor/product/core/listeners/tests/build.xml
===================================================================
--- labs/jbossesb/branches/refactor/product/core/listeners/tests/build.xml 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/listeners/tests/build.xml 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,10 +1,11 @@
<?xml version="1.0"?>
<project name="build.listeners.tests" default="org.jboss.esb.listeners.tests.compile" basedir=".">
- <property name="org.jboss.esb.tests.bin.dir" value="${org.jboss.esb.internal.dest}/tests"/>
+ <property name="org.jboss.esb.module.src.dir" value="../src"/>
+ <property name="org.jboss.esb.module.classes.dir" value="${org.jboss.esb.internal.dest}/classes/listeners"/>
+ <property name="org.jboss.esb.module.tests.src.dir" value="${basedir}/src"/>
+ <property name="org.jboss.esb.tests.classes.dir" value="${org.jboss.esb.internal.dest}/tests"/>
<property name="org.jboss.esb.tests.report.dir" value="${org.jboss.esb.internal.dest}/tests/junit"/>
- <property name="org.jboss.esb.core.bin.dir" value="${org.jboss.esb.internal.dest}/classes"/>
- <property name="org.jboss.esb.tests.src.dir" value="${basedir}/src"/>
<property name="org.jboss.esb.root.dir" value="../.."/>
<property environment="env"/>
@@ -15,8 +16,8 @@
<path id="org.jboss.esb.tests.base.classpath">
<fileset dir="../${org.jboss.esb.ext.lib.dir}"
- includes="activation.jar jbossall-client.jar log4j.jar mail.jar junit.jar"/>
- <pathelement location="${org.jboss.esb.core.bin.dir}"/>
+ includes="activation.jar jbossall-client.jar log4j.jar mail.jar junit.jar emma.jar emma_ant.jar"/>
+ <pathelement location="${org.jboss.esb.module.classes.dir}"/>
</path>
<target name="org.jboss.esb.tests.init">
@@ -24,86 +25,86 @@
<format property="TODAY" pattern="d-MM-yy"/>
</tstamp>
- <mkdir dir="${org.jboss.esb.tests.bin.dir}"/>
+ <mkdir dir="${org.jboss.esb.tests.classes.dir}"/>
<mkdir dir="${org.jboss.esb.tests.report.dir}"/>
</target>
<target name="clean"/>
<target name="purge" depends="clean">
- <delete dir="${org.jboss.esb.tests.bin.dir}"/>
+ <delete dir="${org.jboss.esb.tests.classes.dir}"/>
</target>
<target name="org.jboss.esb.listeners.tests.compile" if="org.jboss.esb.buildtests" depends="org.jboss.esb.tests.init">
<javac
- destdir="${org.jboss.esb.tests.bin.dir}"
+ destdir="${org.jboss.esb.tests.classes.dir}"
classpathref="org.jboss.esb.tests.base.classpath"
debug="${org.jboss.esb.debug}"
optimize="${org.jboss.esb.optimize}"
>
- <src path="${org.jboss.esb.tests.src.dir}"/>
+ <src path="${org.jboss.esb.module.tests.src.dir}"/>
</javac>
</target>
+ <taskdef resource="emma_ant.properties" classpathref="org.jboss.esb.tests.base.classpath" />
<!-- ====================================================================== -->
<!-- T E S T -->
<!-- ====================================================================== -->
<target name="org.jboss.esb.listeners.internal.test">
- <antcall target="org.jboss.esb.listeners.internal.test.unit"/>
- <antcall target="org.jboss.esb.listeners.internal.test.functional"/>
- </target>
+ <property name="org.jboss.esb.module.tests.coverage.dir" value="${org.jboss.esb.internal.dest}/tests/coverage/listeners"/>
+ <property name="org.jboss.esb.module.classes.instr.dir" value="${org.jboss.esb.module.tests.coverage.dir}/instr" />
+ <!-- Instrument the code for code coverage - using emma... -->
+ <delete dir="${org.jboss.esb.module.tests.coverage.dir}" />
+ <mkdir dir="${org.jboss.esb.module.tests.coverage.dir}" />
+ <emma>
+ <instr instrpath="${org.jboss.esb.module.classes.dir}"
+ destdir="${org.jboss.esb.module.classes.instr.dir}"
+ metadatafile="${org.jboss.esb.module.tests.coverage.dir}/coverage.emma" />
+ </emma>
+
+ <!-- Run the tests -->
+ <antcall target="org.jboss.esb.services.internal.test.exec"/>
- <!-- ====================================================================== -->
- <!-- U N I T T E S T S -->
- <!-- ====================================================================== -->
- <target name="org.jboss.esb.listeners.internal.test.unit">
- <echo message="Running tests for module"/>
- <junit printsummary="yes" haltonerror="yes" haltonfailure="yes" showoutput="no" fork="true">
- <formatter type="plain" usefile="false"/>
- <formatter type="xml"/>
- <batchtest todir="${org.jboss.esb.tests.report.dir}">
- <fileset dir="${org.jboss.esb.tests.bin.dir}">
- <include name="**/**/listeners/**/**UnitTest.class"/>
- </fileset>
- </batchtest>
- <classpath>
- <path refid="org.jboss.esb.tests.base.classpath"/>
- <pathelement location="${org.jboss.esb.core.bin.dir}"/>
- <pathelement location="${org.jboss.esb.tests.bin.dir}"/>
- </classpath>
- </junit>
- <junitreport>
- <fileset dir="${org.jboss.esb.tests.report.dir}">
- <include name="*.xml"/>
- </fileset>
- <report format="frames" todir="${org.jboss.esb.tests.report.dir}"/>
- <report format="noframes" todir="${org.jboss.esb.tests.report.dir}"/>
- </junitreport>
+ <!-- Generate the coverage report -->
+ <emma>
+ <report sourcepath="${org.jboss.esb.module.src.dir}" sort="+block,+name,+method,+class" metrics="method:70,block:80,line:80,class:100">
+ <fileset dir="${org.jboss.esb.module.tests.coverage.dir}" >
+ <include name="*.emma" />
+ </fileset>
+ <html outfile="${org.jboss.esb.module.tests.coverage.dir}/index.html" depth="method" columns="name,line,class,method,block"/>
+ </report>
+ </emma>
</target>
-
<!-- ====================================================================== -->
- <!-- F U NC T I O N A L T E S T S -->
+ <!-- U N I T A N D F U N C T I O N A L T E S T S -->
<!-- ====================================================================== -->
- <target name="org.jboss.esb.listeners.internal.test.functional">
+ <target name="org.jboss.esb.services.internal.test.exec">
<echo message="Running tests for module"/>
<junit printsummary="yes" haltonerror="yes" haltonfailure="yes" showoutput="no" fork="true">
<formatter type="plain" usefile="false"/>
<formatter type="xml"/>
<batchtest todir="${org.jboss.esb.tests.report.dir}">
- <fileset dir="${org.jboss.esb.tests.bin.dir}">
- <include name="**/**/listeners/**/**FuncTest.class"/>
+ <fileset dir="${org.jboss.esb.module.tests.src.dir}">
+ <include name="**/**UnitTest.java"/>
+ <include name="**/**FuncTest.java"/>
</fileset>
</batchtest>
<classpath>
+ <!-- using instrumented code for code coverage -->
+ <pathelement location="${org.jboss.esb.module.classes.instr.dir}"/>
+ <pathelement location="${org.jboss.esb.tests.classes.dir}"/>
+ <!-- Need the tests src folder because there may be non-compiled test resources -->
+ <pathelement location="${org.jboss.esb.module.tests.src.dir}"/>
<path refid="org.jboss.esb.tests.base.classpath"/>
- <pathelement location="${org.jboss.esb.core.bin.dir}"/>
- <pathelement location="${org.jboss.esb.tests.bin.dir}"/>
</classpath>
+ <!-- emma jvm args -->
+ <jvmarg value="-Demma.coverage.out.file=${org.jboss.esb.module.tests.coverage.dir}/coverage.emma" />
+ <jvmarg value="-Demma.coverage.out.merge=true" />
</junit>
<junitreport>
<fileset dir="${org.jboss.esb.tests.report.dir}">
@@ -113,5 +114,4 @@
<report format="noframes" todir="${org.jboss.esb.tests.report.dir}"/>
</junitreport>
</target>
-
</project>
Modified: labs/jbossesb/branches/refactor/product/core/processors/src/org/jboss/soa/esb/processors/EsbAbstractProcessor.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/processors/src/org/jboss/soa/esb/processors/EsbAbstractProcessor.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/processors/src/org/jboss/soa/esb/processors/EsbAbstractProcessor.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -49,7 +49,7 @@
private static final String POSTPRC_ELEMENT= "postProcess";
private static final String POSTPRC_CLASS = "actionClass";
- private static final String CTX_PREFIX = "@@ctx@@";
+ public static final String CTX_PREFIX = "@@ctx@@";
public static final String CTX_BATCH_UID = CTX_PREFIX+"batchUid";
public static final String CTX_BATCH_NUM = CTX_PREFIX+"batchNum";
public static final String CTX_INPUT_FILE = CTX_PREFIX+"inputFile";
@@ -58,12 +58,11 @@
private static final String[] s_saMacros =
{CTX_BATCH_UID, CTX_BATCH_NUM ,CTX_INPUT_FILE, CTX_POST_FILE };
- private Map m_oContext = new Hashtable();
+ protected Map <String,Object> m_oContext = new HashMap<String,Object>();
public void clearContext () { m_oContext.clear(); }
public Object rmvContextObj (String p_sKey) { return m_oContext.remove(p_sKey); }
public Object getContextObj (String p_sKey) { return m_oContext.get(p_sKey); }
- @SuppressWarnings("unchecked")
-public Object setContextObj (String p_sKey, Object p_oVal)
+ public Object setContextObj (String p_sKey, Object p_oVal)
{ return m_oContext.put(p_sKey,p_oVal); }
protected DomElement m_oParms ,m_oInstP;
@@ -240,10 +239,10 @@
return (null==BO) ? -1 : BO.getUid();
} //________________________________
- public void notifyOK(Object p_o)
+ public void notifyOK(Serializable p_o)
{ try
- { String sMsg = p_o.toString();
- DomElement[] oaP = m_oParms.getElementChildren(NotificationList.ELEMENT);
+ {
+ DomElement[] oaP = m_oParms.getElementChildren(NotificationList.ELEMENT);
for (int i1=0; i1<oaP.length;i1++)
{ NotificationList oCurr = new NotificationList(oaP[i1]);
if (! oCurr.isOK()) continue;
@@ -251,28 +250,23 @@
m_oLogger.info("BEFORE EXPAND <"+m_oContext.get(CTX_BATCH_UID)+">");
replaceMacros(oCpy);
m_oLogger.info("AFTER EXPAND \n"+oCpy.toString()+"\n");
- getNotifHandler().sendNotifications(oCpy,sMsg);
+ getNotifHandler().sendNotifications(oCpy,p_o);
}
}
catch (Exception e) {}
} //__________________________________
- public void notifyError(Exception p_e, Object p_o)
- { ByteArrayOutputStream oBO = new ByteArrayOutputStream();
- PrintStream oPS = new PrintStream(oBO);
+ public void notifyError(Exception p_e, Serializable p_o)
+ {
try
- { oPS.println(p_o.toString());
- if (null != p_e) p_e.printStackTrace(oPS);
- oPS.close();
-
- String sMsg = oBO.toString();
+ {
DomElement[] oaP = m_oParms.getElementChildren(NotificationList.ELEMENT);
if (oaP.length<1) // Uncomment this line to send only to the list
- getNotifHandler().sendNotifications(sMsg);
+ getNotifHandler().sendNotifications(p_o);
for (int i1=0; i1<oaP.length;i1++)
{ NotificationList oCurr = new NotificationList(oaP[i1]);
if (! oCurr.isErr()) continue;
- getNotifHandler().sendNotifications(oaP[i1],sMsg);
+ getNotifHandler().sendNotifications(oaP[i1],p_o);
}
}
catch (Exception e) {
Modified: labs/jbossesb/branches/refactor/product/core/processors/src/org/jboss/soa/esb/processors/EsbMsgProcessor.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/processors/src/org/jboss/soa/esb/processors/EsbMsgProcessor.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/processors/src/org/jboss/soa/esb/processors/EsbMsgProcessor.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,78 +1,90 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.soa.esb.processors;
-
-import java.lang.reflect.Constructor;
-
-import javax.jms.Message;
-import javax.jms.TextMessage;
-
-import org.jboss.soa.esb.helpers.*;
-
-public class EsbMsgProcessor extends EsbAbstractProcessor
-{
- public EsbMsgProcessor(DomElement p_oP) throws Exception
- { super(p_oP,false);
- } //__________________________________
-
- protected void checkParms() throws Exception {}
- public void execute() throws Exception {}
-
- public void processMessage(Message p_oMsg) throws Exception
- {
- String sPrc = this.getClass().getName();
- sPrc = sPrc.substring(1+sPrc.lastIndexOf("."));
-
- StringBuffer sb = new StringBuffer("Message ");
- if (p_oMsg instanceof TextMessage)
- sb.append("<").append(((TextMessage)p_oMsg).getText()).append("> ");
- String sNotifMsg = sb.toString();
-
- sb.setLength(0);
- try
- {
- try
- { Class oCls = Class.forName(m_oParms.getAttr("actionClass"));
- Constructor oCns = oCls.getConstructor(new Class[] {Message.class,EsbAbstractProcessor.class});
- oCns.newInstance(new Object[] {p_oMsg,this});
-
- super.postProcess();
-
- sb.append(sPrc).append(" processed ").append(sNotifMsg).append(" successfully");
- super.notifyOK(sb.toString());
- }
- catch (Exception e)
- { m_oLogger.fatal("Message processor FAILED",e);
- throw e;
- }
- finally { super.release(); }
- }
-
- catch (Exception eGen)
- {
- System.out.println("test catch for rollback here..");
- super.notifyError(eGen," " + sPrc+" PROBLEMS processing "+sNotifMsg);
- throw eGen;
- }
- }//_________________________
-
-} //____________________________________________________________________________
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.processors;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.io.Serializable;
+
+import javax.jms.Message;
+import javax.jms.TextMessage;
+
+import org.jboss.soa.esb.helpers.*;
+
+public class EsbMsgProcessor extends EsbAbstractProcessor
+{
+ public EsbMsgProcessor(DomElement p_oP) throws Exception
+ { super(p_oP,false);
+ } //__________________________________
+
+ protected void checkParms() throws Exception {}
+ public void execute() throws Exception {}
+
+ public void processMessage(Message p_oMsg) throws Exception
+ {
+ StringBuilder sb = new StringBuilder();
+ if (p_oMsg instanceof TextMessage)
+ sb.append("TextMessage<")
+ .append(((TextMessage)p_oMsg).getText())
+ .append("> ");
+ else
+ sb.append(p_oMsg.toString());
+ System.out.println(sb.toString());
+ }//_________________________
+
+ private static final SimpleDateFormat s_oDF
+ = new SimpleDateFormat("MMMM dd, yyyy ");
+
+ protected String messagePfx()
+ {
+ return
+ s_oDF.format(new Date(System.currentTimeMillis()))
+ +" " +this.getClass().getSimpleName()
+ + " : ";
+ }//_________________________
+
+ /**
+ * Override this method in your derived class
+ * <p />Listeners will call this method to request
+ * the object that has to be sent to the 'ok'
+ * notification list
+ * @return Object - The Rosetta notification framework
+ * will use the toString() method of the returned Object
+ */
+ public Serializable getOkNotification()
+ {
+ return messagePfx()+" Normal completion";
+ }
+ /**
+ * Override this method in your derived class
+ * <p />Listeners will call this method to request
+ * the object that has to be sent to the 'error'
+ * notification list
+ * @return Object - The Rosetta notification framework
+ * will use the toString() method of the returned Object
+ */
+ public Serializable getErrorNotification()
+ {
+ return messagePfx()+" Abnormal end";
+ }
+
+} //____________________________________________________________________________
Copied: labs/jbossesb/branches/refactor/product/core/processors/src/org/jboss/soa/esb/processors/Zap.java (from rev 5352, labs/jbossesb/trunk/product/core/processors/src/org/jboss/soa/esb/processors/Zap.java)
Modified: labs/jbossesb/branches/refactor/product/core/processors/tests/build.xml
===================================================================
--- labs/jbossesb/branches/refactor/product/core/processors/tests/build.xml 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/processors/tests/build.xml 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,10 +1,11 @@
<?xml version="1.0"?>
<project name="build.processors.tests" default="org.jboss.esb.processors.tests.compile" basedir=".">
- <property name="org.jboss.esb.tests.bin.dir" value="${org.jboss.esb.internal.dest}/tests"/>
+ <property name="org.jboss.esb.module.src.dir" value="../src"/>
+ <property name="org.jboss.esb.module.classes.dir" value="${org.jboss.esb.internal.dest}/classes/processors"/>
+ <property name="org.jboss.esb.module.tests.src.dir" value="${basedir}/src"/>
+ <property name="org.jboss.esb.tests.classes.dir" value="${org.jboss.esb.internal.dest}/tests"/>
<property name="org.jboss.esb.tests.report.dir" value="${org.jboss.esb.internal.dest}/tests/junit"/>
- <property name="org.jboss.esb.core.bin.dir" value="${org.jboss.esb.internal.dest}/classes"/>
- <property name="org.jboss.esb.tests.src.dir" value="${basedir}/src"/>
<property name="org.jboss.esb.root.dir" value="../.."/>
<property environment="env"/>
@@ -15,8 +16,8 @@
<path id="org.jboss.esb.tests.base.classpath">
<fileset dir="../${org.jboss.esb.ext.lib.dir}"
- includes="activation.jar jbossall-client.jar log4j.jar mail.jar junit.jar"/>
- <pathelement location="${org.jboss.esb.core.bin.dir}"/>
+ includes="activation.jar jbossall-client.jar log4j.jar mail.jar junit.jar emma.jar emma_ant.jar"/>
+ <pathelement location="${org.jboss.esb.module.classes.dir}"/>
</path>
<target name="org.jboss.esb.tests.init">
@@ -24,86 +25,86 @@
<format property="TODAY" pattern="d-MM-yy"/>
</tstamp>
- <mkdir dir="${org.jboss.esb.tests.bin.dir}"/>
+ <mkdir dir="${org.jboss.esb.tests.classes.dir}"/>
<mkdir dir="${org.jboss.esb.tests.report.dir}"/>
</target>
<target name="clean"/>
<target name="purge" depends="clean">
- <delete dir="${org.jboss.esb.tests.bin.dir}"/>
+ <delete dir="${org.jboss.esb.tests.classes.dir}"/>
</target>
<target name="org.jboss.esb.processors.tests.compile" if="org.jboss.esb.buildtests" depends="org.jboss.esb.tests.init">
<javac
- destdir="${org.jboss.esb.tests.bin.dir}"
+ destdir="${org.jboss.esb.tests.classes.dir}"
classpathref="org.jboss.esb.tests.base.classpath"
debug="${org.jboss.esb.debug}"
optimize="${org.jboss.esb.optimize}"
>
- <src path="${org.jboss.esb.tests.src.dir}"/>
+ <src path="${org.jboss.esb.module.tests.src.dir}"/>
</javac>
</target>
+ <taskdef resource="emma_ant.properties" classpathref="org.jboss.esb.tests.base.classpath" />
<!-- ====================================================================== -->
<!-- T E S T -->
<!-- ====================================================================== -->
<target name="org.jboss.esb.processors.internal.test">
- <antcall target="org.jboss.esb.processors.internal.test.unit"/>
- <antcall target="org.jboss.esb.processors.internal.test.functional"/>
- </target>
+ <property name="org.jboss.esb.module.tests.coverage.dir" value="${org.jboss.esb.internal.dest}/tests/coverage/processors"/>
+ <property name="org.jboss.esb.module.classes.instr.dir" value="${org.jboss.esb.module.tests.coverage.dir}/instr" />
+ <!-- Instrument the code for code coverage - using emma... -->
+ <delete dir="${org.jboss.esb.module.tests.coverage.dir}" />
+ <mkdir dir="${org.jboss.esb.module.tests.coverage.dir}" />
+ <emma>
+ <instr instrpath="${org.jboss.esb.module.classes.dir}"
+ destdir="${org.jboss.esb.module.classes.instr.dir}"
+ metadatafile="${org.jboss.esb.module.tests.coverage.dir}/coverage.emma" />
+ </emma>
- <!-- ====================================================================== -->
- <!-- U N I T T E S T S -->
- <!-- ====================================================================== -->
- <target name="org.jboss.esb.processors.internal.test.unit">
- <echo message="Running tests for module"/>
- <junit printsummary="yes" haltonerror="yes" haltonfailure="yes" showoutput="no" fork="true">
- <formatter type="plain" usefile="false"/>
- <formatter type="xml"/>
- <batchtest todir="${org.jboss.esb.tests.report.dir}">
- <fileset dir="${org.jboss.esb.tests.bin.dir}">
- <include name="**/**/processors/**/**UnitTest.class"/>
- </fileset>
- </batchtest>
- <classpath>
- <path refid="org.jboss.esb.tests.base.classpath"/>
- <pathelement location="${org.jboss.esb.core.bin.dir}"/>
- <pathelement location="${org.jboss.esb.tests.bin.dir}"/>
- </classpath>
- </junit>
- <junitreport>
- <fileset dir="${org.jboss.esb.tests.report.dir}">
- <include name="*.xml"/>
- </fileset>
- <report format="frames" todir="${org.jboss.esb.tests.report.dir}"/>
- <report format="noframes" todir="${org.jboss.esb.tests.report.dir}"/>
- </junitreport>
+ <!-- Run the tests -->
+ <antcall target="org.jboss.esb.services.internal.test.exec"/>
+
+ <!-- Generate the coverage report -->
+ <emma>
+ <report sourcepath="${org.jboss.esb.module.src.dir}" sort="+block,+name,+method,+class" metrics="method:70,block:80,line:80,class:100">
+ <fileset dir="${org.jboss.esb.module.tests.coverage.dir}" >
+ <include name="*.emma" />
+ </fileset>
+ <html outfile="${org.jboss.esb.module.tests.coverage.dir}/index.html" depth="method" columns="name,line,class,method,block"/>
+ </report>
+ </emma>
</target>
-
<!-- ====================================================================== -->
- <!-- F U NC T I O N A L T E S T S -->
+ <!-- U N I T A N D F U N C T I O N A L T E S T S -->
<!-- ====================================================================== -->
- <target name="org.jboss.esb.processors.internal.test.functional">
+ <target name="org.jboss.esb.services.internal.test.exec">
<echo message="Running tests for module"/>
<junit printsummary="yes" haltonerror="yes" haltonfailure="yes" showoutput="no" fork="true">
<formatter type="plain" usefile="false"/>
<formatter type="xml"/>
<batchtest todir="${org.jboss.esb.tests.report.dir}">
- <fileset dir="${org.jboss.esb.tests.bin.dir}">
- <include name="**/**/processors/**/**FuncTest.class"/>
+ <fileset dir="${org.jboss.esb.module.tests.src.dir}">
+ <include name="**/**UnitTest.java"/>
+ <include name="**/**FuncTest.java"/>
</fileset>
</batchtest>
<classpath>
+ <!-- using instrumented code for code coverage -->
+ <pathelement location="${org.jboss.esb.module.classes.instr.dir}"/>
+ <pathelement location="${org.jboss.esb.tests.classes.dir}"/>
+ <!-- Need the tests src folder because there may be non-compiled test resources -->
+ <pathelement location="${org.jboss.esb.module.tests.src.dir}"/>
<path refid="org.jboss.esb.tests.base.classpath"/>
- <pathelement location="${org.jboss.esb.core.bin.dir}"/>
- <pathelement location="${org.jboss.esb.tests.bin.dir}"/>
</classpath>
+ <!-- emma jvm args -->
+ <jvmarg value="-Demma.coverage.out.file=${org.jboss.esb.module.tests.coverage.dir}/coverage.emma" />
+ <jvmarg value="-Demma.coverage.out.merge=true" />
</junit>
<junitreport>
<fileset dir="${org.jboss.esb.tests.report.dir}">
@@ -113,5 +114,4 @@
<report format="noframes" todir="${org.jboss.esb.tests.report.dir}"/>
</junitreport>
</target>
-
</project>
Modified: labs/jbossesb/branches/refactor/product/core/processors/tests/src/org/jboss/soa/esb/processors/tests/DummyUnitTest.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/processors/tests/src/org/jboss/soa/esb/processors/tests/DummyUnitTest.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/processors/tests/src/org/jboss/soa/esb/processors/tests/DummyUnitTest.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -22,6 +22,7 @@
package org.jboss.soa.esb.processors.tests;
import org.jboss.soa.esb.common.tests.BaseTest;
+import org.jboss.soa.esb.processors.Zap;
/**
* Dummy test file.
@@ -40,6 +41,7 @@
log.info("****************************************************************");
log.info(" Dummy unit test called. Replace this with module level tests");
log.info("****************************************************************");
+ new Zap();
}
}
Modified: labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/internal/core/objectstore/BobjStore.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/internal/core/objectstore/BobjStore.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/internal/core/objectstore/BobjStore.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,206 +1,267 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
-
package org.jboss.soa.esb.internal.core.objectstore;
+import java.net.URI;
import java.util.*;
import org.jboss.soa.esb.common.*;
import org.jboss.soa.esb.helpers.*;
import org.jboss.soa.esb.util.*;
-public class BobjStore
-{
- private static String DATASRC_JNDI_NAME;
- public static void setDataSourceJndi(String p_s){ DATASRC_JNDI_NAME = p_s; }
- public static String getDataSourceJndi() { return DATASRC_JNDI_NAME; }
+public class BobjStore {
+ private static String DATASRC_JNDI_NAME;
- private static String TBL_UIDS;
- public static void setUidTableName(String p_s) { TBL_UIDS = p_s; }
- public static String getUidTableName() { return TBL_UIDS; }
+ public static void setDataSourceJndi(String p_s) {
+ DATASRC_JNDI_NAME = p_s;
+ }
- private static String TBL_BATCHES;
- public static void setBatchTableName(String p_s) { TBL_BATCHES = p_s; }
- public static String getBatchTableName() { return TBL_BATCHES; }
+ public static String getDataSourceJndi() {
+ return DATASRC_JNDI_NAME;
+ }
- private static final Map<String,BobjStore> s_oStoreMap
- = new HashMap<String,BobjStore>();
+ private static String TBL_UIDS;
- static
- { try
- { DomElement oConf = DomElement.fromURL(EsbSysProps.getObjStoreConfigFile());
- if (null!=oConf)
- {
- setDataSourceJndi (oConf.getAttr("dataSourceJndiName"));
- setUidTableName (oConf.getAttr("uidTable"));
- setBatchTableName (oConf.getAttr("batchTable"));
- for (DomElement oCurr : oConf.getElementChildren("Class"))
- { String sClass = oCurr.getAttr("name");
- boolean bCrypt = "true".equalsIgnoreCase(oCurr.getAttr("encrypt"));
-
- BobjStore oNew = new BobjStore
- (oCurr.getAttr("type")
- ,oCurr.getAttr("table")
- ,null
- ,sClass.substring(1+sClass.lastIndexOf("."))
- ,bCrypt
- );
+ public static void setUidTableName(String p_s) {
+ TBL_UIDS = p_s;
+ }
- for (DomElement oIcurr : oCurr.getElementChildren("Index"))
- oNew.addLocatorTable(oIcurr.getAttr("table"));
- s_oStoreMap.put(sClass,oNew);
- }
- }
- }
- catch (Exception e)
- { EsbUtil.getDefaultLogger(BobjStore.class).error("BobjStore configuration FAILED"
- ,e);
- }
-
- };
-
- private String m_sSnapType , m_sSnapTbl , m_sClass;
- private List<String> m_olLocators;
- private boolean m_bEncrypt=false;
+ public static String getUidTableName() {
+ return TBL_UIDS;
+ }
- /**
- * Snapshot type getter - The value assigned to this attribute will help if
- * standard SQL queries are required to surf the Object Store's snapshot tables
- * @return String - Value of snapshot type
- * @see Istorable#getSnapType()
- */
- public String getSnapType() { return m_sSnapType; }
- /**
- * Snapshot tablename getter - The value assigned to this attribute is the
- * name of the snapshot table for this object
- * @return String - name of SQL table where snapshots of objects will be stored
- * @see Istorable#getSnapTable()
- */
- public String getSnapTable() { return m_sSnapTbl; }
- /**
- * First locator tablename getter - Locator tables are also called index tables.
- * @return String - name of SQL table where locators(0) will be stored
- * @see Istorable#getLocatorTable()
- * @see BusinessObject#getObjLocator()
- */
- public String getLocatorTable() { return getLocatorTable(0); }
- /**
- * Obtain Nth locator table
- * @param p_n - Index for desired locator table
- * @return String - name of Nth SQL table where for objects will be stored
- * @see BaseBusinessObject#locator(p_i)
- */
- public String getLocatorTable(int p_n)
- { return (null==m_olLocators) ? null
- : (m_olLocators.size() <= p_n) ? null
- : m_olLocators.get(p_n);
- }
+ private static String TBL_BATCHES;
- /**
- * Obtain all locator table names
- * @return Names of all locator tables
- */
- public String[] allLocatorTables()
- { return (null==m_olLocators) ? new String[] {}
- : m_olLocators.toArray(new String[m_olLocators.size()]);
- }
- /**
- * Class suffix getter - Deprecated - Left here for backwards compatibility
- * @return String - Class suffix
- * @see Istorable#getLocatorTable()
- * @see BusinessObject#getObjLocator()
- */
- public String getClassSuffix() { return m_sClass; }
- /**
- * Encryption requirement getter
- * @return boolean - true if Objects stored using this descriptor have to be
- * encrypted - decrypted at storage/retrieval time
- */
- public boolean isEncrypted() { return m_bEncrypt; }
+ public static void setBatchTableName(String p_s) {
+ TBL_BATCHES = p_s;
+ }
- /**
- * Constructor using all fields required by a BobjStore object
- * @param p_sSnapType String - Snapshot type
- * @param p_sSnapTbl String - Snapshot SQL tablename
- * @param p_sLocTbl String - Locator SQL tablename (may be null - No locator table)
- * @param p_sCls String - Class name excluding package prefix
- * @param p_bCrypt boolean - Does data have to be encrypted in the snap table ?
- * @see Istorable
- * @see BusinessObject#classNm()
- */
- protected BobjStore (String p_sSnapType,String p_sSnapTbl, String p_sLocTbl
- ,String p_sCls, boolean p_bCrypt)
- { m_sSnapType = p_sSnapType;
- m_sSnapTbl = p_sSnapTbl;
- addLocatorTable(p_sLocTbl);
- m_sClass = p_sCls;
- m_bEncrypt = p_bCrypt;
- } //________________________________
+ public static String getBatchTableName() {
+ return TBL_BATCHES;
+ }
- private void addLocatorTable(String p_s)
- { if (EsbUtil.isNullString(p_s)) return;
- if (null==m_olLocators)
- m_olLocators = new ArrayList<String>();
- m_olLocators.add(p_s);
- } //________________________________
-
- /**
- * Constructor for non encrypted BobjStore
- * @param p_sSnapType String
- * @param p_sSnapTbl String
- * @param p_sLocTbl String
- * @param p_sCls String
- * @see BobjStore#BobjStore(String,String,String,String,boolean)
- */
- protected BobjStore (String p_sSnapType,String p_sSnapTbl, String p_sLocTbl
- ,String p_sCls)
- { this(p_sSnapType,p_sSnapTbl,p_sLocTbl,p_sCls,false);
- } //________________________________
+ private static final Map<String, BobjStore> s_oStoreMap = new HashMap<String, BobjStore>();
- /**
- * Get a BobjStore object that describes persistence details for objects of
- * class <arg 1>
- * @param p_sClassName Class to search for in descriptor table
- * @return BobjStore - A descriptor that will provide persistence info
- * @see JbossEsbPersistHandler
- * @see BobjStore#getStore(BusinessObject)
- */
- public static BobjStore getStore (String p_sClassName)
- { if (EsbUtil.isNullString(p_sClassName)) return null;
- return s_oStoreMap.get(p_sClassName);
- } //__________________________________
+ static {
+ try {
+ URI objStoreConfig = URI.create(
+ EsbSysProps.getObjStoreConfigFile());
+ DomElement oConf = DomElement.fromInputStream(
+ objStoreConfig.toURL().openStream());
- /**
- * Get a BobjStore object that describes persistence details for
- * BobjStdDTO <arg 1>
- * @param p_sClassName BobjStdDTO for which we need an object store
- * @return BobjStore - A descriptor that will provide persistence info
- * @see JbossEsbPersistHandler
- * @see BobjStore#getStore(String)
- */
- public static BobjStore getStore (BobjStdDTO p_oDto)
- { if (null == p_oDto) return null;
- return getStore(p_oDto.fullClassName());
- } //__________________________________
+ if (null != oConf) {
+ setDataSourceJndi(oConf.getAttr("dataSourceJndiName"));
+ setUidTableName(oConf.getAttr("uidTable"));
+ setBatchTableName(oConf.getAttr("batchTable"));
+ for (DomElement oCurr : oConf.getElementChildren("Class")) {
+ String sClass = oCurr.getAttr("name");
+ boolean bCrypt = "true".equalsIgnoreCase(oCurr
+ .getAttr("encrypt"));
-} //____________________________________________________________________________
+ BobjStore oNew = new BobjStore(oCurr.getAttr("type"), oCurr
+ .getAttr("table"), null, sClass
+ .substring(1 + sClass.lastIndexOf(".")), bCrypt);
+
+ for (DomElement oIcurr : oCurr.getElementChildren("Index"))
+ oNew.addLocatorTable(oIcurr.getAttr("table"));
+ s_oStoreMap.put(sClass, oNew);
+ }
+ }
+ } catch (Exception e) {
+ EsbUtil.getDefaultLogger(BobjStore.class).error(
+ "BobjStore configuration FAILED", e);
+ }
+
+ };
+
+ private String m_sSnapType, m_sSnapTbl, m_sClass;
+
+ private List<String> m_olLocators;
+
+ private boolean m_bEncrypt = false;
+
+ /**
+ * Snapshot type getter - The value assigned to this attribute will help if
+ * standard SQL queries are required to surf the Object Store's snapshot
+ * tables
+ *
+ * @return String - Value of snapshot type
+ * @see Istorable#getSnapType()
+ */
+ public String getSnapType() {
+ return m_sSnapType;
+ }
+
+ /**
+ * Snapshot tablename getter - The value assigned to this attribute is the
+ * name of the snapshot table for this object
+ *
+ * @return String - name of SQL table where snapshots of objects will be
+ * stored
+ * @see Istorable#getSnapTable()
+ */
+ public String getSnapTable() {
+ return m_sSnapTbl;
+ }
+
+ /**
+ * First locator tablename getter - Locator tables are also called index
+ * tables.
+ *
+ * @return String - name of SQL table where locators(0) will be stored
+ * @see Istorable#getLocatorTable()
+ * @see BusinessObject#getObjLocator()
+ */
+ public String getLocatorTable() {
+ return getLocatorTable(0);
+ }
+
+ /**
+ * Obtain Nth locator table
+ *
+ * @param p_n -
+ * Index for desired locator table
+ * @return String - name of Nth SQL table where for objects will be stored
+ * @see BaseBusinessObject#locator(p_i)
+ */
+ public String getLocatorTable(int p_n) {
+ return (null == m_olLocators) ? null
+ : (m_olLocators.size() <= p_n) ? null : m_olLocators.get(p_n);
+ }
+
+ /**
+ * Obtain all locator table names
+ *
+ * @return Names of all locator tables
+ */
+ public String[] allLocatorTables() {
+ return (null == m_olLocators) ? new String[] {} : m_olLocators
+ .toArray(new String[m_olLocators.size()]);
+ }
+
+ /**
+ * Class suffix getter - Deprecated - Left here for backwards compatibility
+ *
+ * @return String - Class suffix
+ * @see Istorable#getLocatorTable()
+ * @see BusinessObject#getObjLocator()
+ */
+ public String getClassSuffix() {
+ return m_sClass;
+ }
+
+ /**
+ * Encryption requirement getter
+ *
+ * @return boolean - true if Objects stored using this descriptor have to be
+ * encrypted - decrypted at storage/retrieval time
+ */
+ public boolean isEncrypted() {
+ return m_bEncrypt;
+ }
+
+ /**
+ * Constructor using all fields required by a BobjStore object
+ *
+ * @param p_sSnapType
+ * String - Snapshot type
+ * @param p_sSnapTbl
+ * String - Snapshot SQL tablename
+ * @param p_sLocTbl
+ * String - Locator SQL tablename (may be null - No locator
+ * table)
+ * @param p_sCls
+ * String - Class name excluding package prefix
+ * @param p_bCrypt
+ * boolean - Does data have to be encrypted in the snap table ?
+ * @see Istorable
+ * @see BusinessObject#classNm()
+ */
+ protected BobjStore(String p_sSnapType, String p_sSnapTbl,
+ String p_sLocTbl, String p_sCls, boolean p_bCrypt) {
+ m_sSnapType = p_sSnapType;
+ m_sSnapTbl = p_sSnapTbl;
+ addLocatorTable(p_sLocTbl);
+ m_sClass = p_sCls;
+ m_bEncrypt = p_bCrypt;
+ } // ________________________________
+
+ private void addLocatorTable(String p_s) {
+ if (EsbUtil.isNullString(p_s))
+ return;
+ if (null == m_olLocators)
+ m_olLocators = new ArrayList<String>();
+ m_olLocators.add(p_s);
+ } // ________________________________
+
+ /**
+ * Constructor for non encrypted BobjStore
+ *
+ * @param p_sSnapType
+ * String
+ * @param p_sSnapTbl
+ * String
+ * @param p_sLocTbl
+ * String
+ * @param p_sCls
+ * String
+ * @see BobjStore#BobjStore(String,String,String,String,boolean)
+ */
+ protected BobjStore(String p_sSnapType, String p_sSnapTbl,
+ String p_sLocTbl, String p_sCls) {
+ this(p_sSnapType, p_sSnapTbl, p_sLocTbl, p_sCls, false);
+ } // ________________________________
+
+ /**
+ * Get a BobjStore object that describes persistence details for objects of
+ * class <arg 1>
+ *
+ * @param p_sClassName
+ * Class to search for in descriptor table
+ * @return BobjStore - A descriptor that will provide persistence info
+ * @see JbossEsbPersistHandler
+ * @see BobjStore#getStore(BusinessObject)
+ */
+ public static BobjStore getStore(String p_sClassName) {
+ if (EsbUtil.isNullString(p_sClassName))
+ return null;
+ return s_oStoreMap.get(p_sClassName);
+ } // __________________________________
+
+ /**
+ * Get a BobjStore object that describes persistence details for BobjStdDTO
+ * <arg 1>
+ *
+ * @param p_sClassName
+ * BobjStdDTO for which we need an object store
+ * @return BobjStore - A descriptor that will provide persistence info
+ * @see JbossEsbPersistHandler
+ * @see BobjStore#getStore(String)
+ */
+ public static BobjStore getStore(BobjStdDTO p_oDto) {
+ if (null == p_oDto)
+ return null;
+ return getStore(p_oDto.fullClassName());
+ } // __________________________________
+
+} // ____________________________________________________________________________
Modified: labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/EJB/JbossEsbNotificationHandler.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/EJB/JbossEsbNotificationHandler.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/EJB/JbossEsbNotificationHandler.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -3,9 +3,11 @@
*/
package org.jboss.soa.esb.services.EJB;
+import java.io.Serializable;
+
/**
* Remote interface for JbossEsbNotificationHandler.
- * @xdoclet-generated at July 5 2006
+ * @xdoclet-generated at July 24 2006
* @copyright The XDoclet Team
* @author XDoclet
* @version ${version}
@@ -14,7 +16,7 @@
extends javax.ejb.EJBObject
{
- public void sendNotifications( java.lang.String p_sParams,java.lang.String p_sMsg )
+ public void sendNotifications( java.lang.String p_sParams,Serializable p_sMsg )
throws java.lang.Exception, java.rmi.RemoteException;
}
Modified: labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/EJB/JbossEsbNotificationHandlerBean.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/EJB/JbossEsbNotificationHandlerBean.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/EJB/JbossEsbNotificationHandlerBean.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -24,6 +24,7 @@
package org.jboss.soa.esb.services.EJB;
+import java.io.Serializable;
import javax.ejb.*;
import javax.naming.*;
import org.jboss.soa.esb.util.*;
@@ -107,12 +108,12 @@
* @param p_sMsg
* @throws Exception
*/
- public void sendNotifications(String p_sParams, String p_sMsg)
+ public void sendNotifications(String p_sParams, Serializable p_oMsg)
throws Exception
{
DomElement oP = (null==p_sParams)?null:DomElement.fromXml(p_sParams);
NotificationList m_oL = (null==oP) ? s_dfltList : new NotificationList(oP);
- m_oL.sendNotification(p_sMsg);
+ m_oL.sendNotification(p_oMsg);
} //__________________________________
} //____________________________________________________________________________
Modified: labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/EJB/JbossEsbNotificationHandlerHome.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/EJB/JbossEsbNotificationHandlerHome.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/EJB/JbossEsbNotificationHandlerHome.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -5,7 +5,7 @@
/**
* Home interface for JbossEsbNotificationHandler.
- * @xdoclet-generated at July 5 2006
+ * @xdoclet-generated at July 27 2006
* @copyright The XDoclet Team
* @author XDoclet
* @version ${version}
Modified: labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/EJB/JbossEsbNotificationHandlerLocal.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/EJB/JbossEsbNotificationHandlerLocal.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/EJB/JbossEsbNotificationHandlerLocal.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -3,6 +3,8 @@
*/
package org.jboss.soa.esb.services.EJB;
+import java.io.Serializable;
+
/**
* Local interface for JbossEsbNotificationHandler.
* @xdoclet-generated at July 5 2006
@@ -14,6 +16,6 @@
extends javax.ejb.EJBLocalObject
{
- public void sendNotifications( java.lang.String p_sParams,java.lang.String p_sMsg ) throws java.lang.Exception;
+ public void sendNotifications( java.lang.String p_sParams,Serializable p_sMsg ) throws java.lang.Exception;
}
Modified: labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/EJB/JbossEsbNotificationHandlerLocalHome.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/EJB/JbossEsbNotificationHandlerLocalHome.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/EJB/JbossEsbNotificationHandlerLocalHome.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -5,7 +5,7 @@
/**
* Local home interface for JbossEsbNotificationHandler.
- * @xdoclet-generated at July 5 2006
+ * @xdoclet-generated at July 27 2006
* @copyright The XDoclet Team
* @author XDoclet
* @version ${version}
Modified: labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/EJB/JbossEsbPersistHandler.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/EJB/JbossEsbPersistHandler.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/EJB/JbossEsbPersistHandler.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -5,7 +5,7 @@
/**
* Remote interface for JbossEsbPersistHandler.
- * @xdoclet-generated at July 12 2006
+ * @xdoclet-generated at July 24 2006
* @copyright The XDoclet Team
* @author XDoclet
* @version ${version}
Modified: labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/EJB/JbossEsbPersistHandlerLocalHome.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/EJB/JbossEsbPersistHandlerLocalHome.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/EJB/JbossEsbPersistHandlerLocalHome.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -5,7 +5,7 @@
/**
* Local home interface for JbossEsbPersistHandler.
- * @xdoclet-generated at July 12 2006
+ * @xdoclet-generated at July 24 2006
* @copyright The XDoclet Team
* @author XDoclet
* @version ${version}
Modified: labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/NotifHandlerBsDelegateLocal.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/NotifHandlerBsDelegateLocal.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/NotifHandlerBsDelegateLocal.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -23,6 +23,7 @@
package org.jboss.soa.esb.services;
import javax.naming.*;
+import java.io.Serializable;
import org.jboss.soa.esb.helpers.*;
import org.jboss.soa.esb.services.EJB.*;
@@ -38,10 +39,10 @@
m_oNotifH = oHu.create();
} //__________________________________
- public void sendNotifications(DomElement p_oP, Object p_o) throws Exception
- { m_oNotifH.sendNotifications(p_oP.toString(),p_o.toString());
+ public void sendNotifications(DomElement p_oP, Serializable p_o) throws Exception
+ { m_oNotifH.sendNotifications(p_oP.toString(),p_o);
}
- public void sendNotifications(Object p_o) throws Exception
- { m_oNotifH.sendNotifications(null,p_o.toString());
+ public void sendNotifications(Serializable p_o) throws Exception
+ { m_oNotifH.sendNotifications(null,p_o);
}
} //____________________________________________________________________________
Modified: labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/NotifHandlerBsDelegateRemote.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/NotifHandlerBsDelegateRemote.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/NotifHandlerBsDelegateRemote.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -25,6 +25,7 @@
import javax.naming.*;
import javax.rmi.*;
+import java.io.Serializable;
import org.jboss.soa.esb.helpers.*;
import org.jboss.soa.esb.services.EJB.*;
@@ -40,10 +41,10 @@
m_oNotifH = oHu.create();
} //__________________________________
- public void sendNotifications(DomElement p_oP, Object p_o) throws Exception
- { m_oNotifH.sendNotifications(p_oP.toString(),p_o.toString());
+ public void sendNotifications(DomElement p_oP, Serializable p_o) throws Exception
+ { m_oNotifH.sendNotifications(p_oP.toString(),p_o);
} //__________________________________
- public void sendNotifications(Object p_o) throws Exception
- { m_oNotifH.sendNotifications(null,p_o.toString());
+ public void sendNotifications(Serializable p_o) throws Exception
+ { m_oNotifH.sendNotifications(null,p_o);
}
} //____________________________________________________________________________
Copied: labs/jbossesb/branches/refactor/product/core/services/src/org/jboss/soa/esb/services/Zap.java (from rev 5352, labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/Zap.java)
Modified: labs/jbossesb/branches/refactor/product/core/services/tests/build.xml
===================================================================
--- labs/jbossesb/branches/refactor/product/core/services/tests/build.xml 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/services/tests/build.xml 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,10 +1,11 @@
<?xml version="1.0"?>
<project name="build.services.tests" default="org.jboss.esb.services.tests.compile" basedir=".">
- <property name="org.jboss.esb.tests.bin.dir" value="${org.jboss.esb.internal.dest}/tests"/>
+ <property name="org.jboss.esb.module.src.dir" value="../src"/>
+ <property name="org.jboss.esb.module.classes.dir" value="${org.jboss.esb.internal.dest}/classes/services"/>
+ <property name="org.jboss.esb.module.tests.src.dir" value="${basedir}/src"/>
+ <property name="org.jboss.esb.tests.classes.dir" value="${org.jboss.esb.internal.dest}/tests"/>
<property name="org.jboss.esb.tests.report.dir" value="${org.jboss.esb.internal.dest}/tests/junit"/>
- <property name="org.jboss.esb.core.bin.dir" value="${org.jboss.esb.internal.dest}/classes"/>
- <property name="org.jboss.esb.tests.src.dir" value="${basedir}/src"/>
<property name="org.jboss.esb.root.dir" value="../.."/>
<property environment="env"/>
@@ -13,16 +14,12 @@
<equals arg1="${org.jboss.esb.frominstall}" arg2="yes"/>
</condition>
-
-
-
<path id="org.jboss.esb.tests.base.classpath">
<fileset dir="../${org.jboss.esb.ext.lib.dir}"
- includes="activation.jar jbossall-client.jar log4j.jar mail.jar junit.jar"/>
+ includes="activation.jar jbossall-client.jar log4j.jar mail.jar junit.jar emma.jar emma_ant.jar"/>
- <pathelement location="${org.jboss.esb.core.bin.dir}/common"/>
- <pathelement location="${org.jboss.esb.core.bin.dir}/services"/>
-
+ <pathelement location="${org.jboss.esb.module.classes.dir}"/>
+ <pathelement location="${org.jboss.esb.internal.dest}/classes/common"/>
</path>
<target name="org.jboss.esb.tests.init">
@@ -30,86 +27,86 @@
<format property="TODAY" pattern="d-MM-yy"/>
</tstamp>
- <mkdir dir="${org.jboss.esb.tests.bin.dir}"/>
+ <mkdir dir="${org.jboss.esb.tests.classes.dir}"/>
<mkdir dir="${org.jboss.esb.tests.report.dir}"/>
</target>
<target name="clean"/>
<target name="purge" depends="clean">
- <delete dir="${org.jboss.esb.tests.bin.dir}"/>
+ <delete dir="${org.jboss.esb.tests.classes.dir}"/>
</target>
<target name="org.jboss.esb.services.tests.compile" if="org.jboss.esb.buildtests" depends="org.jboss.esb.tests.init">
<javac
- destdir="${org.jboss.esb.tests.bin.dir}"
+ destdir="${org.jboss.esb.tests.classes.dir}"
classpathref="org.jboss.esb.tests.base.classpath"
debug="${org.jboss.esb.debug}"
optimize="${org.jboss.esb.optimize}"
>
- <src path="${org.jboss.esb.tests.src.dir}"/>
+ <src path="${org.jboss.esb.module.tests.src.dir}"/>
</javac>
</target>
+ <taskdef resource="emma_ant.properties" classpathref="org.jboss.esb.tests.base.classpath" />
<!-- ====================================================================== -->
<!-- T E S T -->
<!-- ====================================================================== -->
<target name="org.jboss.esb.services.internal.test">
- <antcall target="org.jboss.esb.services.internal.test.unit"/>
- <antcall target="org.jboss.esb.services.internal.test.functional"/>
- </target>
+ <property name="org.jboss.esb.module.tests.coverage.dir" value="${org.jboss.esb.internal.dest}/tests/coverage/services"/>
+ <property name="org.jboss.esb.module.classes.instr.dir" value="${org.jboss.esb.module.tests.coverage.dir}/instr" />
+ <!-- Instrument the code for code coverage - using emma... -->
+ <delete dir="${org.jboss.esb.module.tests.coverage.dir}" />
+ <mkdir dir="${org.jboss.esb.module.tests.coverage.dir}" />
+ <emma>
+ <instr instrpath="${org.jboss.esb.module.classes.dir}"
+ destdir="${org.jboss.esb.module.classes.instr.dir}"
+ metadatafile="${org.jboss.esb.module.tests.coverage.dir}/coverage.emma" />
+ </emma>
- <!-- ====================================================================== -->
- <!-- U N I T T E S T S -->
- <!-- ====================================================================== -->
- <target name="org.jboss.esb.services.internal.test.unit">
- <echo message="Running tests for module"/>
- <junit printsummary="yes" haltonerror="yes" haltonfailure="yes" showoutput="no" fork="true">
- <formatter type="plain" usefile="false"/>
- <formatter type="xml"/>
- <batchtest todir="${org.jboss.esb.tests.report.dir}">
- <fileset dir="${org.jboss.esb.tests.bin.dir}">
- <include name="**/**/services/**/**UnitTest.class"/>
- </fileset>
- </batchtest>
- <classpath>
- <path refid="org.jboss.esb.tests.base.classpath"/>
- <pathelement location="${org.jboss.esb.core.bin.dir}"/>
- <pathelement location="${org.jboss.esb.tests.bin.dir}"/>
- </classpath>
- </junit>
- <junitreport>
- <fileset dir="${org.jboss.esb.tests.report.dir}">
- <include name="*.xml"/>
- </fileset>
- <report format="frames" todir="${org.jboss.esb.tests.report.dir}"/>
- <report format="noframes" todir="${org.jboss.esb.tests.report.dir}"/>
- </junitreport>
+ <!-- Run the tests -->
+ <antcall target="org.jboss.esb.services.internal.test.exec"/>
+
+ <!-- Generate the coverage report -->
+ <emma>
+ <report sourcepath="${org.jboss.esb.module.src.dir}" sort="+block,+name,+method,+class" metrics="method:70,block:80,line:80,class:100">
+ <fileset dir="${org.jboss.esb.module.tests.coverage.dir}" >
+ <include name="*.emma" />
+ </fileset>
+ <html outfile="${org.jboss.esb.module.tests.coverage.dir}/index.html" depth="method" columns="name,line,class,method,block"/>
+ </report>
+ </emma>
</target>
-
<!-- ====================================================================== -->
- <!-- F U NC T I O N A L T E S T S -->
+ <!-- U N I T A N D F U N C T I O N A L T E S T S -->
<!-- ====================================================================== -->
- <target name="org.jboss.esb.services.internal.test.functional">
+ <target name="org.jboss.esb.services.internal.test.exec">
<echo message="Running tests for module"/>
<junit printsummary="yes" haltonerror="yes" haltonfailure="yes" showoutput="no" fork="true">
<formatter type="plain" usefile="false"/>
<formatter type="xml"/>
<batchtest todir="${org.jboss.esb.tests.report.dir}">
- <fileset dir="${org.jboss.esb.tests.bin.dir}">
- <include name="**/**/services/**/**FuncTest.class"/>
+ <fileset dir="${org.jboss.esb.module.tests.src.dir}">
+ <include name="**/**UnitTest.java"/>
+ <include name="**/**FuncTest.java"/>
</fileset>
</batchtest>
<classpath>
+ <!-- using instrumented code for code coverage -->
+ <pathelement location="${org.jboss.esb.module.classes.instr.dir}"/>
+ <pathelement location="${org.jboss.esb.tests.classes.dir}"/>
+ <!-- Need the tests src folder because there may be non-compiled test resources -->
+ <pathelement location="${org.jboss.esb.module.tests.src.dir}"/>
<path refid="org.jboss.esb.tests.base.classpath"/>
- <pathelement location="${org.jboss.esb.core.bin.dir}"/>
- <pathelement location="${org.jboss.esb.tests.bin.dir}"/>
</classpath>
+ <!-- emma jvm args -->
+ <jvmarg value="-Demma.coverage.out.file=${org.jboss.esb.module.tests.coverage.dir}/coverage.emma" />
+ <jvmarg value="-Demma.coverage.out.merge=true" />
</junit>
<junitreport>
<fileset dir="${org.jboss.esb.tests.report.dir}">
@@ -119,5 +116,4 @@
<report format="noframes" todir="${org.jboss.esb.tests.report.dir}"/>
</junitreport>
</target>
-
</project>
Modified: labs/jbossesb/branches/refactor/product/core/services/tests/src/org/jboss/soa/esb/services/tests/notification/NotificationFuncTest.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/services/tests/src/org/jboss/soa/esb/services/tests/notification/NotificationFuncTest.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/core/services/tests/src/org/jboss/soa/esb/services/tests/notification/NotificationFuncTest.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -29,7 +29,8 @@
import org.jboss.soa.esb.helpers.*;
import org.jboss.soa.esb.helpers.persist.SimpleDataSource;
import org.jboss.soa.esb.notification.*;
-import org.jboss.soa.esb.services.*;
+import org.jboss.soa.esb.services.InotificationHandler;
+import org.jboss.soa.esb.services.Zap;
// DON'T FORGET !!
// The Rosetta Application server has to be up and running
@@ -49,6 +50,7 @@
log.info("*******************************************");
log.info("Requires Implementation");
log.info("*******************************************");
+ new Zap();
}
/*
Modified: labs/jbossesb/branches/refactor/product/docs/Install/conf/jbossEsb.properties
===================================================================
--- labs/jbossesb/branches/refactor/product/docs/Install/conf/jbossEsb.properties 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/docs/Install/conf/jbossEsb.properties 2006-07-29 22:08:33 UTC (rev 5353)
@@ -27,13 +27,13 @@
#
# Mail Notification Settings
#
-jbossEsb.mail.smtp.host=mail.mydomain.com
-jbossEsb.mail.smtp.user=user
-jbossEsb.mail.smtp.password=password
-jbossEsb.mail.smtp.port=587
+org.jboss.soa.esb.mail.smtp.host=mail.mydomain.com
+org.jboss.soa.esb.mail.smtp.user=user
+org.jboss.soa.esb.mail.smtp.password=password
+org.jboss.soa.esb.mail.smtp.port=587
#
# Object Store Settings
#
-jbossEsb.objStore.configfile=/mypath/.../ObjStoreExample.xml
\ No newline at end of file
+org.jboss.soa.esb.objStore.configfile=/mypath/.../ObjStoreExample.xml
\ No newline at end of file
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks)
Property changes on: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks
___________________________________________________________________
Name: svn:ignore
+
build
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/bank.properties
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/bank.properties 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/bank.properties 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1 +0,0 @@
-monitored.directory=C:/Temp
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/bank.properties (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/bank.properties)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/build.xml
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/build.xml 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/build.xml 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,125 +0,0 @@
-<project name="BANKS" default="compile" basedir=".">
-
- <property file="bank.properties"/>
- <!-- Some default build locations -->
- <property name="org.jboss.esb.root.dir" value="../../../../../"/>
- <property name="org.jboss.esb.ext.lib.dir" value="${org.jboss.esb.root.dir}/lib/ext"/>
- <property name="org.jboss.esb.samples.loanbroker.banks.dest" value="${basedir}/build"/>
- <property name="org.jboss.esb.samples.loanbroker.banks.classes.dir" value="${basedir}/build/classes/banks/"/>
- <property name="org.jboss.esb.samples.loanbroker.banks.testclasses.dir" value="${basedir}/build/classes/tests/"/>
- <property name="org.jboss.esb.samples.loanbroker.banks.src.dir" value="${basedir}/src"/>
- <property name="org.jboss.esb.samples.loanbroker.banks.test.dir" value="${basedir}/test"/>
- <property name="org.jboss.esb.samples.loanbroker.banks.jar.dest" value="${basedir}/build/dist/lib/"/>
- <property name="org.jboss.esb.samples.loanbroker.banks.lib.ext.dir" value="${basedir}/lib/ext"/>
- <property name="org.jboss.esb.samples.loanbroker.banks.tests.report.dir" value="${basedir}/build/tests"/>
-
- <path id="org.jboss.esb.samples.loanbroker.banks.classpath">
- <fileset dir="${org.jboss.esb.samples.loanbroker.banks.lib.ext.dir}" includes="*.jar"/>
- <fileset dir="${org.jboss.esb.ext.lib.dir}" includes="log4j.jar,jbossall-client.jar"/>
- </path>
- <path id="org.jboss.esb.samples.loanbroker.banks.testclasspath">
- <fileset dir="${org.jboss.esb.samples.loanbroker.banks.lib.ext.dir}" includes="*.jar"/>
- <fileset dir="${org.jboss.esb.ext.lib.dir}" includes="log4j.jar,jbossall-client.jar"/>
- <pathelement location="${org.jboss.esb.samples.loanbroker.banks.classes.dir}"/>
- <pathelement location="${org.jboss.esb.samples.loanbroker.banks.testclasses.dir}"/>
- <fileset dir="${basedir}" includes="log4j.xml"/>
- </path>
-
- <target name="clean">
- <delete dir="${org.jboss.esb.samples.loanbroker.banks.dest}" />
- </target>
- <!-- =================================================================== -->
- <!-- Prepares the directory structure -->
- <!-- =================================================================== -->
- <target name="org.jboss.esb.samples.loanbroker.banks.prepare">
- <mkdir dir="${org.jboss.esb.samples.loanbroker.banks.dest}"/>
- <mkdir dir="${org.jboss.esb.samples.loanbroker.banks.dest}/dist"/>
- <mkdir dir="${org.jboss.esb.samples.loanbroker.banks.dest}/classes/banks"/>
- <mkdir dir="${org.jboss.esb.samples.loanbroker.banks.dest}/classes/tests"/>
- <mkdir dir="${org.jboss.esb.samples.loanbroker.banks.dest}/tests"/>
- <mkdir dir="${org.jboss.esb.samples.loanbroker.banks.dest}/dist/lib"/>
- </target>
-
- <!-- Compilation targets -->
- <target name="org.jboss.esb.samples.loanbroker.banks.compile" depends="org.jboss.esb.samples.loanbroker.banks.prepare"
- description="Compile all classes">
-
- <javac
- destdir="${org.jboss.esb.samples.loanbroker.banks.classes.dir}"
- classpathref="org.jboss.esb.samples.loanbroker.banks.classpath"
- debug="true"
- >
- <src path="${org.jboss.esb.samples.loanbroker.banks.src.dir}"/>
- </javac>
- <javac
- destdir="${org.jboss.esb.samples.loanbroker.banks.testclasses.dir}"
- debug="true"
- classpathref="org.jboss.esb.samples.loanbroker.banks.testclasspath"
- >
- <src path="${org.jboss.esb.samples.loanbroker.banks.test.dir}"/>
- </javac>
- </target>
-
- <!-- javadocs paths -->
- <path id="org.jboss.esb.samples.loanbroker.banks.javadocs.path">
- <pathelement path="esb/classes"/>
- </path>
-
- <!-- Jar targets -->
- <target name="org.jboss.esb.samples.loanbroker.banks.jar" depends="org.jboss.esb.samples.loanbroker.banks.compile">
- <echo message="Building jar file"/>
- <delete file="${org.jboss.esb.samples.loanbroker.banks.dest}/dist/lib/bank.jar" />
- <jar destfile="${org.jboss.esb.samples.loanbroker.banks.dest}/dist/lib/bank.jar"
- basedir="${org.jboss.esb.samples.loanbroker.banks.classes.dir}"
- includes="**/*.class"
- />
- <jar jarfile="${org.jboss.esb.samples.loanbroker.banks.dest}/dist/lib/pollmgt.sar">
- <fileset dir="${org.jboss.esb.samples.loanbroker.banks.lib.ext.dir}" includes="pollmgt.jar,org.sadun.util.jar"/>
- <metainf dir="${basedir}/config/pollmgt/META-INF"/>
- </jar>
- </target>
-
- <target name="runJMSBank" depends="org.jboss.esb.samples.loanbroker.banks.jar">
- <echo>Running JMS Based Bank</echo>
- <echo>Note that your app-server on host: localhost needs to be up and running!</echo>
- <java fork="yes" classname="org.jboss.soa.esb.samples.loanbroker.banks.ManagerJMS" failonerror="true">
- <sysproperty key="java.naming.factory.initial" value="org.jnp.interfaces.NamingContextFactory"/>
- <sysproperty key="java.naming.provider.url" value="localhost:1099"/>
- <classpath refid="org.jboss.esb.samples.loanbroker.banks.testclasspath"/>
- </java>
- </target>
-
- <target name="runFileBank" depends="org.jboss.esb.samples.loanbroker.banks.jar">
- <echo>Running File Based Bank</echo>
- <java fork="yes" classname="org.jboss.soa.esb.samples.loanbroker.banks.ManagerFlatFile" failonerror="true" args="${monitored.directory}">
- <classpath refid="org.jboss.esb.samples.loanbroker.banks.testclasspath"/>
- </java>
- </target>
-
- <!-- Short target names -->
- <target name="compile" depends="org.jboss.esb.samples.loanbroker.banks.compile"/>
- <target name="test" depends="org.jboss.esb.samples.loanbroker.banks.test"/>
- <target name="jar" depends="org.jboss.esb.samples.loanbroker.banks.jar"/>
-
- <!-- ====================================================================== -->
- <!-- U N I T T E S T S -->
- <!-- ====================================================================== -->
- <target name="org.jboss.esb.samples.loanbroker.banks.test" depends="org.jboss.esb.samples.loanbroker.banks.compile">
- <echo message="Running tests for banks"/>
- <junit printsummary="yes" haltonerror="yes" haltonfailure="yes" showoutput="no" fork="true">
- <formatter type="plain" usefile="false"/>
- <formatter type="xml"/>
- <batchtest todir="${org.jboss.esb.samples.loanbroker.banks.tests.report.dir}">
- <fileset dir="${org.jboss.esb.samples.loanbroker.banks.test.dir}">
- <include name="**/**Test.java"/>
- </fileset>
- </batchtest>
- <classpath>
- <!-- Need the tests src folder because there may be non-compiled test resources -->
- <pathelement location="${org.jboss.esb.samples.loanbroker.banks.test.dir}"/>
- <path refid="org.jboss.esb.samples.loanbroker.banks.testclasspath"/>
- </classpath>
- </junit>
- </target>
-
-</project>
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/build.xml (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/build.xml)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/lib (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/lib)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/lib/ext (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/lib/ext)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/lib/ext/junit-4.1.jar
===================================================================
(Binary files differ)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/lib/ext/junit-4.1.jar (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/lib/ext/junit-4.1.jar)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/lib/ext/org.sadun.util.jar
===================================================================
(Binary files differ)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/lib/ext/org.sadun.util.jar (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/lib/ext/org.sadun.util.jar)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/lib/ext/pollmgt.jar
===================================================================
(Binary files differ)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/lib/ext/pollmgt.jar (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/lib/ext/pollmgt.jar)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/lib/ext/xstream-1.1.3.jar
===================================================================
(Binary files differ)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/lib/ext/xstream-1.1.3.jar (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/lib/ext/xstream-1.1.3.jar)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/log4j.xml
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/log4j.xml 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/log4j.xml 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,287 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-
-<!-- ===================================================================== -->
-<!-- -->
-<!-- Log4j Configuration -->
-<!-- -->
-<!-- ===================================================================== -->
-
-<!-- $Id: log4j.xml,v 1.26.2.5 2005/09/15 09:31:02 dimitris Exp $ -->
-
-<!--
- | For more configuration infromation and examples see the Jakarta Log4j
- | owebsite: http://jakarta.apache.org/log4j
- -->
-
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
-
- <!-- ================================= -->
- <!-- Preserve messages in a local file -->
- <!-- ================================= -->
-
- <!-- A time/date based rolling appender -->
- <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
- <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
- <param name="File" value="${jboss.server.home.dir}/log/server.log"/>
- <param name="Append" value="false"/>
-
- <!-- Rollover at midnight each day -->
- <param name="DatePattern" value="'.'yyyy-MM-dd"/>
-
- <!-- Rollover at the top of each hour
- <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
- -->
-
- <layout class="org.apache.log4j.PatternLayout">
- <!-- The default pattern: Date Priority [Category] Message\n -->
- <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
-
- <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
- <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
- -->
- </layout>
- </appender>
-
- <!-- A size based file rolling appender
- <appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender">
- <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
- <param name="File" value="${jboss.server.home.dir}/log/server.log"/>
- <param name="Append" value="false"/>
- <param name="MaxFileSize" value="500KB"/>
- <param name="MaxBackupIndex" value="1"/>
-
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
- </layout>
- </appender>
- -->
-
- <!-- ============================== -->
- <!-- Append messages to the console -->
- <!-- ============================== -->
-
- <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
- <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
- <param name="Target" value="System.out"/>
- <param name="Threshold" value="INFO"/>
-
- <layout class="org.apache.log4j.PatternLayout">
- <!-- The default pattern: Date Priority [Category] Message\n -->
- <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
- </layout>
- </appender>
-
- <!-- ====================== -->
- <!-- More Appender examples -->
- <!-- ====================== -->
-
- <!-- Buffer events and log them asynchronously
- <appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
- <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
- <appender-ref ref="FILE"/>
- <appender-ref ref="CONSOLE"/>
- <appender-ref ref="SMTP"/>
- </appender>
- -->
-
- <!-- EMail events to an administrator
- <appender name="SMTP" class="org.apache.log4j.net.SMTPAppender">
- <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
- <param name="Threshold" value="ERROR"/>
- <param name="To" value="admin at myhost.domain.com"/>
- <param name="From" value="nobody at myhost.domain.com"/>
- <param name="Subject" value="JBoss Sever Errors"/>
- <param name="SMTPHost" value="localhost"/>
- <param name="BufferSize" value="10"/>
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
- </layout>
- </appender>
- -->
-
- <!-- Syslog events
- <appender name="SYSLOG" class="org.apache.log4j.net.SyslogAppender">
- <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
- <param name="Facility" value="LOCAL7"/>
- <param name="FacilityPrinting" value="true"/>
- <param name="SyslogHost" value="localhost"/>
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
- </layout>
- </appender>
- -->
-
- <!-- Log events to JMS (requires a topic to be created)
- <appender name="JMS" class="org.apache.log4j.net.JMSAppender">
- <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
- <param name="Threshold" value="ERROR"/>
- <param name="TopicConnectionFactoryBindingName" value="java:/ConnectionFactory"/>
- <param name="TopicBindingName" value="topic/MyErrorsTopic"/>
- </appender>
- -->
-
- <!-- Log events through SNMP
- <appender name="TRAP_LOG" class="org.apache.log4j.ext.SNMPTrapAppender">
- <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
- <param name="ImplementationClassName" value="org.apache.log4j.ext.JoeSNMPTrapSender"/>
- <param name="ManagementHost" value="127.0.0.1"/>
- <param name="ManagementHostTrapListenPort" value="162"/>
- <param name="EnterpriseOID" value="1.3.6.1.4.1.24.0"/>
- <param name="LocalIPAddress" value="127.0.0.1"/>
- <param name="LocalTrapSendPort" value="161"/>
- <param name="GenericTrapType" value="6"/>
- <param name="SpecificTrapType" value="12345678"/>
- <param name="CommunityString" value="public"/>
- <param name="ForwardStackTraceWithTrap" value="true"/>
- <param name="Threshold" value="DEBUG"/>
- <param name="ApplicationTrapOID" value="1.3.6.1.4.1.24.12.10.22.64"/>
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d,%p,[%t],[%c],%m%n"/>
- </layout>
- </appender>
- -->
-
- <!-- Emit events as JMX notifications
- <appender name="JMX" class="org.jboss.monitor.services.JMXNotificationAppender">
- <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
-
- <param name="Threshold" value="WARN"/>
- <param name="ObjectName" value="jboss.system:service=Logging,type=JMXNotificationAppender"/>
-
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d %-5p [%c] %m"/>
- </layout>
- </appender>
- -->
-
- <!-- ================ -->
- <!-- Limit categories -->
- <!-- ================ -->
-
- <!-- Limit the org.apache category to INFO as its DEBUG is verbose -->
- <category name="org.apache">
- <priority value="INFO"/>
- </category>
-
- <!-- Limit the org.jgroups category to WARN as its INFO is verbose -->
- <category name="org.jgroups">
- <priority value="WARN"/>
- </category>
-
- <!-- Limit jboss axis to INFO as its DEBUG is even more verbose -->
- <category name="org.jboss.axis">
- <priority value="INFO"/>
- </category>
-
- <!-- Limit JBoss categories
- <category name="org.jboss">
- <priority value="INFO"/>
- </category>
- -->
-
- <!-- Limit the JSR77 categories -->
- <category name="org.jboss.management">
- <priority value="INFO"/>
- </category>
-
- <!-- Limit JBoss webservice category
- <category name="org.jboss.webservice">
- <priority value="DEBUG"/>
- </category>
- -->
-
- <!-- Decrease the priority threshold for the org.jboss.varia category
- <category name="org.jboss.varia">
- <priority value="DEBUG"/>
- </category>
- -->
-
- <!-- Show the evolution of the DataSource pool in the logs [inUse/Available/Max]
- <category name="org.jboss.resource.connectionmanager.JBossManagedConnectionPool">
- <priority value="TRACE" class="org.jboss.logging.XLevel"/>
- </category>
- -->
-
- <!--
- | An example of enabling the custom TRACE level priority that is used
- | by the JBoss internals to diagnose low level details. This example
- | turns on TRACE level msgs for the org.jboss.ejb.plugins package and its
- | subpackages. This will produce A LOT of logging output.
- <category name="org.jboss.system">
- <priority value="TRACE" class="org.jboss.logging.XLevel"/>
- </category>
- <category name="org.jboss.ejb.plugins">
- <priority value="TRACE" class="org.jboss.logging.XLevel"/>
- </category>
- -->
-
- <!--
- | Logs these events to SNMP:
- - server starts/stops
- - cluster evolution (node death/startup)
- - When an EJB archive is deployed (and associated verified messages)
- - When an EAR archive is deployed
-
- <category name="org.jboss.system.server.Server">
- <priority value="INFO" />
- <appender-ref ref="TRAP_LOG"/>
- </category>
-
- <category name="org.jboss.ha.framework.interfaces.HAPartition.lifecycle">
- <priority value="INFO" />
- <appender-ref ref="TRAP_LOG"/>
- </category>
-
- <category name="org.jboss.deployment.MainDeployer">
- <priority value="ERROR" />
- <appender-ref ref="TRAP_LOG"/>
- </category>
-
- <category name="org.jboss.ejb.EJBDeployer">
- <priority value="INFO" />
- <appender-ref ref="TRAP_LOG"/>
- </category>
-
- <category name="org.jboss.deployment.EARDeployer">
- <priority value="INFO" />
- <appender-ref ref="TRAP_LOG"/>
- </category>
-
- -->
-
- <!-- ======================= -->
- <!-- Setup the Root category -->
- <!-- ======================= -->
-
- <root>
- <appender-ref ref="CONSOLE"/>
- <appender-ref ref="FILE"/>
- </root>
-
- <!-- Clustering logging -->
- <!-- Uncomment the following to redirect the org.jgroups and
- org.jboss.ha categories to a cluster.log file.
-
- <appender name="CLUSTER" class="org.jboss.logging.appender.RollingFileAppender">
- <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
- <param name="File" value="${jboss.server.home.dir}/log/cluster.log"/>
- <param name="Append" value="false"/>
- <param name="MaxFileSize" value="500KB"/>
- <param name="MaxBackupIndex" value="1"/>
-
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
- </layout>
- </appender>
- <category name="org.jgroups">
- <priority value="DEBUG" />
- <appender-ref ref="CLUSTER"/>
- </category>
- <category name="org.jboss.ha">
- <priority value="DEBUG" />
- <appender-ref ref="CLUSTER"/>
- </category>
- -->
-
-</log4j:configuration>
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/log4j.xml (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/log4j.xml)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/Bank.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/Bank.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/Bank.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,116 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.soa.esb.samples.loanbroker.banks;
-
-import java.math.BigDecimal;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.Priority;
-
-/**
- * This Bank is pretty well focussed on doing one thing, which is giving out loans. On the
- * reception of a BankQuoteRequest it will compute the interest rate it will return
- * in the BankQuoteReply.
- *
- * Each bank instance can be customized using the parameters bankName, RatePremium and MaxLoanTerm.
- *
- * @author kstam
- *
- */
-public class Bank
-{
- private Logger logger = Logger.getLogger(this.getClass());
-
- private static final BigDecimal PRIME_RATE = BigDecimal.valueOf(8.0);
- private static final BigDecimal DEFAULT_RATE_PREMIUM = BigDecimal.valueOf(0.5);
- private static final int DEFAULT_MAX_LOAN_TERM = 30;
- private static final String DEFAULT_BANK_NAME = "DefaultBank";
- private static int _quoteCounter = 0;
-
- //Default values for bank
- private String bankName = DEFAULT_BANK_NAME;
- private BigDecimal ratePremium = DEFAULT_RATE_PREMIUM;
- private int maxLoanTerm = DEFAULT_MAX_LOAN_TERM;
-
- /**
- * The Bank's constructor.
- *
- * @param bankName - the name of the bank
- * @param ratePremium - the premium it charges for the loan
- * @param maxLoanTerm - the maximum loan term
- */
- public Bank(String bankName, BigDecimal ratePremium, int maxLoanTerm) {
- super();
- if (bankName!=null) {
- this.bankName=bankName;
- }
- if (ratePremium!=null) {
- this.ratePremium=ratePremium;
- }
- if (maxLoanTerm > 0) {
- this.maxLoanTerm=maxLoanTerm;
- }
- }
- /**
- * The bank computes the interest rate based on configuration parameters of the bank and
- * the information in the {@link BankQuoteRequest.
- * @param bankQuoteRequest - the bank quote request containing requests parameters
- * @return bankQuoteReply - the bank quote replay contaning the interest rate
- */
- private BankQuoteReply computeBankQuoteReply(BankQuoteRequest bankQuoteRequest)
- {
- BankQuoteReply bankQuoteReply = new BankQuoteReply();
- if (bankQuoteRequest.loanTerm <= maxLoanTerm) {
- BigDecimal interestRate=BigDecimal.valueOf((bankQuoteRequest.loanTerm/12.0)/10.0);
- interestRate=PRIME_RATE.add(ratePremium).add(interestRate);
- bankQuoteReply.setInterestRate(interestRate.setScale(2, BigDecimal.ROUND_HALF_UP));
- bankQuoteReply.setErrorCode(0);
- } else {
- bankQuoteReply.setInterestRate(BigDecimal.valueOf(0.00).setScale(2, BigDecimal.ROUND_HALF_UP));
- bankQuoteReply.setErrorCode(1);
- }
- String quoteId=bankName + "-" + _quoteCounter++;
- bankQuoteReply.setQuoteId(quoteId);
- return bankQuoteReply;
- }
- /**
- * Processes the Loan Quote request and returns the banks reply.
- *
- * @param bankQuoteRequest - the bank quote request
- * @return bankQuoteReply - the bank quote reply
- */
- protected BankQuoteReply processMessage(BankQuoteRequest bankQuoteRequest)
- {
- logger.log(Priority.INFO, "Bank '" + bankName + "' received a request for SSN="
- + bankQuoteRequest.getSsn()
- + " for $" + bankQuoteRequest.loanAmount
- + " over " + bankQuoteRequest.loanTerm + " months.");
- logger.log(Priority.DEBUG, bankQuoteRequest);
-
- BankQuoteReply bankQuoteReply = computeBankQuoteReply(bankQuoteRequest);
- logger.log(Priority.INFO, "Bank '" + bankName + " offers SSN="
- + bankQuoteRequest.getSsn() + " " + bankQuoteReply);
-
- return bankQuoteReply;
- }
-}
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/Bank.java (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/Bank.java)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteReply.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteReply.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteReply.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,106 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/package org.jboss.soa.esb.samples.loanbroker.banks;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-
-
-public class BankQuoteReply implements Serializable
-{
- private static final long serialVersionUID = 1L;
-
- private BigDecimal interestRate;
- private String quoteId;
- private int errorCode;
- /**
- * Gets the SerialVersionUID.
- * @return serialVersionUID
- */
- public static long getSerialVersionUID() {
- return serialVersionUID;
- }
- /**
- * Gets the errorCode.
- * <li>0 - success
- * <li>1 - loan term exceeds the maximum available loan term
- * <li>2 - invalid SSN
- * <li>3 - invalid credit score
- * <li>4 - invalid credit history length
- * <li>5 - invalid loan term
- * <li>6 - invalid message
- * @return errorCode
- */
- public int getErrorCode() {
- return errorCode;
- }
- /**
- * Sets the errorCode.
- * <li>0 - success
- * <li>1 - loan term exceeds the maximum available loan term
- * <li>2 - invalid SSN
- * <li>3 - invalid credit score
- * <li>4 - invalid credit history length
- * <li>5 - invalid loan term
- * @param errorCode
- */
- public void setErrorCode(int errorCode) {
- this.errorCode = errorCode;
- }
- /**
- * Gets the quoted interest rate.
- * @return interestRate
- */
- public BigDecimal getInterestRate() {
- return interestRate;
- }
- /**
- * Sets the quoted interest rate.
- * @param interestRate
- */
- public void setInterestRate(BigDecimal interestRate) {
- this.interestRate = interestRate;
- }
- /**
- * Gets the Quote ID.
- * @return quoteId
- */
- public String getQuoteId() {
- return quoteId;
- }
- /**
- * Sets the quoteId.
- * @param quoteId
- */
- public void setQuoteId(String quoteId) {
- this.quoteId = quoteId;
- }
- /**
- * Returns a human readable string representation of this object.
- * @return toString
- */
- public String toString() {
- return this.getClass().getSimpleName() + "=["
- + "interestRate=" + interestRate
- + ", quoteId=" + quoteId
- + ", errorCode=" + errorCode + "]";
- }
-}
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteReply.java (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteReply.java)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequest.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequest.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequest.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,117 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.soa.esb.samples.loanbroker.banks;
-
-import java.io.Serializable;
-
-
-public class BankQuoteRequest implements Serializable
-{
- private static final long serialVersionUID = 1L;
- public int ssn;
- public int creditScore;
- public int historyLength;
- public int loanAmount;
- public int loanTerm;
- /**
- * Gets for the credit score.
- * @return credit score
- */
- public int getCreditScore() {
- return creditScore;
- }
- /**
- * Sets the credit score.
- * @param creditScore
- */
- public void setCreditScore(int creditScore) {
- this.creditScore = creditScore;
- }
- /**
- * Gets the credit history length (in months).
- * @return credit history length
- */
- public int getHistoryLength() {
- return historyLength;
- }
- /**
- * Sets the credit history length (in months).
- * @param historyLength
- */
- public void setHistoryLength(int historyLength) {
- this.historyLength = historyLength;
- }
- /**
- * Gets the requested loan amount (in dollar).
- * @return the loan amount
- */
- public int getLoanAmount() {
- return loanAmount;
- }
- /**
- * Sets the loan amount.
- * @param loanAmount - the loan amount (in dollar).
- */
- public void setLoanAmount(int loanAmount) {
- this.loanAmount = loanAmount;
- }
- /**
- * Gets the duration of the loan, the term, (in months).
- * @return loanTerm
- */
- public int getLoanTerm() {
- return loanTerm;
- }
- /**
- * Sets the term (duration) of the loan (in months)
- * @param loanTerm
- */
- public void setLoanTerm(int loanTerm) {
- this.loanTerm = loanTerm;
- }
- /**
- * Sets the Social Security Number (SSN).
- * @return ssn
- */
- public int getSsn() {
- return ssn;
- }
- /**
- * Sets the Social Security Number (SSN).
- * @param ssn
- */
- public void setSsn(int ssn) {
- this.ssn = ssn;
- }
- /**
- * Returns a human readable string representation of this object.
- * @return toString
- */
- public String toString() {
- return this.getClass().getSimpleName() + "=["
- + "ssn=" + ssn
- + ", creditScore=" + creditScore
- + ", historyLength=" + historyLength
- + ", loanAmount=" + loanAmount
- + ", loanTerm=" + loanTerm + "]";
- }
-}
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequest.java (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequest.java)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/FileUtil.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/FileUtil.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/FileUtil.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,32 +0,0 @@
-package org.jboss.soa.esb.samples.loanbroker.banks;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-
-public class FileUtil {
-
- public static String readTextFile(File file) throws IOException
- {
- StringBuffer sb = new StringBuffer(1024);
- BufferedReader reader = new BufferedReader(new FileReader(file.getPath()));
- char[] chars = new char[1];
- while( (reader.read(chars)) > -1){
- sb.append(String.valueOf(chars));
- chars = new char[1];
- }
- reader.close();
- return sb.toString();
- }
-
- public static void writeTextFile(File file, String str) throws IOException
- {
- BufferedWriter writer = new BufferedWriter(new FileWriter(file.getPath()));
- writer.write(str);
- writer.close();
- }
-
-}
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/FileUtil.java (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/FileUtil.java)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/ManagerFlatFile.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/ManagerFlatFile.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/ManagerFlatFile.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,203 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.soa.esb.samples.loanbroker.banks;
-
-import java.io.File;
-import java.math.BigDecimal;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.Priority;
-import org.apache.log4j.xml.DOMConfigurator;
-import org.sadun.util.polling.BasePollManager;
-import org.sadun.util.polling.CycleEndEvent;
-import org.sadun.util.polling.CycleStartEvent;
-import org.sadun.util.polling.DirectoryLookupEndEvent;
-import org.sadun.util.polling.DirectoryLookupStartEvent;
-import org.sadun.util.polling.DirectoryPoller;
-import org.sadun.util.polling.FileFoundEvent;
-import org.sadun.util.polling.FileSetFoundEvent;
-
-/**
- * The FlatFilePollManager monitors a directory specified in the configuration. When a file arrives it
- * tries to process the content assuming it contains one line with loan request information.
- * So for example the content of the file could read some like <br>23456890,3,4,20000,5<br>
- * The order of values needs to be SocialSecurityNumber, CreditScore, HistoryLength [month], LoanAmount [dollar],
- * and finally the LoanTerm [month]. The request will be processed and a BankQouteReply is generated. The
- * original file is moved to a 'processed' directory, and the BankQuoteReply is serialized to an 'outgoing'
- * directory from the it can be picked up by the system that dropped the request.
- *
- * @author kstam
- *
- */
-
-class ManagerFlatFile extends BasePollManager
-{
- private Logger logger = Logger.getLogger(this.getClass());
-
- private static final String BANK_NAME = "FileBasedBank";
- private static final BigDecimal RATE_PREMIUM = BigDecimal.valueOf(0.25);
- private static final int MAXLOANTERM = 120;
- protected static final String OUTGOING_DIR = "outgoing";
- protected static final String PREFIX = "reply_to_";
- protected static final String PROCESSED_DIR = "processed";
- /**
- * Handle to the cycle start event.
- */
- public void cycleStarted(CycleStartEvent evt) {
- logger.log(Priority.DEBUG, "Poller awakened "
- + (evt.getPoller().getFilter() == null ? "(no filtering)" : evt
- .getPoller().getFilter().toString()));
- }
- /**
- * Handle to the cycle end event.
- */
- public void cycleEnded(CycleEndEvent evt) {
- logger.log(Priority.DEBUG, "Poller going to sleep");
- }
- /**
- * Handle to the directory lookup start event.
- */
- public void directoryLookupStarted(DirectoryLookupStartEvent evt) {
- logger.log(Priority.DEBUG, "Scanning " + evt.getDirectory());
- }
- /**
- * Handle to the directory lookup end event.
- */
- public void directoryLookupEnded(DirectoryLookupEndEvent evt) {
- logger.log(Priority.DEBUG, "Finished scanning " + evt.getDirectory());
- }
- /**
- * Handle to the file set found event. Currenty this is the only event that
- * is actually used to proces the incoming loan quote requests. Each file
- * is send to be processed.
- */
- public void fileSetFound(FileSetFoundEvent evt) {
- File[] files = evt.getFiles();
-
- for (int i = 0; i < files.length; i++) {
- File file = files[i];
- processFile(file);
- }
- }
- /**
- * Handle to the file found event.
- */
- public void fileFound(FileFoundEvent evt) {
- logger.log(Priority.DEBUG, evt);
- // Add artificial delay
- }
- /**
- * Returns the name of this PollManager and a quick summary of what it does.
- */
- public String toString() {
- return "FlatFilePollManager - a pollmanager which processed incoming -flat file based- loan requests";
- }
- /**
- * Each file is processed assuming it contains one line with loan request information.
- * So for example the content of the file could read some like <br>23456890,3,4,20000,5<br>
- * The order of values needs to be SocialSecurityNumber, CreditScore, HistoryLength [month], LoanAmount [dollar],
- * and finally the LoanTerm [month]. The BankQuoteRequest is processed and a BankQouteReply is generated. The
- * original file is moved to a processed directory, and the BankQuoteReply is serialized to an 'outgoing'
- * directory from the it can be picked up by the system that dropped the request.
- *
- * @param file - incoming flat file with loan quote request info.
- */
- protected void processFile(File file)
- {
- BankQuoteReply bankQuoteReply=new BankQuoteReply();
- bankQuoteReply.setQuoteId(BANK_NAME);
- int errorCode=6;
- String message=null;
- logger.log(Priority.INFO, "Found " + file.getAbsolutePath() );
-
- try {
- BankQuoteRequest bankQuoteRequest = new BankQuoteRequest();
- //Read the content of the file into a String
- message=FileUtil.readTextFile(file);
- String[] messagePart = message.split(",");
-
- errorCode=1;
- bankQuoteRequest.setSsn(Integer.valueOf(messagePart[0]));
- errorCode=2;
- bankQuoteRequest.setCreditScore(Integer.valueOf(messagePart[1]));
- errorCode=3;
- bankQuoteRequest.setHistoryLength(Integer.valueOf(messagePart[2]));
- errorCode=4;
- bankQuoteRequest.setLoanAmount(Integer.valueOf(messagePart[3]));
- errorCode=5;
- bankQuoteRequest.setLoanTerm(Integer.valueOf(messagePart[4]));
-
- Bank fileBasedBank = new Bank(BANK_NAME, RATE_PREMIUM, MAXLOANTERM);
- bankQuoteReply = fileBasedBank.processMessage(bankQuoteRequest);
- } catch (Throwable e) {
- //Package up the error, so it can be processed
- logger.log(Priority.ERROR, e.getMessage());
- bankQuoteReply.setErrorCode(errorCode);
- }
-
- try {
- //Create the outgoing response file
- File outgoingDir = new File(file.getParent() + "/" + OUTGOING_DIR);
- if (!outgoingDir.exists()) {
- outgoingDir.mkdir();
- }
- File outgoingFile = new File(outgoingDir + "/" + PREFIX + file.getName());
- logger.log(Priority.INFO, "Creating outgoing file " + outgoingFile.getAbsolutePath());
- outgoingFile.createNewFile();
- String reply=bankQuoteReply.getInterestRate() + "," + bankQuoteReply.getQuoteId() + "," + bankQuoteReply.getErrorCode();
- logger.log(Priority.INFO, "Writing reply " + reply);
- FileUtil.writeTextFile(outgoingFile, reply);
-
- //Move the processed file away so it does not get processed again
- File processedDir = new File(file.getParent() + "/" + PROCESSED_DIR);
- if (!processedDir.exists()) {
- processedDir.mkdir();
- }
- logger.log(Priority.INFO, "Moving file " + file.getName() + " to processed directory");
- File processedFile = new File(processedDir.getAbsolutePath() + "/" + file.getName());
- file.renameTo(processedFile);
- if (file.exists()) {
- file.delete();
- }
- } catch (Exception e) {
- logger.log(Priority.ERROR, e.getMessage(), e);
- }
- }
-
- public static void main(String[] args)
- {
- DOMConfigurator.configure("log4j.xml");
- String monitoredDirectoryStr = "C:/Temp";
- if (args!=null && args.length > 0) {
- monitoredDirectoryStr=args[0];
- }
- File monitoredDirectory = new File(monitoredDirectoryStr);
- if (!monitoredDirectory.exists() || !monitoredDirectory.isDirectory()){
- System.out.println("Invalid directory " + monitoredDirectory.getAbsolutePath());
- }
- DirectoryPoller poller = new DirectoryPoller(monitoredDirectory);
- poller.addPollManager(new ManagerFlatFile());
- poller.start();
- }
-
-
-}
\ No newline at end of file
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/ManagerFlatFile.java (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/ManagerFlatFile.java)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/ManagerJMS.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/ManagerJMS.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/ManagerJMS.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,121 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.soa.esb.samples.loanbroker.banks;
-
-import java.math.BigDecimal;
-import java.util.Properties;
-
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.Queue;
-import javax.jms.QueueConnection;
-import javax.jms.QueueConnectionFactory;
-import javax.jms.QueueReceiver;
-import javax.jms.QueueSender;
-import javax.jms.QueueSession;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.xml.DOMConfigurator;
-
-import com.thoughtworks.xstream.XStream;
-import com.thoughtworks.xstream.io.xml.DomDriver;
-
-public class ManagerJMS implements javax.jms.MessageListener
-{
- private static Logger log = Logger.getLogger(ManagerJMS.class);
- private static final String BANK_NAME = "JMSBasedBank";
- private static final BigDecimal RATE_PREMIUM = BigDecimal.valueOf(0.50);
- private static final int MAXLOANTERM = 120;
- private static InitialContext ctx;
- private static Properties properties = new Properties();
- QueueConnection inQueueConnection;
-
- public void listen()
- {
- try {
- properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
- properties.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
- properties.put(Context.PROVIDER_URL, "localhost");
- ctx = new InitialContext(properties);
- log.info("Looking up queue");
- Queue inQueue = (Queue) ctx.lookup("queue/A");
- log.info("Looking up connection factory");
- QueueConnectionFactory qcf = (QueueConnectionFactory) ctx.lookup("UIL2ConnectionFactory");
- log.info("Creating connection");
- inQueueConnection = qcf.createQueueConnection();
- log.info("Creating session");
- QueueSession qs = inQueueConnection .createQueueSession(false, Session.DUPS_OK_ACKNOWLEDGE);
- QueueReceiver qr = qs.createReceiver(inQueue);
- qr.setMessageListener(this);
- inQueueConnection .start();
- } catch (Exception e) {
- log.error(e.getMessage(),e);
- }
- }
-
- public void onMessage(Message message) {
- QueueConnection outQueueConnection;
- log.info("Got message: " + message);
- try {
- TextMessage textMessage = (TextMessage) message;
- String xml=textMessage.getText();
- XStream xstream = new XStream(new DomDriver());
- BankQuoteRequest bankQuoteRequest = (BankQuoteRequest) xstream.fromXML(xml);
- Bank bank = new Bank(BANK_NAME, RATE_PREMIUM, MAXLOANTERM);
- BankQuoteReply bankQuoteReply = bank.processMessage(bankQuoteRequest);
- String bankQuoteReplyXML = xstream.toXML(bankQuoteReply);
- Queue outQueue = (Queue) ctx.lookup("queue/B");
- log.info("Looking up connection factory");
- QueueConnectionFactory qcf = (QueueConnectionFactory) ctx.lookup("UIL2ConnectionFactory");
- log.info("Creating connection");
- outQueueConnection = qcf.createQueueConnection();
- try {
- log.info("Creating session");
- QueueSession qs = outQueueConnection.createQueueSession(false, Session.DUPS_OK_ACKNOWLEDGE);
- TextMessage responseTextMessage =qs.createTextMessage(bankQuoteReplyXML);
- QueueSender queueSender = qs.createSender(outQueue);
- queueSender.send(responseTextMessage);
- } catch (JMSException je) {
- log.error(je.getMessage(),je);
- }finally {
- outQueueConnection.close();
- }
- } catch (Exception e) {
- log.error(e.getMessage(),e);
- }
- }
-
- public void close() throws JMSException{
- inQueueConnection.close();
- }
-
- public static void main(String[] args)
- {
- DOMConfigurator.configure("log4j.xml");
- ManagerJMS managerJMS = new ManagerJMS();
- managerJMS.listen();
- }
-}
\ No newline at end of file
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/ManagerJMS.java (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/ManagerJMS.java)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteReplyTest.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteReplyTest.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteReplyTest.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,63 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.soa.esb.samples.loanbroker.banks;
-
-import static org.junit.Assert.*;
-
-import java.math.BigDecimal;
-
-import junit.framework.JUnit4TestAdapter;
-
-import org.apache.log4j.Logger;
-import org.junit.Test;
-
-import com.thoughtworks.xstream.XStream;
-
-public class BankQuoteReplyTest {
-
- private Logger logger = Logger.getLogger(this.getClass());
-
- /**
- * Testing the XML layout of a BankQuoteReply
- */
- @Test public void obtainExampleXML(){
- BankQuoteReply bankQuoteReply = new BankQuoteReply();
- bankQuoteReply.setErrorCode(0);
- bankQuoteReply.setInterestRate(BigDecimal.valueOf(11.7));
- bankQuoteReply.setQuoteId("JBBANK_1");
-
- XStream xstream = new XStream();
- String bankQuoteReplyXml=xstream.toXML(bankQuoteReply);
- logger.info("xml=\n" + bankQuoteReplyXml);
- String expectedXml =
- "<org.jboss.soa.esb.samples.loanbroker.banks.BankQuoteReply>\n"
- + " <interestRate>11.7</interestRate>\n"
- + " <quoteId>JBBANK_1</quoteId>\n"
- + " <errorCode>0</errorCode>\n"
- + "</org.jboss.soa.esb.samples.loanbroker.banks.BankQuoteReply>";
- assertTrue(expectedXml.equals(bankQuoteReplyXml));
- }
-
- public static junit.framework.Test suite() {
- return new JUnit4TestAdapter(BankQuoteReplyTest.class);
- }
-}
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteReplyTest.java (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteReplyTest.java)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequestTest.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequestTest.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequestTest.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,64 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.soa.esb.samples.loanbroker.banks;
-
-import static org.junit.Assert.*;
-import junit.framework.JUnit4TestAdapter;
-
-import org.apache.log4j.Logger;
-import org.junit.Test;
-
-import com.thoughtworks.xstream.XStream;
-
-public class BankQuoteRequestTest {
-
- private Logger logger = Logger.getLogger(this.getClass());
-
- /**
- * Testing the XML layout of a BankQuoteRequest
- */
- @Test public void obtainExampleXML(){
- BankQuoteRequest bankQuoteRequest = new BankQuoteRequest();
- bankQuoteRequest.setSsn(123456890);
- bankQuoteRequest.setCreditScore(3);
- bankQuoteRequest.setHistoryLength(4);
- bankQuoteRequest.setLoanTerm(5);
- bankQuoteRequest.setLoanAmount(20000);
-
- XStream xstream = new XStream();
- String bankQuoteRequestXml=xstream.toXML(bankQuoteRequest);
- logger.info("xml=\n" + bankQuoteRequestXml);
- String expectedXml =
- "<org.jboss.soa.esb.samples.loanbroker.banks.BankQuoteRequest>\n"
- + " <ssn>123456890</ssn>\n"
- + " <creditScore>3</creditScore>\n"
- + " <historyLength>4</historyLength>\n"
- + " <loanAmount>20000</loanAmount>\n"
- + " <loanTerm>5</loanTerm>\n"
- + "</org.jboss.soa.esb.samples.loanbroker.banks.BankQuoteRequest>";
- assertTrue(expectedXml.equals(bankQuoteRequestXml));
- }
-
- public static junit.framework.Test suite() {
- return new JUnit4TestAdapter(BankQuoteRequestTest.class);
- }
-}
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequestTest.java (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/BankQuoteRequestTest.java)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/BankTest.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/BankTest.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/BankTest.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,71 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.soa.esb.samples.loanbroker.banks;
-
-import static org.junit.Assert.*;
-
-import java.math.BigDecimal;
-
-import junit.framework.JUnit4TestAdapter;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.Priority;
-import org.junit.Test;
-
-public class BankTest {
-
- private Logger logger = Logger.getLogger(this.getClass());
-
- /**
- * Tests the computation of the interestRate for the TestBank.
- *
- */
- @Test public void processLoanRequest(){
-
- //Building a BankQuoteRequest
- BankQuoteRequest bankQuoteRequest = new BankQuoteRequest();
- bankQuoteRequest.setSsn(123456890);
- bankQuoteRequest.setCreditScore(3);
- bankQuoteRequest.setHistoryLength(4);
- bankQuoteRequest.setLoanTerm(72);
- bankQuoteRequest.setLoanAmount(20000);
- logger.log(Priority.INFO, bankQuoteRequest);
-
- //Getting a Bank Instance
- String bankName = "TestBank";
- BigDecimal ratePrimium = BigDecimal.valueOf(0.25);
- int maxLoanTerm = 120;
- Bank bank = new Bank(bankName, ratePrimium, maxLoanTerm);
-
- //Getting a quote from this bank
- BankQuoteReply bankQuoteReply = bank.processMessage(bankQuoteRequest);
- logger.log(Priority.INFO, bankQuoteReply);
-
- //Checking for validity
- BigDecimal expectedInterestRate = BigDecimal.valueOf(8.85);
- assertTrue(bankQuoteReply.getInterestRate().equals(expectedInterestRate));
- }
-
- public static junit.framework.Test suite() {
- return new JUnit4TestAdapter(BankTest.class);
- }
-}
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/BankTest.java (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/BankTest.java)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/FlatFileProcessorTest.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/FlatFileProcessorTest.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/FlatFileProcessorTest.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,111 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.soa.esb.samples.loanbroker.banks;
-
-import static org.junit.Assert.*;
-
-import java.io.File;
-
-import junit.framework.JUnit4TestAdapter;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.Priority;
-import org.junit.Test;
-
-public class FlatFileProcessorTest {
-
- private Logger logger = Logger.getLogger(this.getClass());
- private static String FLAT_FILE = "FlatFileProcessorTest.txt";
- /**
- * Tests the processing of flat file containing a loan quote request. First
- * we try to find a temporary directory. When this succeeds we drop a
- * loan request file in there and try to process it.
- *
- */
- @Test public void processRequest()
- {
- File writableDir=null;
- logger.log(Priority.INFO, "Check to see if I can write to /tmp");
- File tmpDir = new File("/tmp");
- if (tmpDir.exists() && tmpDir.canWrite()) {
- writableDir=tmpDir;
- } else {
- File tempDir = new File("C:/temp");
- if (tempDir.exists() && tempDir.canWrite()) {
- writableDir=tempDir;
- } else {
- logger.log(Priority.ERROR, "Could not find either /tmp or C:\\Temp for a temporary "
- + "writing space.");
- assertTrue(false);
- }
- }
-// We found a temp space so now we can drop in a load request file.
- try {
- logger.log(Priority.INFO, "Creating " + FLAT_FILE + " file in " + writableDir.getAbsolutePath());
- File loanRequestFile = new File(writableDir.getAbsolutePath() + "/"+ FLAT_FILE);
- if (loanRequestFile.exists()) {
- loanRequestFile.delete();
- }
- loanRequestFile.createNewFile();
- String str="23456890,3,4,20000,5";
- FileUtil.writeTextFile(loanRequestFile, str);
-
- logger.log(Priority.INFO, "Processing FlatFileProcessorTest.txt");
- ManagerFlatFile pollManager = new ManagerFlatFile();
- pollManager.processFile(loanRequestFile);
-
- //Check to see if the file is now moved.
- assertFalse(loanRequestFile.exists());
-
- File processedFile = new File(writableDir.getAbsolutePath() + "/"
- + ManagerFlatFile.PROCESSED_DIR + "/" + FLAT_FILE);
- logger.log(Priority.INFO, "Check to see if " + processedFile.getAbsolutePath()
- + " exists");
- assertTrue(processedFile.exists());
- logger.log(Priority.INFO, "OK");
-
- File replyToFile = new File(writableDir.getAbsolutePath() + "/"
- + ManagerFlatFile.OUTGOING_DIR + "/" + ManagerFlatFile.PREFIX
- + FLAT_FILE);
- logger.log(Priority.INFO, "Check to see if " + replyToFile.getAbsolutePath()
- + " exists");
- assertTrue(replyToFile.exists());
- logger.log(Priority.INFO, "OK");
-
- //Checking the content of the reply
- logger.log(Priority.INFO, "Check the reply, should be ('8.29,FileBasedBank-0,0'");
- assertTrue("8.29,FileBasedBank-0,0".equals(FileUtil.readTextFile(replyToFile)));
- logger.log(Priority.INFO, "OK");
- //Cleaning up
- processedFile.delete();
- replyToFile.delete();
-
- } catch (Throwable e) {
- logger.log(Priority.ERROR,e.getMessage(),e);
- assertTrue(false);
- }
- }
-
- public static junit.framework.Test suite() {
- return new JUnit4TestAdapter(FlatFileProcessorTest.class);
- }
-}
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/FlatFileProcessorTest.java (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/FlatFileProcessorTest.java)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/JmsProcessorTest.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/JmsProcessorTest.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/JmsProcessorTest.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,96 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.soa.esb.samples.loanbroker.banks;
-
-import java.util.Properties;
-
-import javax.jms.Queue;
-import javax.jms.QueueConnection;
-import javax.jms.QueueConnectionFactory;
-import javax.jms.QueueSender;
-import javax.jms.QueueSession;
-import javax.jms.TextMessage;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-
-import junit.framework.JUnit4TestAdapter;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.Priority;
-import org.junit.Test;
-import static org.junit.Assert.*;
-import com.thoughtworks.xstream.XStream;
-
-public class JmsProcessorTest {
-
- private Logger logger = Logger.getLogger(this.getClass());
-
- /**
- * This can be activate if the server is running and you want
- * to drop a message on the queue
- *
- */
- @Test public void sendLoanRequestXML()
- {
-
- // Building a BankQuoteRequest
- BankQuoteRequest bankQuoteRequest = new BankQuoteRequest();
- bankQuoteRequest.setSsn(123456890);
- bankQuoteRequest.setCreditScore(3);
- bankQuoteRequest.setHistoryLength(4);
- bankQuoteRequest.setLoanTerm(72);
- bankQuoteRequest.setLoanAmount(20000);
- logger.log(Priority.INFO, bankQuoteRequest);
- XStream xstream = new XStream();
- String bankQuoteRequestXml=xstream.toXML(bankQuoteRequest);
-
- QueueSession sess;
- Queue queue;
- try {
- Properties properties = new Properties();
- properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
- properties.put(Context.URL_PKG_PREFIXES , "org.jnp.interfaces");
- properties.put(Context.PROVIDER_URL , "localhost");
- InitialContext ctx = new InitialContext(properties);
- queue = (Queue) ctx.lookup("queue/A");
- QueueConnectionFactory factory = (QueueConnectionFactory) ctx
- .lookup("ConnectionFactory");
- QueueConnection cnn = factory.createQueueConnection();
- sess = cnn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
- TextMessage msg = sess.createTextMessage(bankQuoteRequestXml);
- QueueSender sender = sess.createSender(queue);
- sender.send(msg);
- //if the test gets here without errors it passes.
- assertTrue(true);
- } catch (Exception e) {
- //if it fails it may be because the server is not up and the Queue is not found
- //I'm not letting the test fail, since we may want to do nightly build/test runs
- //which may not have the server up.
- logger.log(Priority.ERROR, e.getMessage(), e);
- logger.log(Priority.ERROR, "Is the server up and running?");
- }
- }
-
- public static junit.framework.Test suite() {
- return new JUnit4TestAdapter(JmsProcessorTest.class);
- }
-}
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/JmsProcessorTest.java (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/JmsProcessorTest.java)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/conf (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/conf)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/conf/LoanBrokerConfig.xml
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/conf/LoanBrokerConfig.xml 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/conf/LoanBrokerConfig.xml 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,29 +0,0 @@
-<ListenOnJMS
- parmsReloadSecs="60"
->
- <CreditRequest
- actionClass="org.jboss.soa.esb.samples.loanbroker.actions.ProcessCreditRequest"
- maxThreads="1"
- listenQueue="queue/A"
- listenMsgSelector="sample_loanbroker_servicecode='creditRequest'"
- >
-
- <NotificationList type="OK">
- <target class="NotifyQueues" >
- <queue jndiName="queue/A">
- <messageProp name="sample_loanbroker_servicecode" value="creditResponse" />
- </queue>
- </target>
- </NotificationList>
-
- </CreditRequest>
-
- <CreditResponse
- actionClass="org.jboss.soa.esb.samples.loanbroker.actions.ProcessCreditResponse"
- maxThreads="1"
- listenQueue="queue/A"
- listenMsgSelector="sample_loanbroker_servicecode='creditResponse'"
- >
-
- </CreditResponse>
-</ListenOnJMS>
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/conf/LoanBrokerConfig.xml (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/conf/LoanBrokerConfig.xml)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/conf/ObjStore.xml
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/conf/ObjStore.xml 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/conf/ObjStore.xml 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,19 +0,0 @@
-<ObjectStore
- dataSourceJndiName="java:JbossEsbDS"
- uidTable="uid_table"
- batchTable="batches" >
-
- <Class name="org.jboss.soa.esb.common.bizclasses.Person"
- table="object_snap"
- type="Person"
- encrypt="false" >
- <Index table="people_index" />
- </Class>
-
- <Class name="org.jboss.soa.esb.samples.loanbroker.domain.Customer"
- table="object_snap"
- type="Customer"
- encrypt="false" >
- <Index table="customer_index" />
- </Class>
-</ObjectStore>
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/conf/ObjStore.xml (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/conf/ObjStore.xml)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessCreditRequest.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessCreditRequest.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessCreditRequest.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,50 +0,0 @@
-package org.jboss.soa.esb.samples.loanbroker.actions;
-
-import org.jboss.soa.esb.processors.*;
-import org.jboss.soa.esb.samples.loanbroker.creditagency.CreditCheckRequest;
-import org.jboss.soa.esb.samples.loanbroker.creditagency.CreditCheckResponse;
-import org.jboss.soa.esb.helpers.*;
-
-import com.sun.mail.iap.Response;
-
-import javax.jms.*;
-
-import java.util.Random;
-
-
-public class ProcessCreditRequest extends EsbMsgProcessor
-{
- public Integer creditScore;
-
- /*
- * the base class sets up the parameter tree being used by this action class
- */
- public ProcessCreditRequest(DomElement p_parms) throws Exception
- {
- super(p_parms);
- }
-
- public void processMessage(Message p_oMsg) throws Exception
- {
- if (! (p_oMsg instanceof ObjectMessage))
- throw new Exception("Message must be a ObjectMessage");
- System.out.println(p_oMsg);
- CreditCheckRequest creditRequest = (CreditCheckRequest)((ObjectMessage)p_oMsg).getObject();
-
- //use the notification framework to send back our response
- //use a dummy score between 0 and 10
- Random generator = new Random();
- creditScore = new Integer(generator.nextInt(10));
- }
-
- protected void checkParms() throws Exception
- {
- }
-
- //this is how the response is sent back, through OK notification
- //you could also send back a special ERROR credit score condition
- public Object getOkNotification()
- {
- return creditScore;
- }
-}
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessCreditRequest.java (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessCreditRequest.java)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessCreditResponse.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessCreditResponse.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessCreditResponse.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,24 +0,0 @@
-package org.jboss.soa.esb.samples.loanbroker.actions;
-
-import java.util.Random;
-
-import javax.jms.Message;
-import javax.jms.ObjectMessage;
-
-import org.jboss.soa.esb.helpers.DomElement;
-import org.jboss.soa.esb.processors.EsbMsgProcessor;
-import org.jboss.soa.esb.samples.loanbroker.creditagency.CreditCheckRequest;
-
-public class ProcessCreditResponse extends EsbMsgProcessor {
-
- public ProcessCreditResponse(DomElement p_oP) throws Exception {
- super(p_oP);
-
- }
-
- public void processMessage(Message p_oMsg) throws Exception
- {
- System.out.println(p_oMsg);
- }
-
-}
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessCreditResponse.java (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/actions/ProcessCreditResponse.java)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/adapters (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/adapters)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/adapters/CustomerAdapter.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/adapters/CustomerAdapter.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/adapters/CustomerAdapter.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,67 +0,0 @@
-package org.jboss.soa.esb.samples.loanbroker.adapters;
-
-import java.text.*;
-
-import org.jboss.soa.esb.samples.loanbroker.domain.Customer;
-import org.jboss.soa.esb.samples.loanbroker.web.WebCustomer;
-import org.jboss.soa.esb.util.*;
-import org.jboss.soa.esb.common.bizclasses.*;
-
-public class CustomerAdapter
-{
- // No objects of this class - only static methods
- private CustomerAdapter() {}
-
- private static final NumberFormat s_NF = new DecimalFormat("#########0.00");
-
- public static Customer esbFromWeb (WebCustomer p_o)
- {
- Person oP = new Person((String)null);
- oP.setField(Person.ATTRIB.fmlyN, p_o.name);
-
- Address oAdd = new Address((String)null);
- oAdd.setField(Address.ATTRIB.strLine1, p_o.address);
- oAdd.setRole("loan");
- oP.addAddress(oAdd);
-
- Customer oRet = new Customer((String)null);
- oRet.setField(Customer.ATTRIB.empName ,p_o.employerName);
- oRet.setField(Customer.ATTRIB.salary ,s_NF.format(p_o.salary));
- oRet.setField(Customer.ATTRIB.loanDur ,Integer.toString(p_o.loanDuration));
- oRet.setField(Customer.ATTRIB.loanAmt ,s_NF.format(p_o.loanAmount));
-
- return oRet;
- }//_________________________________________
-
- public static WebCustomer webFromEsb (Customer p_o)
- {
- String sName = null;
- String sAddr = null;
- Person oP = p_o.getPerson();
- if (null!=oP)
- { sName = oP.getField(Person.ATTRIB.fmlyN);
- Address oAdd = oP.getAddressRole("loan");
- sAddr = (null==oAdd) ? null : oAdd.getField(Address.ATTRIB.strLine1);
- }
-
- String sEmployer = p_o.getField(Customer.ATTRIB.empName);
- String sAux = p_o.getField(Customer.ATTRIB.salary);
- double dSalary = 0.;
- if (! EsbUtil.isNullString(sAux))
- try {dSalary = s_NF.parse(sAux).doubleValue();}
- catch (Exception e) {/* OK leave it at zero */ }
-
- sAux = p_o.getField(Customer.ATTRIB.loanDur);
- int iLoanDur = (null==sAux)? 0 : Integer.parseInt(sAux);
-
- double dAmount = 0.;
- sAux = p_o.getField(Customer.ATTRIB.loanAmt);
- if (! EsbUtil.isNullString(sAux))
- try {dAmount = s_NF.parse(sAux).doubleValue();}
- catch (Exception e) {/* OK leave it at zero */ }
-
- return new WebCustomer(sName,sAddr,sEmployer,dSalary,iLoanDur,dAmount);
- }//_________________________________________
-
-
-}
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/adapters/CustomerAdapter.java (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/adapters/CustomerAdapter.java)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditAgency.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditAgency.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditAgency.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,11 +0,0 @@
-package org.jboss.soa.esb.samples.loanbroker.creditagency;
-
-public class CreditAgency {
-
- public static CreditCheckResponse getScore(CreditCheckRequest cr) {
- //return a score based on some random formula here
-
- return null;
-
- }
-}
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditAgency.java (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditAgency.java)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditAgencyJMSConsumer.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditAgencyJMSConsumer.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditAgencyJMSConsumer.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,71 +0,0 @@
-package org.jboss.soa.esb.samples.loanbroker.creditagency;
-
-import org.jboss.soa.esb.samples.loanbroker.domain.*;
-
-import javax.jms.*;
-import javax.naming.*;
-
-import org.jboss.soa.esb.helpers.*;
-
-public class CreditAgencyJMSConsumer
-{
- private static final String JNDI_URL = "localhost";
- private static final String JNDI_TYPE = AppServerContext.SERVER_TYPE.jboss.toString();
-
- private Context m_oCtx;
-
- public CreditAgencyJMSConsumer(String p_sq) throws Exception
- {
- consumeMessages(p_sq);
- Thread.sleep(1000);
- } //__________________________________
-
- public int consumeMessages(String p_sName) throws Exception
- {
-
- m_oCtx = AppServerContext.getServerContext(JNDI_TYPE,JNDI_URL);
-
- MessageConsumer oCns = null;
- oCns = getQueue(p_sName);
- while (true)
- { Message oMsg = oCns.receive(200);
- if (null==oMsg) {
- continue; }
- CreditCheckRequest creditRequest = (CreditCheckRequest)((ObjectMessage)oMsg).getObject();
-// System.out.println("JBossESB - CreditAgency received request...");
-// dumpMessage(oMsg); //comment out if you don't want to see this
-
- }
-
- } //__________________________________
-
- void dumpMessage(Message pM)
- {
- System.out.println(pM);
- } //__________________________________
-
- QueueReceiver getQueue(String p_sJndi) throws Exception
- {
- QueueConnection oQconn = null;
- QueueSession oQsess = null;
- QueueConnectionFactory qcf = (QueueConnectionFactory) m_oCtx
- .lookup("ConnectionFactory");
-
- oQconn = qcf.createQueueConnection();
- oQsess = oQconn.createQueueSession(false
- ,QueueSession.AUTO_ACKNOWLEDGE);
- javax.jms.Queue oQueue
- = (javax.jms.Queue) m_oCtx.lookup(p_sJndi);
-
- QueueReceiver oRcv = oQsess.createReceiver(oQueue);
- oQconn.start();
- return oRcv;
- } //__________________________________
-
-
-
- public static void main(String args[]) throws Exception{
- new CreditAgencyJMSConsumer(LoanBrokerConstants.CREDIT_CHECK_QUEUE);
- }
-
-} //____________________________________________________________________________
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditAgencyJMSConsumer.java (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditAgencyJMSConsumer.java)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditCheckRequest.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditCheckRequest.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditCheckRequest.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,41 +0,0 @@
-package org.jboss.soa.esb.samples.loanbroker.creditagency;
-
-import java.io.Serializable;
-import java.util.Date;
-import java.util.Random;
-
-/*
- * class used internally by the CreditAgency
- */
-
-public class CreditCheckRequest implements Serializable{
- public long requestID;
- public long timestamp;
- public double amount, salary;
- public int duration;
- public String customerID;
-
- private static Random generator = new Random();
-
-
- public CreditCheckRequest(double salary, int duration, String customerID) {
- this.requestID=generator.nextLong() ; //generate some fake random number for the request ID
- this.timestamp=System.currentTimeMillis();
- this.salary=salary;
- this.duration=duration;
- this.customerID=customerID;
- }
-
- public String toString() {
- StringBuffer buff = new StringBuffer("-- JBossESB: CreditRequest message --");
- buff.append("\t requestID: " + this.requestID + "\n");
- buff.append("\t customer ID: " + this.customerID + "\n");
- buff.append("\t amount: " + this.amount + "\n");
- buff.append("\t duration: " + this.duration + "\n");
- buff.append("\t salary: " + this.salary + "\n");
-
- return buff.toString();
-
- }
-
-}
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditCheckRequest.java (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditCheckRequest.java)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditCheckResponse.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditCheckResponse.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditCheckResponse.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,16 +0,0 @@
-package org.jboss.soa.esb.samples.loanbroker.creditagency;
-
-import java.io.*;
-
-public class CreditCheckResponse implements Serializable{
- public long requestID;
- public long timestamp;
- public int score;
-
- public CreditCheckResponse(long requestID, int score) {
- this.requestID=requestID;
- this.timestamp=System.currentTimeMillis();
- this.score = score;
- }
-
-}
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditCheckResponse.java (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/creditagency/CreditCheckResponse.java)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/domain (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/domain)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/domain/CreditRating.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/domain/CreditRating.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/domain/CreditRating.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,56 +0,0 @@
-package org.jboss.soa.esb.samples.loanbroker.domain;
-
-import java.util.*;
-
-import org.jboss.soa.esb.util.*;
-
-public class CreditRating extends BaseBusinessObject
-{
- public enum ATTRIB
- {score
- };
- private EnumMap<ATTRIB,String>m_oData;
-
- public CreditRating(String p_sElem) {super(p_sElem);}
- public CreditRating(String p_sElem, long p_lUid){super(p_sElem, p_lUid);}
-
- @SuppressWarnings("unchecked")
- public CreditRating(BobjStdDTO p_oDto) throws Exception
- { super(p_oDto);
-
- for (ATTRIB oCurr : ATTRIB.values())
- setField(oCurr,p_oDto.getAttr(oCurr.toString()));
- } //__________________________________
-
- public BobjStdDTO toDTO() throws Exception
- { BobjStdDTO oRet = super.toDTO();
-
- for (ATTRIB oCurr : ATTRIB.values())
- oRet.addAttr(oCurr.toString(), getField(oCurr));
- return oRet;
- }//_________________________________________
-
- public String setField(ATTRIB pKey, String pVal)
- { if (null==pKey) return null;
- String sRet = (null==m_oData)? null : m_oData.remove(pKey);
- if (! EsbUtil.isNullString(pVal))
- { if (null==m_oData)
- m_oData = new EnumMap<ATTRIB,String>(ATTRIB.class);
- m_oData.put(pKey,pVal);
- }
- return sRet;
- } //__________________________________
-
- public String getField(ATTRIB pKey)
- { if (null==pKey) return null;
- if (null==m_oData) return null;
- return m_oData.get(pKey);
- } //__________________________________
-
- public void setScore(int pI) {setField(ATTRIB.score, Integer.toString(pI)); }
- public int getScore()
- { try { return Integer.getInteger(getField(ATTRIB.score)); }
- catch (Exception e) { return 0; }
- } //__________________________________
-}
-
\ No newline at end of file
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/domain/CreditRating.java (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/domain/CreditRating.java)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/domain/Customer.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/domain/Customer.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/domain/Customer.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,99 +0,0 @@
-package org.jboss.soa.esb.samples.loanbroker.domain;
-
-import java.util.*;
-import java.text.*;
-
-import org.jboss.soa.esb.util.*;
-import org.jboss.soa.esb.common.bizclasses.*;
-
-public class Customer extends BaseBusinessObject
-{
- public enum ATTRIB
- {empName
- ,salary
- ,loanDur
- ,loanAmt
- };
- private EnumMap<ATTRIB,String>m_oData;
-
- public enum OBJ
- {person
- ,rating
- }
-
- private Person person;
- private CreditRating rating;
-
- public Customer(String p_sElem) {super(p_sElem);}
- public Customer(String p_sElem, long p_lUid){super(p_sElem, p_lUid);}
-
- @SuppressWarnings("unchecked")
- public Customer(BobjStdDTO p_oDto) throws Exception
- { super(p_oDto);
-
- for (ATTRIB oCurr : ATTRIB.values())
- setField(oCurr,p_oDto.getAttr(oCurr.toString()));
- person = (Person) p_oDto.getBobj(OBJ.person.toString());
- rating = (CreditRating)p_oDto.getBobj(OBJ.rating.toString());
- } //__________________________________
-
- public BobjStdDTO toDTO() throws Exception
- { BobjStdDTO oRet = super.toDTO();
-
- for (ATTRIB oCurr : ATTRIB.values())
- oRet.addAttr(oCurr.toString(), getField(oCurr));
- oRet.addBobj(OBJ.person.toString(),person);
- oRet.addBobj(OBJ.rating.toString(),rating);
- return oRet;
- }//_________________________________________
-
- private static final NumberFormat s_NF = new DecimalFormat("#########0.00");
- public Customer(String name, String address, String employerName, double salary, int loanDuration, double loanAMount)
- {
- getPerson();
- person.setField(Person.ATTRIB.fmlyN, name);
-
- Address oAdd = new Address((String)null);
- oAdd.setField(Address.ATTRIB.strLine1, address);
- person.addAddress(oAdd);
-
- setField(ATTRIB.empName ,employerName);
- setField(ATTRIB.salary ,s_NF.format(salary));
- setField(ATTRIB.loanDur ,Integer.toString(loanDuration));
- setField(ATTRIB.loanAmt ,s_NF.format(loanAMount));
- }//_________________________________________
-
- public String setField(ATTRIB pKey, String pVal)
- { if (null==pKey) return null;
- String sRet = (null==m_oData)? null : m_oData.remove(pKey);
- if (! EsbUtil.isNullString(pVal))
- { if (null==m_oData)
- m_oData = new EnumMap<ATTRIB,String>(ATTRIB.class);
- m_oData.put(pKey,pVal);
- }
- return sRet;
- } //__________________________________
-
- public String getField(ATTRIB pKey)
- { if (null==pKey) return null;
- if (null==m_oData) return null;
- return m_oData.get(pKey);
- } //__________________________________
-
- public void setperson(Person pO) { person = pO; }
- public Person getPerson()
- { return (null!=person)? person : (person=new Person((String)null));
- }
-
- public void setRating(CreditRating pO) { rating = pO; }
- public CreditRating getRating()
- { return (null!=rating)? rating : (rating=new CreditRating((String)null));
- }
-
- public String[] locator() {
- if (null==person) return new String[] {"","",""};
- return person.locator();
- }
-
-}
-
\ No newline at end of file
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/domain/Customer.java (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/domain/Customer.java)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/domain/LoanBrokerConstants.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/domain/LoanBrokerConstants.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/domain/LoanBrokerConstants.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,10 +0,0 @@
-package org.jboss.soa.esb.samples.loanbroker.domain;
-
-public class LoanBrokerConstants {
- public static final String SELECTOR_SERVICE = "sample_loanbroker_servicecode";
- public static final String CREDIT_CHECK_REQUEST = "creditRequest";
- public static final String CREDIT_CHECK_RESPONSE = "creditResponse";
- public static final String CREDIT_CHECK_QUEUE = "queue/A";
-
-
-}
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/domain/LoanBrokerConstants.java (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/domain/LoanBrokerConstants.java)
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/web (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/web)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/web/LaunchDummy.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/web/LaunchDummy.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/web/LaunchDummy.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,15 +0,0 @@
-package org.jboss.soa.esb.samples.loanbroker.web;
-
-import org.jboss.soa.esb.listeners.JmsQueueListener;
-
-public class LaunchDummy {
-
- /**
- * @param args
- */
- public static void main(String[] args) throws Exception{
- JmsQueueListener jms = new JmsQueueListener(args [0]);
-
- }
-
-}
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/web/LaunchDummy.java (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/web/LaunchDummy.java)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/web/LoanBrokerWS.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/web/LoanBrokerWS.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/web/LoanBrokerWS.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,105 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*
-*/
-
-package org.jboss.soa.esb.samples.loanbroker.web;
-
-
-import javax.jws.WebMethod;
-import javax.jws.WebService;
-import javax.jws.soap.SOAPBinding;
-import javax.jws.soap.SOAPBinding.Use;
-
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.naming.InitialContext;
-import javax.rmi.PortableRemoteObject;
-
-import javax.jms.*;
-
-
-import java.util.Properties;
-
-import org.jboss.soa.esb.samples.loanbroker.adapters.CustomerAdapter;
-import org.jboss.soa.esb.samples.loanbroker.creditagency.CreditCheckRequest;
-import org.jboss.soa.esb.samples.loanbroker.domain.LoanBrokerConstants;
-import org.jboss.soa.esb.services.*;
-import org.jboss.soa.esb.common.*;
-import org.jboss.soa.esb.helpers.AppServerContext;
-
-//Change targetNameSpace to your deployment info
- at WebService(name = "LoanBrokerWS", targetNamespace="http://localhost/loanbroker")
- at SOAPBinding(style = SOAPBinding.Style.RPC)
-public class LoanBrokerWS
-{
- private static final String JNDI_URL = "localhost";
- private static final String JNDI_TYPE = AppServerContext.SERVER_TYPE.jboss.toString();
-
- at WebMethod
-//method name is .NET friendly
-public void RequestLoan(WebCustomer customer) {
- try {
-
- //get handle to the JBossESB Event object store
- IpersistHandler esbHandler = PersistHandlerFactory.getPersistHandler("remote",
- EsbSysProps.getJndiServerType(),
- EsbSysProps.getJndiServerURL());
-
- //convert the WebCustomer to an ESB Customer capable of being persisted to the event store
- long lUid = esbHandler.addObject(CustomerAdapter.esbFromWeb(customer));
-
- //create the CreditCheckRequest object expected by the CreditAgency service
- //we are not going to persist this request to the CreditAgency, but you might want to...
- CreditCheckRequest creditRequest = new CreditCheckRequest(customer.salary,
- customer.loanDuration,
- Long.toString(lUid));
-
- //Send the CreditRequest to the queue which the JMSListener process is listening to
- Context ctx = AppServerContext.getServerContext(JNDI_TYPE, JNDI_URL);
- Queue queue = (Queue) ctx.lookup(LoanBrokerConstants.CREDIT_CHECK_QUEUE);
- QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
- QueueConnection cnn = factory.createQueueConnection();
- QueueSession sess = cnn.createQueueSession(false,QueueSession.AUTO_ACKNOWLEDGE);
- ObjectMessage msg = sess.createObjectMessage(creditRequest);
- MessageProducer sender = sess.createSender(queue);
- sender = sess.createSender(queue);
- msg.setStringProperty(LoanBrokerConstants.SELECTOR_SERVICE, LoanBrokerConstants.CREDIT_CHECK_REQUEST);
- sender.send(msg);
-
-
- //only for test here
- //msg.setStringProperty(LoanBrokerConstants.SELECTOR_SERVICE, LoanBrokerConstants.CREDIT_CHECK_RESPONSE);
- //sender.send(msg);
-
- } catch (Exception e) {
- e.printStackTrace ();
- }
-
-}
-
-public static void main(String args[]) throws Exception{
- LoanBrokerWS ws = new LoanBrokerWS();
- WebCustomer customer = new WebCustomer("John Doe", "123 My St.", "JBoss", 50.00, 12, 100.00);
- ws.RequestLoan(customer);
-
- }
-}
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/web/LoanBrokerWS.java (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/web/LoanBrokerWS.java)
Deleted: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/web/WebCustomer.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/web/WebCustomer.java 2006-07-29 14:51:59 UTC (rev 5352)
+++ labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/web/WebCustomer.java 2006-07-29 22:08:33 UTC (rev 5353)
@@ -1,34 +0,0 @@
-package org.jboss.soa.esb.samples.loanbroker.web;
-
-public class WebCustomer
-{
- public String name ,address ,employerName;
- public double salary ,loanAmount;
- public int loanDuration;
- private int creditScore;
-
- public WebCustomer(String name, String address, String employerName, double salary, int loanDuration, double loanAmount)
- {
- this.name = name;
- this.address = address;
- this.employerName = employerName;
- this.salary = salary;
- this.loanAmount = loanAmount;
- this.loanDuration = loanDuration;
- this.creditScore = 0;
-
- }//_________________________________________
-
- //Using .NET friendly method names for accessors
- public String GetName() { return this.name; }
- public void SetName(String val) { this.name=val; }
-
- public String GetAddress(){ return this.address; }
- public void SetAddress(String val){ this.address=val; }
-
-
-
-
-
-
-}
Copied: labs/jbossesb/branches/refactor/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/web/WebCustomer.java (from rev 5352, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/java/src/org/jboss/soa/esb/samples/loanbroker/web/WebCustomer.java)
Copied: labs/jbossesb/branches/refactor/product/lib/ext/emma.jar (from rev 5352, labs/jbossesb/trunk/product/lib/ext/emma.jar)
Copied: labs/jbossesb/branches/refactor/product/lib/ext/emma_ant.jar (from rev 5352, labs/jbossesb/trunk/product/lib/ext/emma_ant.jar)
More information about the jboss-svn-commits
mailing list